Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional AxiosRequestConfig parameter to typescript-nestjs service functions #20222

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { HttpService } from '@nestjs/axios';
{{^useAxiosHttpModule}}
import { HttpService, Injectable, Optional } from '@nestjs/common';
{{/useAxiosHttpModule}}
import { AxiosResponse } from 'axios';
import { AxiosRequestConfig, AxiosResponse } from 'axios';
import { Observable, from, of, switchMap } from 'rxjs';
{{#imports}}
import { {{classname}} } from '../{{filename}}';
Expand Down Expand Up @@ -93,14 +93,15 @@ export class {{classname}} {
{{/allParams}}* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
{{/useSingleRequestParameter}}
* @param {*} [options] Override http request option.
*/
{{#useSingleRequestParameter}}
public {{nickname}}({{#allParams.0}}requestParameters: {{classname}}{{operationIdCamelCase}}Request, {{/allParams.0}}): Observable<AxiosResponse<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>>;
public {{nickname}}({{#allParams.0}}requestParameters: {{classname}}{{operationIdCamelCase}}Request, {{/allParams.0}}): Observable<any> {
public {{nickname}}({{#allParams.0}}requestParameters: {{classname}}{{operationIdCamelCase}}Request, {{/allParams.0}}options?: AxiosRequestConfig): Observable<AxiosResponse<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>>;
public {{nickname}}({{#allParams.0}}requestParameters: {{classname}}{{operationIdCamelCase}}Request, {{/allParams.0}}options?: AxiosRequestConfig): Observable<any> {
{{/useSingleRequestParameter}}
{{^useSingleRequestParameter}}
public {{nickname}}({{#allParams}}{{^isConstEnumParam}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/isConstEnumParam}}{{/allParams}}): Observable<AxiosResponse<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>>;
public {{nickname}}({{#allParams}}{{^isConstEnumParam}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/isConstEnumParam}}{{/allParams}}): Observable<any> {
public {{nickname}}({{#allParams}}{{^isConstEnumParam}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/isConstEnumParam}}{{/allParams}}options?: AxiosRequestConfig): Observable<AxiosResponse<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>>;
public {{nickname}}({{#allParams}}{{^isConstEnumParam}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/isConstEnumParam}}{{/allParams}}options?: AxiosRequestConfig): Observable<any> {
{{/useSingleRequestParameter}}
{{#allParams.0}}
{{#useSingleRequestParameter}}
Expand Down Expand Up @@ -291,7 +292,8 @@ export class {{classname}} {
responseType: "blob",
{{/isResponseFile}}
withCredentials: this.configuration.withCredentials,
headers: headers
headers: {...headers, ...options?.headers},
...options,
}
);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/* tslint:disable:no-unused-variable member-ordering */

import { HttpService, Injectable, Optional } from '@nestjs/common';
import { AxiosResponse } from 'axios';
import { AxiosRequestConfig, AxiosResponse } from 'axios';
import { Observable, from, of, switchMap } from 'rxjs';
import { ApiResponse } from '../model/apiResponse';
import { Pet } from '../model/pet';
Expand Down Expand Up @@ -49,9 +49,10 @@ export class PetService {
* @param pet Pet object that needs to be added to the store
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
* @param {*} [options] Override http request option.
*/
public addPet(pet: Pet, ): Observable<AxiosResponse<Pet>>;
public addPet(pet: Pet, ): Observable<any> {
public addPet(pet: Pet, options?: AxiosRequestConfig): Observable<AxiosResponse<Pet>>;
public addPet(pet: Pet, options?: AxiosRequestConfig): Observable<any> {
if (pet === null || pet === undefined) {
throw new Error('Required parameter pet was null or undefined when calling addPet.');
}
Expand Down Expand Up @@ -96,7 +97,8 @@ export class PetService {
pet,
{
withCredentials: this.configuration.withCredentials,
headers: headers
headers: {...headers, ...options?.headers},
...options,
}
);
})
Expand All @@ -109,9 +111,10 @@ export class PetService {
* @param apiKey
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
* @param {*} [options] Override http request option.
*/
public deletePet(petId: number, apiKey?: string, ): Observable<AxiosResponse<any>>;
public deletePet(petId: number, apiKey?: string, ): Observable<any> {
public deletePet(petId: number, apiKey?: string, options?: AxiosRequestConfig): Observable<AxiosResponse<any>>;
public deletePet(petId: number, apiKey?: string, options?: AxiosRequestConfig): Observable<any> {
if (petId === null || petId === undefined) {
throw new Error('Required parameter petId was null or undefined when calling deletePet.');
}
Expand Down Expand Up @@ -150,7 +153,8 @@ export class PetService {
return this.httpClient.delete<any>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
{
withCredentials: this.configuration.withCredentials,
headers: headers
headers: {...headers, ...options?.headers},
...options,
}
);
})
Expand All @@ -162,9 +166,10 @@ export class PetService {
* @param status Status values that need to be considered for filter
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
* @param {*} [options] Override http request option.
*/
public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, ): Observable<AxiosResponse<Array<Pet>>>;
public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, ): Observable<any> {
public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: AxiosRequestConfig): Observable<AxiosResponse<Array<Pet>>>;
public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: AxiosRequestConfig): Observable<any> {
if (status === null || status === undefined) {
throw new Error('Required parameter status was null or undefined when calling findPetsByStatus.');
}
Expand Down Expand Up @@ -208,7 +213,8 @@ export class PetService {
{
params: queryParameters,
withCredentials: this.configuration.withCredentials,
headers: headers
headers: {...headers, ...options?.headers},
...options,
}
);
})
Expand All @@ -220,9 +226,10 @@ export class PetService {
* @param tags Tags to filter by
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
* @param {*} [options] Override http request option.
*/
public findPetsByTags(tags: Array<string>, ): Observable<AxiosResponse<Array<Pet>>>;
public findPetsByTags(tags: Array<string>, ): Observable<any> {
public findPetsByTags(tags: Array<string>, options?: AxiosRequestConfig): Observable<AxiosResponse<Array<Pet>>>;
public findPetsByTags(tags: Array<string>, options?: AxiosRequestConfig): Observable<any> {
if (tags === null || tags === undefined) {
throw new Error('Required parameter tags was null or undefined when calling findPetsByTags.');
}
Expand Down Expand Up @@ -266,7 +273,8 @@ export class PetService {
{
params: queryParameters,
withCredentials: this.configuration.withCredentials,
headers: headers
headers: {...headers, ...options?.headers},
...options,
}
);
})
Expand All @@ -278,9 +286,10 @@ export class PetService {
* @param petId ID of pet to return
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
* @param {*} [options] Override http request option.
*/
public getPetById(petId: number, ): Observable<AxiosResponse<Pet>>;
public getPetById(petId: number, ): Observable<any> {
public getPetById(petId: number, options?: AxiosRequestConfig): Observable<AxiosResponse<Pet>>;
public getPetById(petId: number, options?: AxiosRequestConfig): Observable<any> {
if (petId === null || petId === undefined) {
throw new Error('Required parameter petId was null or undefined when calling getPetById.');
}
Expand Down Expand Up @@ -316,7 +325,8 @@ export class PetService {
return this.httpClient.get<Pet>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
{
withCredentials: this.configuration.withCredentials,
headers: headers
headers: {...headers, ...options?.headers},
...options,
}
);
})
Expand All @@ -328,9 +338,10 @@ export class PetService {
* @param pet Pet object that needs to be added to the store
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
* @param {*} [options] Override http request option.
*/
public updatePet(pet: Pet, ): Observable<AxiosResponse<Pet>>;
public updatePet(pet: Pet, ): Observable<any> {
public updatePet(pet: Pet, options?: AxiosRequestConfig): Observable<AxiosResponse<Pet>>;
public updatePet(pet: Pet, options?: AxiosRequestConfig): Observable<any> {
if (pet === null || pet === undefined) {
throw new Error('Required parameter pet was null or undefined when calling updatePet.');
}
Expand Down Expand Up @@ -375,7 +386,8 @@ export class PetService {
pet,
{
withCredentials: this.configuration.withCredentials,
headers: headers
headers: {...headers, ...options?.headers},
...options,
}
);
})
Expand All @@ -389,9 +401,10 @@ export class PetService {
* @param status Updated status of the pet
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
* @param {*} [options] Override http request option.
*/
public updatePetWithForm(petId: number, name?: string, status?: string, ): Observable<AxiosResponse<any>>;
public updatePetWithForm(petId: number, name?: string, status?: string, ): Observable<any> {
public updatePetWithForm(petId: number, name?: string, status?: string, options?: AxiosRequestConfig): Observable<AxiosResponse<any>>;
public updatePetWithForm(petId: number, name?: string, status?: string, options?: AxiosRequestConfig): Observable<any> {
if (petId === null || petId === undefined) {
throw new Error('Required parameter petId was null or undefined when calling updatePetWithForm.');
}
Expand Down Expand Up @@ -449,7 +462,8 @@ export class PetService {
convertFormParamsToString ? formParams!.toString() : formParams!,
{
withCredentials: this.configuration.withCredentials,
headers: headers
headers: {...headers, ...options?.headers},
...options,
}
);
})
Expand All @@ -463,9 +477,10 @@ export class PetService {
* @param file file to upload
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
* @param {*} [options] Override http request option.
*/
public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, ): Observable<AxiosResponse<ApiResponse>>;
public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, ): Observable<any> {
public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, options?: AxiosRequestConfig): Observable<AxiosResponse<ApiResponse>>;
public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, options?: AxiosRequestConfig): Observable<any> {
if (petId === null || petId === undefined) {
throw new Error('Required parameter petId was null or undefined when calling uploadFile.');
}
Expand Down Expand Up @@ -528,7 +543,8 @@ export class PetService {
convertFormParamsToString ? formParams!.toString() : formParams!,
{
withCredentials: this.configuration.withCredentials,
headers: headers
headers: {...headers, ...options?.headers},
...options,
}
);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/* tslint:disable:no-unused-variable member-ordering */

import { HttpService, Injectable, Optional } from '@nestjs/common';
import { AxiosResponse } from 'axios';
import { AxiosRequestConfig, AxiosResponse } from 'axios';
import { Observable, from, of, switchMap } from 'rxjs';
import { Order } from '../model/order';
import { Configuration } from '../configuration';
Expand Down Expand Up @@ -48,9 +48,10 @@ export class StoreService {
* @param orderId ID of the order that needs to be deleted
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
* @param {*} [options] Override http request option.
*/
public deleteOrder(orderId: string, ): Observable<AxiosResponse<any>>;
public deleteOrder(orderId: string, ): Observable<any> {
public deleteOrder(orderId: string, options?: AxiosRequestConfig): Observable<AxiosResponse<any>>;
public deleteOrder(orderId: string, options?: AxiosRequestConfig): Observable<any> {
if (orderId === null || orderId === undefined) {
throw new Error('Required parameter orderId was null or undefined when calling deleteOrder.');
}
Expand Down Expand Up @@ -79,7 +80,8 @@ export class StoreService {
return this.httpClient.delete<any>(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`,
{
withCredentials: this.configuration.withCredentials,
headers: headers
headers: {...headers, ...options?.headers},
...options,
}
);
})
Expand All @@ -90,9 +92,10 @@ export class StoreService {
* Returns a map of status codes to quantities
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
* @param {*} [options] Override http request option.
*/
public getInventory(): Observable<AxiosResponse<{ [key: string]: number; }>>;
public getInventory(): Observable<any> {
public getInventory(options?: AxiosRequestConfig): Observable<AxiosResponse<{ [key: string]: number; }>>;
public getInventory(options?: AxiosRequestConfig): Observable<any> {
let headers = {...this.defaultHeaders};

let accessTokenObservable: Observable<any> = of(null);
Expand Down Expand Up @@ -123,7 +126,8 @@ export class StoreService {
return this.httpClient.get<{ [key: string]: number; }>(`${this.basePath}/store/inventory`,
{
withCredentials: this.configuration.withCredentials,
headers: headers
headers: {...headers, ...options?.headers},
...options,
}
);
})
Expand All @@ -135,9 +139,10 @@ export class StoreService {
* @param orderId ID of pet that needs to be fetched
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
* @param {*} [options] Override http request option.
*/
public getOrderById(orderId: number, ): Observable<AxiosResponse<Order>>;
public getOrderById(orderId: number, ): Observable<any> {
public getOrderById(orderId: number, options?: AxiosRequestConfig): Observable<AxiosResponse<Order>>;
public getOrderById(orderId: number, options?: AxiosRequestConfig): Observable<any> {
if (orderId === null || orderId === undefined) {
throw new Error('Required parameter orderId was null or undefined when calling getOrderById.');
}
Expand Down Expand Up @@ -168,7 +173,8 @@ export class StoreService {
return this.httpClient.get<Order>(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`,
{
withCredentials: this.configuration.withCredentials,
headers: headers
headers: {...headers, ...options?.headers},
...options,
}
);
})
Expand All @@ -180,9 +186,10 @@ export class StoreService {
* @param order order placed for purchasing the pet
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
* @param {*} [options] Override http request option.
*/
public placeOrder(order: Order, ): Observable<AxiosResponse<Order>>;
public placeOrder(order: Order, ): Observable<any> {
public placeOrder(order: Order, options?: AxiosRequestConfig): Observable<AxiosResponse<Order>>;
public placeOrder(order: Order, options?: AxiosRequestConfig): Observable<any> {
if (order === null || order === undefined) {
throw new Error('Required parameter order was null or undefined when calling placeOrder.');
}
Expand Down Expand Up @@ -219,7 +226,8 @@ export class StoreService {
order,
{
withCredentials: this.configuration.withCredentials,
headers: headers
headers: {...headers, ...options?.headers},
...options,
}
);
})
Expand Down
Loading
Loading