feat: support for showExtensions on Response objects (#6535)
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
openapi: "3.0.0"
|
||||
|
||||
paths:
|
||||
/:
|
||||
get:
|
||||
operationId: "myOperation"
|
||||
tags: ["myTag"]
|
||||
summary: an operation
|
||||
responses:
|
||||
'200':
|
||||
description: a pet to be returned
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
'404':
|
||||
x-error: true
|
||||
x-error-codes: [NOT_FOUND]
|
||||
description: Not found
|
||||
@@ -0,0 +1,15 @@
|
||||
swagger: "2.0"
|
||||
|
||||
paths:
|
||||
/:
|
||||
get:
|
||||
operationId: "myOperation"
|
||||
tags: ["myTag"]
|
||||
summary: an operation
|
||||
responses:
|
||||
"200":
|
||||
description: ok
|
||||
'404':
|
||||
x-error: true
|
||||
x-error-codes: [NOT_FOUND]
|
||||
description: Not found
|
||||
49
test/e2e-cypress/tests/features/response-extension.js
Normal file
49
test/e2e-cypress/tests/features/response-extension.js
Normal file
@@ -0,0 +1,49 @@
|
||||
describe("Response extension feature", () => {
|
||||
describe("in Swagger 2", () => {
|
||||
const swagger2BaseUrl = "/?showExtensions=true&docExpansion=full&url=/documents/features/response-extension.swagger.yaml"
|
||||
|
||||
describe("without x- values", () => {
|
||||
it("should omit response extensions section", () => {
|
||||
cy.visit(swagger2BaseUrl)
|
||||
.get("tr.response[data-code='200'] td.response-col_description div.response__extension")
|
||||
.should("not.exist")
|
||||
})
|
||||
})
|
||||
|
||||
describe("with x- values", () => {
|
||||
it("should list each value", () => {
|
||||
const page = cy.visit(swagger2BaseUrl)
|
||||
|
||||
page.get("tr.response[data-code='404'] td.response-col_description div.response__extension:nth-child(2)")
|
||||
.should("have.text", "x-error: true")
|
||||
|
||||
page.get("tr.response[data-code='404'] td.response-col_description div.response__extension:nth-child(3)")
|
||||
.should("have.text", "x-error-codes: List [ \"NOT_FOUND\" ]")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("in OpenAPI 3", () => {
|
||||
const openAPI3BaseUrl = "/?showExtensions=true&docExpansion=full&url=/documents/features/response-extension.openapi.yaml"
|
||||
|
||||
describe("without x- values", () => {
|
||||
it("should omit response extensions section", () => {
|
||||
cy.visit(openAPI3BaseUrl)
|
||||
.get("tr.response[data-code='200'] td.response-col_description div.response__extension")
|
||||
.should("not.exist")
|
||||
})
|
||||
})
|
||||
|
||||
describe("with x- values", () => {
|
||||
it("should list each value", () => {
|
||||
const page = cy.visit(openAPI3BaseUrl)
|
||||
|
||||
page.get("tr.response[data-code='404'] td.response-col_description div.response__extension:nth-child(2)")
|
||||
.should("have.text", "x-error: true")
|
||||
|
||||
page.get("tr.response[data-code='404'] td.response-col_description div.response__extension:nth-child(3)")
|
||||
.should("have.text", "x-error-codes: List [ \"NOT_FOUND\" ]")
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user