fix: missing commas in response header values #6183 (#6515)

This commit is contained in:
Lucia Sarni
2020-10-15 04:37:12 +02:00
committed by GitHub
parent 65ea764b61
commit 99fda81ae0
3 changed files with 60 additions and 1 deletions

View File

@@ -65,7 +65,8 @@ export default class LiveResponse extends React.Component {
const Curl = getComponent("curl")
const ResponseBody = getComponent("responseBody")
const returnObject = headersKeys.map(key => {
return <span className="headerline" key={key}> {key}: {headers[key]} </span>
var joinedHeaders = Array.isArray(headers[key]) ? headers[key].join() : headers[key]
return <span className="headerline" key={key}> {key}: {joinedHeaders} </span>
})
const hasHeaders = returnObject.length !== 0

View File

@@ -0,0 +1,37 @@
swagger: "2.0"
info:
title: Response headers test
version: 1.0.0
host: httpbin.org
schemes: [https]
paths:
/response-headers:
get:
summary: Run the request using the default parameter values
parameters:
- in: query
name: X-Header1
type: string
x-example: 'value1,value2'
required: true
- in: query
name: X-Header2
type: string
x-example: 'value3, value4'
required: true
- in: query
name: X-Header3
type: array
items:
type: string
x-example: [value5, value6]
collectionFormat: multi
required: true
- in: query
name: Access-Control-Expose-Headers
type: string
x-example: 'X-Header1, X-Header2, X-Header3, Access-Control-Expose-Headers'
required: true
responses:
200:
description: ok

View File

@@ -0,0 +1,21 @@
describe("When trying it out", () => {
it("should render the response headers as comma separated lists", () => {
cy.visit("/?url=/documents/bugs/6183.yaml")
.get("#operations-default-get_response_headers")
.click()
.get(".try-out__btn")
.click()
.get(".btn.execute")
.click()
.wait(1000)
.get(".response-col_description .microlight")
.find(("span:contains(\"value1,value2\")"))
.should("exist")
.get(".response-col_description .microlight")
.find(("span:contains(\"value3,value4\")"))
.should("exist")
.get(".response-col_description .microlight")
.find(("span:contains(\"value5,value6\")"))
.should("exist")
})
})