I am trying to design an endpoint of our API and the payload is an object 
which (in Java) is represented by a base class and several sub classes.

definitions:

  AnimalType:

    type: string

    enum: &animal_type_values

    - dog

    - cat

    - pig

    - horse


  EntityType:

    description: An enumeration of the supported entity types

    type: string

    enum:

    - Animal

    - Crop

    - Person

    - Building


  Entity:

    discriminator: entity_type

    required:

      - entity_type

      - id

    properties:

      id:

        type: integer

        format: int64

        readOnly: true

        description: The internal entity id for this entity representation

        example: 1438752

      entity_type:

        $ref: '#/definitions/EntityType'


  AnimalPayload:

    discriminator: animal_type

    allOf:

      - $ref: '#/definitions/Dog'

      - $ref: '#/definitions/Cat'

      - $ref: '#/definitions/Pig'

      - $ref: '#/definitions/Horse'


  Animal:

    discriminator: animal_type

    allOf:

      - $ref: '#/definitions/Entity'

      - type: object

        required:

          - animal_type

        properties:

          animal_type:

            $ref: '#/definitions/AnimalType'

          name:

            type: string

            readOnly: true    

          birth_date:

            type: string

            format: date

         breed:



  Dog:

    allOf:

      - $ref: '#/definitions/Animal'

      - type: object

        properties:

          day_of_month:

            type: integer

            format: int32

            readOnly: true

  Cat:

    allOf:

      - $ref: '#/definitions/Animal'

      - type: object

        properties:

          day_of_month:

            type: integer

            format: int32

            readOnly: true

          end_month:

            type: integer

            format: int32

            readOnly: true

  YearlyBillCycle:

    allOf:

      - $ref: '#/definitions/Animal'

      - type: object

        properties:

          day_of_year:

            type: integer

            format: int32

            readOnly: true

  SegmentedMonthlyBillCycle:

    allOf:

      - $ref: '#/definitions/Animal'

      - type: object

        properties:

          daysOfMonth:

            type: string
            readOnly: true 

-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to