swagger-api / swagger-api/swagger-ui
When using Try It Out with Open API 3, multiple cookie apiKeys are separated with & not ; as required by curl
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
When multiple API keys are specified in the security object, Try it Out separates the name value pairs with an ampersand. Curl expects a semi colon and the request will fail
_I'm attempting to locate the source of the error, am new to react and the code base, any guidance would be appreciated.
looks like the problem will be in the creation of the request headers prior to calling the curl formatting function in swagger-ui/src/core/curlify.js
But I'm still at the stage of fumbling around trying to orient myself in the code._
| Q | A |
|---|---|
| Bug or feature request? | BUG |
| Which Swagger/OpenAPI version? | 3 |
| Which Swagger-UI version? | "version":"3.9.3" |
| How did you install Swagger-UI? | git clone, npm run-script build, ws |
| Which browser & version? | Version 64.0.3282.140 |
| Which operating system? | windows 7 |
Demonstration API definition
openapi: 3.0.5
info:
title: test api
description: test api
version: 1.0.0
paths:
/tests:
get:
description: "test use of two api keys in cookie"
operationId: testGet
tags:
- test
responses:
'200':
description: test
content:
# application/json:
# schema:{}
# {
# "title": "test-response",
# "type": "object",
# "properties": {
# "value": "integer"
# }
# }
components:
securitySchemes:
keyA:
type: apiKey
in: cookie
name: key-a
keyB:
type: apiKey
in: cookie
name: keyB
security:
- keyA: []
keyB: []
servers:
- url: 'http://localhost'
description: localhost
Expected Behavior
Try it out should create a call like this:
curl -X GET "http://localhost/tests" -H "accept: */*" -H "Cookie: key-a=a; keyB=b"
or
curl -X GET "http://localhost/tests" -H "accept: */*" -b "key-a=a; keyB=b"
see:
http://www.mit.edu/afs.new/sipb/user/ssen/src/curl-7.11.1/docs/curl.html
Current Behavior
Try it out produces this:
curl -X GET "http://localhost/tests" -H "accept: */*" -H "Cookie: key-a=a&keyB=b"
Context
This issue is preventing me from using swagger to demonstrate a new API over a system with a legacy security model that requires multiple cookie values to be passed
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in swagger-ui/src/core/curlify.js and trace how multiple cookie API keys become request headers before curl formatting. Reproduce the OpenAPI 3 example, then confirm that Try It Out and generated curl use semicolons between cookie name-value pairs instead of ampersands.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, openapi
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100