Skip to content

OpenAPI 3.0 spec not parsing required properly #27

Closed
@viralanomaly

Description

@viralanomaly

I have a spec with components that look like this:


components:
  schemas:
    Credit:
      type: object
      properties:
        clientId:
          type: string
    CreditCreate:
      allOf:
        - $ref: '#/components/schemas/Credit'
        - required:
          - clientId

I'm doing it like this because there are about 30 fields in credit, and 10 in required. All the fields in required are present in the linked object (or objects if I'm linking more than one). This is rejected by the code in validators.py inside SchemaValidator. iter_errors calls itself recursively on each piece of the allOf, but this doesn't let me reuse another object and simply add some fields as required. I worked around it for now by telling iter_errors to check that the properties field contains something before erroring, but I'm not sure that it is the correct fix.

This behavior is supported in the swagger editor and in redoc, so I'm working off the assumption that it should be valid 3.0 syntax.

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