Discriminator property cannot be a separate enum type

Issue #247 resolved
Keenan Pepper created an issue

Example schema that fails:

(The problem is that it tries to verify that petType is a string type, but since it’s a reference to another type, it doesn’t realize that it is in fact string.)

definitions:
  PetType:
    type: string
    enum:
      - Cat
      - Dog
  Pet:
    type: object
    discriminator: petType
    properties:
      name:
        type: string
      petType:
        $ref: '#/definitions/PetType'
    required:
    - name
    - petType
  Cat:
    description: A representation of a cat
    allOf:
    - $ref: '#/definitions/Pet'
    - type: object
      properties:
        huntingSkill:
          type: string
          description: The measured skill for hunting
          default: lazy
          enum:
          - clueless
          - lazy
          - adventurous
          - aggressive
      required:
      - huntingSkill
  Dog:
    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

Comments (1)

  1. Log in to comment