swagger-api / swagger-api/swagger-ui
Topbar plugin is only included in Standalone
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Q&A
- Method of installation: npm
- Swagger-UI version: 3.21.0
Content & configuration
Swagger-UI configuration options:
SwaggerUI({
urls: [/* ... */],
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUI.presets.apis,
SwaggerUIStandalonePreset // Brings in TopbarPlugin
],
plugins: [/* ... */],
layout: 'CustomLayoutUsingTopbar',
validatorUrl: null,
displayOperationId: true,
filter: true,
operationsSorter: 'alpha',
defaultModelsExpandDepth: 0
});
Describe the bug you're encountering
The Topbar plugin is not available in the plugins property of the Swagger UI object. It seems to live in its own directory and only gets imported in the standalone preset.
To reproduce...
Steps to reproduce the behavior:
- In your Swagger UI configuration, import
swagger-uiasSwaggerUI. - Add
SwaggerUI.plugins.Topbarto your plugin configuration. - Use a layout that includes Topbar.
- Load your Swagger UI website.
Expected behavior
The website renders, topbar and all.
Actual behavior
The website does not render and there's an error in the console:
Could not find component Topbar
Additional context or thoughts
As you can see from my configuration, I can work around this by including the Standalone preset. However, that forces me to serve a whole bunch of code that does not need to go to the browser at all.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the SwaggerUI.plugins.Topbar entry point and the SwaggerUIStandalonePreset import described in the report. Check how the Topbar plugin is exposed outside the standalone preset, then reproduce the configuration with a custom layout. Done means the site renders with Topbar available through the plugins property without requiring the standalone preset.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100