mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-03 14:10:56 +00:00
[typescript-nestjs] Accept async function for fetching access token (#18190)
* feat: starts accepting async function for fetching access token in typescript-nestjs * fix: adds Provider in the import to fix build error * chore: deletes package lock * chore: deletes package lock for v6 * fix: switches to switchMap for map
This commit is contained in:
parent
406d00fe9b
commit
c64d569a7d
@ -3,7 +3,7 @@ import { DynamicModule, Module, Global, Provider } from '@nestjs/common';
|
||||
import { HttpModule, HttpService } from '@nestjs/axios';
|
||||
{{/useAxiosHttpModule}}
|
||||
{{^useAxiosHttpModule}}
|
||||
import { DynamicModule, HttpService, HttpModule, Module, Global } from '@nestjs/common';
|
||||
import { DynamicModule, HttpService, HttpModule, Module, Global, Provider } from '@nestjs/common';
|
||||
{{/useAxiosHttpModule}}
|
||||
import { AsyncConfiguration, Configuration, ConfigurationFactory } from './configuration';
|
||||
|
||||
|
@ -9,11 +9,12 @@ import { HttpService } from '@nestjs/axios';
|
||||
import { HttpService, Inject, Injectable, Optional } from '@nestjs/common';
|
||||
{{/useAxiosHttpModule}}
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, from, of, switchMap } from 'rxjs';
|
||||
{{#imports}}
|
||||
import { {{classname}} } from '../{{filename}}';
|
||||
{{/imports}}
|
||||
import { Configuration } from '../configuration';
|
||||
import { COLLECTION_FORMATS } from '../variables';
|
||||
{{#withInterfaces}}
|
||||
import { {{classname}}Interface } from './{{classFilename}}Interface';
|
||||
{{/withInterfaces}}
|
||||
@ -117,6 +118,8 @@ export class {{classname}} {
|
||||
{{/isArray}}
|
||||
{{/headerParams}}
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
{{#authMethods}}
|
||||
// authentication ({{name}}) required
|
||||
{{#isApiKey}}
|
||||
@ -144,17 +147,16 @@ export class {{classname}} {
|
||||
{{/isBasicBasic}}
|
||||
{{#isBasicBearer}}
|
||||
if (typeof this.configuration.accessToken === 'function') {
|
||||
headers['Authorization'] = `Bearer ${this.configuration.accessToken()}`;
|
||||
accessTokenObservable = from(Promise.resolve(this.configuration.accessToken()));
|
||||
} else if (this.configuration.accessToken) {
|
||||
headers['Authorization'] = `Bearer ${this.configuration.accessToken}`;
|
||||
accessTokenObservable = from(Promise.resolve(this.configuration.accessToken));
|
||||
}
|
||||
{{/isBasicBearer}}
|
||||
{{#isOAuth}}
|
||||
if (this.configuration.accessToken) {
|
||||
const accessToken = typeof this.configuration.accessToken === 'function'
|
||||
? this.configuration.accessToken()
|
||||
: this.configuration.accessToken;
|
||||
headers['Authorization'] = 'Bearer ' + accessToken;
|
||||
accessTokenObservable = typeof this.configuration.accessToken === 'function'
|
||||
? from(Promise.resolve(this.configuration.accessToken()))
|
||||
: from(Promise.resolve(this.configuration.accessToken))
|
||||
}
|
||||
|
||||
{{/isOAuth}}
|
||||
@ -224,6 +226,12 @@ export class {{classname}} {
|
||||
{{/formParams}}
|
||||
|
||||
{{/hasFormParams}}
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.{{httpMethod}}{{^isResponseFile}}<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>{{/isResponseFile}}(`${this.basePath}{{{path}}}`,{{#isBodyAllowed}}
|
||||
{{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}{{#hasFormParams}}convertFormParamsToString ? formParams!.toString() : formParams!{{/hasFormParams}}{{^hasFormParams}}null{{/hasFormParams}}{{/bodyParam}},{{/isBodyAllowed}}
|
||||
{
|
||||
@ -237,6 +245,8 @@ export class {{classname}} {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
{{/operation}}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { DynamicModule, HttpService, HttpModule, Module, Global } from '@nestjs/common';
|
||||
import { DynamicModule, HttpService, HttpModule, Module, Global, Provider } from '@nestjs/common';
|
||||
import { AsyncConfiguration, Configuration, ConfigurationFactory } from './configuration';
|
||||
|
||||
import { PetService } from './api/pet.service';
|
||||
|
@ -13,10 +13,11 @@
|
||||
|
||||
import { HttpService, Inject, Injectable, Optional } from '@nestjs/common';
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, from, of, switchMap } from 'rxjs';
|
||||
import { ApiResponse } from '../model/apiResponse';
|
||||
import { Pet } from '../model/pet';
|
||||
import { Configuration } from '../configuration';
|
||||
import { COLLECTION_FORMATS } from '../variables';
|
||||
|
||||
|
||||
@Injectable()
|
||||
@ -56,12 +57,13 @@ export class PetService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (petstore_auth) required
|
||||
if (this.configuration.accessToken) {
|
||||
const accessToken = typeof this.configuration.accessToken === 'function'
|
||||
? this.configuration.accessToken()
|
||||
: this.configuration.accessToken;
|
||||
headers['Authorization'] = 'Bearer ' + accessToken;
|
||||
accessTokenObservable = typeof this.configuration.accessToken === 'function'
|
||||
? from(Promise.resolve(this.configuration.accessToken()))
|
||||
: from(Promise.resolve(this.configuration.accessToken))
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
@ -83,6 +85,12 @@ export class PetService {
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers['Content-Type'] = httpContentTypeSelected;
|
||||
}
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.post<Pet>(`${this.basePath}/pet`,
|
||||
pet,
|
||||
{
|
||||
@ -90,6 +98,8 @@ export class PetService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Deletes a pet
|
||||
@ -112,12 +122,13 @@ export class PetService {
|
||||
headers['api_key'] = String(apiKey);
|
||||
}
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (petstore_auth) required
|
||||
if (this.configuration.accessToken) {
|
||||
const accessToken = typeof this.configuration.accessToken === 'function'
|
||||
? this.configuration.accessToken()
|
||||
: this.configuration.accessToken;
|
||||
headers['Authorization'] = 'Bearer ' + accessToken;
|
||||
accessTokenObservable = typeof this.configuration.accessToken === 'function'
|
||||
? from(Promise.resolve(this.configuration.accessToken()))
|
||||
: from(Promise.resolve(this.configuration.accessToken))
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
@ -131,12 +142,20 @@ export class PetService {
|
||||
// to determine the Content-Type header
|
||||
const consumes: string[] = [
|
||||
];
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.delete<any>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
|
||||
{
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Finds Pets by status
|
||||
@ -159,12 +178,13 @@ export class PetService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (petstore_auth) required
|
||||
if (this.configuration.accessToken) {
|
||||
const accessToken = typeof this.configuration.accessToken === 'function'
|
||||
? this.configuration.accessToken()
|
||||
: this.configuration.accessToken;
|
||||
headers['Authorization'] = 'Bearer ' + accessToken;
|
||||
accessTokenObservable = typeof this.configuration.accessToken === 'function'
|
||||
? from(Promise.resolve(this.configuration.accessToken()))
|
||||
: from(Promise.resolve(this.configuration.accessToken))
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
@ -180,6 +200,12 @@ export class PetService {
|
||||
// to determine the Content-Type header
|
||||
const consumes: string[] = [
|
||||
];
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.get<Array<Pet>>(`${this.basePath}/pet/findByStatus`,
|
||||
{
|
||||
params: queryParameters,
|
||||
@ -187,6 +213,8 @@ export class PetService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Finds Pets by tags
|
||||
@ -209,12 +237,13 @@ export class PetService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (petstore_auth) required
|
||||
if (this.configuration.accessToken) {
|
||||
const accessToken = typeof this.configuration.accessToken === 'function'
|
||||
? this.configuration.accessToken()
|
||||
: this.configuration.accessToken;
|
||||
headers['Authorization'] = 'Bearer ' + accessToken;
|
||||
accessTokenObservable = typeof this.configuration.accessToken === 'function'
|
||||
? from(Promise.resolve(this.configuration.accessToken()))
|
||||
: from(Promise.resolve(this.configuration.accessToken))
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
@ -230,6 +259,12 @@ export class PetService {
|
||||
// to determine the Content-Type header
|
||||
const consumes: string[] = [
|
||||
];
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.get<Array<Pet>>(`${this.basePath}/pet/findByTags`,
|
||||
{
|
||||
params: queryParameters,
|
||||
@ -237,6 +272,8 @@ export class PetService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Find pet by ID
|
||||
@ -254,6 +291,8 @@ export class PetService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (api_key) required
|
||||
if (this.configuration.apiKeys?.["api_key"]) {
|
||||
headers['api_key'] = this.configuration.apiKeys["api_key"];
|
||||
@ -272,12 +311,20 @@ export class PetService {
|
||||
// to determine the Content-Type header
|
||||
const consumes: string[] = [
|
||||
];
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.get<Pet>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
|
||||
{
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Update an existing pet
|
||||
@ -295,12 +342,13 @@ export class PetService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (petstore_auth) required
|
||||
if (this.configuration.accessToken) {
|
||||
const accessToken = typeof this.configuration.accessToken === 'function'
|
||||
? this.configuration.accessToken()
|
||||
: this.configuration.accessToken;
|
||||
headers['Authorization'] = 'Bearer ' + accessToken;
|
||||
accessTokenObservable = typeof this.configuration.accessToken === 'function'
|
||||
? from(Promise.resolve(this.configuration.accessToken()))
|
||||
: from(Promise.resolve(this.configuration.accessToken))
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
@ -322,6 +370,12 @@ export class PetService {
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers['Content-Type'] = httpContentTypeSelected;
|
||||
}
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.put<Pet>(`${this.basePath}/pet`,
|
||||
pet,
|
||||
{
|
||||
@ -329,6 +383,8 @@ export class PetService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Updates a pet in the store with form data
|
||||
@ -350,12 +406,13 @@ export class PetService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (petstore_auth) required
|
||||
if (this.configuration.accessToken) {
|
||||
const accessToken = typeof this.configuration.accessToken === 'function'
|
||||
? this.configuration.accessToken()
|
||||
: this.configuration.accessToken;
|
||||
headers['Authorization'] = 'Bearer ' + accessToken;
|
||||
accessTokenObservable = typeof this.configuration.accessToken === 'function'
|
||||
? from(Promise.resolve(this.configuration.accessToken()))
|
||||
: from(Promise.resolve(this.configuration.accessToken))
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
@ -390,6 +447,12 @@ export class PetService {
|
||||
formParams!.append('status', <any>status);
|
||||
}
|
||||
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.post<any>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
|
||||
convertFormParamsToString ? formParams!.toString() : formParams!,
|
||||
{
|
||||
@ -397,6 +460,8 @@ export class PetService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* uploads an image
|
||||
@ -418,12 +483,13 @@ export class PetService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (petstore_auth) required
|
||||
if (this.configuration.accessToken) {
|
||||
const accessToken = typeof this.configuration.accessToken === 'function'
|
||||
? this.configuration.accessToken()
|
||||
: this.configuration.accessToken;
|
||||
headers['Authorization'] = 'Bearer ' + accessToken;
|
||||
accessTokenObservable = typeof this.configuration.accessToken === 'function'
|
||||
? from(Promise.resolve(this.configuration.accessToken()))
|
||||
: from(Promise.resolve(this.configuration.accessToken))
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
@ -463,6 +529,12 @@ export class PetService {
|
||||
formParams!.append('file', <any>file);
|
||||
}
|
||||
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.post<ApiResponse>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,
|
||||
convertFormParamsToString ? formParams!.toString() : formParams!,
|
||||
{
|
||||
@ -470,5 +542,7 @@ export class PetService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -13,9 +13,10 @@
|
||||
|
||||
import { HttpService, Inject, Injectable, Optional } from '@nestjs/common';
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, from, of, switchMap } from 'rxjs';
|
||||
import { Order } from '../model/order';
|
||||
import { Configuration } from '../configuration';
|
||||
import { COLLECTION_FORMATS } from '../variables';
|
||||
|
||||
|
||||
@Injectable()
|
||||
@ -55,6 +56,8 @@ export class StoreService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
];
|
||||
@ -66,12 +69,20 @@ export class StoreService {
|
||||
// to determine the Content-Type header
|
||||
const consumes: string[] = [
|
||||
];
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.delete<any>(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`,
|
||||
{
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
@ -84,6 +95,8 @@ export class StoreService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (api_key) required
|
||||
if (this.configuration.apiKeys?.["api_key"]) {
|
||||
headers['api_key'] = this.configuration.apiKeys["api_key"];
|
||||
@ -101,12 +114,20 @@ export class StoreService {
|
||||
// to determine the Content-Type header
|
||||
const consumes: string[] = [
|
||||
];
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.get<{ [key: string]: number; }>(`${this.basePath}/store/inventory`,
|
||||
{
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Find purchase order by ID
|
||||
@ -124,6 +145,8 @@ export class StoreService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
@ -137,12 +160,20 @@ export class StoreService {
|
||||
// to determine the Content-Type header
|
||||
const consumes: string[] = [
|
||||
];
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.get<Order>(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`,
|
||||
{
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Place an order for a pet
|
||||
@ -160,6 +191,8 @@ export class StoreService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
@ -178,6 +211,12 @@ export class StoreService {
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers['Content-Type'] = httpContentTypeSelected;
|
||||
}
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.post<Order>(`${this.basePath}/store/order`,
|
||||
order,
|
||||
{
|
||||
@ -185,5 +224,7 @@ export class StoreService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -13,9 +13,10 @@
|
||||
|
||||
import { HttpService, Inject, Injectable, Optional } from '@nestjs/common';
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, from, of, switchMap } from 'rxjs';
|
||||
import { User } from '../model/user';
|
||||
import { Configuration } from '../configuration';
|
||||
import { COLLECTION_FORMATS } from '../variables';
|
||||
|
||||
|
||||
@Injectable()
|
||||
@ -55,6 +56,8 @@ export class UserService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (api_key) required
|
||||
if (this.configuration.apiKeys?.["api_key"]) {
|
||||
headers['api_key'] = this.configuration.apiKeys["api_key"];
|
||||
@ -76,6 +79,12 @@ export class UserService {
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers['Content-Type'] = httpContentTypeSelected;
|
||||
}
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.post<any>(`${this.basePath}/user`,
|
||||
user,
|
||||
{
|
||||
@ -83,6 +92,8 @@ export class UserService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
@ -100,6 +111,8 @@ export class UserService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (api_key) required
|
||||
if (this.configuration.apiKeys?.["api_key"]) {
|
||||
headers['api_key'] = this.configuration.apiKeys["api_key"];
|
||||
@ -121,6 +134,12 @@ export class UserService {
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers['Content-Type'] = httpContentTypeSelected;
|
||||
}
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.post<any>(`${this.basePath}/user/createWithArray`,
|
||||
user,
|
||||
{
|
||||
@ -128,6 +147,8 @@ export class UserService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
@ -145,6 +166,8 @@ export class UserService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (api_key) required
|
||||
if (this.configuration.apiKeys?.["api_key"]) {
|
||||
headers['api_key'] = this.configuration.apiKeys["api_key"];
|
||||
@ -166,6 +189,12 @@ export class UserService {
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers['Content-Type'] = httpContentTypeSelected;
|
||||
}
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.post<any>(`${this.basePath}/user/createWithList`,
|
||||
user,
|
||||
{
|
||||
@ -173,6 +202,8 @@ export class UserService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Delete user
|
||||
@ -190,6 +221,8 @@ export class UserService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (api_key) required
|
||||
if (this.configuration.apiKeys?.["api_key"]) {
|
||||
headers['api_key'] = this.configuration.apiKeys["api_key"];
|
||||
@ -206,12 +239,20 @@ export class UserService {
|
||||
// to determine the Content-Type header
|
||||
const consumes: string[] = [
|
||||
];
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.delete<any>(`${this.basePath}/user/${encodeURIComponent(String(username))}`,
|
||||
{
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Get user by user name
|
||||
@ -229,6 +270,8 @@ export class UserService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
@ -242,12 +285,20 @@ export class UserService {
|
||||
// to determine the Content-Type header
|
||||
const consumes: string[] = [
|
||||
];
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.get<User>(`${this.basePath}/user/${encodeURIComponent(String(username))}`,
|
||||
{
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Logs user into the system
|
||||
@ -278,6 +329,8 @@ export class UserService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
@ -291,6 +344,12 @@ export class UserService {
|
||||
// to determine the Content-Type header
|
||||
const consumes: string[] = [
|
||||
];
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.get<string>(`${this.basePath}/user/login`,
|
||||
{
|
||||
params: queryParameters,
|
||||
@ -298,6 +357,8 @@ export class UserService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
@ -310,6 +371,8 @@ export class UserService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (api_key) required
|
||||
if (this.configuration.apiKeys?.["api_key"]) {
|
||||
headers['api_key'] = this.configuration.apiKeys["api_key"];
|
||||
@ -326,12 +389,20 @@ export class UserService {
|
||||
// to determine the Content-Type header
|
||||
const consumes: string[] = [
|
||||
];
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.get<any>(`${this.basePath}/user/logout`,
|
||||
{
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Updated user
|
||||
@ -354,6 +425,8 @@ export class UserService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (api_key) required
|
||||
if (this.configuration.apiKeys?.["api_key"]) {
|
||||
headers['api_key'] = this.configuration.apiKeys["api_key"];
|
||||
@ -375,6 +448,12 @@ export class UserService {
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers['Content-Type'] = httpContentTypeSelected;
|
||||
}
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.put<any>(`${this.basePath}/user/${encodeURIComponent(String(username))}`,
|
||||
user,
|
||||
{
|
||||
@ -382,5 +461,7 @@ export class UserService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -14,10 +14,11 @@
|
||||
import { Inject, Injectable, Optional } from '@nestjs/common';
|
||||
import { HttpService } from '@nestjs/axios';
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, from, of, switchMap } from 'rxjs';
|
||||
import { ApiResponse } from '../model/apiResponse';
|
||||
import { Pet } from '../model/pet';
|
||||
import { Configuration } from '../configuration';
|
||||
import { COLLECTION_FORMATS } from '../variables';
|
||||
|
||||
|
||||
@Injectable()
|
||||
@ -57,12 +58,13 @@ export class PetService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (petstore_auth) required
|
||||
if (this.configuration.accessToken) {
|
||||
const accessToken = typeof this.configuration.accessToken === 'function'
|
||||
? this.configuration.accessToken()
|
||||
: this.configuration.accessToken;
|
||||
headers['Authorization'] = 'Bearer ' + accessToken;
|
||||
accessTokenObservable = typeof this.configuration.accessToken === 'function'
|
||||
? from(Promise.resolve(this.configuration.accessToken()))
|
||||
: from(Promise.resolve(this.configuration.accessToken))
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
@ -84,6 +86,12 @@ export class PetService {
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers['Content-Type'] = httpContentTypeSelected;
|
||||
}
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.post<Pet>(`${this.basePath}/pet`,
|
||||
pet,
|
||||
{
|
||||
@ -91,6 +99,8 @@ export class PetService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Deletes a pet
|
||||
@ -113,12 +123,13 @@ export class PetService {
|
||||
headers['api_key'] = String(apiKey);
|
||||
}
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (petstore_auth) required
|
||||
if (this.configuration.accessToken) {
|
||||
const accessToken = typeof this.configuration.accessToken === 'function'
|
||||
? this.configuration.accessToken()
|
||||
: this.configuration.accessToken;
|
||||
headers['Authorization'] = 'Bearer ' + accessToken;
|
||||
accessTokenObservable = typeof this.configuration.accessToken === 'function'
|
||||
? from(Promise.resolve(this.configuration.accessToken()))
|
||||
: from(Promise.resolve(this.configuration.accessToken))
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
@ -132,12 +143,20 @@ export class PetService {
|
||||
// to determine the Content-Type header
|
||||
const consumes: string[] = [
|
||||
];
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.delete<any>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
|
||||
{
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Finds Pets by status
|
||||
@ -160,12 +179,13 @@ export class PetService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (petstore_auth) required
|
||||
if (this.configuration.accessToken) {
|
||||
const accessToken = typeof this.configuration.accessToken === 'function'
|
||||
? this.configuration.accessToken()
|
||||
: this.configuration.accessToken;
|
||||
headers['Authorization'] = 'Bearer ' + accessToken;
|
||||
accessTokenObservable = typeof this.configuration.accessToken === 'function'
|
||||
? from(Promise.resolve(this.configuration.accessToken()))
|
||||
: from(Promise.resolve(this.configuration.accessToken))
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
@ -181,6 +201,12 @@ export class PetService {
|
||||
// to determine the Content-Type header
|
||||
const consumes: string[] = [
|
||||
];
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.get<Array<Pet>>(`${this.basePath}/pet/findByStatus`,
|
||||
{
|
||||
params: queryParameters,
|
||||
@ -188,6 +214,8 @@ export class PetService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Finds Pets by tags
|
||||
@ -210,12 +238,13 @@ export class PetService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (petstore_auth) required
|
||||
if (this.configuration.accessToken) {
|
||||
const accessToken = typeof this.configuration.accessToken === 'function'
|
||||
? this.configuration.accessToken()
|
||||
: this.configuration.accessToken;
|
||||
headers['Authorization'] = 'Bearer ' + accessToken;
|
||||
accessTokenObservable = typeof this.configuration.accessToken === 'function'
|
||||
? from(Promise.resolve(this.configuration.accessToken()))
|
||||
: from(Promise.resolve(this.configuration.accessToken))
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
@ -231,6 +260,12 @@ export class PetService {
|
||||
// to determine the Content-Type header
|
||||
const consumes: string[] = [
|
||||
];
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.get<Array<Pet>>(`${this.basePath}/pet/findByTags`,
|
||||
{
|
||||
params: queryParameters,
|
||||
@ -238,6 +273,8 @@ export class PetService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Find pet by ID
|
||||
@ -255,6 +292,8 @@ export class PetService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (api_key) required
|
||||
if (this.configuration.apiKeys?.["api_key"]) {
|
||||
headers['api_key'] = this.configuration.apiKeys["api_key"];
|
||||
@ -273,12 +312,20 @@ export class PetService {
|
||||
// to determine the Content-Type header
|
||||
const consumes: string[] = [
|
||||
];
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.get<Pet>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
|
||||
{
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Update an existing pet
|
||||
@ -296,12 +343,13 @@ export class PetService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (petstore_auth) required
|
||||
if (this.configuration.accessToken) {
|
||||
const accessToken = typeof this.configuration.accessToken === 'function'
|
||||
? this.configuration.accessToken()
|
||||
: this.configuration.accessToken;
|
||||
headers['Authorization'] = 'Bearer ' + accessToken;
|
||||
accessTokenObservable = typeof this.configuration.accessToken === 'function'
|
||||
? from(Promise.resolve(this.configuration.accessToken()))
|
||||
: from(Promise.resolve(this.configuration.accessToken))
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
@ -323,6 +371,12 @@ export class PetService {
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers['Content-Type'] = httpContentTypeSelected;
|
||||
}
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.put<Pet>(`${this.basePath}/pet`,
|
||||
pet,
|
||||
{
|
||||
@ -330,6 +384,8 @@ export class PetService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Updates a pet in the store with form data
|
||||
@ -351,12 +407,13 @@ export class PetService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (petstore_auth) required
|
||||
if (this.configuration.accessToken) {
|
||||
const accessToken = typeof this.configuration.accessToken === 'function'
|
||||
? this.configuration.accessToken()
|
||||
: this.configuration.accessToken;
|
||||
headers['Authorization'] = 'Bearer ' + accessToken;
|
||||
accessTokenObservable = typeof this.configuration.accessToken === 'function'
|
||||
? from(Promise.resolve(this.configuration.accessToken()))
|
||||
: from(Promise.resolve(this.configuration.accessToken))
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
@ -391,6 +448,12 @@ export class PetService {
|
||||
formParams!.append('status', <any>status);
|
||||
}
|
||||
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.post<any>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
|
||||
convertFormParamsToString ? formParams!.toString() : formParams!,
|
||||
{
|
||||
@ -398,6 +461,8 @@ export class PetService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* uploads an image
|
||||
@ -419,12 +484,13 @@ export class PetService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (petstore_auth) required
|
||||
if (this.configuration.accessToken) {
|
||||
const accessToken = typeof this.configuration.accessToken === 'function'
|
||||
? this.configuration.accessToken()
|
||||
: this.configuration.accessToken;
|
||||
headers['Authorization'] = 'Bearer ' + accessToken;
|
||||
accessTokenObservable = typeof this.configuration.accessToken === 'function'
|
||||
? from(Promise.resolve(this.configuration.accessToken()))
|
||||
: from(Promise.resolve(this.configuration.accessToken))
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
@ -464,6 +530,12 @@ export class PetService {
|
||||
formParams!.append('file', <any>file);
|
||||
}
|
||||
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.post<ApiResponse>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,
|
||||
convertFormParamsToString ? formParams!.toString() : formParams!,
|
||||
{
|
||||
@ -471,5 +543,7 @@ export class PetService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -14,9 +14,10 @@
|
||||
import { Inject, Injectable, Optional } from '@nestjs/common';
|
||||
import { HttpService } from '@nestjs/axios';
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, from, of, switchMap } from 'rxjs';
|
||||
import { Order } from '../model/order';
|
||||
import { Configuration } from '../configuration';
|
||||
import { COLLECTION_FORMATS } from '../variables';
|
||||
|
||||
|
||||
@Injectable()
|
||||
@ -56,6 +57,8 @@ export class StoreService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
];
|
||||
@ -67,12 +70,20 @@ export class StoreService {
|
||||
// to determine the Content-Type header
|
||||
const consumes: string[] = [
|
||||
];
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.delete<any>(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`,
|
||||
{
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
@ -85,6 +96,8 @@ export class StoreService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (api_key) required
|
||||
if (this.configuration.apiKeys?.["api_key"]) {
|
||||
headers['api_key'] = this.configuration.apiKeys["api_key"];
|
||||
@ -102,12 +115,20 @@ export class StoreService {
|
||||
// to determine the Content-Type header
|
||||
const consumes: string[] = [
|
||||
];
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.get<{ [key: string]: number; }>(`${this.basePath}/store/inventory`,
|
||||
{
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Find purchase order by ID
|
||||
@ -125,6 +146,8 @@ export class StoreService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
@ -138,12 +161,20 @@ export class StoreService {
|
||||
// to determine the Content-Type header
|
||||
const consumes: string[] = [
|
||||
];
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.get<Order>(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`,
|
||||
{
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Place an order for a pet
|
||||
@ -161,6 +192,8 @@ export class StoreService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
@ -179,6 +212,12 @@ export class StoreService {
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers['Content-Type'] = httpContentTypeSelected;
|
||||
}
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.post<Order>(`${this.basePath}/store/order`,
|
||||
order,
|
||||
{
|
||||
@ -186,5 +225,7 @@ export class StoreService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -14,9 +14,10 @@
|
||||
import { Inject, Injectable, Optional } from '@nestjs/common';
|
||||
import { HttpService } from '@nestjs/axios';
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, from, of, switchMap } from 'rxjs';
|
||||
import { User } from '../model/user';
|
||||
import { Configuration } from '../configuration';
|
||||
import { COLLECTION_FORMATS } from '../variables';
|
||||
|
||||
|
||||
@Injectable()
|
||||
@ -56,6 +57,8 @@ export class UserService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (api_key) required
|
||||
if (this.configuration.apiKeys?.["api_key"]) {
|
||||
headers['api_key'] = this.configuration.apiKeys["api_key"];
|
||||
@ -77,6 +80,12 @@ export class UserService {
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers['Content-Type'] = httpContentTypeSelected;
|
||||
}
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.post<any>(`${this.basePath}/user`,
|
||||
user,
|
||||
{
|
||||
@ -84,6 +93,8 @@ export class UserService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
@ -101,6 +112,8 @@ export class UserService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (api_key) required
|
||||
if (this.configuration.apiKeys?.["api_key"]) {
|
||||
headers['api_key'] = this.configuration.apiKeys["api_key"];
|
||||
@ -122,6 +135,12 @@ export class UserService {
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers['Content-Type'] = httpContentTypeSelected;
|
||||
}
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.post<any>(`${this.basePath}/user/createWithArray`,
|
||||
user,
|
||||
{
|
||||
@ -129,6 +148,8 @@ export class UserService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
@ -146,6 +167,8 @@ export class UserService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (api_key) required
|
||||
if (this.configuration.apiKeys?.["api_key"]) {
|
||||
headers['api_key'] = this.configuration.apiKeys["api_key"];
|
||||
@ -167,6 +190,12 @@ export class UserService {
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers['Content-Type'] = httpContentTypeSelected;
|
||||
}
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.post<any>(`${this.basePath}/user/createWithList`,
|
||||
user,
|
||||
{
|
||||
@ -174,6 +203,8 @@ export class UserService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Delete user
|
||||
@ -191,6 +222,8 @@ export class UserService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (api_key) required
|
||||
if (this.configuration.apiKeys?.["api_key"]) {
|
||||
headers['api_key'] = this.configuration.apiKeys["api_key"];
|
||||
@ -207,12 +240,20 @@ export class UserService {
|
||||
// to determine the Content-Type header
|
||||
const consumes: string[] = [
|
||||
];
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.delete<any>(`${this.basePath}/user/${encodeURIComponent(String(username))}`,
|
||||
{
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Get user by user name
|
||||
@ -230,6 +271,8 @@ export class UserService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
@ -243,12 +286,20 @@ export class UserService {
|
||||
// to determine the Content-Type header
|
||||
const consumes: string[] = [
|
||||
];
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.get<User>(`${this.basePath}/user/${encodeURIComponent(String(username))}`,
|
||||
{
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Logs user into the system
|
||||
@ -279,6 +330,8 @@ export class UserService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/xml',
|
||||
@ -292,6 +345,12 @@ export class UserService {
|
||||
// to determine the Content-Type header
|
||||
const consumes: string[] = [
|
||||
];
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.get<string>(`${this.basePath}/user/login`,
|
||||
{
|
||||
params: queryParameters,
|
||||
@ -299,6 +358,8 @@ export class UserService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
@ -311,6 +372,8 @@ export class UserService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (api_key) required
|
||||
if (this.configuration.apiKeys?.["api_key"]) {
|
||||
headers['api_key'] = this.configuration.apiKeys["api_key"];
|
||||
@ -327,12 +390,20 @@ export class UserService {
|
||||
// to determine the Content-Type header
|
||||
const consumes: string[] = [
|
||||
];
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.get<any>(`${this.basePath}/user/logout`,
|
||||
{
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Updated user
|
||||
@ -355,6 +426,8 @@ export class UserService {
|
||||
|
||||
let headers = {...this.defaultHeaders};
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
// authentication (api_key) required
|
||||
if (this.configuration.apiKeys?.["api_key"]) {
|
||||
headers['api_key'] = this.configuration.apiKeys["api_key"];
|
||||
@ -376,6 +449,12 @@ export class UserService {
|
||||
if (httpContentTypeSelected != undefined) {
|
||||
headers['Content-Type'] = httpContentTypeSelected;
|
||||
}
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.put<any>(`${this.basePath}/user/${encodeURIComponent(String(username))}`,
|
||||
user,
|
||||
{
|
||||
@ -383,5 +462,7 @@ export class UserService {
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user