-
Notifications
You must be signed in to change notification settings - Fork 9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(oas31): render responses with empty content field (#9664)
Refs #9199
- Loading branch information
Showing
10 changed files
with
356 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
test/e2e-cypress/e2e/features/plugins/oas31/oas31-response-empty-content.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* @prettier | ||
*/ | ||
|
||
describe("OpenAPI 3.1.0 response with empty content", () => { | ||
it("should render a response", () => { | ||
cy.visit( | ||
"/?configUrl=/configs/oas31-response-no-content.yaml&url=/documents/features/oas31-response-empty-content.yaml" | ||
) | ||
.get("#operations-Enterprise-get_enterprise_detail") | ||
.click() | ||
.get( | ||
"#operations-Enterprise-get_enterprise_detail [data-code=404] .response-col_description__inner" | ||
) | ||
.contains("No enterprise matching the requested ID could be found.") | ||
.get( | ||
"#operations-Enterprise-get_enterprise_detail [data-code=404] .model-example" | ||
) | ||
.should("not.exist") | ||
}) | ||
}) |
21 changes: 21 additions & 0 deletions
21
test/e2e-cypress/e2e/features/plugins/oas31/oas31-response-empty-media-type.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* @prettier | ||
*/ | ||
|
||
describe("OpenAPI 3.1.0 response with empty Media Type Object", () => { | ||
it("should render a response", () => { | ||
cy.visit( | ||
"/?configUrl=/configs/oas31-response-no-content.yaml&url=/documents/features/oas31-response-empty-media-type.yaml" | ||
) | ||
.get("#operations-Enterprise-get_enterprise_detail") | ||
.click() | ||
.get( | ||
"#operations-Enterprise-get_enterprise_detail [data-code=404] .response-col_description__inner" | ||
) | ||
.contains("No enterprise matching the requested ID could be found.") | ||
.get( | ||
"#operations-Enterprise-get_enterprise_detail [data-code=404] .model-example" | ||
) | ||
.should("not.exist") | ||
}) | ||
}) |
21 changes: 21 additions & 0 deletions
21
test/e2e-cypress/e2e/features/plugins/oas31/oas31-response-no-content.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* @prettier | ||
*/ | ||
|
||
describe("OpenAPI 3.1.0 response without content", () => { | ||
it("should render a response", () => { | ||
cy.visit( | ||
"/?configUrl=/configs/oas31-response-no-content.yaml&url=/documents/features/oas31-response-no-content.yaml" | ||
) | ||
.get("#operations-Enterprise-get_enterprise_detail") | ||
.click() | ||
.get( | ||
"#operations-Enterprise-get_enterprise_detail [data-code=404] .response-col_description__inner" | ||
) | ||
.contains("No enterprise matching the requested ID could be found.") | ||
.get( | ||
"#operations-Enterprise-get_enterprise_detail [data-code=404] .model-example" | ||
) | ||
.should("not.exist") | ||
}) | ||
}) |
3 changes: 3 additions & 0 deletions
3
test/e2e-cypress/static/configs/oas31-response-no-content.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
defaultModelRendering: "model" | ||
defaultModelExpandDepth: 0 | ||
defaultModelsExpandDepth: -1 |
91 changes: 91 additions & 0 deletions
91
test/e2e-cypress/static/documents/features/oas31-response-empty-content.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
openapi: '3.1.0' | ||
|
||
info: | ||
title: Our API | ||
description: extended description of Our API | ||
version: 0.1.0 | ||
|
||
servers: | ||
- url: http://localhost | ||
description: included for completeness; not our actual url | ||
|
||
tags: | ||
- name: Enterprise | ||
description: Operations with Enterprise ID | ||
|
||
paths: | ||
/v0/enterprise/{id}: | ||
get: | ||
tags: | ||
- Enterprise | ||
summary: Get detailed info about an enterprise. | ||
description: | | ||
Returns detailed information for the specified Enterprise ID. | ||
This operation may *only* be performed by a **platform admin** or a | ||
client with sufficient permissions. | ||
operationId: get_enterprise_detail | ||
parameters: | ||
- $ref: '#/components/parameters/traceIDHeader' | ||
- $ref: '#/components/parameters/enterpriseIDPath' | ||
responses: | ||
404: | ||
description: No enterprise matching the requested ID could be found. | ||
content: {} | ||
components: | ||
parameters: | ||
enterpriseIDPath: | ||
$ref: '#/components/parameters/idInPath' | ||
description: The Enterprise ID used to perform this request. | ||
example: "12422" | ||
|
||
idInPath: | ||
name: id | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
|
||
traceIDHeader: | ||
name: X-Trace-Id | ||
in: header | ||
description: Optional UUID for log tracing | ||
required: false | ||
schema: | ||
type: string | ||
|
||
schemas: | ||
EnterpriseDetailResponse: | ||
title: Enterprise Detail Response | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
description: Unique ID for this enterprise. | ||
example: "3121" | ||
mfa_enforced: | ||
type: boolean | ||
description: Indicates whether MFA is enforced for this enterprise. | ||
example: true | ||
modules: | ||
type: array | ||
description: List of modules this enterprise is authorized to access. | ||
items: | ||
type: string | ||
example: [ | ||
human_resources, | ||
project_management | ||
] | ||
name: | ||
type: string | ||
description: The name of the enterprise. | ||
example: Kathy's Plumbing | ||
status: | ||
type: string | ||
description: Inidicates current status of this enterprise. | ||
enum: | ||
- offline | ||
- online | ||
- pending_deletion | ||
- unknown | ||
example: online |
92 changes: 92 additions & 0 deletions
92
test/e2e-cypress/static/documents/features/oas31-response-empty-media-type.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
openapi: '3.1.0' | ||
|
||
info: | ||
title: Our API | ||
description: extended description of Our API | ||
version: 0.1.0 | ||
|
||
servers: | ||
- url: http://localhost | ||
description: included for completeness; not our actual url | ||
|
||
tags: | ||
- name: Enterprise | ||
description: Operations with Enterprise ID | ||
|
||
paths: | ||
/v0/enterprise/{id}: | ||
get: | ||
tags: | ||
- Enterprise | ||
summary: Get detailed info about an enterprise. | ||
description: | | ||
Returns detailed information for the specified Enterprise ID. | ||
This operation may *only* be performed by a **platform admin** or a | ||
client with sufficient permissions. | ||
operationId: get_enterprise_detail | ||
parameters: | ||
- $ref: '#/components/parameters/traceIDHeader' | ||
- $ref: '#/components/parameters/enterpriseIDPath' | ||
responses: | ||
404: | ||
description: No enterprise matching the requested ID could be found. | ||
content: | ||
application/json: {} | ||
components: | ||
parameters: | ||
enterpriseIDPath: | ||
$ref: '#/components/parameters/idInPath' | ||
description: The Enterprise ID used to perform this request. | ||
example: "12422" | ||
|
||
idInPath: | ||
name: id | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
|
||
traceIDHeader: | ||
name: X-Trace-Id | ||
in: header | ||
description: Optional UUID for log tracing | ||
required: false | ||
schema: | ||
type: string | ||
|
||
schemas: | ||
EnterpriseDetailResponse: | ||
title: Enterprise Detail Response | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
description: Unique ID for this enterprise. | ||
example: "3121" | ||
mfa_enforced: | ||
type: boolean | ||
description: Indicates whether MFA is enforced for this enterprise. | ||
example: true | ||
modules: | ||
type: array | ||
description: List of modules this enterprise is authorized to access. | ||
items: | ||
type: string | ||
example: [ | ||
human_resources, | ||
project_management | ||
] | ||
name: | ||
type: string | ||
description: The name of the enterprise. | ||
example: Kathy's Plumbing | ||
status: | ||
type: string | ||
description: Inidicates current status of this enterprise. | ||
enum: | ||
- offline | ||
- online | ||
- pending_deletion | ||
- unknown | ||
example: online |
Oops, something went wrong.