Comments (5)
According to docs there are 4 settings that contain names with dots:
syntaxHighlight.activated
syntaxHighlight.theme
urls.primaryName
It looks to me like request.curlOptions
is not a separate option but something that we should set inside requestInterceptor
, ex.:
requestInterceptor: (request) => {
request.curlOptions = ["-g", "--limit-rate 20k"]
return request
}
In case of urls.primaryName
, there exists the urls
setting but it's actually an array. The way we access it is correct, as in we take urls.primaryName
as a name of a config and not as a path inside an object:
It seems like the only settings that would need to be merged into another are to do with syntaxHighlight
.
from swagger-ui.
It looks like the place to merge the options would be after merging the different configs
Line 195 in 8ba4ffc
We need to take care of the precedence of the configs, which is:
From lowest to highest precedence:
The swagger-config.yaml in the project root directory, if it exists, is baked into the application
configuration object passed as an argument to Swagger UI (SwaggerUI({ ... }))
configuration document fetched from a specified configUrl
configuration items passed as key/value pairs in the URL query string
so we can't just overwrite the syntaxHighlight
properties if we have syntaxHighlight.activated
and/or syntaxHighlight.theme
.
For example if we have:
syntaxHighlight.activated: false
passed to Swagger UI as an argumentsyntaxHighlight: { theme: "agate", activated: true }
in the config fetched from the specifiedconfigUrl
The one that should take precedence is syntaxHighlight: { theme: "agate", activated: true }
, so we can't simply do something like this:
if (mergedConfig["syntaxHighlight.activated"]) {
mergedConfig.syntaxHighlight.activated = mergedConfig["syntaxHighlight.activated"]
}
as the result would be: syntaxHighlight: { theme: "agate", activated: false }
.
Additionally, it's possible that we could initially set syntaxHighlight: false
and then in the URL search params specify syntaxHighlight.activated=true
, so trying to access mergedConfig.syntaxHighlight.activated
would throw an error.
from swagger-ui.
A rough idea for setting syntaxHighlight
:
const setSyntaxHighlight = (config) => {
if (typeof config.syntaxHighlight === "object") {
mergedConfig.syntaxHighlight = config.syntaxHighlight
} else if (config.syntaxHighlight === false) {
mergedConfig.syntaxHighlight = false
}
if (config["syntaxHighlight.activated"]!= null) {
mergedConfig.syntaxHighlight = !mergedConfig.syntaxHighlight
? { activated: config["syntaxHighlight.activated"], theme: "agate" }
: { ...mergedConfig.syntaxHighlight, activated: config["syntaxHighlight.activated"] }
}
if (config["syntaxHighlight.theme"] != null) {
mergedConfig.syntaxHighlight = !mergedConfig.syntaxHighlight
? { theme: config["syntaxHighlight.theme"], activated: true}
: { ...mergedConfig.syntaxHighlight, theme: config["syntaxHighlight.theme"] }
}
}
setSyntaxHighlight(localConfig)
setSyntaxHighlight(combinedConfig)
setSyntaxHighlight(fetchedConfig)
setSyntaxHighlight(queryConfig)
delete mergedConfig["syntaxHighlight.activated"]
delete mergedConfig["syntaxHighlight.theme"]
from swagger-ui.
According to docs there are 3 settings that contain names with dots:
syntaxHighlight.activated
syntaxHighlight.theme
urls.primaryName
We've decided that the only way to set these types of options would be through query parameters.
As such, we'll only need to check for them after getting query options and then set them inside the objects by using the immutable lodash set
(from lodash/fp/set
). After doing so, we can safely delete these settings from the query config.
from swagger-ui.
Addressed in 6923111
from swagger-ui.
Related Issues (20)
- Resolver error: Could not resolve reference: Could not resolve pointer:
- Swagger UI not showing on vercel? I have a solution here it is HOT 1
- Only first path parameter is replaced in "Try it out" HOT 4
- ramda-adjunct tried to access ramda HOT 5
- Addition of audience parameter to oauth config
- OpenAPI 3.1.: examples in webhooks are being overwritten by the examples in schema HOT 4
- [OpenAPI 3.1] Example value is not generated for nested objects that are referenced via allOf HOT 11
- Add missing default configuration options HOT 6
- CSS source map is broken HOT 1
- operation level server override option always appears for OAS 3.1 specification HOT 2
- No name property is assigned to "Server" Combobox.
- 5.17.12 HOT 1
- Add a dark mode for the page
- swagger-ui-react: spec does not update on prop change and resets to default on page refresh HOT 1
- Path Parameter is not being passed through Request URL and Curl Command. HOT 3
- UI css scrambled
- Ensures the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds (.btn-primary)
- Swagger-UI DownloadURL autocomplete
- Resolver error at $ref Could not resolve reference: JSON Pointer evaluation failed while evaluating token "paths" against an unexpected Element
- Idk
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swagger-ui.