Skip to content

Combination of allOf and discriminator gives false warnings #765

@fehguy

Description

@fehguy

If you create a schema with definitions that include a discriminator, you will get a false warning that some models are not in use. In fact, they may be in use indirectly.

For example:

  Animal:
    type: object
    discriminator: petType
    properties:
      commonName:
        type: string
  Cat:
    allOf:
      - $ref: '#/definitions/Animal'
      - type: object
        properties:
          isFurry:
            type: boolean
            default: false

Will give a warning like such:

image

It can be difficult to decide what may be referenced by a discriminator, I believe we can encapsulate it in a fairly simple rule:

  • If a schema contains the discriminator field, AND that schema is referenced in an allOf construct, AND neither models are inline schemas, we should ignore any warnings that the allOf model is unused.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions