We have a spec with inheritance in the model definitions. The base 
definition has a discriminator property defined that is an enumeration. 
This works fine when generating the client and server. However, it is 
problematic for the documentation presented using swagger-ui.

The issue is that then the model is displayed in swagger-ui, the 
discriminator property is a dropdown list that specifies all the enum 
values as an option for that model. This is incorrect, in that only one 
enum value is valid for that definition.

Is there a way to set a default value or set the value of the discriminator 
property in the swagger spec? Or in swagger-ui?

Another option would be to hide or disable the property altogether (from a 
documentation perspective) because the property really does not need to be 
displayed at all.


definitions:
ObjectType:
  type: string
  enum:
  - dog
  - cat
  - mouse
  - snake


Animal:
    type: object
    discriminator: object_type
    required:
      - id
      - object_type
    properties:
      id:
        type: integer
        format: int64
      object_type:

        $ref: '#/definitions/ObjectType'

Cat:
  allOf:
    - $ref: '#/definitions/Animal'
    - type: object
      discriminator: object_type
      required:
        - object_type
      properties:          
        object_type:
          $ref: '#/definitions/ObjectType'
        name:
          type: string

Dog:
  allOf:
    - $ref: '#/definitions/Animal'
    - type: object
      discriminator: object_type
      required:
        - object_type
      properties:          
        object_type:
          $ref: '#/definitions/ObjectType'
        name:
          type: string


The documentation has no need for the discriminator to be displayed, at 
least in this case. Is there a way to either:

   - Hide or disable the object_type property
   - Set the value of the object_type property to the name enumeration 
   value for that type.

-- 
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