Swagger UI Dist Config
See original GitHub issueTemporary solution: …open-api.controller.ts
@Get('/')
async index(ctx: Context) {
...
const template = await promisify(readFile)(join('your_custom_index_template_path/index.tpl.html'), 'utf8');
...
}
…your_custom_index_template/index.tpl.html
...
const ui = SwaggerUIBundle({
{{ urls }},{{ primaryName }}
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout",
...more config here
})
...
I think this is quite inconvenience now. Maybe we should add swaggerui option in the option of opneapi if we are still using swagger-ui-dist? Or maybe adding this tutorial to cookbook if nothing is gonna change in short time?
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Configuration - Swagger Documentation
Swagger UI accepts configuration parameters in four locations. From lowest to highest precedence: The swagger-config.yaml in the project root directory, if it ...
Read more >Configure swagger-ui-dist URL server side #5710 - GitHub
This issue is related to the #4624 and the swagger-ui-dist library. There is no way to change the url on the server side...
Read more >swagger-ui-dist - npm
Start using swagger-ui-dist in your project by running `npm i swagger-ui-dist`. There are 368 other projects in the npm registry using ...
Read more >How to use the swagger-ui-dist.absolutePath function in ...
To help you get started, we've selected a few swagger-ui-dist.absolutePath examples, based on ... config'; export default () => { const swaggerIndex =...
Read more >Swagger UI tutorial | Documenting APIs - Idratherbewriting.com
In your command prompt, browse to the Swagger UI dist directory. To browse in the Windows command ... Configuring Swagger UI parameters.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Ok, I see. I took a look at the Swagger documentation as well, most of the options can be “stringified”.
Here how I see how to update to the
SwaggerController:To implement this, we need to:
Update
index.tpl.html.Update the files
index.*.spec.html(that test template renders for each scenario) to end with:Add two new tests to
swagger-controller.spec.ts:SwaggerController>has a "index" method that>should properly render the template given options are { url: "xxx" } and uiOptions are { docExpansion:"none" }.. Spec file to add:index.url.ui-options.spec.html.SwaggerController>has a "index" method that>should properly render the template given options are [{ url: "v1.json", name: "v1" }] and uiOptions are { docExpansion:"none" }.Spec file to add:index.no-primary.ui-options.spec.html.Finally update
swagger-controller.tsto use theuiOptionswithJSON.strifigify(lines 94 & 109)Don’t worry, the PR does not require to add too much code. The two new tests are pretty much a copy-past of old ones as well as the new template specs. If you feel like to take it, I’ll assign it to you.
should properly render the template given options are { url: "xxx" } and uiOptions are { docExpansion:"none" }inspired fromshould properly render the template given options are { url: "xxx" }should properly render the template given options are [{ url: "v1.json", name: "v1" }] and uiOptions are { docExpansion:"none" }inspired fromshould properly render the template given options are [{ url: "v1.json", name: "v1" } ...]index.url.ui-options.spec.htmlinspired fromindex.url.spec.htmlindex.no-primary.ui-options.spec.htmlinspired fromindex.no-primary.spec.html