diff --git a/common/changes/@typespec/openapi3/openapi3-FixCsvFormat_2023-09-19-21-04.json b/common/changes/@typespec/openapi3/openapi3-FixCsvFormat_2023-09-19-21-04.json new file mode 100644 index 0000000000..cdcd568687 --- /dev/null +++ b/common/changes/@typespec/openapi3/openapi3-FixCsvFormat_2023-09-19-21-04.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@typespec/openapi3", + "comment": "Fix issue with CSV format representation.", + "type": "none" + } + ], + "packageName": "@typespec/openapi3" +} \ No newline at end of file diff --git a/packages/openapi3/src/openapi.ts b/packages/openapi3/src/openapi.ts index ac109efeec..cefb96bced 100644 --- a/packages/openapi3/src/openapi.ts +++ b/packages/openapi3/src/openapi.ts @@ -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, { diff --git a/packages/openapi3/test/parameters.test.ts b/packages/openapi3/test/parameters.test.ts index 70c7eb7ce7..80b8c6e315 100644 --- a/packages/openapi3/test/parameters.test.ts +++ b/packages/openapi3/test/parameters.test.ts @@ -54,7 +54,8 @@ describe("openapi3: parameters", () => { deepStrictEqual(params[1], { in: "query", name: "$csv", - style: "simple", + style: "form", + explode: false, schema: { type: "array", items: {