fix(oas3): attempt to render schemas not resolved by swagger-client (#9629)
Refs #9513
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @prettier
|
||||
*/
|
||||
|
||||
describe("OpenAPI 3.0 complex spec with allOf and nested references", () => {
|
||||
it("should render nested references", () => {
|
||||
cy.visit("/?url=/documents/features/oas3-complex-spec.json").then(() => {
|
||||
cy.get(
|
||||
"[id='model-com.sap.ctsm.backend.core.api.study.v1.StudyAPIv1.StudyTreatments-create']"
|
||||
)
|
||||
.find("button")
|
||||
.click()
|
||||
cy.get(".property-row")
|
||||
.contains("scenario")
|
||||
.siblings()
|
||||
.as("scenarioSiblings")
|
||||
cy.get("@scenarioSiblings").find("button").click()
|
||||
cy.get("@scenarioSiblings")
|
||||
.find("span")
|
||||
.contains("scenarioID")
|
||||
.should("not.exist")
|
||||
cy.get("@scenarioSiblings")
|
||||
.find("span")
|
||||
.contains("Scenarios (for create)")
|
||||
.should("exist")
|
||||
.click()
|
||||
cy.get("@scenarioSiblings")
|
||||
.find("span")
|
||||
.contains("scenarioID")
|
||||
.should("exist")
|
||||
cy.get("@scenarioSiblings")
|
||||
.find("span")
|
||||
.contains("#/components/schemas/unresolvedRef")
|
||||
.should("exist")
|
||||
})
|
||||
})
|
||||
})
|
||||
62964
test/e2e-cypress/static/documents/features/oas3-complex-spec.json
Normal file
62964
test/e2e-cypress/static/documents/features/oas3-complex-spec.json
Normal file
File diff suppressed because it is too large
Load Diff
62
test/unit/core/plugins/oas3/selectors.js
Normal file
62
test/unit/core/plugins/oas3/selectors.js
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @prettier
|
||||
*/
|
||||
import { fromJS } from "immutable"
|
||||
import { findSchema } from "core/plugins/oas3/spec-extensions/selectors"
|
||||
|
||||
describe("findSchema", function () {
|
||||
const state = fromJS({
|
||||
resolvedSubtrees: {
|
||||
components: {
|
||||
schemas: {
|
||||
resolvedSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
name: {
|
||||
type: "string",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
json: {
|
||||
components: {
|
||||
schemas: {
|
||||
unresolvedSchema: {
|
||||
$ref: "#/components/schemas/resolvedSchema",
|
||||
},
|
||||
resolvedSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
name: {
|
||||
type: "string",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
it("should get an unresolved schema", function () {
|
||||
const result = findSchema(state, "unresolvedSchema")
|
||||
|
||||
expect(result).toEqual(
|
||||
state.getIn(["json", "components", "schemas", "unresolvedSchema"])
|
||||
)
|
||||
})
|
||||
|
||||
it("should get a resolved schema", function () {
|
||||
const result = findSchema(state, "resolvedSchema")
|
||||
|
||||
expect(result).toEqual(
|
||||
state.getIn([
|
||||
"resolvedSubtrees",
|
||||
"components",
|
||||
"schemas",
|
||||
"resolvedSchema",
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user