diff --git a/src/core/plugins/oas3/components/callbacks.jsx b/src/core/plugins/oas3/components/callbacks.jsx index 51d74f80..56a8fd18 100644 --- a/src/core/plugins/oas3/components/callbacks.jsx +++ b/src/core/plugins/oas3/components/callbacks.jsx @@ -16,8 +16,14 @@ const Callbacks = (props) => { return

{callbackName}

{ callback.map((pathItem, pathItemName) => { + if(pathItemName === "$$ref") { + return null + } return
{ pathItem.map((operation, method) => { + if(method === "$$ref") { + return null + } let op = fromJS({ operation }) diff --git a/test/e2e/scenarios/bugs/4445.js b/test/e2e/scenarios/bugs/4445.js new file mode 100644 index 00000000..17c7a203 --- /dev/null +++ b/test/e2e/scenarios/bugs/4445.js @@ -0,0 +1,32 @@ +describe("bug #4445: callback-via-$ref rendering", function () { + let mainPage + beforeEach(function (client, done) { + mainPage = client + .url("localhost:3230") + .page.main() + + client.waitForElementVisible(".download-url-input", 5000) + .pause(5000) + .clearValue(".download-url-input") + .setValue(".download-url-input", "http://localhost:3230/test-specs/bugs/4445.yaml") + .click("button.download-url-button") + .pause(1000) + + done() + }) + afterEach(function (client, done) { + done() + }) + it("expands an operation that has a visible callback", function (client) { + client.waitForElementVisible(".opblock-tag-section", 10000) + .click(".opblock") + .waitForElementVisible(".opblock-body", 5000) + .click(".opblock-section-header > .tab-header > div.tab-item:nth-of-type(2)") + .waitForElementVisible(".callbacks-container .opblock", 5000) + .click(".callbacks-container .opblock") + .waitForElementVisible(".callbacks-container .opblock-body", 5000) + .assert.containsText(".callbacks-container .opblock-description-wrapper:nth-of-type(2) p", "subscription payload") + + client.end() + }) +}) diff --git a/test/e2e/specs/bugs/4445.yaml b/test/e2e/specs/bugs/4445.yaml new file mode 100644 index 00000000..72ec7dd1 --- /dev/null +++ b/test/e2e/specs/bugs/4445.yaml @@ -0,0 +1,64 @@ +openapi: 3.0.0 +info: + title: Callback Example + version: 1.0.0 +paths: + /streams: + post: + description: subscribes a client to receive out-of-band data + parameters: + - name: callbackUrl + in: query + required: true + description: | + the location where data will be sent. Must be network accessible + by the source server + schema: + type: string + format: uri + example: https://tonys-server.com + responses: + '201': + description: subscription successfully created + content: + application/json: + schema: + description: subscription information + required: + - subscriptionId + properties: + subscriptionId: + description: this unique identifier allows management of the subscription + type: string + example: 2531329f-fb09-4ef7-887e-84e648214436 + callbacks: + # the name `onData` is a convenience locator + onData: + $ref: '#/components/callbacks/onData' +components: + callbacks: + onData: + # when data is sent, it will be sent to the `callbackUrl` provided + # when making the subscription PLUS the suffix `/data` + '{$request.query.callbackUrl}/data': + post: + requestBody: + description: subscription payload + content: + application/json: + schema: + properties: + timestamp: + type: string + format: date-time + userData: + type: string + responses: + '202': + description: | + Your server implementation should return this HTTP status code + if the data was received successfully + '204': + description: | + Your server should return this HTTP status code if no longer interested + in further updates