From c3f9fddb9616a8b3ac2e324276ace8e4e3417877 Mon Sep 17 00:00:00 2001 From: Simeon Borko Date: Wed, 31 Jan 2024 14:23:14 +0100 Subject: [PATCH 1/2] typescript-fetch: nullify URL search field instead of delete --- .../src/main/resources/typescript-fetch/api.mustache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/typescript-fetch/api.mustache b/modules/swagger-codegen/src/main/resources/typescript-fetch/api.mustache index bcdb03acf2c..23fc5709cfa 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-fetch/api.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-fetch/api.mustache @@ -52,7 +52,7 @@ export class BaseAPI { this.basePath = configuration.basePath || this.basePath; } } -}; +} /** * @@ -224,7 +224,7 @@ export const {{classname}}FetchParamCreator = function (configuration?: Configur {{/bodyParam}} localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; + localVarUrlObj.search = null; localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); {{#hasFormParams}} localVarRequestOptions.body = localVarFormParams.toString(); From 6c938fd4814fe7bca9483bbd0c626a1a21448a96 Mon Sep 17 00:00:00 2001 From: Simeon Borko Date: Wed, 31 Jan 2024 14:27:48 +0100 Subject: [PATCH 2/2] samples/typescript-fetch: regenerated --- .../typescript-fetch/.swagger-codegen/VERSION | 2 +- .../typescript-fetch/api.ts | 14 +++--- .../builds/default/.swagger-codegen/VERSION | 2 +- .../typescript-fetch/builds/default/api.ts | 46 +++++++++---------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/samples/client/petstore-security-test/typescript-fetch/.swagger-codegen/VERSION b/samples/client/petstore-security-test/typescript-fetch/.swagger-codegen/VERSION index 855ff9501eb..6f4ec437a9b 100644 --- a/samples/client/petstore-security-test/typescript-fetch/.swagger-codegen/VERSION +++ b/samples/client/petstore-security-test/typescript-fetch/.swagger-codegen/VERSION @@ -1 +1 @@ -2.4.0-SNAPSHOT \ No newline at end of file +2.4.40-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore-security-test/typescript-fetch/api.ts b/samples/client/petstore-security-test/typescript-fetch/api.ts index d69e2ae751d..19c31894d90 100644 --- a/samples/client/petstore-security-test/typescript-fetch/api.ts +++ b/samples/client/petstore-security-test/typescript-fetch/api.ts @@ -40,7 +40,7 @@ export interface FetchAPI { } /** - * + * * @export * @interface FetchArgs */ @@ -50,12 +50,12 @@ export interface FetchArgs { } /** - * + * * @export * @class BaseAPI */ export class BaseAPI { - protected configuration: Configuration; + protected configuration?: Configuration; constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected fetch: FetchAPI = portableFetch) { if (configuration) { @@ -63,16 +63,16 @@ export class BaseAPI { this.basePath = configuration.basePath || this.basePath; } } -}; +} /** - * + * * @export * @class RequiredError * @extends {Error} */ export class RequiredError extends Error { - name: "RequiredError" + name = "RequiredError" constructor(public field: string, msg?: string) { super(msg); } @@ -122,7 +122,7 @@ export const FakeApiFetchParamCreator = function (configuration?: Configuration) localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; + localVarUrlObj.search = null; localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); localVarRequestOptions.body = localVarFormParams.toString(); diff --git a/samples/client/petstore/typescript-fetch/builds/default/.swagger-codegen/VERSION b/samples/client/petstore/typescript-fetch/builds/default/.swagger-codegen/VERSION index 8c7754221a4..6f4ec437a9b 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/.swagger-codegen/VERSION +++ b/samples/client/petstore/typescript-fetch/builds/default/.swagger-codegen/VERSION @@ -1 +1 @@ -2.4.19-SNAPSHOT \ No newline at end of file +2.4.40-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/typescript-fetch/builds/default/api.ts b/samples/client/petstore/typescript-fetch/builds/default/api.ts index 263c89d41d8..7e1be018694 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/api.ts @@ -17,7 +17,7 @@ import * as url from "url"; import * as portableFetch from "portable-fetch"; import { Configuration } from "./configuration"; -const BASE_PATH = "https://petstore.swagger.io/v2".replace(/\/+$/, ""); +const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); /** * @@ -55,7 +55,7 @@ export interface FetchArgs { * @class BaseAPI */ export class BaseAPI { - protected configuration: Configuration; + protected configuration?: Configuration; constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected fetch: FetchAPI = portableFetch) { if (configuration) { @@ -72,7 +72,7 @@ export class BaseAPI { * @extends {Error} */ export class RequiredError extends Error { - name: "RequiredError" + name = "RequiredError" constructor(public field: string, msg?: string) { super(msg); } @@ -386,7 +386,7 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration) localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; + localVarUrlObj.search = null; localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; localVarRequestOptions.body = needsSerialization ? JSON.stringify(body || {}) : (body || ""); @@ -431,7 +431,7 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration) localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; + localVarUrlObj.search = null; localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); return { @@ -472,7 +472,7 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration) localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; + localVarUrlObj.search = null; localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); return { @@ -513,7 +513,7 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration) localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; + localVarUrlObj.search = null; localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); return { @@ -550,7 +550,7 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration) localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; + localVarUrlObj.search = null; localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); return { @@ -589,7 +589,7 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration) localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; + localVarUrlObj.search = null; localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); const needsSerialization = ("Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; localVarRequestOptions.body = needsSerialization ? JSON.stringify(body || {}) : (body || ""); @@ -642,7 +642,7 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration) localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; + localVarUrlObj.search = null; localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); localVarRequestOptions.body = localVarFormParams.toString(); @@ -694,7 +694,7 @@ export const PetApiFetchParamCreator = function (configuration?: Configuration) localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; + localVarUrlObj.search = null; localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); localVarRequestOptions.body = localVarFormParams.toString(); @@ -1103,7 +1103,7 @@ export const StoreApiFetchParamCreator = function (configuration?: Configuration localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; + localVarUrlObj.search = null; localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); return { @@ -1134,7 +1134,7 @@ export const StoreApiFetchParamCreator = function (configuration?: Configuration localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; + localVarUrlObj.search = null; localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); return { @@ -1163,7 +1163,7 @@ export const StoreApiFetchParamCreator = function (configuration?: Configuration localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; + localVarUrlObj.search = null; localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); return { @@ -1193,7 +1193,7 @@ export const StoreApiFetchParamCreator = function (configuration?: Configuration localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; + localVarUrlObj.search = null; localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); const needsSerialization = ("Order" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; localVarRequestOptions.body = needsSerialization ? JSON.stringify(body || {}) : (body || ""); @@ -1422,7 +1422,7 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration) localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; + localVarUrlObj.search = null; localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; localVarRequestOptions.body = needsSerialization ? JSON.stringify(body || {}) : (body || ""); @@ -1454,7 +1454,7 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration) localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; + localVarUrlObj.search = null; localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; localVarRequestOptions.body = needsSerialization ? JSON.stringify(body || {}) : (body || ""); @@ -1486,7 +1486,7 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration) localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; + localVarUrlObj.search = null; localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); const needsSerialization = ("Array<User>" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; localVarRequestOptions.body = needsSerialization ? JSON.stringify(body || {}) : (body || ""); @@ -1517,7 +1517,7 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration) localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; + localVarUrlObj.search = null; localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); return { @@ -1546,7 +1546,7 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration) localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; + localVarUrlObj.search = null; localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); return { @@ -1587,7 +1587,7 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration) localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; + localVarUrlObj.search = null; localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); return { @@ -1610,7 +1610,7 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration) localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; + localVarUrlObj.search = null; localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); return { @@ -1646,7 +1646,7 @@ export const UserApiFetchParamCreator = function (configuration?: Configuration) localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query); // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943 - delete localVarUrlObj.search; + localVarUrlObj.search = null; localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers); const needsSerialization = ("User" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json'; localVarRequestOptions.body = needsSerialization ? JSON.stringify(body || {}) : (body || "");