swagger-api / swagger-api/swagger-ui
Support Json spec overwrite attribute after fetch spec from URL, URLs or local path
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Content & configuration
Swagger/OpenAPI definition:
Pet Store Example
Swagger-UI configuration options:
I'm just using dev-helper-initializer
/* eslint-disable no-undef */
window.onload = function() {
window["SwaggerUIBundle"] = window["swagger-ui-bundle"]
window["SwaggerUIStandalonePreset"] = window["swagger-ui-standalone-preset"]
// Build a system
const ui = SwaggerUIBundle({
urls: [
{url:"https://petstore3.swagger.io/api/v3/openapi.json",name:"Pet Store Example",specOverwrite: {servers:[{ "url": "http://test.com" },{ "url": "http://real.org" }]}},
],
dom_id: "#swagger-ui",
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
// requestSnippetsEnabled: true,
layout: "StandaloneLayout"
})
window.ui = ui
ui.initOAuth({
clientId: "your-client-id",
clientSecret: "your-client-secret-if-required",
realm: "your-realms",
appName: "your-app-name",
scopeSeparator: " ",
scopes: "openid profile email phone address",
additionalQueryStringParams: {},
useBasicAuthenticationWithAccessCodeGrant: false,
usePkceWithAuthorizationCodeGrant: false
})
}
?yourQueryStringConfig
Is your feature request related to a problem?
Describe the solution you'd like
- The idea is to provide additional config to overwrite or add JSON spec attribute after fetching from URL, URLs or local path
Describe alternatives you've considered
- This is my draft PR: https://github.com/swagger-api/swagger-ui/pull/9614
- Sorry, Frontend is not my expertise, but hopefully you could understand the idea
Additional context
- Sometimes the service returns JSON spec is underlying gateway domain. Service doesn't need to know about it's domain. And the server domain could be controlled by DevOps team. In order to do that, instead of passing the domain ENV into the service. We could overwrite the spec attribute after fetch
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 with the SwaggerUIBundle configuration and the dev-helper-initializer example, then compare the behavior with the draft PR at #9614. Trace how specs from urls, a URL, or a local path are fetched and determine where the requested overwrite configuration should be applied. Done means the configured JSON attributes are applied after fetching each supported spec source.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, openapi
- Domain
- api, frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100