Skip to content

Commit 8cef3ad

Browse files
authored
fix: path-item $ref operation metadata storage (#4489)
1 parent cbff025 commit 8cef3ad

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed

src/core/plugins/spec/reducers.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,11 @@ export default {
118118
let operationPath = ["paths", ...path]
119119
let metaPath = ["meta", "paths", ...path]
120120

121-
if(!state.getIn(["json", ...operationPath]) && !state.getIn(["resolved", ...operationPath])) {
121+
if(
122+
!state.getIn(["json", ...operationPath])
123+
&& !state.getIn(["resolved", ...operationPath])
124+
&& !state.getIn(["resolvedSubtrees", ...operationPath])
125+
) {
122126
// do nothing if the operation does not exist
123127
return state
124128
}

test/e2e/scenarios/bugs/4485.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
describe("bug #4485: operation metadata storage when referenced via path item $ref", function () {
2+
let mainPage
3+
beforeEach(function (client, done) {
4+
mainPage = client
5+
.url("localhost:3230")
6+
.page.main()
7+
8+
client.waitForElementVisible(".download-url-input", 5000)
9+
.pause(2000)
10+
.clearValue(".download-url-input")
11+
.setValue(".download-url-input", "http://localhost:3230/test-specs/bugs/4485/main.yaml")
12+
.click("button.download-url-button")
13+
.pause(1000)
14+
15+
done()
16+
})
17+
afterEach(function (client, done) {
18+
done()
19+
})
20+
it("sets a consumes value for a body parameter correctly", function (client) {
21+
client.waitForElementVisible(".opblock-tag-section", 10000)
22+
.click(".opblock")
23+
.waitForElementVisible(".opblock-body", 5000)
24+
.click("button.btn.try-out__btn")
25+
.click("select.content-type [value=\"application/xml\"]")
26+
.pause(500)
27+
.assert.value("select.content-type", "application/xml")
28+
29+
client.end()
30+
})
31+
})

test/e2e/specs/bugs/4485/book.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
post:
3+
description: Book
4+
operationId: buy
5+
summary: Buy a book
6+
tags:
7+
- Book
8+
consumes:
9+
- application/json
10+
- application/xml
11+
parameters:
12+
- name: requestBody
13+
in: body
14+
description: Buy a Book
15+
required: true

test/e2e/specs/bugs/4485/main.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
swagger: '2.0'
3+
paths:
4+
"/v1/book":
5+
"$ref": "./book.yaml"

0 commit comments

Comments
 (0)