asdf-schema-1.0.0

ASDF Schema

Description

Extending YAML Schema and JSON Schema to add support for some ASDF-specific checks, related to ndarrays.

Outline

Schema Definitions

This node must validate against all of the following:

  • This type is an object with the following properties:
    • max_ndim
      integer
      Specifies that the corresponding ndarray is at most the given number of dimensions. If the array has fewer dimensions, it should be logically treated as if it were “broadcast” to the expected dimensions by adding 1’s to the front of the shape list.

      Minimum value: 0
    • ndim
      integer
      Specifies that the matching ndarray is exactly the given number of dimensions.

      Minimum value: 0
    • datatype
      object
      Specifies the datatype of the ndarray.

      By default, an array is considered “matching” if the array can be cast to the given datatype without data loss. For exact datatype matching, set exact_datatype to true.

      This node must validate against all of the following:

    • exact_datatype
      boolean
      If true, the datatype must match exactly.

      Default value:
      False
      
    • additionalItems
      object

      This node must validate against any of the following:

      • boolean
    • items
      object

      This node must validate against any of the following:

    • additionalProperties
      object

      This node must validate against any of the following:

      • boolean
    • definitions
      object
      object
    • properties
      object
      object
    • patternProperties
      object
      object
    • dependencies
      object
      object
    • allOf
      schemaArray
    • anyOf
      schemaArray
    • oneOf
      schemaArray
    • not
      #

Internal Definitions

  • schemaArray
    array
    Minimum length: 1
    Items in the array are restricted to the following types:
  • Original Schema

    %YAML 1.1
    ---
    $schema: "http://json-schema.org/draft-04/schema"
    id: "http://stsci.edu/schemas/asdf/asdf-schema-1.0.0"
    title:
      ASDF Schema
    description: |
      Extending YAML Schema and JSON Schema to add support for some ASDF-specific
      checks, related to [ndarrays](ref:core/ndarray-1.0.0).
    allOf:
      - $ref: "http://stsci.edu/schemas/yaml-schema/draft-01"
      - type: object
        properties:
          max_ndim:
            description: |
              Specifies that the corresponding **ndarray** is at most the
              given number of dimensions.  If the array has fewer
              dimensions, it should be logically treated as if it were
              "broadcast" to the expected dimensions by adding 1's to the
              front of the shape list.
            type: integer
            minimum: 0
    
          ndim:
            description: |
              Specifies that the matching **ndarray** is exactly the given
              number of dimensions.
            type: integer
            minimum: 0
    
          datatype:
            description: |
              Specifies the datatype of the **ndarray**.
    
              By default, an array is considered "matching" if the array
              can be cast to the given datatype without data loss.  For
              exact datatype matching, set `exact_datatype` to `true`.
            allOf:
              - $ref: "http://stsci.edu/schemas/asdf/core/ndarray-1.0.0#/definitions/datatype"
    
          exact_datatype:
            description: |
              If `true`, the datatype must match exactly.
            type: boolean
            default: false
    
          # Redefine JSON schema validators in terms of this document so that
          # we can check nested objects:
          additionalItems:
            anyOf:
              - type: boolean
              - $ref: "#"
          items:
            anyOf:
              - $ref: "#"
              - $ref: "#/definitions/schemaArray"
          additionalProperties:
            anyOf:
              - type: boolean
              - $ref: "#"
          definitions:
            type: object
            additionalProperties:
              $ref: "#"
          properties:
            type: object
            additionalProperties:
              $ref: "#"
          patternProperties:
            type: object
            additionalProperties:
              $ref: "#"
          dependencies:
            type: object
            additionalProperties:
              anyOf:
                - $ref: "#"
                - $ref: "http://json-schema.org/draft-04/schema#definitions/stringArray"
          allOf:
            $ref: "#/definitions/schemaArray"
          anyOf:
            $ref: "#/definitions/schemaArray"
          oneOf:
            $ref: "#/definitions/schemaArray"
          not:
            $ref: "#"
    
    definitions:
      schemaArray:
        type: array
        minItems: 1
        items:
          $ref: "#"
    ...