Skip to content

Commit

Permalink
OpenAPI3 - Fix CSV format representation (#2446)
Browse files Browse the repository at this point in the history
Fixes #2234.
  • Loading branch information
tjprescott authored Sep 20, 2023
1 parent 4c1c6f3 commit 8e3240a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/openapi3",
"comment": "Fix issue with CSV format representation.",
"type": "none"
}
],
"packageName": "@typespec/openapi3"
}
7 changes: 6 additions & 1 deletion packages/openapi3/src/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,12 @@ function createOAPIEmitter(program: Program, options: ResolvedOpenAPI3EmitterOpt
ph.in = parameter.type;
if (parameter.type === "query" || parameter.type === "header") {
if (parameter.format === "csv" || parameter.format === "simple") {
ph.style = "simple";
if (parameter.type === "query") {
ph.style = "form";
ph.explode = false;
} else {
ph.style = "simple";
}
} else if (parameter.format === "multi" || parameter.format === "form") {
if (parameter.type === "header") {
reportDiagnostic(program, {
Expand Down
3 changes: 2 additions & 1 deletion packages/openapi3/test/parameters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ describe("openapi3: parameters", () => {
deepStrictEqual(params[1], {
in: "query",
name: "$csv",
style: "simple",
style: "form",
explode: false,
schema: {
type: "array",
items: {
Expand Down

0 comments on commit 8e3240a

Please sign in to comment.