Skip to content

Commit 99fda81

Browse files
author
Lucia Sarni
authored
fix: missing commas in response header values #6183 (#6515)
1 parent 65ea764 commit 99fda81

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

src/core/components/live-response.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ export default class LiveResponse extends React.Component {
6565
const Curl = getComponent("curl")
6666
const ResponseBody = getComponent("responseBody")
6767
const returnObject = headersKeys.map(key => {
68-
return <span className="headerline" key={key}> {key}: {headers[key]} </span>
68+
var joinedHeaders = Array.isArray(headers[key]) ? headers[key].join() : headers[key]
69+
return <span className="headerline" key={key}> {key}: {joinedHeaders} </span>
6970
})
7071
const hasHeaders = returnObject.length !== 0
7172

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
swagger: "2.0"
2+
info:
3+
title: Response headers test
4+
version: 1.0.0
5+
host: httpbin.org
6+
schemes: [https]
7+
paths:
8+
/response-headers:
9+
get:
10+
summary: Run the request using the default parameter values
11+
parameters:
12+
- in: query
13+
name: X-Header1
14+
type: string
15+
x-example: 'value1,value2'
16+
required: true
17+
- in: query
18+
name: X-Header2
19+
type: string
20+
x-example: 'value3, value4'
21+
required: true
22+
- in: query
23+
name: X-Header3
24+
type: array
25+
items:
26+
type: string
27+
x-example: [value5, value6]
28+
collectionFormat: multi
29+
required: true
30+
- in: query
31+
name: Access-Control-Expose-Headers
32+
type: string
33+
x-example: 'X-Header1, X-Header2, X-Header3, Access-Control-Expose-Headers'
34+
required: true
35+
responses:
36+
200:
37+
description: ok
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
describe("When trying it out", () => {
2+
it("should render the response headers as comma separated lists", () => {
3+
cy.visit("/?url=/documents/bugs/6183.yaml")
4+
.get("#operations-default-get_response_headers")
5+
.click()
6+
.get(".try-out__btn")
7+
.click()
8+
.get(".btn.execute")
9+
.click()
10+
.wait(1000)
11+
.get(".response-col_description .microlight")
12+
.find(("span:contains(\"value1,value2\")"))
13+
.should("exist")
14+
.get(".response-col_description .microlight")
15+
.find(("span:contains(\"value3,value4\")"))
16+
.should("exist")
17+
.get(".response-col_description .microlight")
18+
.find(("span:contains(\"value5,value6\")"))
19+
.should("exist")
20+
})
21+
})

0 commit comments

Comments
 (0)