Skip to content

Commit dc9650b

Browse files
authored
fix(config): address getting configUrl from options (#9840)
Refs #9819
1 parent 6cba057 commit dc9650b

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

src/core/config/defaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const defaultOptions = Object.freeze({
99
spec: {},
1010
url: "",
1111
urls: null,
12+
configUrl: null,
1213
layout: "BaseLayout",
1314
docExpansion: "list",
1415
maxDisplayedTags: -1,

src/core/config/sources/query.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ const optionsFromQuery = () => (options) => {
1313
const urlSearchParams = options.queryConfigEnabled ? parseSearch() : {}
1414

1515
return Object.entries(urlSearchParams).reduce((acc, [key, value]) => {
16-
if (key === "urls.primaryName") {
16+
// TODO([email protected]): drop support for `config` in the next major release
17+
if (key === "config") {
18+
acc["configUrl"] = value
19+
} else if (key === "urls.primaryName") {
1720
acc[key] = value
1821
} else {
1922
acc = set(acc, key, value)

src/core/config/type-cast/mappings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import undefinedStringTypeCaster from "./type-casters/undefined-string"
1515
import defaultOptions from "../defaults"
1616

1717
const typeCasters = {
18-
configUrl: { typeCaster: stringTypeCaster },
18+
configUrl: { typeCaster: nullableStringTypeCaster },
1919
deepLinking: {
2020
typeCaster: booleanTypeCaster,
2121
defaultValue: defaultOptions.deepLinking,

src/core/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ export default function SwaggerUI(userOptions) {
5151
store.register([mergedOptions.plugins, InlinePlugin])
5252
const system = store.getSystem()
5353

54-
const configURL = queryOptions.config ?? mergedOptions.configUrl
5554
const systemOptions = optionsFromSystem({ system })(mergedOptions)
5655

57-
optionsFromURL({ url: configURL, system })(mergedOptions)
56+
optionsFromURL({ url: mergedOptions.configUrl, system })(mergedOptions)
5857
.then((urlOptions) => {
5958
const urlOptionsFailedToFetch = urlOptions === null
6059

0 commit comments

Comments
 (0)