1👍
by adding another url
entry to a "js dict" you essentially override the first entry. "Last one counts" does apply to both js and python wrt dictionaries/objects. That is simply how the languages work.
What you can do is use the swagger-ui topbar feature as a selector. Notice the urls
list instead of an url
.
Also notice that this is the settings.py
snippet. No need for a custom template. This can all be achieved from the settings.
SPECTACULAR_SETTINGS = {
"SERVE_INCLUDE_SCHEMA": False,
"SWAGGER_UI_SETTINGS": '''{
deepLinking: true,
urls: [{url: "/en/api/v1/schema/yaml", name: "yaml"}, {url: "/en/api/v1/schema/json", name: "json"}],
presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset],
layout: "StandaloneLayout",
}''',
}
I don’t really understand the reason for this though. Content-wise both are identical, i.e. they contain exactly the same information just with a different encoding. And swagger-ui does translate one representation into the other internally anyway.
👤Insa
Source:stackexchange.com