From 5bd63074c464ce1c699130e6dfff3f6ee5ed7a4e Mon Sep 17 00:00:00 2001 From: Bernd Hacker Date: Tue, 27 Aug 2019 11:17:41 +0200 Subject: [PATCH] [typescript-rxjs] support HEAD method, improve formatting (#3766) * feat(typescript-rxjs): add support for HEAD method * feat(typescript-rxjs): improve formatting * feat(typescript-rxjs): regenerate samples * feat(typescript-rxjs): generate samples * feat(typescript-rxjs): use better white space, regnerate samples --- .../resources/typescript-rxjs/apis.mustache | 2 +- .../resources/typescript-rxjs/runtime.mustache | 18 +++++++++--------- .../builds/default/apis/PetApi.ts | 16 ++++++++-------- .../builds/default/apis/StoreApi.ts | 8 ++++---- .../builds/default/apis/UserApi.ts | 16 ++++++++-------- .../typescript-rxjs/builds/default/runtime.ts | 18 +++++++++--------- .../builds/es6-target/apis/PetApi.ts | 16 ++++++++-------- .../builds/es6-target/apis/StoreApi.ts | 8 ++++---- .../builds/es6-target/apis/UserApi.ts | 16 ++++++++-------- .../builds/es6-target/runtime.ts | 18 +++++++++--------- .../builds/with-interfaces/apis/PetApi.ts | 16 ++++++++-------- .../builds/with-interfaces/apis/StoreApi.ts | 8 ++++---- .../builds/with-interfaces/apis/UserApi.ts | 16 ++++++++-------- .../builds/with-interfaces/runtime.ts | 18 +++++++++--------- .../builds/with-npm-version/apis/PetApi.ts | 16 ++++++++-------- .../builds/with-npm-version/apis/StoreApi.ts | 8 ++++---- .../builds/with-npm-version/apis/UserApi.ts | 16 ++++++++-------- .../builds/with-npm-version/runtime.ts | 18 +++++++++--------- 18 files changed, 126 insertions(+), 126 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-rxjs/apis.mustache b/modules/openapi-generator/src/main/resources/typescript-rxjs/apis.mustache index 70614d7f79a..3c548d7b547 100644 --- a/modules/openapi-generator/src/main/resources/typescript-rxjs/apis.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-rxjs/apis.mustache @@ -175,7 +175,7 @@ export class {{classname}} extends BaseAPI { responseType: 'blob' {{/isResponseFile}} }); - } + }; {{/operation}} } diff --git a/modules/openapi-generator/src/main/resources/typescript-rxjs/runtime.mustache b/modules/openapi-generator/src/main/resources/typescript-rxjs/runtime.mustache index 27f466a6650..555ee5aad66 100644 --- a/modules/openapi-generator/src/main/resources/typescript-rxjs/runtime.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-rxjs/runtime.mustache @@ -65,7 +65,7 @@ export class BaseAPI { const next = this.clone(); next.middleware = next.middleware.concat(middlewares); return next; - } + }; withPreMiddleware = (preMiddlewares: Array) => this.withMiddleware(preMiddlewares.map((pre) => ({ pre }))); @@ -73,7 +73,7 @@ export class BaseAPI { withPostMiddleware = (postMiddlewares: Array) => this.withMiddleware(postMiddlewares.map((post) => ({ post }))); - protected request = (requestOpts: RequestOpts): Observable => + protected request = (requestOpts: RequestOpts): Observable => this.rxjsRequest(this.createRequestArgs(requestOpts)).pipe( map((res) => { if (res.status >= 200 && res.status < 300) { @@ -91,17 +91,17 @@ export class BaseAPI { // do not handle correctly sometimes. url += '?' + queryString(requestOpts.query); } - + return { url, method: requestOpts.method, headers: requestOpts.headers, body: requestOpts.body instanceof FormData ? requestOpts.body : JSON.stringify(requestOpts.body), - responseType: requestOpts.responseType || 'json' + responseType: requestOpts.responseType || 'json', }; } - private rxjsRequest = (params: RequestArgs): Observable => + private rxjsRequest = (params: RequestArgs): Observable => of(params).pipe( map((request) => { this.middleware.filter((item) => item.pre).forEach((mw) => (request = mw.pre!(request))); @@ -122,7 +122,7 @@ export class BaseAPI { * and then shallow cloning data members. */ private clone = (): T => - Object.assign(Object.create(Object.getPrototypeOf(this)), this) + Object.assign(Object.create(Object.getPrototypeOf(this)), this); } // export for not being a breaking change @@ -138,7 +138,7 @@ export const COLLECTION_FORMATS = { }; export type Json = any; -export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS'; +export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD'; export type HttpHeaders = { [key: string]: string }; export type HttpQuery = { [key: string]: string | number | null | boolean | Array }; export type HttpBody = Json | FormData; @@ -153,7 +153,7 @@ export interface RequestOpts { responseType?: 'json' | 'blob' | 'arraybuffer' | 'text'; } -export const encodeURI = (value: any) => encodeURIComponent(String(value)) +export const encodeURI = (value: any) => encodeURIComponent(String(value)); const queryString = (params: HttpQuery): string => Object.keys(params) .map((key) => { @@ -171,7 +171,7 @@ export const throwIfRequired = (params: {[key: string]: any}, key: string, nickn if (!params || params[key] === null || params[key] === undefined) { throw new RequiredError(`Required parameter ${key} was null or undefined when calling ${nickname}.`); } -} +}; // alias for easier importing export interface RequestArgs extends AjaxRequest {} diff --git a/samples/client/petstore/typescript-rxjs/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript-rxjs/builds/default/apis/PetApi.ts index 1d8a5f00110..a5328a8c728 100644 --- a/samples/client/petstore/typescript-rxjs/builds/default/apis/PetApi.ts +++ b/samples/client/petstore/typescript-rxjs/builds/default/apis/PetApi.ts @@ -82,7 +82,7 @@ export class PetApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; /** * Deletes a pet @@ -105,7 +105,7 @@ export class PetApi extends BaseAPI { method: 'DELETE', headers, }); - } + }; /** * Multiple status values can be provided with comma separated strings @@ -133,7 +133,7 @@ export class PetApi extends BaseAPI { headers, query, }); - } + }; /** * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. @@ -161,7 +161,7 @@ export class PetApi extends BaseAPI { headers, query, }); - } + }; /** * Returns a single pet @@ -179,7 +179,7 @@ export class PetApi extends BaseAPI { method: 'GET', headers, }); - } + }; /** * Update an existing pet @@ -203,7 +203,7 @@ export class PetApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; /** * Updates a pet in the store with form data @@ -235,7 +235,7 @@ export class PetApi extends BaseAPI { headers, body: formData, }); - } + }; /** * uploads an image @@ -267,7 +267,7 @@ export class PetApi extends BaseAPI { headers, body: formData, }); - } + }; } diff --git a/samples/client/petstore/typescript-rxjs/builds/default/apis/StoreApi.ts b/samples/client/petstore/typescript-rxjs/builds/default/apis/StoreApi.ts index b3e038e8948..623b48bdede 100644 --- a/samples/client/petstore/typescript-rxjs/builds/default/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-rxjs/builds/default/apis/StoreApi.ts @@ -45,7 +45,7 @@ export class StoreApi extends BaseAPI { path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(requestParameters.orderId)), method: 'DELETE', }); - } + }; /** * Returns a map of status codes to quantities @@ -61,7 +61,7 @@ export class StoreApi extends BaseAPI { method: 'GET', headers, }); - } + }; /** * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -74,7 +74,7 @@ export class StoreApi extends BaseAPI { path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(requestParameters.orderId)), method: 'GET', }); - } + }; /** * Place an order for a pet @@ -92,6 +92,6 @@ export class StoreApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; } diff --git a/samples/client/petstore/typescript-rxjs/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript-rxjs/builds/default/apis/UserApi.ts index c356d96e91c..2194fdfe9f6 100644 --- a/samples/client/petstore/typescript-rxjs/builds/default/apis/UserApi.ts +++ b/samples/client/petstore/typescript-rxjs/builds/default/apis/UserApi.ts @@ -69,7 +69,7 @@ export class UserApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; /** * Creates list of users with given input array @@ -87,7 +87,7 @@ export class UserApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; /** * Creates list of users with given input array @@ -105,7 +105,7 @@ export class UserApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; /** * This can only be done by the logged in user. @@ -118,7 +118,7 @@ export class UserApi extends BaseAPI { path: '/user/{username}'.replace('{username}', encodeURI(requestParameters.username)), method: 'DELETE', }); - } + }; /** * Get user by user name @@ -130,7 +130,7 @@ export class UserApi extends BaseAPI { path: '/user/{username}'.replace('{username}', encodeURI(requestParameters.username)), method: 'GET', }); - } + }; /** * Logs user into the system @@ -149,7 +149,7 @@ export class UserApi extends BaseAPI { method: 'GET', query, }); - } + }; /** * Logs out current logged in user session @@ -159,7 +159,7 @@ export class UserApi extends BaseAPI { path: '/user/logout', method: 'GET', }); - } + }; /** * This can only be done by the logged in user. @@ -179,6 +179,6 @@ export class UserApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; } diff --git a/samples/client/petstore/typescript-rxjs/builds/default/runtime.ts b/samples/client/petstore/typescript-rxjs/builds/default/runtime.ts index 01e3bb106fe..1bbd8633b29 100644 --- a/samples/client/petstore/typescript-rxjs/builds/default/runtime.ts +++ b/samples/client/petstore/typescript-rxjs/builds/default/runtime.ts @@ -76,7 +76,7 @@ export class BaseAPI { const next = this.clone(); next.middleware = next.middleware.concat(middlewares); return next; - } + }; withPreMiddleware = (preMiddlewares: Array) => this.withMiddleware(preMiddlewares.map((pre) => ({ pre }))); @@ -84,7 +84,7 @@ export class BaseAPI { withPostMiddleware = (postMiddlewares: Array) => this.withMiddleware(postMiddlewares.map((post) => ({ post }))); - protected request = (requestOpts: RequestOpts): Observable => + protected request = (requestOpts: RequestOpts): Observable => this.rxjsRequest(this.createRequestArgs(requestOpts)).pipe( map((res) => { if (res.status >= 200 && res.status < 300) { @@ -102,17 +102,17 @@ export class BaseAPI { // do not handle correctly sometimes. url += '?' + queryString(requestOpts.query); } - + return { url, method: requestOpts.method, headers: requestOpts.headers, body: requestOpts.body instanceof FormData ? requestOpts.body : JSON.stringify(requestOpts.body), - responseType: requestOpts.responseType || 'json' + responseType: requestOpts.responseType || 'json', }; } - private rxjsRequest = (params: RequestArgs): Observable => + private rxjsRequest = (params: RequestArgs): Observable => of(params).pipe( map((request) => { this.middleware.filter((item) => item.pre).forEach((mw) => (request = mw.pre!(request))); @@ -133,7 +133,7 @@ export class BaseAPI { * and then shallow cloning data members. */ private clone = (): T => - Object.assign(Object.create(Object.getPrototypeOf(this)), this) + Object.assign(Object.create(Object.getPrototypeOf(this)), this); } // export for not being a breaking change @@ -149,7 +149,7 @@ export const COLLECTION_FORMATS = { }; export type Json = any; -export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS'; +export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD'; export type HttpHeaders = { [key: string]: string }; export type HttpQuery = { [key: string]: string | number | null | boolean | Array }; export type HttpBody = Json | FormData; @@ -164,7 +164,7 @@ export interface RequestOpts { responseType?: 'json' | 'blob' | 'arraybuffer' | 'text'; } -export const encodeURI = (value: any) => encodeURIComponent(String(value)) +export const encodeURI = (value: any) => encodeURIComponent(String(value)); const queryString = (params: HttpQuery): string => Object.keys(params) .map((key) => { @@ -182,7 +182,7 @@ export const throwIfRequired = (params: {[key: string]: any}, key: string, nickn if (!params || params[key] === null || params[key] === undefined) { throw new RequiredError(`Required parameter ${key} was null or undefined when calling ${nickname}.`); } -} +}; // alias for easier importing export interface RequestArgs extends AjaxRequest {} diff --git a/samples/client/petstore/typescript-rxjs/builds/es6-target/apis/PetApi.ts b/samples/client/petstore/typescript-rxjs/builds/es6-target/apis/PetApi.ts index 1d8a5f00110..a5328a8c728 100644 --- a/samples/client/petstore/typescript-rxjs/builds/es6-target/apis/PetApi.ts +++ b/samples/client/petstore/typescript-rxjs/builds/es6-target/apis/PetApi.ts @@ -82,7 +82,7 @@ export class PetApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; /** * Deletes a pet @@ -105,7 +105,7 @@ export class PetApi extends BaseAPI { method: 'DELETE', headers, }); - } + }; /** * Multiple status values can be provided with comma separated strings @@ -133,7 +133,7 @@ export class PetApi extends BaseAPI { headers, query, }); - } + }; /** * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. @@ -161,7 +161,7 @@ export class PetApi extends BaseAPI { headers, query, }); - } + }; /** * Returns a single pet @@ -179,7 +179,7 @@ export class PetApi extends BaseAPI { method: 'GET', headers, }); - } + }; /** * Update an existing pet @@ -203,7 +203,7 @@ export class PetApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; /** * Updates a pet in the store with form data @@ -235,7 +235,7 @@ export class PetApi extends BaseAPI { headers, body: formData, }); - } + }; /** * uploads an image @@ -267,7 +267,7 @@ export class PetApi extends BaseAPI { headers, body: formData, }); - } + }; } diff --git a/samples/client/petstore/typescript-rxjs/builds/es6-target/apis/StoreApi.ts b/samples/client/petstore/typescript-rxjs/builds/es6-target/apis/StoreApi.ts index b3e038e8948..623b48bdede 100644 --- a/samples/client/petstore/typescript-rxjs/builds/es6-target/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-rxjs/builds/es6-target/apis/StoreApi.ts @@ -45,7 +45,7 @@ export class StoreApi extends BaseAPI { path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(requestParameters.orderId)), method: 'DELETE', }); - } + }; /** * Returns a map of status codes to quantities @@ -61,7 +61,7 @@ export class StoreApi extends BaseAPI { method: 'GET', headers, }); - } + }; /** * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -74,7 +74,7 @@ export class StoreApi extends BaseAPI { path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(requestParameters.orderId)), method: 'GET', }); - } + }; /** * Place an order for a pet @@ -92,6 +92,6 @@ export class StoreApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; } diff --git a/samples/client/petstore/typescript-rxjs/builds/es6-target/apis/UserApi.ts b/samples/client/petstore/typescript-rxjs/builds/es6-target/apis/UserApi.ts index c356d96e91c..2194fdfe9f6 100644 --- a/samples/client/petstore/typescript-rxjs/builds/es6-target/apis/UserApi.ts +++ b/samples/client/petstore/typescript-rxjs/builds/es6-target/apis/UserApi.ts @@ -69,7 +69,7 @@ export class UserApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; /** * Creates list of users with given input array @@ -87,7 +87,7 @@ export class UserApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; /** * Creates list of users with given input array @@ -105,7 +105,7 @@ export class UserApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; /** * This can only be done by the logged in user. @@ -118,7 +118,7 @@ export class UserApi extends BaseAPI { path: '/user/{username}'.replace('{username}', encodeURI(requestParameters.username)), method: 'DELETE', }); - } + }; /** * Get user by user name @@ -130,7 +130,7 @@ export class UserApi extends BaseAPI { path: '/user/{username}'.replace('{username}', encodeURI(requestParameters.username)), method: 'GET', }); - } + }; /** * Logs user into the system @@ -149,7 +149,7 @@ export class UserApi extends BaseAPI { method: 'GET', query, }); - } + }; /** * Logs out current logged in user session @@ -159,7 +159,7 @@ export class UserApi extends BaseAPI { path: '/user/logout', method: 'GET', }); - } + }; /** * This can only be done by the logged in user. @@ -179,6 +179,6 @@ export class UserApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; } diff --git a/samples/client/petstore/typescript-rxjs/builds/es6-target/runtime.ts b/samples/client/petstore/typescript-rxjs/builds/es6-target/runtime.ts index 01e3bb106fe..1bbd8633b29 100644 --- a/samples/client/petstore/typescript-rxjs/builds/es6-target/runtime.ts +++ b/samples/client/petstore/typescript-rxjs/builds/es6-target/runtime.ts @@ -76,7 +76,7 @@ export class BaseAPI { const next = this.clone(); next.middleware = next.middleware.concat(middlewares); return next; - } + }; withPreMiddleware = (preMiddlewares: Array) => this.withMiddleware(preMiddlewares.map((pre) => ({ pre }))); @@ -84,7 +84,7 @@ export class BaseAPI { withPostMiddleware = (postMiddlewares: Array) => this.withMiddleware(postMiddlewares.map((post) => ({ post }))); - protected request = (requestOpts: RequestOpts): Observable => + protected request = (requestOpts: RequestOpts): Observable => this.rxjsRequest(this.createRequestArgs(requestOpts)).pipe( map((res) => { if (res.status >= 200 && res.status < 300) { @@ -102,17 +102,17 @@ export class BaseAPI { // do not handle correctly sometimes. url += '?' + queryString(requestOpts.query); } - + return { url, method: requestOpts.method, headers: requestOpts.headers, body: requestOpts.body instanceof FormData ? requestOpts.body : JSON.stringify(requestOpts.body), - responseType: requestOpts.responseType || 'json' + responseType: requestOpts.responseType || 'json', }; } - private rxjsRequest = (params: RequestArgs): Observable => + private rxjsRequest = (params: RequestArgs): Observable => of(params).pipe( map((request) => { this.middleware.filter((item) => item.pre).forEach((mw) => (request = mw.pre!(request))); @@ -133,7 +133,7 @@ export class BaseAPI { * and then shallow cloning data members. */ private clone = (): T => - Object.assign(Object.create(Object.getPrototypeOf(this)), this) + Object.assign(Object.create(Object.getPrototypeOf(this)), this); } // export for not being a breaking change @@ -149,7 +149,7 @@ export const COLLECTION_FORMATS = { }; export type Json = any; -export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS'; +export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD'; export type HttpHeaders = { [key: string]: string }; export type HttpQuery = { [key: string]: string | number | null | boolean | Array }; export type HttpBody = Json | FormData; @@ -164,7 +164,7 @@ export interface RequestOpts { responseType?: 'json' | 'blob' | 'arraybuffer' | 'text'; } -export const encodeURI = (value: any) => encodeURIComponent(String(value)) +export const encodeURI = (value: any) => encodeURIComponent(String(value)); const queryString = (params: HttpQuery): string => Object.keys(params) .map((key) => { @@ -182,7 +182,7 @@ export const throwIfRequired = (params: {[key: string]: any}, key: string, nickn if (!params || params[key] === null || params[key] === undefined) { throw new RequiredError(`Required parameter ${key} was null or undefined when calling ${nickname}.`); } -} +}; // alias for easier importing export interface RequestArgs extends AjaxRequest {} diff --git a/samples/client/petstore/typescript-rxjs/builds/with-interfaces/apis/PetApi.ts b/samples/client/petstore/typescript-rxjs/builds/with-interfaces/apis/PetApi.ts index 1d8a5f00110..a5328a8c728 100644 --- a/samples/client/petstore/typescript-rxjs/builds/with-interfaces/apis/PetApi.ts +++ b/samples/client/petstore/typescript-rxjs/builds/with-interfaces/apis/PetApi.ts @@ -82,7 +82,7 @@ export class PetApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; /** * Deletes a pet @@ -105,7 +105,7 @@ export class PetApi extends BaseAPI { method: 'DELETE', headers, }); - } + }; /** * Multiple status values can be provided with comma separated strings @@ -133,7 +133,7 @@ export class PetApi extends BaseAPI { headers, query, }); - } + }; /** * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. @@ -161,7 +161,7 @@ export class PetApi extends BaseAPI { headers, query, }); - } + }; /** * Returns a single pet @@ -179,7 +179,7 @@ export class PetApi extends BaseAPI { method: 'GET', headers, }); - } + }; /** * Update an existing pet @@ -203,7 +203,7 @@ export class PetApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; /** * Updates a pet in the store with form data @@ -235,7 +235,7 @@ export class PetApi extends BaseAPI { headers, body: formData, }); - } + }; /** * uploads an image @@ -267,7 +267,7 @@ export class PetApi extends BaseAPI { headers, body: formData, }); - } + }; } diff --git a/samples/client/petstore/typescript-rxjs/builds/with-interfaces/apis/StoreApi.ts b/samples/client/petstore/typescript-rxjs/builds/with-interfaces/apis/StoreApi.ts index b3e038e8948..623b48bdede 100644 --- a/samples/client/petstore/typescript-rxjs/builds/with-interfaces/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-rxjs/builds/with-interfaces/apis/StoreApi.ts @@ -45,7 +45,7 @@ export class StoreApi extends BaseAPI { path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(requestParameters.orderId)), method: 'DELETE', }); - } + }; /** * Returns a map of status codes to quantities @@ -61,7 +61,7 @@ export class StoreApi extends BaseAPI { method: 'GET', headers, }); - } + }; /** * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -74,7 +74,7 @@ export class StoreApi extends BaseAPI { path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(requestParameters.orderId)), method: 'GET', }); - } + }; /** * Place an order for a pet @@ -92,6 +92,6 @@ export class StoreApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; } diff --git a/samples/client/petstore/typescript-rxjs/builds/with-interfaces/apis/UserApi.ts b/samples/client/petstore/typescript-rxjs/builds/with-interfaces/apis/UserApi.ts index c356d96e91c..2194fdfe9f6 100644 --- a/samples/client/petstore/typescript-rxjs/builds/with-interfaces/apis/UserApi.ts +++ b/samples/client/petstore/typescript-rxjs/builds/with-interfaces/apis/UserApi.ts @@ -69,7 +69,7 @@ export class UserApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; /** * Creates list of users with given input array @@ -87,7 +87,7 @@ export class UserApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; /** * Creates list of users with given input array @@ -105,7 +105,7 @@ export class UserApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; /** * This can only be done by the logged in user. @@ -118,7 +118,7 @@ export class UserApi extends BaseAPI { path: '/user/{username}'.replace('{username}', encodeURI(requestParameters.username)), method: 'DELETE', }); - } + }; /** * Get user by user name @@ -130,7 +130,7 @@ export class UserApi extends BaseAPI { path: '/user/{username}'.replace('{username}', encodeURI(requestParameters.username)), method: 'GET', }); - } + }; /** * Logs user into the system @@ -149,7 +149,7 @@ export class UserApi extends BaseAPI { method: 'GET', query, }); - } + }; /** * Logs out current logged in user session @@ -159,7 +159,7 @@ export class UserApi extends BaseAPI { path: '/user/logout', method: 'GET', }); - } + }; /** * This can only be done by the logged in user. @@ -179,6 +179,6 @@ export class UserApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; } diff --git a/samples/client/petstore/typescript-rxjs/builds/with-interfaces/runtime.ts b/samples/client/petstore/typescript-rxjs/builds/with-interfaces/runtime.ts index 01e3bb106fe..1bbd8633b29 100644 --- a/samples/client/petstore/typescript-rxjs/builds/with-interfaces/runtime.ts +++ b/samples/client/petstore/typescript-rxjs/builds/with-interfaces/runtime.ts @@ -76,7 +76,7 @@ export class BaseAPI { const next = this.clone(); next.middleware = next.middleware.concat(middlewares); return next; - } + }; withPreMiddleware = (preMiddlewares: Array) => this.withMiddleware(preMiddlewares.map((pre) => ({ pre }))); @@ -84,7 +84,7 @@ export class BaseAPI { withPostMiddleware = (postMiddlewares: Array) => this.withMiddleware(postMiddlewares.map((post) => ({ post }))); - protected request = (requestOpts: RequestOpts): Observable => + protected request = (requestOpts: RequestOpts): Observable => this.rxjsRequest(this.createRequestArgs(requestOpts)).pipe( map((res) => { if (res.status >= 200 && res.status < 300) { @@ -102,17 +102,17 @@ export class BaseAPI { // do not handle correctly sometimes. url += '?' + queryString(requestOpts.query); } - + return { url, method: requestOpts.method, headers: requestOpts.headers, body: requestOpts.body instanceof FormData ? requestOpts.body : JSON.stringify(requestOpts.body), - responseType: requestOpts.responseType || 'json' + responseType: requestOpts.responseType || 'json', }; } - private rxjsRequest = (params: RequestArgs): Observable => + private rxjsRequest = (params: RequestArgs): Observable => of(params).pipe( map((request) => { this.middleware.filter((item) => item.pre).forEach((mw) => (request = mw.pre!(request))); @@ -133,7 +133,7 @@ export class BaseAPI { * and then shallow cloning data members. */ private clone = (): T => - Object.assign(Object.create(Object.getPrototypeOf(this)), this) + Object.assign(Object.create(Object.getPrototypeOf(this)), this); } // export for not being a breaking change @@ -149,7 +149,7 @@ export const COLLECTION_FORMATS = { }; export type Json = any; -export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS'; +export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD'; export type HttpHeaders = { [key: string]: string }; export type HttpQuery = { [key: string]: string | number | null | boolean | Array }; export type HttpBody = Json | FormData; @@ -164,7 +164,7 @@ export interface RequestOpts { responseType?: 'json' | 'blob' | 'arraybuffer' | 'text'; } -export const encodeURI = (value: any) => encodeURIComponent(String(value)) +export const encodeURI = (value: any) => encodeURIComponent(String(value)); const queryString = (params: HttpQuery): string => Object.keys(params) .map((key) => { @@ -182,7 +182,7 @@ export const throwIfRequired = (params: {[key: string]: any}, key: string, nickn if (!params || params[key] === null || params[key] === undefined) { throw new RequiredError(`Required parameter ${key} was null or undefined when calling ${nickname}.`); } -} +}; // alias for easier importing export interface RequestArgs extends AjaxRequest {} diff --git a/samples/client/petstore/typescript-rxjs/builds/with-npm-version/apis/PetApi.ts b/samples/client/petstore/typescript-rxjs/builds/with-npm-version/apis/PetApi.ts index 1d8a5f00110..a5328a8c728 100644 --- a/samples/client/petstore/typescript-rxjs/builds/with-npm-version/apis/PetApi.ts +++ b/samples/client/petstore/typescript-rxjs/builds/with-npm-version/apis/PetApi.ts @@ -82,7 +82,7 @@ export class PetApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; /** * Deletes a pet @@ -105,7 +105,7 @@ export class PetApi extends BaseAPI { method: 'DELETE', headers, }); - } + }; /** * Multiple status values can be provided with comma separated strings @@ -133,7 +133,7 @@ export class PetApi extends BaseAPI { headers, query, }); - } + }; /** * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. @@ -161,7 +161,7 @@ export class PetApi extends BaseAPI { headers, query, }); - } + }; /** * Returns a single pet @@ -179,7 +179,7 @@ export class PetApi extends BaseAPI { method: 'GET', headers, }); - } + }; /** * Update an existing pet @@ -203,7 +203,7 @@ export class PetApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; /** * Updates a pet in the store with form data @@ -235,7 +235,7 @@ export class PetApi extends BaseAPI { headers, body: formData, }); - } + }; /** * uploads an image @@ -267,7 +267,7 @@ export class PetApi extends BaseAPI { headers, body: formData, }); - } + }; } diff --git a/samples/client/petstore/typescript-rxjs/builds/with-npm-version/apis/StoreApi.ts b/samples/client/petstore/typescript-rxjs/builds/with-npm-version/apis/StoreApi.ts index b3e038e8948..623b48bdede 100644 --- a/samples/client/petstore/typescript-rxjs/builds/with-npm-version/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-rxjs/builds/with-npm-version/apis/StoreApi.ts @@ -45,7 +45,7 @@ export class StoreApi extends BaseAPI { path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(requestParameters.orderId)), method: 'DELETE', }); - } + }; /** * Returns a map of status codes to quantities @@ -61,7 +61,7 @@ export class StoreApi extends BaseAPI { method: 'GET', headers, }); - } + }; /** * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -74,7 +74,7 @@ export class StoreApi extends BaseAPI { path: '/store/order/{orderId}'.replace('{orderId}', encodeURI(requestParameters.orderId)), method: 'GET', }); - } + }; /** * Place an order for a pet @@ -92,6 +92,6 @@ export class StoreApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; } diff --git a/samples/client/petstore/typescript-rxjs/builds/with-npm-version/apis/UserApi.ts b/samples/client/petstore/typescript-rxjs/builds/with-npm-version/apis/UserApi.ts index c356d96e91c..2194fdfe9f6 100644 --- a/samples/client/petstore/typescript-rxjs/builds/with-npm-version/apis/UserApi.ts +++ b/samples/client/petstore/typescript-rxjs/builds/with-npm-version/apis/UserApi.ts @@ -69,7 +69,7 @@ export class UserApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; /** * Creates list of users with given input array @@ -87,7 +87,7 @@ export class UserApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; /** * Creates list of users with given input array @@ -105,7 +105,7 @@ export class UserApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; /** * This can only be done by the logged in user. @@ -118,7 +118,7 @@ export class UserApi extends BaseAPI { path: '/user/{username}'.replace('{username}', encodeURI(requestParameters.username)), method: 'DELETE', }); - } + }; /** * Get user by user name @@ -130,7 +130,7 @@ export class UserApi extends BaseAPI { path: '/user/{username}'.replace('{username}', encodeURI(requestParameters.username)), method: 'GET', }); - } + }; /** * Logs user into the system @@ -149,7 +149,7 @@ export class UserApi extends BaseAPI { method: 'GET', query, }); - } + }; /** * Logs out current logged in user session @@ -159,7 +159,7 @@ export class UserApi extends BaseAPI { path: '/user/logout', method: 'GET', }); - } + }; /** * This can only be done by the logged in user. @@ -179,6 +179,6 @@ export class UserApi extends BaseAPI { headers, body: requestParameters.body, }); - } + }; } diff --git a/samples/client/petstore/typescript-rxjs/builds/with-npm-version/runtime.ts b/samples/client/petstore/typescript-rxjs/builds/with-npm-version/runtime.ts index 01e3bb106fe..1bbd8633b29 100644 --- a/samples/client/petstore/typescript-rxjs/builds/with-npm-version/runtime.ts +++ b/samples/client/petstore/typescript-rxjs/builds/with-npm-version/runtime.ts @@ -76,7 +76,7 @@ export class BaseAPI { const next = this.clone(); next.middleware = next.middleware.concat(middlewares); return next; - } + }; withPreMiddleware = (preMiddlewares: Array) => this.withMiddleware(preMiddlewares.map((pre) => ({ pre }))); @@ -84,7 +84,7 @@ export class BaseAPI { withPostMiddleware = (postMiddlewares: Array) => this.withMiddleware(postMiddlewares.map((post) => ({ post }))); - protected request = (requestOpts: RequestOpts): Observable => + protected request = (requestOpts: RequestOpts): Observable => this.rxjsRequest(this.createRequestArgs(requestOpts)).pipe( map((res) => { if (res.status >= 200 && res.status < 300) { @@ -102,17 +102,17 @@ export class BaseAPI { // do not handle correctly sometimes. url += '?' + queryString(requestOpts.query); } - + return { url, method: requestOpts.method, headers: requestOpts.headers, body: requestOpts.body instanceof FormData ? requestOpts.body : JSON.stringify(requestOpts.body), - responseType: requestOpts.responseType || 'json' + responseType: requestOpts.responseType || 'json', }; } - private rxjsRequest = (params: RequestArgs): Observable => + private rxjsRequest = (params: RequestArgs): Observable => of(params).pipe( map((request) => { this.middleware.filter((item) => item.pre).forEach((mw) => (request = mw.pre!(request))); @@ -133,7 +133,7 @@ export class BaseAPI { * and then shallow cloning data members. */ private clone = (): T => - Object.assign(Object.create(Object.getPrototypeOf(this)), this) + Object.assign(Object.create(Object.getPrototypeOf(this)), this); } // export for not being a breaking change @@ -149,7 +149,7 @@ export const COLLECTION_FORMATS = { }; export type Json = any; -export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS'; +export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD'; export type HttpHeaders = { [key: string]: string }; export type HttpQuery = { [key: string]: string | number | null | boolean | Array }; export type HttpBody = Json | FormData; @@ -164,7 +164,7 @@ export interface RequestOpts { responseType?: 'json' | 'blob' | 'arraybuffer' | 'text'; } -export const encodeURI = (value: any) => encodeURIComponent(String(value)) +export const encodeURI = (value: any) => encodeURIComponent(String(value)); const queryString = (params: HttpQuery): string => Object.keys(params) .map((key) => { @@ -182,7 +182,7 @@ export const throwIfRequired = (params: {[key: string]: any}, key: string, nickn if (!params || params[key] === null || params[key] === undefined) { throw new RequiredError(`Required parameter ${key} was null or undefined when calling ${nickname}.`); } -} +}; // alias for easier importing export interface RequestArgs extends AjaxRequest {}