spacetelescope / stdatamodels

https://stdatamodels.readthedocs.io
Other
5 stars 24 forks source link

`fits-schema` metaschema only checks top level `fits_hdu` and `fits_keyword` #261

Open braingram opened 5 months ago

braingram commented 5 months ago

The fits-schema metaschema used for several (but not all) of the datamodel schemas does not check fits_hdu or fits_keyword if they are present in the top-most portion of the schema.

For example, the following schema will correctly fail a call to check_schema:

%YAML 1.1
---
$schema: "http://stsci.edu/schemas/fits-schema/fits-schema"
id: "http://stsci.edu/schemas/jwst_datamodel/test.schema"
type: object
fits_hdu:
  - "invalid list"
fits_keyword:
  - "invalid keyword"
>>> asdf.schema.check_schema(schema)
ValidationError: ['invalid keyword'] is not of type 'string'

Failed validating 'type' in schema['allOf'][1]['properties']['fits_keyword']:
    {'type': 'string'}

On instance['fits_keyword']:
    ['invalid keyword']

However if the fits_hdu (or fits_keyword) is nested in the schema the check_schema will incorrectly pass:

%YAML 1.1
---
$schema: "http://stsci.edu/schemas/fits-schema/fits-schema"
id: "http://stsci.edu/schemas/jwst_datamodel/test.schema"
type: object
properties:
  area_table:
    fits_hdu:
      - "invalid list"
    fits_keyword:
      - "invalid keyword"
>>> asdf.schema.check_schema(schema)  # passes with no ValidationError

All uses of fits_hdu and fits_keyword that I'm able to find in stdatamodels is of the second type (so the metaschema provides no validation for any of these parts of the schemas). Note that the fits_hdu and fits_keyword handling by stdatamodels (mapping model properties and fits data) is unaffected by this metaschema issue.