Myles J
Myles J

Reputation: 2880

How do I change the order of controllers in Swagger?

OrderActionsBy appears to be available for ordering methods within controllers but what about ordering controllers?

Upvotes: 5

Views: 3478

Answers (2)

Christian Davén
Christian Davén

Reputation: 18187

It appears that the order of the controllers (or tags, or action groups) is defined by the controller classes' filenames!

I stumbled on this, and it may not be entirely correct, but changing from "XyzController.cs" to "1XyzController.cs" put the controller at the top in the documentation!

It seems this changes the order of the tags in the tags array in swagger.json.

(This order does not, however, keep when exporting to HTML from the Swagger Editor.)

Upvotes: 1

KiKoS
KiKoS

Reputation: 438

Actually i don't think it's possible, there is an open issue from 2018 on the Swashbuckle repository on github that suggests a possible solution to the problem but it never got implemented. Github

Edit: i thought that the implementation on github got embraced but it wasn't.

Upvotes: 5

Related Questions