feat(deps): integrate swagger-client@3.22.0 (#9202)

This commit is contained in:
Vladimír Gorej
2023-09-13 10:43:27 +02:00
committed by GitHub
parent 2c04153614
commit d89726a24b
6 changed files with 502 additions and 510 deletions

View File

@@ -4,5 +4,6 @@ module.exports = {
rootDir: path.join(__dirname, '..', '..'), rootDir: path.join(__dirname, '..', '..'),
testEnvironment: 'jsdom', testEnvironment: 'jsdom',
testMatch: ['**/test/build-artifacts/**/*.js'], testMatch: ['**/test/build-artifacts/**/*.js'],
setupFiles: ['<rootDir>/test/unit/jest-shim.js'],
transformIgnorePatterns: ['/node_modules/(?!(swagger-client|react-syntax-highlighter)/)'], transformIgnorePatterns: ['/node_modules/(?!(swagger-client|react-syntax-highlighter)/)'],
}; };

973
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -105,7 +105,7 @@
"reselect": "^4.1.8", "reselect": "^4.1.8",
"serialize-error": "^8.1.0", "serialize-error": "^8.1.0",
"sha.js": "^2.4.11", "sha.js": "^2.4.11",
"swagger-client": "^3.20.0", "swagger-client": "^3.22.0",
"url-parse": "^1.5.10", "url-parse": "^1.5.10",
"xml": "=1.0.1", "xml": "=1.0.1",
"xml-but-prettier": "^1.0.1", "xml-but-prettier": "^1.0.1",

View File

@@ -153,7 +153,10 @@ export default function SwaggerUI(opts) {
}, },
spec: { spec: {
spec: "", spec: "",
// support Relative References
url: constructorConfig.url url: constructorConfig.url
? new URL(constructorConfig.url, document.baseURI || location.href).toString()
: constructorConfig.url,
}, },
requestSnippets: constructorConfig.requestSnippets requestSnippets: constructorConfig.requestSnippets
}, constructorConfig.initialState) }, constructorConfig.initialState)
@@ -190,6 +193,19 @@ export default function SwaggerUI(opts) {
let localConfig = system.specSelectors.getLocalConfig ? system.specSelectors.getLocalConfig() : {} let localConfig = system.specSelectors.getLocalConfig ? system.specSelectors.getLocalConfig() : {}
let mergedConfig = deepExtend({}, localConfig, constructorConfig, fetchedConfig || {}, queryConfig) 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 // deep extend mangles domNode, we need to set it manually
if(domNode) { if(domNode) {
mergedConfig.domNode = domNode mergedConfig.domNode = domNode

View File

@@ -8,11 +8,13 @@ describe("configuration options: `urls` and `urls.primaryName`", () => {
.get("select > option") .get("select > option")
.eq(0) .eq(0)
.should("have.text", "One") .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") .get("select > option")
.eq(1) .eq(1)
.should("have.text", "Two") .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", () => { it("should render the first URL in the list", () => {
@@ -21,19 +23,20 @@ describe("configuration options: `urls` and `urls.primaryName`", () => {
.should("have.text", "OneOAS 2.0") .should("have.text", "OneOAS 2.0")
.window() .window()
.then(win => win.ui.specSelectors.url()) .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`", () => { it("should respect a `urls.primaryName`", () => {
cy.visit("/?configUrl=/configs/urls-primary-name.yaml") cy.visit("/?configUrl=/configs/urls-primary-name.yaml")
.get("select") .get("select")
.should("have.value", "/documents/features/urls/2.yaml") .should("contain.value", "/documents/features/urls/2.yaml")
.get("h2.title") .get("h2.title")
.should("have.text", "TwoOAS 3.0") .should("have.text", "TwoOAS 3.0")
.window() .window()
.then(win => win.ui.specSelectors.url()) .then(win => win.ui.specSelectors.url())
.should("equal", "/documents/features/urls/2.yaml") .get("select")
.should("contain.value", "/documents/features/urls/2.yaml")
}) })
}) })

View File

@@ -19,13 +19,6 @@ import "./commands"
// Alternatively you can use CommonJS syntax: // Alternatively you can use CommonJS syntax:
// require('./commands') // 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) => { Cypress.on("uncaught:exception", (err, runnable) => {
console.log(JSON.stringify(err, null, 2)) console.log(JSON.stringify(err, null, 2))
return true return true