fix(config): address getting configUrl from options (#9840)

Refs #9819
This commit is contained in:
Oliwia Rogala
2024-04-18 14:35:50 +02:00
committed by GitHub
parent 6cba05706e
commit dc9650b80b
4 changed files with 7 additions and 4 deletions

View File

@@ -9,6 +9,7 @@ const defaultOptions = Object.freeze({
spec: {},
url: "",
urls: null,
configUrl: null,
layout: "BaseLayout",
docExpansion: "list",
maxDisplayedTags: -1,

View File

@@ -13,7 +13,10 @@ const optionsFromQuery = () => (options) => {
const urlSearchParams = options.queryConfigEnabled ? parseSearch() : {}
return Object.entries(urlSearchParams).reduce((acc, [key, value]) => {
if (key === "urls.primaryName") {
// 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)

View File

@@ -15,7 +15,7 @@ import undefinedStringTypeCaster from "./type-casters/undefined-string"
import defaultOptions from "../defaults"
const typeCasters = {
configUrl: { typeCaster: stringTypeCaster },
configUrl: { typeCaster: nullableStringTypeCaster },
deepLinking: {
typeCaster: booleanTypeCaster,
defaultValue: defaultOptions.deepLinking,

View File

@@ -51,10 +51,9 @@ export default function SwaggerUI(userOptions) {
store.register([mergedOptions.plugins, InlinePlugin])
const system = store.getSystem()
const configURL = queryOptions.config ?? mergedOptions.configUrl
const systemOptions = optionsFromSystem({ system })(mergedOptions)
optionsFromURL({ url: configURL, system })(mergedOptions)
optionsFromURL({ url: mergedOptions.configUrl, system })(mergedOptions)
.then((urlOptions) => {
const urlOptionsFailedToFetch = urlOptions === null