0

I am doing a swagger file and there are some occasions when I use the same object on different cases. I am asking to myself if there is any way to change, for example, the mandatory fields from the place where the object is referenced and not on the object. An example:

ObjectA:
    type: object
    required:
        - A_1
    properties:
        A_1:
            type: string
        A_2:
            type: string
        A_3:
            type: string

Object_uses_A_1
    type: object
    properties:
        A:
            $ref: '#/definitions/ObjectA'
            # Any way to make A_2 a required field of ObjectA in this case??
        Other:
            type: string

Object_uses_A_2
    type: object
    properties:
        A:
            $ref: '#/definitions/ObjectA'
            # Any way to make A_3 a required field of ObjectA in this case??
        Other:
            type: string
Cœur
  • 37,241
  • 25
  • 195
  • 267
Eloy Fernández Franco
  • 1,350
  • 1
  • 24
  • 47
  • Possible duplicate of [How to make a field in a definition required for some operations and not others](https://stackoverflow.com/questions/30895944/how-to-make-a-field-in-a-definition-required-for-some-operations-and-not-others) – Helen Sep 15 '17 at 15:31
  • Thanks @Helen I'll check!! – Eloy Fernández Franco Sep 15 '17 at 15:32
  • To recap the linked Q&A: No, it's not possible to override the required properties. You'll have to define these properties in each model and add them to `required` where needed. – Helen Sep 15 '17 at 15:33

0 Answers0