fix(schema example): xml gen should follow json gen behavior (#6555)

* ref: #6470 
* fixes: #6540
* fixes: #4943 

* add example override option to json
* add example override option to xml
* added basic oneOf and anyOf support
* fix anyof|oneof
* only lift xml to items


Co-authored-by: Tim Lai <timothy.lai@gmail.com>
This commit is contained in:
Mahtis Michel
2020-11-03 19:58:59 +01:00
committed by GitHub
parent 64ae7af565
commit 288c89bdbb
8 changed files with 488 additions and 228 deletions

View File

@@ -0,0 +1,20 @@
describe("#4943: XML example not rendered correctly with oneOf", () => {
it("should render integer property correctly", () => {
cy
.visit("/?url=/documents/bugs/4943.yaml")
.get("#operations-Test-postTest")
.click()
.get(".microlight")
.contains("<b>0</b>")
})
it("should render oneOf property correctly", () => {
cy
.visit("/?url=/documents/bugs/4943.yaml")
.get("#operations-Test-postTest")
.click()
.get(".try-out__btn")
.click()
.get(".microlight")
.contains("<c>\n\t</c>")
})
})

View File

@@ -0,0 +1,11 @@
describe("#6540: XML example not rendered correctly with oneOf", () => {
it("should render xml like json", () => {
const expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test>\n\t<a>string</a>\n\t<b>0</b>\n\t<c>\n\t\t<ObjectType>Text</ObjectType>\n\t\t<Data>This is a text</Data>\n\t</c>\n\t<c>\n\t\t<ObjectType>image</ObjectType>\n\t\t<Data>This is a image</Data>\n\t</c>\n\t<d>\n\t\t<ObjectType>Text</ObjectType>\n\t\t<Data>This is a text</Data>\n\t</d>\n\t<d>\n\t\t<ObjectType>image</ObjectType>\n\t\t<Data>This is a image</Data>\n\t</d>\n</test>"
cy
.visit("/?url=/documents/bugs/6540.yaml")
.get("#operations-Test-postTest")
.click()
.get(".microlight")
.contains(expected)
})
})