Skip to content

Remote ref mentioned in discriminator are not being added to the definitions #927

@gracekarina

Description

@gracekarina

Remote refs models mentioned in discriminator are not being add to the definitions part of the spec after resolving.
When a model uses discriminator and the models are remote, and not directly reference in the spec, the parser does not add them to the final swagger/openApi.

# API definition

swagger: '2.0'
info:
  version: '1.0.0'
  title: Discriminator and Resolved YAML
paths:
  /pet:
    get:
      responses:
        200:
          description: A single pet
          schema:
            $ref: 'remote.yaml/#/definitions/Pet'
# Domain

definitions:
  Pet:
    type: object
    discriminator: petType
    properties:
      name:
        type: string
      petType:
        type: string
        enum: [Cat, Dog]
    required:
    - name
    - petType

  Cat:  ## "Cat" will be used as the discriminator value
    description: A representation of a cat
    allOf:
    - $ref: '#/definitions/Pet'
    - type: object
      properties:
        huntingSkill:
          type: string
          description: The measured skill for hunting
          enum:
          - clueless
          - lazy
          - adventurous
          - aggressive
      required:
      - huntingSkill

  Dog:  ## "Dog" will be used as the discriminator value
    description: A representation of a dog
    allOf:
    - $ref: '#/definitions/Pet'
    - type: object
      properties:
        packSize:
          type: integer
          format: int32
          description: the size of the pack the dog is from
          default: 0
          minimum: 0
      required:
      - packSize

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