From 32c1e925dc63b3230ab8dbde5311018a71fc89bc Mon Sep 17 00:00:00 2001 From: Fabian Sellmann <9982477+FabianSellmann@users.noreply.github.com> Date: Thu, 10 Jun 2021 00:23:50 +0800 Subject: [PATCH] [typescript-fetch] runtime: pass init and url as returned by the premiddleware to the postmiddleware (#9716) * pass init and url as returned by the premiddleware to the postmiddleware Current implementation will always pass the initial url and init object. However if a pre middleware changes returns an object whose `init` or `url` property refer to a different url string or object, any following post middleware wont have access to it. Effectively providing the post middleware with a completely different request information then what was actually used to make the fetch call. * update samples and docs --- .../src/main/resources/typescript-fetch/runtime.mustache | 4 ++-- .../petstore/typescript-fetch/builds/default-v3.0/runtime.ts | 4 ++-- .../petstore/typescript-fetch/builds/default/runtime.ts | 4 ++-- .../client/petstore/typescript-fetch/builds/enum/runtime.ts | 4 ++-- .../typescript-fetch/builds/es6-target/src/runtime.ts | 4 ++-- .../typescript-fetch/builds/multiple-parameters/runtime.ts | 4 ++-- .../builds/prefix-parameter-interfaces/src/runtime.ts | 4 ++-- .../builds/typescript-three-plus/src/runtime.ts | 4 ++-- .../typescript-fetch/builds/with-interfaces/runtime.ts | 4 ++-- .../typescript-fetch/builds/with-npm-version/src/runtime.ts | 4 ++-- .../builds/without-runtime-checks/src/runtime.ts | 4 ++-- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache index e0498e0e316..8df16e9074e 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache @@ -79,8 +79,8 @@ export class BaseAPI { if (middleware.post) { response = await middleware.post({ fetch: this.fetchApi, - url, - init, + url: fetchParams.url, + init: fetchParams.init, response: response.clone(), }) || response; } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/runtime.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/runtime.ts index be992e2dac8..6924269e546 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/runtime.ts @@ -90,8 +90,8 @@ export class BaseAPI { if (middleware.post) { response = await middleware.post({ fetch: this.fetchApi, - url, - init, + url: fetchParams.url, + init: fetchParams.init, response: response.clone(), }) || response; } diff --git a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts index 20374a38659..8ae5f65348c 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts @@ -90,8 +90,8 @@ export class BaseAPI { if (middleware.post) { response = await middleware.post({ fetch: this.fetchApi, - url, - init, + url: fetchParams.url, + init: fetchParams.init, response: response.clone(), }) || response; } diff --git a/samples/client/petstore/typescript-fetch/builds/enum/runtime.ts b/samples/client/petstore/typescript-fetch/builds/enum/runtime.ts index d558d0ad7de..c4d82bccb8f 100644 --- a/samples/client/petstore/typescript-fetch/builds/enum/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/enum/runtime.ts @@ -90,8 +90,8 @@ export class BaseAPI { if (middleware.post) { response = await middleware.post({ fetch: this.fetchApi, - url, - init, + url: fetchParams.url, + init: fetchParams.init, response: response.clone(), }) || response; } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts index 20374a38659..8ae5f65348c 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts @@ -90,8 +90,8 @@ export class BaseAPI { if (middleware.post) { response = await middleware.post({ fetch: this.fetchApi, - url, - init, + url: fetchParams.url, + init: fetchParams.init, response: response.clone(), }) || response; } diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/runtime.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/runtime.ts index 20374a38659..8ae5f65348c 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/runtime.ts @@ -90,8 +90,8 @@ export class BaseAPI { if (middleware.post) { response = await middleware.post({ fetch: this.fetchApi, - url, - init, + url: fetchParams.url, + init: fetchParams.init, response: response.clone(), }) || response; } diff --git a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/runtime.ts index 20374a38659..8ae5f65348c 100644 --- a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/runtime.ts @@ -90,8 +90,8 @@ export class BaseAPI { if (middleware.post) { response = await middleware.post({ fetch: this.fetchApi, - url, - init, + url: fetchParams.url, + init: fetchParams.init, response: response.clone(), }) || response; } diff --git a/samples/client/petstore/typescript-fetch/builds/typescript-three-plus/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/typescript-three-plus/src/runtime.ts index 95601f9e307..40ac35e9d19 100644 --- a/samples/client/petstore/typescript-fetch/builds/typescript-three-plus/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/typescript-three-plus/src/runtime.ts @@ -90,8 +90,8 @@ export class BaseAPI { if (middleware.post) { response = await middleware.post({ fetch: this.fetchApi, - url, - init, + url: fetchParams.url, + init: fetchParams.init, response: response.clone(), }) || response; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts index 20374a38659..8ae5f65348c 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts @@ -90,8 +90,8 @@ export class BaseAPI { if (middleware.post) { response = await middleware.post({ fetch: this.fetchApi, - url, - init, + url: fetchParams.url, + init: fetchParams.init, response: response.clone(), }) || response; } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts index 20374a38659..8ae5f65348c 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts @@ -90,8 +90,8 @@ export class BaseAPI { if (middleware.post) { response = await middleware.post({ fetch: this.fetchApi, - url, - init, + url: fetchParams.url, + init: fetchParams.init, response: response.clone(), }) || response; } diff --git a/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/runtime.ts index 20374a38659..8ae5f65348c 100644 --- a/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/runtime.ts @@ -90,8 +90,8 @@ export class BaseAPI { if (middleware.post) { response = await middleware.post({ fetch: this.fetchApi, - url, - init, + url: fetchParams.url, + init: fetchParams.init, response: response.clone(), }) || response; }