-
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): fix re-rendering of the Webhooks component (#9938)
Refs #9937
- Loading branch information
Showing
4 changed files
with
97 additions
and
2 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
35 changes: 35 additions & 0 deletions
35
test/e2e-cypress/e2e/features/plugins/oas31/oas31-webhook-examples.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,35 @@ | ||
/** | ||
* @prettier | ||
*/ | ||
|
||
describe("OpenAPI 3.1.0 webhook", () => { | ||
it("should render the correct example for the request body", () => { | ||
cy.visit("/?url=/documents/features/oas31-webhook-examples.yaml") | ||
.get("#operations-webhooks-test-webhook") | ||
.click() | ||
.get(".body-param__example") | ||
.should("contain", '"userId": "userId example from examples"') | ||
.and("contain", '"orderId": "orderId example from examples"') | ||
.get(".examples-select-element") | ||
.eq(0) | ||
.select("TestExample2") | ||
.get(".body-param__example") | ||
.should("contain", '"userId": "second userId example from examples"') | ||
.and("contain", '"orderId": "second orderId example from examples"') | ||
}) | ||
|
||
it("should render the correct example for the response", () => { | ||
cy.visit("/?url=/documents/features/oas31-webhook-examples.yaml") | ||
.get("#operations-webhooks-test-webhook") | ||
.click() | ||
.get(".example.microlight") | ||
.should("contain", '"userId": "userId example from examples"') | ||
.and("contain", '"orderId": "orderId example from examples"') | ||
.get(".examples-select-element") | ||
.eq(1) | ||
.select("TestExample2") | ||
.get(".example.microlight") | ||
.should("contain", '"userId": "second userId example from examples"') | ||
.and("contain", '"orderId": "second orderId example from examples"') | ||
}) | ||
}) |
59 changes: 59 additions & 0 deletions
59
test/e2e-cypress/static/documents/features/oas31-webhook-examples.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,59 @@ | ||
openapi: 3.1.0 | ||
info: | ||
version: 1.0.0 | ||
title: Examples | ||
description: '' | ||
webhooks: | ||
test-webhook: | ||
post: | ||
operationId: test-webhook | ||
requestBody: | ||
required: true | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/TestSchema' | ||
examples: | ||
TestExample1: | ||
$ref: '#/components/examples/TestExample1' | ||
TestExample2: | ||
$ref: '#/components/examples/TestExample2' | ||
responses: | ||
'200': | ||
description: OK | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/TestSchema' | ||
examples: | ||
TestExample1: | ||
$ref: '#/components/examples/TestExample1' | ||
TestExample2: | ||
$ref: '#/components/examples/TestExample2' | ||
components: | ||
schemas: | ||
TestSchema: | ||
type: object | ||
properties: | ||
userId: | ||
type: string | ||
examples: ['userId example from schema'] | ||
orders: | ||
type: array | ||
items: | ||
type: object | ||
properties: | ||
orderId: | ||
type: string | ||
examples: ['orderId example from schema'] | ||
examples: | ||
TestExample1: | ||
value: | ||
userId: 'userId example from examples' | ||
orders: | ||
- orderId: 'orderId example from examples' | ||
TestExample2: | ||
value: | ||
userId: 'second userId example from examples' | ||
orders: | ||
- orderId: 'second orderId example from examples' |