Forum Discussion

nandan's avatar
nandan
New Contributor
2 years ago
Solved

how to change the order of display when using inheritance

hi  Experts/colleagues,

i'm using the the swagger UI latest version for my swagger API documentation.

When using the inheritance via allOf capability, the swagger UI does not respect the order in which the properties are added.

pseudo code:

Approach 1 : 

Customer:

  properties:

    id:...

    userName:...

    allOf:

      - $ref: #/component/schemas/Address

      - type: object

Approach 2:

Customer:

  type: object

   allOf:

      - $ref: #/component/schemas/Address

      - type: object

         properties:

             id:...

             userName:...

 

irrespective of the above two approaches, the swagger UI displays the properties of the Address first and then later the individual properties of the Address object.

 

Can you please share , how i could control the order of the display using the YAML representation  of openAPI specification.

thanks!!

Sharing an Example using the User and Address.

my goal: i would like to have the ID first in the Swagger UI