Repository: pmcelhaney/counterfact
Pull request #454 (2023-06-15 08:21:25)

Fix: Found an error when headers name contains `-`
Related to this Issue https://github.com/pmcelhaney/counterfact/issues/453, cc @pmcelhaney


Patch:
diff --git a/.changeset/twenty-eggs-sleep.md b/.changeset/twenty-eggs-sleep.md
new file mode 100644
index 0000000..6ad145c
--- /dev/null
+++ b/.changeset/twenty-eggs-sleep.md
@@ -0,0 +1,5 @@
+---
+"counterfact": patch
+---
+
+Fix: Found an error when headers name contains `-`
diff --git a/src/typescript-generator/parameters-type-coder.js b/src/typescript-generator/parameters-type-coder.js
index 0e9a45d..aecdbd1 100644
--- a/src/typescript-generator/parameters-type-coder.js
+++ b/src/typescript-generator/parameters-type-coder.js
@@ -28,7 +28,7 @@ export class ParametersTypeCoder extends Coder {
           ? requirement.get("schema")
           : requirement;
 
-        return `${name}${optionalFlag}: ${new SchemaTypeCoder(schema).write(
+        return `"${name}${optionalFlag}": ${new SchemaTypeCoder(schema).write(
           script
         )}`;
       });


Test patch:
diff --git a/test/typescript-generator/__snapshots__/end-to-end.test.js.snap b/test/typescript-generator/__snapshots__/end-to-end.test.js.snap
index fb1bde6..ce82466 100644
--- a/test/typescript-generator/__snapshots__/end-to-end.test.js.snap
+++ b/test/typescript-generator/__snapshots__/end-to-end.test.js.snap
@@ -842,7 +842,7 @@ class Context {
           "exports": Map {
             "HTTP_GET" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: {status?: \\"available\\" | \\"pending\\" | \\"sold\\"}, path: never, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: {\\"status?\\": \\"available\\" | \\"pending\\" | \\"sold\\"}, path: never, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 200: {
           headers: {};
           content: {
@@ -1053,7 +1053,7 @@ class Context {
     "exports": Map {
       "HTTP_GET" => Object {
         "beforeExport": "",
-        "code": "({ query, path, header, body, context, proxy }: { query: {status?: \\"available\\" | \\"pending\\" | \\"sold\\"}, path: never, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+        "code": "({ query, path, header, body, context, proxy }: { query: {\\"status?\\": \\"available\\" | \\"pending\\" | \\"sold\\"}, path: never, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 200: {
           headers: {};
           content: {
@@ -1281,7 +1281,7 @@ class Context {
           "exports": Map {
             "HTTP_GET" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: {tags?: Array<string>}, path: never, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: {\\"tags?\\": Array<string>}, path: never, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 200: {
           headers: {};
           content: {
@@ -1492,7 +1492,7 @@ class Context {
     "exports": Map {
       "HTTP_GET" => Object {
         "beforeExport": "",
-        "code": "({ query, path, header, body, context, proxy }: { query: {tags?: Array<string>}, path: never, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+        "code": "({ query, path, header, body, context, proxy }: { query: {\\"tags?\\": Array<string>}, path: never, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 200: {
           headers: {};
           content: {
@@ -1748,7 +1748,7 @@ class Context {
           "exports": Map {
             "HTTP_GET" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {petId: number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"petId\\": number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 200: {
           headers: {};
           content: {
@@ -1791,7 +1791,7 @@ class Context {
             },
             "HTTP_POST" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: {name?: number, status?: string}, path: {petId: number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: {\\"name?\\": number, \\"status?\\": string}, path: {\\"petId\\": number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 405: {
           headers: {};
           content: {};
@@ -1809,7 +1809,7 @@ class Context {
             },
             "HTTP_DELETE" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {petId: string}, header: {api_key?: string}, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"petId\\": string}, header: {\\"api_key?\\": string}, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 400: {
           headers: {};
           content: {};
@@ -1999,7 +1999,7 @@ class Context {
           "exports": Map {
             "HTTP_GET" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {petId: number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"petId\\": number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 200: {
           headers: {};
           content: {
@@ -2042,7 +2042,7 @@ class Context {
             },
             "HTTP_POST" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: {name?: number, status?: string}, path: {petId: number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: {\\"name?\\": number, \\"status?\\": string}, path: {\\"petId\\": number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 405: {
           headers: {};
           content: {};
@@ -2060,7 +2060,7 @@ class Context {
             },
             "HTTP_DELETE" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {petId: string}, header: {api_key?: string}, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"petId\\": string}, header: {\\"api_key?\\": string}, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 400: {
           headers: {};
           content: {};
@@ -2250,7 +2250,7 @@ class Context {
           "exports": Map {
             "HTTP_GET" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {petId: number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"petId\\": number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 200: {
           headers: {};
           content: {
@@ -2293,7 +2293,7 @@ class Context {
             },
             "HTTP_POST" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: {name?: number, status?: string}, path: {petId: number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: {\\"name?\\": number, \\"status?\\": string}, path: {\\"petId\\": number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 405: {
           headers: {};
           content: {};
@@ -2311,7 +2311,7 @@ class Context {
             },
             "HTTP_DELETE" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {petId: string}, header: {api_key?: string}, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"petId\\": string}, header: {\\"api_key?\\": string}, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 400: {
           headers: {};
           content: {};
@@ -2505,7 +2505,7 @@ class Context {
     "exports": Map {
       "HTTP_GET" => Object {
         "beforeExport": "",
-        "code": "({ query, path, header, body, context, proxy }: { query: never, path: {petId: number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+        "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"petId\\": number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 200: {
           headers: {};
           content: {
@@ -2548,7 +2548,7 @@ class Context {
       },
       "HTTP_POST" => Object {
         "beforeExport": "",
-        "code": "({ query, path, header, body, context, proxy }: { query: {name?: number, status?: string}, path: {petId: number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+        "code": "({ query, path, header, body, context, proxy }: { query: {\\"name?\\": number, \\"status?\\": string}, path: {\\"petId\\": number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 405: {
           headers: {};
           content: {};
@@ -2566,7 +2566,7 @@ class Context {
       },
       "HTTP_DELETE" => Object {
         "beforeExport": "",
-        "code": "({ query, path, header, body, context, proxy }: { query: never, path: {petId: string}, header: {api_key?: string}, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+        "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"petId\\": string}, header: {\\"api_key?\\": string}, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 400: {
           headers: {};
           content: {};
@@ -2775,7 +2775,7 @@ class Context {
           "exports": Map {
             "HTTP_POST" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: {additionalMetadata?: number}, path: {petId: number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: {\\"additionalMetadata?\\": number}, path: {\\"petId\\": number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 200: {
           headers: {};
           content: {
@@ -2908,7 +2908,7 @@ class Context {
     "exports": Map {
       "HTTP_POST" => Object {
         "beforeExport": "",
-        "code": "({ query, path, header, body, context, proxy }: { query: {additionalMetadata?: number}, path: {petId: number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+        "code": "({ query, path, header, body, context, proxy }: { query: {\\"additionalMetadata?\\": number}, path: {\\"petId\\": number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 200: {
           headers: {};
           content: {
@@ -3586,7 +3586,7 @@ class Context {
           "exports": Map {
             "HTTP_GET" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {orderId: number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"orderId\\": number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 200: {
           headers: {};
           content: {
@@ -3629,7 +3629,7 @@ class Context {
             },
             "HTTP_DELETE" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {orderId: number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"orderId\\": number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 400: {
           headers: {};
           content: {};
@@ -3759,7 +3759,7 @@ class Context {
           "exports": Map {
             "HTTP_GET" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {orderId: number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"orderId\\": number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 200: {
           headers: {};
           content: {
@@ -3802,7 +3802,7 @@ class Context {
             },
             "HTTP_DELETE" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {orderId: number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"orderId\\": number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 400: {
           headers: {};
           content: {};
@@ -3936,7 +3936,7 @@ class Context {
     "exports": Map {
       "HTTP_GET" => Object {
         "beforeExport": "",
-        "code": "({ query, path, header, body, context, proxy }: { query: never, path: {orderId: number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+        "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"orderId\\": number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 200: {
           headers: {};
           content: {
@@ -3979,7 +3979,7 @@ class Context {
       },
       "HTTP_DELETE" => Object {
         "beforeExport": "",
-        "code": "({ query, path, header, body, context, proxy }: { query: never, path: {orderId: number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+        "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"orderId\\": number}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 400: {
           headers: {};
           content: {};
@@ -4730,7 +4730,7 @@ class Context {
           "exports": Map {
             "HTTP_GET" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: {username?: string, password?: string}, path: never, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: {\\"username?\\": string, \\"password?\\": string}, path: never, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 200: {
           headers: {
 \\"X-Rate-Limit\\": { schema: number},
@@ -4847,7 +4847,7 @@ class Context {
     "exports": Map {
       "HTTP_GET" => Object {
         "beforeExport": "",
-        "code": "({ query, path, header, body, context, proxy }: { query: {username?: string, password?: string}, path: never, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+        "code": "({ query, path, header, body, context, proxy }: { query: {\\"username?\\": string, \\"password?\\": string}, path: never, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 200: {
           headers: {
 \\"X-Rate-Limit\\": { schema: number},
@@ -5215,7 +5215,7 @@ class Context {
           "exports": Map {
             "HTTP_GET" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {username: string}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"username\\": string}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 200: {
           headers: {};
           content: {
@@ -5258,7 +5258,7 @@ class Context {
             },
             "HTTP_PUT" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {username: string}, header: never, body: User, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"username\\": string}, header: never, body: User, context: typeof Context, response: ResponseBuilderFactory<{
 [statusCode in HttpStatusCode]: {
           headers: {};
           content: {};
@@ -5276,7 +5276,7 @@ class Context {
             },
             "HTTP_DELETE" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {username: string}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"username\\": string}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 400: {
           headers: {};
           content: {};
@@ -5407,7 +5407,7 @@ class Context {
           "exports": Map {
             "HTTP_GET" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {username: string}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"username\\": string}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 200: {
           headers: {};
           content: {
@@ -5450,7 +5450,7 @@ class Context {
             },
             "HTTP_PUT" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {username: string}, header: never, body: User, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"username\\": string}, header: never, body: User, context: typeof Context, response: ResponseBuilderFactory<{
 [statusCode in HttpStatusCode]: {
           headers: {};
           content: {};
@@ -5468,7 +5468,7 @@ class Context {
             },
             "HTTP_DELETE" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {username: string}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"username\\": string}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 400: {
           headers: {};
           content: {};
@@ -5599,7 +5599,7 @@ class Context {
           "exports": Map {
             "HTTP_GET" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {username: string}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"username\\": string}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 200: {
           headers: {};
           content: {
@@ -5642,7 +5642,7 @@ class Context {
             },
             "HTTP_PUT" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {username: string}, header: never, body: User, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"username\\": string}, header: never, body: User, context: typeof Context, response: ResponseBuilderFactory<{
 [statusCode in HttpStatusCode]: {
           headers: {};
           content: {};
@@ -5660,7 +5660,7 @@ class Context {
             },
             "HTTP_DELETE" => Object {
               "beforeExport": "",
-              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {username: string}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+              "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"username\\": string}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 400: {
           headers: {};
           content: {};
@@ -5795,7 +5795,7 @@ class Context {
     "exports": Map {
       "HTTP_GET" => Object {
         "beforeExport": "",
-        "code": "({ query, path, header, body, context, proxy }: { query: never, path: {username: string}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+        "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"username\\": string}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 200: {
           headers: {};
           content: {
@@ -5838,7 +5838,7 @@ class Context {
       },
       "HTTP_PUT" => Object {
         "beforeExport": "",
-        "code": "({ query, path, header, body, context, proxy }: { query: never, path: {username: string}, header: never, body: User, context: typeof Context, response: ResponseBuilderFactory<{
+        "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"username\\": string}, header: never, body: User, context: typeof Context, response: ResponseBuilderFactory<{
 [statusCode in HttpStatusCode]: {
           headers: {};
           content: {};
@@ -5856,7 +5856,7 @@ class Context {
       },
       "HTTP_DELETE" => Object {
         "beforeExport": "",
-        "code": "({ query, path, header, body, context, proxy }: { query: never, path: {username: string}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
+        "code": "({ query, path, header, body, context, proxy }: { query: never, path: {\\"username\\": string}, header: never, body: undefined, context: typeof Context, response: ResponseBuilderFactory<{
 400: {
           headers: {};
           content: {};
diff --git a/test/typescript-generator/__snapshots__/operation-type-coder.test.js.snap b/test/typescript-generator/__snapshots__/operation-type-coder.test.js.snap
index 793c9c4..4088dd5 100644
--- a/test/typescript-generator/__snapshots__/operation-type-coder.test.js.snap
+++ b/test/typescript-generator/__snapshots__/operation-type-coder.test.js.snap
@@ -45,9 +45,9 @@ exports[`an OperationTypeCoder generates a complex post operation (OpenAPI 2) 1`
   context,
   proxy,
 }: {
-  query: { name?: string };
-  path: { id?: string };
-  header: { name?: string };
+  query: { \\"name?\\": string };
+  path: { \\"id?\\": string };
+  header: { \\"name?\\": string };
   body: Type;
   context: typeof default;
   response: ResponseBuilderFactory<{
@@ -107,9 +107,9 @@ exports[`an OperationTypeCoder generates a complex post operation 1`] = `
   context,
   proxy,
 }: {
-  query: { name?: string };
-  path: { id?: string };
-  header: { name?: string };
+  query: { \\"name?\\": string };
+  path: { \\"id?\\": string };
+  header: { \\"name?\\": string };
   body: Type;
   context: typeof default;
   response: ResponseBuilderFactory<{
diff --git a/test/typescript-generator/__snapshots__/parameters-type-coder.test.js.snap b/test/typescript-generator/__snapshots__/parameters-type-coder.test.js.snap
index 44fbf98..c5a4bd4 100644
--- a/test/typescript-generator/__snapshots__/parameters-type-coder.test.js.snap
+++ b/test/typescript-generator/__snapshots__/parameters-type-coder.test.js.snap
@@ -6,7 +6,7 @@ exports[`a ParametersTypeCoder generates type never when there is no match 1`] =
 `;
 
 exports[`a ParametersTypeCoder generates types for parameters (OAS2): header 1`] = `
-"type TestType = { name?: string };
+"type TestType = { \\"name?\\": string };
 "
 `;
 
@@ -16,12 +16,12 @@ exports[`a ParametersTypeCoder generates types for parameters (OAS2): path 1`] =
 `;
 
 exports[`a ParametersTypeCoder generates types for parameters (OAS2): query 1`] = `
-"type TestType = { name?: string; age?: string };
+"type TestType = { \\"name?\\": string; \\"age?\\": string };
 "
 `;
 
 exports[`a ParametersTypeCoder generates types for parameters: header 1`] = `
-"type TestType = { name?: string };
+"type TestType = { \\"name?\\": string };
 "
 `;
 
@@ -31,6 +31,6 @@ exports[`a ParametersTypeCoder generates types for parameters: path 1`] = `
 `;
 
 exports[`a ParametersTypeCoder generates types for parameters: query 1`] = `
-"type TestType = { name?: string; age?: string };
+"type TestType = { \\"name?\\": string; \\"age?\\": string };
 "
 `;