diff --git a/src/core/components/object-model.jsx b/src/core/components/object-model.jsx index 9cea3e48..0f323a4a 100644 --- a/src/core/components/object-model.jsx +++ b/src/core/components/object-model.jsx @@ -43,6 +43,7 @@ export default class ObjectModel extends Component { let requiredProperties = schema.get("required") let infoProperties = schema .filter( ( v, key) => ["maxProperties", "minProperties", "nullable"].indexOf(key) !== -1 ) + let deprecated = schema.get("deprecated") const JumpToPath = getComponent("JumpToPath", true) const Markdown = getComponent("Markdown", true) @@ -92,6 +93,18 @@ export default class ObjectModel extends Component { } + { + !deprecated ? null : + + + deprecated: + + + true + + + + } { !(properties && properties.size) ? null : properties.entrySeq().filter( ([, value]) => { diff --git a/test/e2e-cypress/static/documents/bugs/6369-oas2-display.yaml b/test/e2e-cypress/static/documents/bugs/6369-oas2-display.yaml new file mode 100644 index 00000000..d45fe498 --- /dev/null +++ b/test/e2e-cypress/static/documents/bugs/6369-oas2-display.yaml @@ -0,0 +1,26 @@ +swagger: "2.0" +info: + description: "OAS 2.0 sample with Object Model deprecated: true" + version: "0.0.1" + title: "Swagger Sample" +paths: + /test/: + get: + responses: + '200': + description: Successful Response +definitions: + IdentificationProfile: + type: object + deprecated: true + properties: + code: + type: integer + format: int32 + message: + type: string + IDP2: + type: array + deprecated: true + items: + type: string diff --git a/test/e2e-cypress/static/documents/bugs/6369-oas2-no-display.yaml b/test/e2e-cypress/static/documents/bugs/6369-oas2-no-display.yaml new file mode 100644 index 00000000..8e875428 --- /dev/null +++ b/test/e2e-cypress/static/documents/bugs/6369-oas2-no-display.yaml @@ -0,0 +1,26 @@ +swagger: "2.0" +info: + description: "OAS 2.0 sample with Object Model deprecated: true" + version: "0.0.1" + title: "Swagger Sample" +paths: + /test/: + get: + responses: + '200': + description: Successful Response +definitions: + IdentificationProfile: + type: object + deprecated: false + properties: + code: + type: integer + format: int32 + message: + type: string + IDP2: + type: array + deprecated: true + items: + type: string diff --git a/test/e2e-cypress/static/documents/bugs/6369-oas3-display.yaml b/test/e2e-cypress/static/documents/bugs/6369-oas3-display.yaml new file mode 100644 index 00000000..88c83b15 --- /dev/null +++ b/test/e2e-cypress/static/documents/bugs/6369-oas3-display.yaml @@ -0,0 +1,28 @@ +openapi: 3.0.2 +info: + title: "OAS 3.0 sample with Object Model deprecated: true" + version: 0.1.0 +servers: + - url: http://testserver1.com +paths: + /test/: + get: + responses: + '200': + description: Successful Response +components: + schemas: + IdentificationProfile: + type: object + deprecated: true + properties: + code: + type: integer + format: int32 + message: + type: string + IDP2: + type: array + deprecated: true + items: + type: string diff --git a/test/e2e-cypress/static/documents/bugs/6369-oas3-no-display.yaml b/test/e2e-cypress/static/documents/bugs/6369-oas3-no-display.yaml new file mode 100644 index 00000000..3508f5a0 --- /dev/null +++ b/test/e2e-cypress/static/documents/bugs/6369-oas3-no-display.yaml @@ -0,0 +1,28 @@ +openapi: 3.0.2 +info: + title: "OAS 3.0 sample with Object Model deprecated: true" + version: 0.1.0 +servers: + - url: http://testserver1.com +paths: + /test/: + get: + responses: + '200': + description: Successful Response +components: + schemas: + IdentificationProfile: + type: object + deprecated: false + properties: + code: + type: integer + format: int32 + message: + type: string + IDP2: + type: array + deprecated: true + items: + type: string diff --git a/test/e2e-cypress/tests/bugs/6369.js b/test/e2e-cypress/tests/bugs/6369.js new file mode 100644 index 00000000..9182f4da --- /dev/null +++ b/test/e2e-cypress/tests/bugs/6369.js @@ -0,0 +1,44 @@ +describe("#6369: Object model render of field: deprecated", () => { + describe("OAS3", () => { + it("should display row with td:deprecated when set to true", () => { + cy.visit("/?url=/documents/bugs/6369-oas3-display.yaml") + .get("#model-IdentificationProfile > .model-box") + .click() + .get("#model-IdentificationProfile .model-box .model .inner-object table") + .find("tr") + .should("have.length", 3) + .contains("td", "deprecated") + }) + it("should not display row with td:deprecated when set to false", () => { + cy.visit("/?url=/documents/bugs/6369-oas3-no-display.yaml") + .get("#model-IdentificationProfile > .model-box") + .click() + .get("#model-IdentificationProfile .model-box .model .inner-object table") + .find("tr") + .should("have.length", 2) + .get("#model-IdentificationProfile .model-box .model .inner-object table") + .find(("td:contains(\"deprecated\")")) + .should("not.exist") + }) + }) + describe ("OAS2", () => { + it("should display row with td:deprecated when set to true", () => { + cy.visit("/?url=/documents/bugs/6369-oas2-display.yaml") + .get("#model-IdentificationProfile > .model-box") + .click() + .get("#model-IdentificationProfile .model-box .model .inner-object") + .contains("td", "deprecated") + }) + it("should not display row with td:deprecated when set to false", () => { + cy.visit("/?url=/documents/bugs/6369-oas2-no-display.yaml") + .get("#model-IdentificationProfile > .model-box") + .click() + .get("#model-IdentificationProfile .model-box .model .inner-object table") + .find("tr") + .should("have.length", 2) + .get("#model-IdentificationProfile .model-box .model .inner-object table") + .find(("td:contains(\"deprecated\")")) + .should("not.exist") + }) + }) +})