Skip to content

Commit

Permalink
fix(config): address getting configUrl from options (#9840)
Browse files Browse the repository at this point in the history
Refs #9819
  • Loading branch information
glowcloud committed Apr 18, 2024
1 parent 6cba057 commit dc9650b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/core/config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const defaultOptions = Object.freeze({
spec: {},
url: "",
urls: null,
configUrl: null,
layout: "BaseLayout",
docExpansion: "list",
maxDisplayedTags: -1,
Expand Down
5 changes: 4 additions & 1 deletion src/core/config/sources/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/core/config/type-cast/mappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit dc9650b

Please sign in to comment.