swagger: change default example based on tag

Viewed 26

New to swagger, but can't find out if this is possible. This is a bad example, but for simplicity's sake:

Pretend I have an api endpoint /animal/{type}. {type} is a string with enum: ["bird", "fish", "mammal"]. I have tags Fly, Swim, and Run. I've created three examples under components: examples: and added the $ref. When I go to the swagger page, I have my three sections, Fly, Swim, and Run, with the endpoint under it. I can change the example in the example dropdown, etc. That's all working great.

Is there a way to tell swagger to set the default to the bird example in the Fly section, the fish example in the swim section, and the mammal example in the Run section? Everything else for that api endpoint is the same, so I don't want to make 3 separate entries and have to update 3 different sections whenever there is a change.

I was hoping there might be a way under example: to say if section === 'Fly' then set the default somehow. Maybe just change the order of the examples (ugly but would work) or set the default example to a ref.

Thanks!

0 Answers
Related