Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

enum of objects in swagger UI?

I have an enum of other definitions in my Swagger spec:

"action": {
  "title": "Action",
  "description": "Action to apply to matching requests",
  "type": "object",
  "enum": [ 
    {"delayAction": {"$ref": "#/definitions/delayAction"}}, 
    {"abortAction": {"$ref": "#/definitions/abortAction"}},
    {"traceAction": {"$ref": "#/definitions/traceAction"}}
  ]
}

and delayAction, abortAction, and traceAction are all defined.

But in the Swagger UI the model for action is empty.

enter image description here

How can I modify my Swagger definition so Swagger UI can show the definition of action in the model?

like image 505
davetropeano Avatar asked Sep 03 '25 14:09

davetropeano


1 Answers

ChartFormat:
  type: object
  description: chart info
  properties:
    chartMode:
      oneOf:
      - $ref: '#/components/schemas/NumberMode'
      - $ref: '#/components/schemas/BarChartMode' 
      - $ref: '#/components/schemas/LineChartMode'
      - $ref: '#/components/schemas/PieMode'

use oneOf keyword

like image 78
XW L Avatar answered Sep 05 '25 06:09

XW L