Skip to content

allOf does not pass the openapi schema check for "valid" required scenarios #546

@califlower

Description

@califlower

We have some specs (that I don't agree are good specs per se) that are technically valid but aren't passing oas-schema-check.
For example:

   CloudAppDataset:
      allOf:
      - $ref: '#/components/schemas/CloudAppDatasetCreate'
      - type: object
        required:
        - datasetId
        - status
        properties:
          datasetId:
            type: string
            minLength: 1
            maxLength: 50
            description: Unique identifier for the CloudApp dataset.
            example: tdi_dataset_01n2xcejqtf2nbrexx3vqjhp15

throws

#0 251.3 Rule: oas-schema-check
#0 251.3 - Severity: error
#0 251.3 - Message: `required` field `status` is not defined in `properties`
#0 251.3 - Path: $.components.schemas['WarehouseDataset'].allOf[1].required[1]
#0 251.3 - How to fix:
#0 251.3 Make sure each schema has a value type defined. Without a type, the schema is useless

technically required is only checkable on the instance of an object (which is a whole other thing and means you can't really check it at build time), but I think for the spirit of this schema checker is that at least for allOf it needs to check the completed object not just each arm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions