Skip to content

Investigate being more lenient in handling allOf #311

@mnahkies

Description

@mnahkies

Currently we take a pretty strict interpretation of allOf which means that constructs like the below don't work as a user might expect:

components:
  schemas:
    PartialObject:
      type: object
      properties:
        foo:
          type: string
        bar:
          type: number
    RequiredObject:
      allOf:
        - $ref: '#/components/schemas/PartialObject'
        - required:
          - foo
          - bar

Currently this ends up as {foo?: string, bar?: number} & {[key: string]: never} which isn't very useful, though fairly faithful to the specification ({foo?: string, bar?: number} & {foo: unknown, bar: unknown} might arguably be more accurate)

Other tooling such as swagger editor instead merges/flattens the schemas together, eg:

Image

We should investigate whether its possible to relax the rules a bit here, without compromising the ability to create types like Dog & Cat

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions