From a5c233ef57ef9e6969645c1eccb807c42eaa22c7 Mon Sep 17 00:00:00 2001 From: "K.Himeno" <6715229+Himenon@users.noreply.github.com> Date: Sun, 11 Feb 2024 23:13:13 +0900 Subject: [PATCH] style: code format (#128) --- examples/apis/client.ts | 4 +- examples/apis/sample-axios.ts | 2 +- examples/apis/sample-debug.ts | 2 +- examples/apis/sample-fetch.ts | 2 +- examples/apis/sample-superagent.ts | 2 +- examples/readme-sample/ast-code-template.ts | 2 +- .../readme-sample/text-base-code-template.ts | 2 +- .../use-extract-schema-params.ts | 2 +- jest.config.cjs | 2 +- jest.snapshot.config.cjs | 2 +- scripts/tools/shell.ts | 2 +- .../_shared/ApiClientArgument.ts | 2 +- .../_shared/ApiClientInterface.ts | 14 ++-- .../_shared/MethodBody/CallRequest.ts | 2 +- .../_shared/MethodBody/PathParameter.ts | 2 +- .../__tests__/PathParameter-test.ts | 42 +++++------ .../_shared/MethodBody/index.ts | 10 +-- src/code-templates/_shared/utils.ts | 72 +++++++++---------- .../class-api-client/ApiClientClass/Method.ts | 2 +- .../class-api-client/ApiClientClass/index.ts | 2 +- src/code-templates/class-api-client/index.ts | 2 +- .../CurryingArrowFunction.ts | 2 +- .../currying-functional-api-client/index.ts | 2 +- .../FunctionalApiClient/ArrowFunction.ts | 2 +- .../ClientTypeDefinition.ts | 4 +- .../functional-api-client/index.ts | 2 +- src/index.ts | 8 +-- src/internal/FileSystem/index.ts | 10 +-- src/internal/OpenApiTools/Comment.ts | 2 +- src/internal/OpenApiTools/Guard.ts | 2 +- src/internal/OpenApiTools/Parser.ts | 8 +-- src/internal/OpenApiTools/TypeNodeContext.ts | 15 ++-- src/internal/OpenApiTools/Walker/Store.ts | 4 +- .../OpenApiTools/components/Headers.ts | 2 +- .../OpenApiTools/components/Operation.ts | 8 +-- .../OpenApiTools/components/Parameter.ts | 2 +- .../OpenApiTools/components/Parameters.ts | 51 +++++++------ .../OpenApiTools/components/PathItem.ts | 4 +- .../OpenApiTools/components/PathItems.ts | 5 +- .../OpenApiTools/components/Reference.ts | 2 +- .../OpenApiTools/components/RequestBodies.ts | 5 +- .../OpenApiTools/components/RequestBody.ts | 2 +- .../OpenApiTools/components/Response.ts | 4 +- .../OpenApiTools/components/Responses.ts | 2 +- .../OpenApiTools/components/Schema.ts | 2 +- .../OpenApiTools/components/Schemas.ts | 4 +- src/internal/OpenApiTools/paths/index.ts | 10 +-- src/internal/OpenApiTools/toTypeNode.ts | 9 ++- src/internal/ResolveReference/index.ts | 6 +- src/internal/TsGenerator/factory/index.ts | 4 +- src/internal/TsGenerator/factory/utils.ts | 4 +- src/internal/Validator/index.ts | 2 +- src/typedef/OpenApi.ts | 2 +- 53 files changed, 180 insertions(+), 185 deletions(-) diff --git a/examples/apis/client.ts b/examples/apis/client.ts index 7bff5370..0b361059 100644 --- a/examples/apis/client.ts +++ b/examples/apis/client.ts @@ -91,7 +91,7 @@ export const createClient = (apiClient: ApiClient, const _baseUrl = baseUrl.replace(/\/$/, ""); return { getBooks: (option?: RequestOption): Promise => { - const url = _baseUrl + `/get/books`; + const url = `${_baseUrl}/get/books`; const headers = { Accept: "application/json", }; @@ -105,7 +105,7 @@ export const createClient = (apiClient: ApiClient, ); }, searchBooks: (params: Params$searchBooks, option?: RequestOption): Promise => { - const url = _baseUrl + `/search/books`; + const url = `${_baseUrl}/search/books`; const headers = { Accept: "application/json", }; diff --git a/examples/apis/sample-axios.ts b/examples/apis/sample-axios.ts index 89f73324..c4d941a2 100644 --- a/examples/apis/sample-axios.ts +++ b/examples/apis/sample-axios.ts @@ -33,7 +33,7 @@ const apiClientImpl: ApiClient = { options?: RequestOption, ): Promise => { const query = generateQueryString(queryParameters); - const requestUrl = query ? url + "?" + encodeURI(query) : url; + const requestUrl = query ? `${url}?${encodeURI(query)}` : url; const response = await axios.default.request({ url: requestUrl, method: convertHttpMethodToAxiosMethod(httpMethod), diff --git a/examples/apis/sample-debug.ts b/examples/apis/sample-debug.ts index 3fdbaa4b..b9579499 100644 --- a/examples/apis/sample-debug.ts +++ b/examples/apis/sample-debug.ts @@ -15,7 +15,7 @@ const apiClientImpl: ApiClient = { options?: RequestOption, ): Promise => { const query = generateQueryString(queryParameters); - const requestUrl = query ? url + "?" + encodeURI(query) : url; + const requestUrl = query ? `${url}?${encodeURI(query)}` : url; console.log({ httpMethod, url, diff --git a/examples/apis/sample-fetch.ts b/examples/apis/sample-fetch.ts index 4080d9a2..d46a0325 100644 --- a/examples/apis/sample-fetch.ts +++ b/examples/apis/sample-fetch.ts @@ -17,7 +17,7 @@ const apiClientImpl: ApiClient = { options?: RequestOption, ): Promise => { const query = generateQueryString(queryParameters); - const requestUrl = query ? url + "?" + encodeURI(query) : url; + const requestUrl = query ? `${url}?${encodeURI(query)}` : url; const response = await fetch(requestUrl, { body: JSON.stringify(requestBody), headers, diff --git a/examples/apis/sample-superagent.ts b/examples/apis/sample-superagent.ts index 12d5a12f..64e77d8e 100644 --- a/examples/apis/sample-superagent.ts +++ b/examples/apis/sample-superagent.ts @@ -19,7 +19,7 @@ const apiClientImpl: ApiClient = { options?: RequestOption, ): Promise => { const query = generateQueryString(queryParameters); - const requestUrl = query ? url + "?" + encodeURI(query) : url; + const requestUrl = query ? `${url}?${encodeURI(query)}` : url; return new Promise((resolve, reject) => { const agent = Superagent; diff --git a/examples/readme-sample/ast-code-template.ts b/examples/readme-sample/ast-code-template.ts index 40ed7233..0f8ef13d 100644 --- a/examples/readme-sample/ast-code-template.ts +++ b/examples/readme-sample/ast-code-template.ts @@ -1,7 +1,7 @@ import { TsGenerator } from "@himenon/openapi-typescript-code-generator/dist/api"; import * as Types from "@himenon/openapi-typescript-code-generator/dist/types"; -interface Option {} +type Option = {}; const factory = TsGenerator.Factory.create(); diff --git a/examples/readme-sample/text-base-code-template.ts b/examples/readme-sample/text-base-code-template.ts index 5680e1bf..c5304793 100644 --- a/examples/readme-sample/text-base-code-template.ts +++ b/examples/readme-sample/text-base-code-template.ts @@ -5,7 +5,7 @@ interface Option { } const generator: Types.CodeGenerator.GenerateFunction