fix: models view when object key contains deprecated:true (#6371)

fixes #6369
This commit is contained in:
Tim Lai
2020-09-09 16:43:01 -07:00
committed by GitHub
parent 5123b47ef4
commit d4eea4da1b
6 changed files with 165 additions and 0 deletions

View File

@@ -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 {
</td>
</tr>
}
{
!deprecated ? null :
<tr className={"property"}>
<td>
deprecated:
</td>
<td>
true
</td>
</tr>
}
{
!(properties && properties.size) ? null : properties.entrySeq().filter(
([, value]) => {

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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")
})
})
})