swagger-api / swagger-api/swagger-client
OAS3 seems not to support multiple cookies
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 2.7k
- Forks
- 765
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 6
Description
Q&A (please complete the following information)
- OS: [e.g. macOS] macOS
- Environment: [e.g. Chrome 59, Node.js v10.0.0] Node v22.22.0
- Method of installation: [e.g. npm, unpkg] pnpm
- Swagger-Client version: [e.g. 3.8.0] 3.35.5
- Swagger/OpenAPI version: [e.g. Swagger 2.0, OpenAPI 3.0] OAS3
Content & configuration
Swagger/OpenAPI definition:
n/a
Swagger-Client usage:
import SwaggerClient from "swagger-client";
const operationId = "cookieTest";
const req = SwaggerClient.buildRequest({
spec: {
openapi: "3.1.0",
paths: {
"/": {
get: {
operationId,
parameters: [
{
name: "c1",
in: "cookie",
},
{
name: "c2",
in: "cookie",
},
],
},
},
},
},
operationId,
parameters: {
c1: "v1",
c2: "v2",
},
});
console.log(req.headers.Cookie);
if (req.headers.Cookie === "c2=v2") {
console.log("Seems like should be both cookies");
}
Describe the bug you're encountering
To reproduce...
Steps to reproduce the behavior:
- Set more than one cookie parameter
- Observe that only last cookie is set
Expected behavior
Expect when there are multiple cookies set, they will all be set. However, only last is set.
Additional context or thoughts
In https://github.com/swagger-api/swagger-js/blob/7baca902b84d757ff7490cd66d0cb5ead6ad5834/src/execute/oas3/parameter-builders.js#L118 Cookie is always overwritten in both cases. OAS2 was not examined
req.headers.Cookie = serializeCookie({ [cookieName]: cookieValue });
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 src/execute/oas3/parameter-builders.js at the referenced cookie-building code around line 118. Run the provided SwaggerClient.buildRequest reproduction with c1 and c2, then verify that the resulting Cookie header preserves both values rather than only the last one.
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
- 55/100