diff --git a/src/plugins/topbar/topbar.jsx b/src/plugins/topbar/topbar.jsx index 3549ece5..9dc07ba4 100644 --- a/src/plugins/topbar/topbar.jsx +++ b/src/plugins/topbar/topbar.jsx @@ -87,7 +87,8 @@ export default class Topbar extends React.Component { if(urls && urls.length) { var targetIndex = this.state.selectedIndex - let primaryName = configs["urls.primaryName"] + let search = parseSearch() + let primaryName = search["urls.primaryName"] || configs["urls.primaryName"] if(primaryName) { urls.forEach((spec, i) => { diff --git a/test/e2e-cypress/static/pages/multiple-urls/index.html b/test/e2e-cypress/static/pages/multiple-urls/index.html new file mode 100644 index 00000000..e7d47542 --- /dev/null +++ b/test/e2e-cypress/static/pages/multiple-urls/index.html @@ -0,0 +1,80 @@ + + + + + + + Swagger UI + + + + + + + + +
+ + + + + + + diff --git a/test/e2e-cypress/tests/features/plugins/topbar/linking-to-configured-urls.js b/test/e2e-cypress/tests/features/plugins/topbar/linking-to-configured-urls.js new file mode 100644 index 00000000..fc24aac0 --- /dev/null +++ b/test/e2e-cypress/tests/features/plugins/topbar/linking-to-configured-urls.js @@ -0,0 +1,23 @@ +describe("Loading specs by url.primaryName param", () => { + describe("with no param", () => { + it("should load the default spec", () => { + cy.visit("/pages/multiple-urls/index.html") + .get("span.url") + .contains("/documents/petstore-expanded.openapi.yaml") + }) + }) + describe("with an invalid param", () => { + it("should fall back to the default spec", () => { + cy.visit("/pages/multiple-urls/index.html?urls.primaryName=undefinedUrlName") + .get("span.url") + .contains("/documents/petstore-expanded.openapi.yaml") + }) + }) + describe("with a valid url.primaryName param", () => { + it("should render the requested spec", () => { + cy.visit("/pages/multiple-urls/index.html?urls.primaryName=Petstore Swagger") + .get("span.url") + .contains("/documents/petstore.swagger.yaml") + }) + }) +})