Allow null in the JSON Schema enums of optional literal arguments

Nine model arguments are typed Optional[Literal[...]] with a default of None, for example align in fixed_pattern_noise. apischema renders them as a nullable type with an enum of the strings alone:

"type": ["string", "null"],
"enum": ["center", "top_left", "top_right", "bottom_left", "bottom_right"]

A value has to satisfy both keywords, so align: null, the default, fails validation while Pyxel runs it without complaint. Tools that validate a configuration against the schema report an error the user did not make.

The generated script now adds null to every enum whose type already allows it, before the schema is written or checked. Regenerated pyxel/static/pyxel_schema.json with tox -e json_schema; only these nine enums change:

  • charge_collection: fixed_pattern_noise.align, persistence.trap_densities_align, persistence.trap_capacities_align
  • charge_generation: conversion_with_qe_map.align, load_charge.align, dark_current_dd.particle_type
  • photon_collection: load_image.align, usaf_illumination.align
  • readout_electronics: simple_adc.data_type

The new test fails against the previous schema and passes with this one, and still rejects an unknown keyword.

Merge request reports

Loading
Loading