swagger-api / swagger-api/swagger-ui

Topbar plugin is only included in Standalone

Open
#5,226 5 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: support
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:

  1. In your Swagger UI configuration, import swagger-ui as SwaggerUI.
  2. Add SwaggerUI.plugins.Topbar to your plugin configuration.
  3. Use a layout that includes Topbar.
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.