From e1b1bdae737dd815b102859c2d1139803665f86e Mon Sep 17 00:00:00 2001 From: Kei Sakamoto Date: Tue, 4 Apr 2023 14:23:46 +0900 Subject: [PATCH 1/2] fix: type of style property in requestEncodings --- src/code-templates/_shared/ApiClientInterface.ts | 4 +--- src/code-templates/_shared/MethodBody/index.ts | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/code-templates/_shared/ApiClientInterface.ts b/src/code-templates/_shared/ApiClientInterface.ts index 92b15d2a..01d054d7 100644 --- a/src/code-templates/_shared/ApiClientInterface.ts +++ b/src/code-templates/_shared/ApiClientInterface.ts @@ -128,9 +128,7 @@ const createEncodingInterface = (factory: TsGenerator.Factory.Type) => { factory.PropertySignature.create({ name: "style", optional: true, - type: factory.TypeReferenceNode.create({ - name: "string", - }), + type: factory.TypeNode.create({ type: "string", enum: ["form", "spaceDelimited", "pipeDelimited", "deepObject"] }), }), factory.PropertySignature.create({ name: "explode", diff --git a/src/code-templates/_shared/MethodBody/index.ts b/src/code-templates/_shared/MethodBody/index.ts index ded17193..f0af0c51 100644 --- a/src/code-templates/_shared/MethodBody/index.ts +++ b/src/code-templates/_shared/MethodBody/index.ts @@ -82,6 +82,9 @@ export const create = (factory: TsGenerator.Factory.Type, params: CodeGenerator. factory.VariableDeclaration.create({ name: "requestEncodings", initializer: identifier, + type: factory.TypeReferenceNode.create({ + name: "Record>", + }), }), ], }), From a4277fb1fdfe2ae933dbbf550bba8f1b6fcbb657 Mon Sep 17 00:00:00 2001 From: Kei Sakamoto Date: Tue, 4 Apr 2023 19:04:53 +0900 Subject: [PATCH 2/2] chore: update snapshots --- .../__snapshots__/argo-rollout-test.ts.snap | 2 +- .../class/__snapshots__/format.domain.ts.snap | 2 +- .../class/__snapshots__/kubernetes-test.ts.snap | 2 +- .../__snapshots__/multi-type.test.domain.ts.snap | 2 +- .../class/__snapshots__/spit-code-test.ts.snap | 2 +- .../__snapshots__/template-only-test.ts.snap | 6 +++--- .../typedef-with-template-test.ts.snap | 16 ++++++++-------- .../unknown-schema-domain-test.ts.snap | 2 +- .../__snapshots__/argo-rollout-test.ts.snap | 2 +- .../__snapshots__/format.domain.ts.snap | 2 +- .../__snapshots__/kubernetes-test.ts.snap | 2 +- .../__snapshots__/multi-type.test.domain.ts.snap | 2 +- .../__snapshots__/spit-code-test.ts.snap | 2 +- .../__snapshots__/template-only-test.ts.snap | 6 +++--- .../typedef-with-template-test.ts.snap | 16 ++++++++-------- .../unknown-schema-domain-test.ts.snap | 2 +- 16 files changed, 34 insertions(+), 34 deletions(-) diff --git a/test/__tests__/class/__snapshots__/argo-rollout-test.ts.snap b/test/__tests__/class/__snapshots__/argo-rollout-test.ts.snap index 70102e56..4e5c61a1 100644 --- a/test/__tests__/class/__snapshots__/argo-rollout-test.ts.snap +++ b/test/__tests__/class/__snapshots__/argo-rollout-test.ts.snap @@ -3829,7 +3829,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } diff --git a/test/__tests__/class/__snapshots__/format.domain.ts.snap b/test/__tests__/class/__snapshots__/format.domain.ts.snap index 6f36973a..98bdfa5c 100644 --- a/test/__tests__/class/__snapshots__/format.domain.ts.snap +++ b/test/__tests__/class/__snapshots__/format.domain.ts.snap @@ -46,7 +46,7 @@ export namespace ErrorResponse { } export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } diff --git a/test/__tests__/class/__snapshots__/kubernetes-test.ts.snap b/test/__tests__/class/__snapshots__/kubernetes-test.ts.snap index e3f62e1d..bf815e85 100644 --- a/test/__tests__/class/__snapshots__/kubernetes-test.ts.snap +++ b/test/__tests__/class/__snapshots__/kubernetes-test.ts.snap @@ -41028,7 +41028,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } diff --git a/test/__tests__/class/__snapshots__/multi-type.test.domain.ts.snap b/test/__tests__/class/__snapshots__/multi-type.test.domain.ts.snap index 60052ac0..b65beff1 100644 --- a/test/__tests__/class/__snapshots__/multi-type.test.domain.ts.snap +++ b/test/__tests__/class/__snapshots__/multi-type.test.domain.ts.snap @@ -45,7 +45,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } diff --git a/test/__tests__/class/__snapshots__/spit-code-test.ts.snap b/test/__tests__/class/__snapshots__/spit-code-test.ts.snap index 60055d74..370fa1dd 100644 --- a/test/__tests__/class/__snapshots__/spit-code-test.ts.snap +++ b/test/__tests__/class/__snapshots__/spit-code-test.ts.snap @@ -126,7 +126,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } diff --git a/test/__tests__/class/__snapshots__/template-only-test.ts.snap b/test/__tests__/class/__snapshots__/template-only-test.ts.snap index 60862544..5e1573d5 100644 --- a/test/__tests__/class/__snapshots__/template-only-test.ts.snap +++ b/test/__tests__/class/__snapshots__/template-only-test.ts.snap @@ -63,7 +63,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } @@ -253,7 +253,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } @@ -407,7 +407,7 @@ export namespace ErrorResponse { } export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } diff --git a/test/__tests__/class/__snapshots__/typedef-with-template-test.ts.snap b/test/__tests__/class/__snapshots__/typedef-with-template-test.ts.snap index 73f0ba33..eace8729 100644 --- a/test/__tests__/class/__snapshots__/typedef-with-template-test.ts.snap +++ b/test/__tests__/class/__snapshots__/typedef-with-template-test.ts.snap @@ -412,7 +412,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } @@ -585,7 +585,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } @@ -1034,7 +1034,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } @@ -1211,7 +1211,7 @@ export namespace ErrorResponse { } export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } @@ -1373,7 +1373,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } @@ -1441,7 +1441,7 @@ export class Client { "Content-Type": "application/x-www-form-urlencoded", Accept: "application/json" }; - const requestEncodings = { + const requestEncodings: Record> = { "application/x-www-form-urlencoded": { "color": { "style": "form", @@ -1463,7 +1463,7 @@ export class Client { "Content-Type": params.headers["Content-Type"], Accept: "application/json" }; - const requestEncodings = { + const requestEncodings: Record> = { "application/x-www-form-urlencoded": { "color": { "style": "form", @@ -1599,7 +1599,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } diff --git a/test/__tests__/class/__snapshots__/unknown-schema-domain-test.ts.snap b/test/__tests__/class/__snapshots__/unknown-schema-domain-test.ts.snap index 23e8c56d..62928183 100644 --- a/test/__tests__/class/__snapshots__/unknown-schema-domain-test.ts.snap +++ b/test/__tests__/class/__snapshots__/unknown-schema-domain-test.ts.snap @@ -44,7 +44,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } diff --git a/test/__tests__/functional/__snapshots__/argo-rollout-test.ts.snap b/test/__tests__/functional/__snapshots__/argo-rollout-test.ts.snap index 43548b48..125c8245 100644 --- a/test/__tests__/functional/__snapshots__/argo-rollout-test.ts.snap +++ b/test/__tests__/functional/__snapshots__/argo-rollout-test.ts.snap @@ -3829,7 +3829,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } diff --git a/test/__tests__/functional/__snapshots__/format.domain.ts.snap b/test/__tests__/functional/__snapshots__/format.domain.ts.snap index 871c1cfc..70b71ed8 100644 --- a/test/__tests__/functional/__snapshots__/format.domain.ts.snap +++ b/test/__tests__/functional/__snapshots__/format.domain.ts.snap @@ -46,7 +46,7 @@ export namespace ErrorResponse { } export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } diff --git a/test/__tests__/functional/__snapshots__/kubernetes-test.ts.snap b/test/__tests__/functional/__snapshots__/kubernetes-test.ts.snap index a75e5c81..b0ea1a8a 100644 --- a/test/__tests__/functional/__snapshots__/kubernetes-test.ts.snap +++ b/test/__tests__/functional/__snapshots__/kubernetes-test.ts.snap @@ -41028,7 +41028,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } diff --git a/test/__tests__/functional/__snapshots__/multi-type.test.domain.ts.snap b/test/__tests__/functional/__snapshots__/multi-type.test.domain.ts.snap index 27af116a..b007d37a 100644 --- a/test/__tests__/functional/__snapshots__/multi-type.test.domain.ts.snap +++ b/test/__tests__/functional/__snapshots__/multi-type.test.domain.ts.snap @@ -45,7 +45,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } diff --git a/test/__tests__/functional/__snapshots__/spit-code-test.ts.snap b/test/__tests__/functional/__snapshots__/spit-code-test.ts.snap index 907414b2..48eb2761 100644 --- a/test/__tests__/functional/__snapshots__/spit-code-test.ts.snap +++ b/test/__tests__/functional/__snapshots__/spit-code-test.ts.snap @@ -126,7 +126,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } diff --git a/test/__tests__/functional/__snapshots__/template-only-test.ts.snap b/test/__tests__/functional/__snapshots__/template-only-test.ts.snap index ba5c91b8..c6f3ba23 100644 --- a/test/__tests__/functional/__snapshots__/template-only-test.ts.snap +++ b/test/__tests__/functional/__snapshots__/template-only-test.ts.snap @@ -63,7 +63,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } @@ -256,7 +256,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } @@ -413,7 +413,7 @@ export namespace ErrorResponse { } export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } diff --git a/test/__tests__/functional/__snapshots__/typedef-with-template-test.ts.snap b/test/__tests__/functional/__snapshots__/typedef-with-template-test.ts.snap index 6a1363db..e2874356 100644 --- a/test/__tests__/functional/__snapshots__/typedef-with-template-test.ts.snap +++ b/test/__tests__/functional/__snapshots__/typedef-with-template-test.ts.snap @@ -412,7 +412,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } @@ -588,7 +588,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } @@ -1040,7 +1040,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } @@ -1220,7 +1220,7 @@ export namespace ErrorResponse { } export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } @@ -1384,7 +1384,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } @@ -1452,7 +1452,7 @@ export const createClient = (apiClient: ApiClient, "Content-Type": "application/x-www-form-urlencoded", Accept: "application/json" }; - const requestEncodings = { + const requestEncodings: Record> = { "application/x-www-form-urlencoded": { "color": { "style": "form", @@ -1474,7 +1474,7 @@ export const createClient = (apiClient: ApiClient, "Content-Type": params.headers["Content-Type"], Accept: "application/json" }; - const requestEncodings = { + const requestEncodings: Record> = { "application/x-www-form-urlencoded": { "color": { "style": "form", @@ -1613,7 +1613,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; } diff --git a/test/__tests__/functional/__snapshots__/unknown-schema-domain-test.ts.snap b/test/__tests__/functional/__snapshots__/unknown-schema-domain-test.ts.snap index 2640e98e..dfac984e 100644 --- a/test/__tests__/functional/__snapshots__/unknown-schema-domain-test.ts.snap +++ b/test/__tests__/functional/__snapshots__/unknown-schema-domain-test.ts.snap @@ -44,7 +44,7 @@ export namespace ErrorResponse { export interface Encoding { contentType?: string; headers?: Record; - style?: string; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; explode?: boolean; allowReserved?: boolean; }