Some checks failed
Node.js CI / build (push) Failing after 2s
Node.js CI / e2e-tests (+(a11y|security|bugs)/**/*cy.js) (push) Failing after 2s
Node.js CI / e2e-tests (features/**/!(o|d|m)*.cy.js) (push) Failing after 2s
Node.js CI / e2e-tests (features/**/+(o|d)*.cy.js) (push) Failing after 2s
Node.js CI / e2e-tests (features/**/m*.cy.js) (push) Failing after 2s
CodeQL / Analyze (javascript) (push) Failing after 1m15s
Security scan for docker image / build (push) Failing after 59s
29 lines
716 B
JavaScript
Executable File
29 lines
716 B
JavaScript
Executable File
/**
|
|
* @prettier
|
|
*/
|
|
import set from "lodash/set"
|
|
import { parseSearch } from "core/utils"
|
|
|
|
/**
|
|
* Receives options from the query string of the URL where SwaggerUI
|
|
* is being served.
|
|
*/
|
|
|
|
const optionsFromQuery = () => (options) => {
|
|
const urlSearchParams = options.queryConfigEnabled ? parseSearch() : {}
|
|
|
|
return Object.entries(urlSearchParams).reduce((acc, [key, value]) => {
|
|
// TODO(oliwia.rogala@smartbear.com): drop support for `config` in the next major release
|
|
if (key === "config") {
|
|
acc["configUrl"] = value
|
|
} else if (key === "urls.primaryName") {
|
|
acc[key] = value
|
|
} else {
|
|
acc = set(acc, key, value)
|
|
}
|
|
return acc
|
|
}, {})
|
|
}
|
|
|
|
export default optionsFromQuery
|