mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 12:40:53 +00:00
Add httpClient config to typescript-nestjs generator (#19876)
* feat: add httpClient to config * chore: generate samples and doc * refactor: change import to type * chore: generate samples and doc
This commit is contained in:
parent
ca032113f2
commit
0a39a1760e
@ -62,10 +62,12 @@ export class {{classname}} {
|
||||
protected basePath = '{{{basePath}}}';
|
||||
public defaultHeaders: Record<string,string> = {};
|
||||
public configuration = new Configuration();
|
||||
protected httpClient: HttpService;
|
||||
|
||||
constructor(protected httpClient: HttpService, @Optional() configuration: Configuration) {
|
||||
constructor(httpClient: HttpService, @Optional() configuration: Configuration) {
|
||||
this.configuration = configuration || this.configuration;
|
||||
this.basePath = configuration?.basePath || this.basePath;
|
||||
this.httpClient = configuration?.httpClient || httpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,3 +1,4 @@
|
||||
import type { HttpService } from '@nestjs/axios';
|
||||
import { ModuleMetadata, Type } from '@nestjs/common/interfaces';
|
||||
|
||||
export interface ConfigurationParameters {
|
||||
@ -7,6 +8,7 @@ export interface ConfigurationParameters {
|
||||
accessToken?: string | Promise<string> | (() => string | Promise<string>);
|
||||
basePath?: string;
|
||||
withCredentials?: boolean;
|
||||
httpClient?: HttpService;
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
@ -16,6 +18,7 @@ export class Configuration {
|
||||
accessToken?: string | Promise<string> | (() => string | Promise<string>);
|
||||
basePath?: string;
|
||||
withCredentials?: boolean;
|
||||
httpClient?: HttpService;
|
||||
|
||||
constructor(configurationParameters: ConfigurationParameters = {}) {
|
||||
this.apiKeys = configurationParameters.apiKeys;
|
||||
@ -24,6 +27,7 @@ export class Configuration {
|
||||
this.accessToken = configurationParameters.accessToken;
|
||||
this.basePath = configurationParameters.basePath;
|
||||
this.withCredentials = configurationParameters.withCredentials;
|
||||
this.httpClient = configurationParameters.httpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,10 +26,12 @@ export class PetService {
|
||||
protected basePath = 'http://petstore.swagger.io/v2';
|
||||
public defaultHeaders: Record<string,string> = {};
|
||||
public configuration = new Configuration();
|
||||
protected httpClient: HttpService;
|
||||
|
||||
constructor(protected httpClient: HttpService, @Optional() configuration: Configuration) {
|
||||
constructor(httpClient: HttpService, @Optional() configuration: Configuration) {
|
||||
this.configuration = configuration || this.configuration;
|
||||
this.basePath = configuration?.basePath || this.basePath;
|
||||
this.httpClient = configuration?.httpClient || httpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,10 +25,12 @@ export class StoreService {
|
||||
protected basePath = 'http://petstore.swagger.io/v2';
|
||||
public defaultHeaders: Record<string,string> = {};
|
||||
public configuration = new Configuration();
|
||||
protected httpClient: HttpService;
|
||||
|
||||
constructor(protected httpClient: HttpService, @Optional() configuration: Configuration) {
|
||||
constructor(httpClient: HttpService, @Optional() configuration: Configuration) {
|
||||
this.configuration = configuration || this.configuration;
|
||||
this.basePath = configuration?.basePath || this.basePath;
|
||||
this.httpClient = configuration?.httpClient || httpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,10 +25,12 @@ export class UserService {
|
||||
protected basePath = 'http://petstore.swagger.io/v2';
|
||||
public defaultHeaders: Record<string,string> = {};
|
||||
public configuration = new Configuration();
|
||||
protected httpClient: HttpService;
|
||||
|
||||
constructor(protected httpClient: HttpService, @Optional() configuration: Configuration) {
|
||||
constructor(httpClient: HttpService, @Optional() configuration: Configuration) {
|
||||
this.configuration = configuration || this.configuration;
|
||||
this.basePath = configuration?.basePath || this.basePath;
|
||||
this.httpClient = configuration?.httpClient || httpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,3 +1,4 @@
|
||||
import type { HttpService } from '@nestjs/axios';
|
||||
import { ModuleMetadata, Type } from '@nestjs/common/interfaces';
|
||||
|
||||
export interface ConfigurationParameters {
|
||||
@ -7,6 +8,7 @@ export interface ConfigurationParameters {
|
||||
accessToken?: string | Promise<string> | (() => string | Promise<string>);
|
||||
basePath?: string;
|
||||
withCredentials?: boolean;
|
||||
httpClient?: HttpService;
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
@ -16,6 +18,7 @@ export class Configuration {
|
||||
accessToken?: string | Promise<string> | (() => string | Promise<string>);
|
||||
basePath?: string;
|
||||
withCredentials?: boolean;
|
||||
httpClient?: HttpService;
|
||||
|
||||
constructor(configurationParameters: ConfigurationParameters = {}) {
|
||||
this.apiKeys = configurationParameters.apiKeys;
|
||||
@ -24,6 +27,7 @@ export class Configuration {
|
||||
this.accessToken = configurationParameters.accessToken;
|
||||
this.basePath = configurationParameters.basePath;
|
||||
this.withCredentials = configurationParameters.withCredentials;
|
||||
this.httpClient = configurationParameters.httpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,10 +27,12 @@ export class PetService {
|
||||
protected basePath = 'http://petstore.swagger.io/v2';
|
||||
public defaultHeaders: Record<string,string> = {};
|
||||
public configuration = new Configuration();
|
||||
protected httpClient: HttpService;
|
||||
|
||||
constructor(protected httpClient: HttpService, @Optional() configuration: Configuration) {
|
||||
constructor(httpClient: HttpService, @Optional() configuration: Configuration) {
|
||||
this.configuration = configuration || this.configuration;
|
||||
this.basePath = configuration?.basePath || this.basePath;
|
||||
this.httpClient = configuration?.httpClient || httpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,10 +26,12 @@ export class StoreService {
|
||||
protected basePath = 'http://petstore.swagger.io/v2';
|
||||
public defaultHeaders: Record<string,string> = {};
|
||||
public configuration = new Configuration();
|
||||
protected httpClient: HttpService;
|
||||
|
||||
constructor(protected httpClient: HttpService, @Optional() configuration: Configuration) {
|
||||
constructor(httpClient: HttpService, @Optional() configuration: Configuration) {
|
||||
this.configuration = configuration || this.configuration;
|
||||
this.basePath = configuration?.basePath || this.basePath;
|
||||
this.httpClient = configuration?.httpClient || httpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,10 +26,12 @@ export class UserService {
|
||||
protected basePath = 'http://petstore.swagger.io/v2';
|
||||
public defaultHeaders: Record<string,string> = {};
|
||||
public configuration = new Configuration();
|
||||
protected httpClient: HttpService;
|
||||
|
||||
constructor(protected httpClient: HttpService, @Optional() configuration: Configuration) {
|
||||
constructor(httpClient: HttpService, @Optional() configuration: Configuration) {
|
||||
this.configuration = configuration || this.configuration;
|
||||
this.basePath = configuration?.basePath || this.basePath;
|
||||
this.httpClient = configuration?.httpClient || httpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,3 +1,4 @@
|
||||
import type { HttpService } from '@nestjs/axios';
|
||||
import { ModuleMetadata, Type } from '@nestjs/common/interfaces';
|
||||
|
||||
export interface ConfigurationParameters {
|
||||
@ -7,6 +8,7 @@ export interface ConfigurationParameters {
|
||||
accessToken?: string | Promise<string> | (() => string | Promise<string>);
|
||||
basePath?: string;
|
||||
withCredentials?: boolean;
|
||||
httpClient?: HttpService;
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
@ -16,6 +18,7 @@ export class Configuration {
|
||||
accessToken?: string | Promise<string> | (() => string | Promise<string>);
|
||||
basePath?: string;
|
||||
withCredentials?: boolean;
|
||||
httpClient?: HttpService;
|
||||
|
||||
constructor(configurationParameters: ConfigurationParameters = {}) {
|
||||
this.apiKeys = configurationParameters.apiKeys;
|
||||
@ -24,6 +27,7 @@ export class Configuration {
|
||||
this.accessToken = configurationParameters.accessToken;
|
||||
this.basePath = configurationParameters.basePath;
|
||||
this.withCredentials = configurationParameters.withCredentials;
|
||||
this.httpClient = configurationParameters.httpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user