typescript-nestjs: removed unused basePath from api.service template (#8811)

* (nestjs) removed unused basePath from api.service template 8810

* Update modules/openapi-generator/src/main/resources/typescript-nestjs/api.service.mustache

Co-authored-by: Esteban Gehring <esteban.gehring@gmail.com>

* added missing parenthesis on Global() decorator

Co-authored-by: Esteban Gehring <esteban.gehring@gmail.com>
This commit is contained in:
Rafael Ceron 2021-02-25 02:43:21 -05:00 committed by GitHub
parent df1ae03960
commit 34c77c2807
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 31 deletions

View File

@ -7,7 +7,7 @@ import { {{classname}} } from './{{importPath}}';
{{/apis}} {{/apis}}
{{/apiInfo}} {{/apiInfo}}
@Global @Global()
@Module({ @Module({
imports: [ HttpModule ], imports: [ HttpModule ],
exports: [ exports: [

View File

@ -1,14 +1,13 @@
{{>licenseInfo}} {{>licenseInfo}}
/* tslint:disable:no-unused-variable member-ordering */ /* tslint:disable:no-unused-variable member-ordering */
import { HttpService, Inject, Injectable } from '@nestjs/common'; import { HttpService, Inject, Injectable, Optional } from '@nestjs/common';
import { AxiosResponse } from 'axios'; import { AxiosResponse } from 'axios';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
{{#imports}} {{#imports}}
import { {{classname}} } from '../{{filename}}'; import { {{classname}} } from '../{{filename}}';
{{/imports}} {{/imports}}
import { Configuration } from '../configuration'; import { Configuration } from '../configuration';
import { COLLECTION_FORMATS } from '../variables';
{{#withInterfaces}} {{#withInterfaces}}
import { {{classname}}Interface } from './{{classFilename}}Interface'; import { {{classname}}Interface } from './{{classFilename}}Interface';
{{/withInterfaces}} {{/withInterfaces}}
@ -32,9 +31,9 @@ export class {{classname}} {
public defaultHeaders = new Map() public defaultHeaders = new Map()
public configuration = new Configuration(); public configuration = new Configuration();
constructor(protected httpClient: HttpService, configuration: Configuration) { constructor(protected httpClient: HttpService, @Optional() configuration: Configuration) {
this.configuration = configuration; this.configuration = configuration || this.configuration;
this.basePath = basePath || configuration.basePath || this.basePath; this.basePath = configuration?.basePath || this.basePath;
} }
/** /**

View File

@ -5,7 +5,7 @@ import { PetService } from './api/pet.service';
import { StoreService } from './api/store.service'; import { StoreService } from './api/store.service';
import { UserService } from './api/user.service'; import { UserService } from './api/user.service';
@Global @Global()
@Module({ @Module({
imports: [ HttpModule ], imports: [ HttpModule ],
exports: [ exports: [

View File

@ -11,13 +11,12 @@
*/ */
/* tslint:disable:no-unused-variable member-ordering */ /* tslint:disable:no-unused-variable member-ordering */
import { HttpService, Inject, Injectable } from '@nestjs/common'; import { HttpService, Inject, Injectable, Optional } from '@nestjs/common';
import { AxiosResponse } from 'axios'; import { AxiosResponse } from 'axios';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { ApiResponse } from '../model/apiResponse'; import { ApiResponse } from '../model/apiResponse';
import { Pet } from '../model/pet'; import { Pet } from '../model/pet';
import { Configuration } from '../configuration'; import { Configuration } from '../configuration';
import { COLLECTION_FORMATS } from '../variables';
@Injectable() @Injectable()
@ -27,9 +26,9 @@ export class PetService {
public defaultHeaders = new Map() public defaultHeaders = new Map()
public configuration = new Configuration(); public configuration = new Configuration();
constructor(protected httpClient: HttpService, configuration: Configuration) { constructor(protected httpClient: HttpService, @Optional() configuration: Configuration) {
this.configuration = configuration; this.configuration = configuration || this.configuration;
this.basePath = basePath || configuration.basePath || this.basePath; this.basePath = configuration?.basePath || this.basePath;
} }
/** /**

View File

@ -11,12 +11,11 @@
*/ */
/* tslint:disable:no-unused-variable member-ordering */ /* tslint:disable:no-unused-variable member-ordering */
import { HttpService, Inject, Injectable } from '@nestjs/common'; import { HttpService, Inject, Injectable, Optional } from '@nestjs/common';
import { AxiosResponse } from 'axios'; import { AxiosResponse } from 'axios';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { Order } from '../model/order'; import { Order } from '../model/order';
import { Configuration } from '../configuration'; import { Configuration } from '../configuration';
import { COLLECTION_FORMATS } from '../variables';
@Injectable() @Injectable()
@ -26,9 +25,9 @@ export class StoreService {
public defaultHeaders = new Map() public defaultHeaders = new Map()
public configuration = new Configuration(); public configuration = new Configuration();
constructor(protected httpClient: HttpService, configuration: Configuration) { constructor(protected httpClient: HttpService, @Optional() configuration: Configuration) {
this.configuration = configuration; this.configuration = configuration || this.configuration;
this.basePath = basePath || configuration.basePath || this.basePath; this.basePath = configuration?.basePath || this.basePath;
} }
/** /**

View File

@ -11,12 +11,11 @@
*/ */
/* tslint:disable:no-unused-variable member-ordering */ /* tslint:disable:no-unused-variable member-ordering */
import { HttpService, Inject, Injectable } from '@nestjs/common'; import { HttpService, Inject, Injectable, Optional } from '@nestjs/common';
import { AxiosResponse } from 'axios'; import { AxiosResponse } from 'axios';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { User } from '../model/user'; import { User } from '../model/user';
import { Configuration } from '../configuration'; import { Configuration } from '../configuration';
import { COLLECTION_FORMATS } from '../variables';
@Injectable() @Injectable()
@ -26,9 +25,9 @@ export class UserService {
public defaultHeaders = new Map() public defaultHeaders = new Map()
public configuration = new Configuration(); public configuration = new Configuration();
constructor(protected httpClient: HttpService, configuration: Configuration) { constructor(protected httpClient: HttpService, @Optional() configuration: Configuration) {
this.configuration = configuration; this.configuration = configuration || this.configuration;
this.basePath = basePath || configuration.basePath || this.basePath; this.basePath = configuration?.basePath || this.basePath;
} }
/** /**