swagger-api / swagger-api/swagger-ui

passing config to swagger-ui-dist to be able to set swagger URL

Open
#9,237 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

How do I pass config to swagger-ui-dist?

I just need to do something like

import swaggerUI from 'swagger-ui-dist';
const swaggerUI.updateConfig({url: MY_CUSTOM_URL_TO_SWAGGER_FILE});
const swaggerUiAssetPath = swaggerUI.getAbsoluteFSPath();

ofc updateConfig method is something I made up as a pseudo code for demonstration of what I want to do.

I have seen some solution in issue https://github.com/swagger-api/swagger-ui/issues/9163 with adding a custom html initialiser. But honestly it's ugly solution and adds complexity with handling of serving this html file, and taking care of its dependencies. In my opinion kind of goes against the original idea of swagger-ui-dist. There must be a better way.

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 by examining how swagger-ui-dist is used to serve the bundled assets and compare it with the custom HTML initializer described in issue 9163. The work is done when consumers can provide a custom Swagger URL through the package without maintaining a separate HTML initializer.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.