sanic-org / sanic-openapi

Easily document your Sanic API with a UI

Home Page:https://sanic-openapi.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] Custom Ordering of Endpoints and Authorization

amit-d-bahir opened this issue · comments

Is your feature request related to a problem? Please describe your use case.

  • Is there a way in which I can give an ordering in which the endpoints are displayed on the UI? I just want to have one endpoint at the top always.
  • Is there any way in which I can provide an argument in a decorator so that a particular endpoint does not have authorization enabled (i.e the padlock icon is not shown)

Describe the solution you'd like
For ordering, if I can give priority as topmost then it will always be on the top.
For authorization, adding a decorator that excludes_authorization.

You can control this with tags. They should appear in the order in which the tags are created.

I am able to group the endpoints using tags. But the order in which those endpoints occur under those tags on the UI is random every time I restart the server.
Is there any way I can have a particular tag always on top?

You can customize with the Swagger config

app.config.SWAGGER_UI_CONFIGURATION = {
    "operationsSorter": "method",
}

Sounds like for your need, you might need to pass a function, which can only be done in the JS. I am not sure there is a good way to do that just now.

To be 💯 honest, it is not likely to be a feature that will be added to this package. I am actively working on sanic-ext Read more. Having more control over the static assets will be something available there, and should be a near drop-in replacement for sanic-openapi (at least for OAS3, we are dropping the @doc and OAS2).

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is incorrect, please respond with an update. Thank you for your contributions.