Open pawelngei opened 1 year ago
Hi @pawelngei
yeah, some extensions would be nice... but I would not make it a separate parameter like NinjaAPI(swagger_params={})
- the idea for future is add ability to add way more OpenAPI doc viewers as plugins (swagger, redocs, rapidocs, etc)
I think most flexible approach would be to just add a context that will be passed to a html template that renders that doc engine.. like:
api = NinjaAPI(docs_context={'swagger': {'persistAuthorization': True}}}
If I was to write the code (can't promise I'll have time right now), would it be enough to pass and test docs_context
for swagger
only, or should I test redoc
as well? Should I update the docs, or leave it to you / other maintainers?
Created a PR implementing both Swagger, Redoc and tests, hopefully it's good enough to get merged ;)
Is your feature request related to a problem? Please describe. Currently Django-Ninja's Swagger doesn't remember tokens between refresh, which can be pretty annoying when developing permission-heavy endpoints requiring refreshing the docs. As far as I'm aware, the
openapi_extra
doesn't pass any parameters (like https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/ ) to SwaggerUI itself.Describe the solution you'd like We could introduce a new parameter, like
swaggerui_params
(and maybe a matchingredoc_params
), which will be a dictionary of parameters passed to each UI (for example viaswagger.html
orswagger-ui-init.js
)Alternatively, we could set
persistAuthorization
as a separate boolean option toNinjaAPI
, as justpersist_doc_authorization=true
. This will be a simpler case, but might be limiting to the users in the long run.Should we implement either of these, it would be good to put an example in the docs, especially https://django-ninja.rest-framework.com/guides/api-docs/ .