Skip to content

Commit

Permalink
feat(deps): integrate swagger-client@3.22.0 (#9202)
Browse files Browse the repository at this point in the history
  • Loading branch information
char0n committed Sep 13, 2023
1 parent 2c04153 commit d89726a
Show file tree
Hide file tree
Showing 6 changed files with 502 additions and 510 deletions.
1 change: 1 addition & 0 deletions config/jest/jest.artifact.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ module.exports = {
rootDir: path.join(__dirname, '..', '..'),
testEnvironment: 'jsdom',
testMatch: ['**/test/build-artifacts/**/*.js'],
setupFiles: ['<rootDir>/test/unit/jest-shim.js'],
transformIgnorePatterns: ['/node_modules/(?!(swagger-client|react-syntax-highlighter)/)'],
};
973 changes: 476 additions & 497 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"reselect": "^4.1.8",
"serialize-error": "^8.1.0",
"sha.js": "^2.4.11",
"swagger-client": "^3.20.0",
"swagger-client": "^3.22.0",
"url-parse": "^1.5.10",
"xml": "=1.0.1",
"xml-but-prettier": "^1.0.1",
Expand Down
16 changes: 16 additions & 0 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ export default function SwaggerUI(opts) {
},
spec: {
spec: "",
// support Relative References
url: constructorConfig.url
? new URL(constructorConfig.url, document.baseURI || location.href).toString()
: constructorConfig.url,
},
requestSnippets: constructorConfig.requestSnippets
}, constructorConfig.initialState)
Expand Down Expand Up @@ -190,6 +193,19 @@ export default function SwaggerUI(opts) {
let localConfig = system.specSelectors.getLocalConfig ? system.specSelectors.getLocalConfig() : {}
let mergedConfig = deepExtend({}, localConfig, constructorConfig, fetchedConfig || {}, queryConfig)

// support Relative References in `url` config option
if (mergedConfig.url) {
mergedConfig.url = new URL(mergedConfig.url, document.baseURI || location.href).toString()
}

// support Relative References in `urls` config option
if (Array.isArray(mergedConfig.urls)) {
mergedConfig.urls = mergedConfig.urls.map(({ url , ...rest}) => ({
url: new URL(url, document.baseURI || location.href).toString(),
...rest,
}))
}

// deep extend mangles domNode, we need to set it manually
if(domNode) {
mergedConfig.domNode = domNode
Expand Down
13 changes: 8 additions & 5 deletions test/e2e-cypress/e2e/features/urls.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ describe("configuration options: `urls` and `urls.primaryName`", () => {
.get("select > option")
.eq(0)
.should("have.text", "One")
.should("have.attr", "value", "/documents/features/urls/1.yaml")
.should("have.attr", "value", )
.and("match", /\/documents\/features\/urls\/1\.yaml$/)
.get("select > option")
.eq(1)
.should("have.text", "Two")
.should("have.attr", "value", "/documents/features/urls/2.yaml")
.should("have.attr", "value")
.and("match", /\/documents\/features\/urls\/2\.yaml$/)
})

it("should render the first URL in the list", () => {
Expand All @@ -21,19 +23,20 @@ describe("configuration options: `urls` and `urls.primaryName`", () => {
.should("have.text", "OneOAS 2.0")
.window()
.then(win => win.ui.specSelectors.url())
.should("equal", "/documents/features/urls/1.yaml")
.should("match", /\/documents\/features\/urls\/1\.yaml$/)
})
})

it("should respect a `urls.primaryName`", () => {
cy.visit("/?configUrl=/configs/urls-primary-name.yaml")
.get("select")
.should("have.value", "/documents/features/urls/2.yaml")
.should("contain.value", "/documents/features/urls/2.yaml")
.get("h2.title")
.should("have.text", "TwoOAS 3.0")
.window()
.then(win => win.ui.specSelectors.url())
.should("equal", "/documents/features/urls/2.yaml")
.get("select")
.should("contain.value", "/documents/features/urls/2.yaml")
})
})

Expand Down
7 changes: 0 additions & 7 deletions test/e2e-cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ import "./commands"
// Alternatively you can use CommonJS syntax:
// require('./commands')


// Remove fetch, so Cypress can intercept XHRs
// see https://github.com/cypress-io/cypress/issues/95
Cypress.on("window:before:load", win => {
win.fetch = null
})

Cypress.on("uncaught:exception", (err, runnable) => {
console.log(JSON.stringify(err, null, 2))
return true
Expand Down

0 comments on commit d89726a

Please sign in to comment.