Skip to content

Commit 8d67acc

Browse files
martinnovakmacjohnny
authored andcommitted
[typescript-angular] allow empty string basePath (#3489)
* [typescript-angular] Fixing #2731 - empty string basePath * typescript-angular: refactor base path configuration * typescript-angular: refactor base path configuration
1 parent 9ca4bac commit 8d67acc

File tree

44 files changed

+323
-215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+323
-215
lines changed

modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,14 @@ export class {{classname}} {
6666
{{/useHttpClient}}
6767

6868
constructor(protected {{#useHttpClient}}httpClient: HttpClient{{/useHttpClient}}{{^useHttpClient}}http: Http{{/useHttpClient}}, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
69-
7069
if (configuration) {
7170
this.configuration = configuration;
72-
this.configuration.basePath = configuration.basePath || basePath || this.basePath;
73-
74-
} else {
75-
this.configuration.basePath = basePath || this.basePath;
71+
}
72+
if (typeof this.configuration.basePath !== 'string') {
73+
if (typeof basePath !== 'string') {
74+
basePath = this.basePath;
75+
}
76+
this.configuration.basePath = basePath;
7677
}
7778
{{#useHttpClient}}
7879
this.encoder = this.configuration.encoder || new CustomHttpParameterCodec();

samples/client/petstore/typescript-angular-v2/default/api/pet.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@ export class PetService {
3535
public encoder: QueryEncoder;
3636

3737
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
38-
3938
if (configuration) {
4039
this.configuration = configuration;
41-
this.configuration.basePath = configuration.basePath || basePath || this.basePath;
42-
43-
} else {
44-
this.configuration.basePath = basePath || this.basePath;
40+
}
41+
if (typeof this.configuration.basePath !== 'string') {
42+
if (typeof basePath !== 'string') {
43+
basePath = this.basePath;
44+
}
45+
this.configuration.basePath = basePath;
4546
}
4647
this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper();
4748
}

samples/client/petstore/typescript-angular-v2/default/api/store.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ export class StoreService {
3434
public encoder: QueryEncoder;
3535

3636
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
37-
3837
if (configuration) {
3938
this.configuration = configuration;
40-
this.configuration.basePath = configuration.basePath || basePath || this.basePath;
41-
42-
} else {
43-
this.configuration.basePath = basePath || this.basePath;
39+
}
40+
if (typeof this.configuration.basePath !== 'string') {
41+
if (typeof basePath !== 'string') {
42+
basePath = this.basePath;
43+
}
44+
this.configuration.basePath = basePath;
4445
}
4546
this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper();
4647
}

samples/client/petstore/typescript-angular-v2/default/api/user.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ export class UserService {
3434
public encoder: QueryEncoder;
3535

3636
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
37-
3837
if (configuration) {
3938
this.configuration = configuration;
40-
this.configuration.basePath = configuration.basePath || basePath || this.basePath;
41-
42-
} else {
43-
this.configuration.basePath = basePath || this.basePath;
39+
}
40+
if (typeof this.configuration.basePath !== 'string') {
41+
if (typeof basePath !== 'string') {
42+
basePath = this.basePath;
43+
}
44+
this.configuration.basePath = basePath;
4445
}
4546
this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper();
4647
}

samples/client/petstore/typescript-angular-v2/npm/api/pet.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@ export class PetService {
3535
public encoder: QueryEncoder;
3636

3737
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
38-
3938
if (configuration) {
4039
this.configuration = configuration;
41-
this.configuration.basePath = configuration.basePath || basePath || this.basePath;
42-
43-
} else {
44-
this.configuration.basePath = basePath || this.basePath;
40+
}
41+
if (typeof this.configuration.basePath !== 'string') {
42+
if (typeof basePath !== 'string') {
43+
basePath = this.basePath;
44+
}
45+
this.configuration.basePath = basePath;
4546
}
4647
this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper();
4748
}

samples/client/petstore/typescript-angular-v2/npm/api/store.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ export class StoreService {
3434
public encoder: QueryEncoder;
3535

3636
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
37-
3837
if (configuration) {
3938
this.configuration = configuration;
40-
this.configuration.basePath = configuration.basePath || basePath || this.basePath;
41-
42-
} else {
43-
this.configuration.basePath = basePath || this.basePath;
39+
}
40+
if (typeof this.configuration.basePath !== 'string') {
41+
if (typeof basePath !== 'string') {
42+
basePath = this.basePath;
43+
}
44+
this.configuration.basePath = basePath;
4445
}
4546
this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper();
4647
}

samples/client/petstore/typescript-angular-v2/npm/api/user.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ export class UserService {
3434
public encoder: QueryEncoder;
3535

3636
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
37-
3837
if (configuration) {
3938
this.configuration = configuration;
40-
this.configuration.basePath = configuration.basePath || basePath || this.basePath;
41-
42-
} else {
43-
this.configuration.basePath = basePath || this.basePath;
39+
}
40+
if (typeof this.configuration.basePath !== 'string') {
41+
if (typeof basePath !== 'string') {
42+
basePath = this.basePath;
43+
}
44+
this.configuration.basePath = basePath;
4445
}
4546
this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper();
4647
}

samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ export class PetService implements PetServiceInterface {
3636
public encoder: QueryEncoder;
3737

3838
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
39-
4039
if (configuration) {
4140
this.configuration = configuration;
42-
this.configuration.basePath = configuration.basePath || basePath || this.basePath;
43-
44-
} else {
45-
this.configuration.basePath = basePath || this.basePath;
41+
}
42+
if (typeof this.configuration.basePath !== 'string') {
43+
if (typeof basePath !== 'string') {
44+
basePath = this.basePath;
45+
}
46+
this.configuration.basePath = basePath;
4647
}
4748
this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper();
4849
}

samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@ export class StoreService implements StoreServiceInterface {
3535
public encoder: QueryEncoder;
3636

3737
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
38-
3938
if (configuration) {
4039
this.configuration = configuration;
41-
this.configuration.basePath = configuration.basePath || basePath || this.basePath;
42-
43-
} else {
44-
this.configuration.basePath = basePath || this.basePath;
40+
}
41+
if (typeof this.configuration.basePath !== 'string') {
42+
if (typeof basePath !== 'string') {
43+
basePath = this.basePath;
44+
}
45+
this.configuration.basePath = basePath;
4546
}
4647
this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper();
4748
}

samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@ export class UserService implements UserServiceInterface {
3535
public encoder: QueryEncoder;
3636

3737
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
38-
3938
if (configuration) {
4039
this.configuration = configuration;
41-
this.configuration.basePath = configuration.basePath || basePath || this.basePath;
42-
43-
} else {
44-
this.configuration.basePath = basePath || this.basePath;
40+
}
41+
if (typeof this.configuration.basePath !== 'string') {
42+
if (typeof basePath !== 'string') {
43+
basePath = this.basePath;
44+
}
45+
this.configuration.basePath = basePath;
4546
}
4647
this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper();
4748
}

samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ export class PetService {
3333
public encoder: HttpParameterCodec;
3434

3535
constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
36-
3736
if (configuration) {
3837
this.configuration = configuration;
39-
this.configuration.basePath = configuration.basePath || basePath || this.basePath;
40-
41-
} else {
42-
this.configuration.basePath = basePath || this.basePath;
38+
}
39+
if (typeof this.configuration.basePath !== 'string') {
40+
if (typeof basePath !== 'string') {
41+
basePath = this.basePath;
42+
}
43+
this.configuration.basePath = basePath;
4344
}
4445
this.encoder = this.configuration.encoder || new CustomHttpParameterCodec();
4546
}

samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ export class StoreService {
3232
public encoder: HttpParameterCodec;
3333

3434
constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
35-
3635
if (configuration) {
3736
this.configuration = configuration;
38-
this.configuration.basePath = configuration.basePath || basePath || this.basePath;
39-
40-
} else {
41-
this.configuration.basePath = basePath || this.basePath;
37+
}
38+
if (typeof this.configuration.basePath !== 'string') {
39+
if (typeof basePath !== 'string') {
40+
basePath = this.basePath;
41+
}
42+
this.configuration.basePath = basePath;
4243
}
4344
this.encoder = this.configuration.encoder || new CustomHttpParameterCodec();
4445
}

samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ export class UserService {
3232
public encoder: HttpParameterCodec;
3333

3434
constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
35-
3635
if (configuration) {
3736
this.configuration = configuration;
38-
this.configuration.basePath = configuration.basePath || basePath || this.basePath;
39-
40-
} else {
41-
this.configuration.basePath = basePath || this.basePath;
37+
}
38+
if (typeof this.configuration.basePath !== 'string') {
39+
if (typeof basePath !== 'string') {
40+
basePath = this.basePath;
41+
}
42+
this.configuration.basePath = basePath;
4243
}
4344
this.encoder = this.configuration.encoder || new CustomHttpParameterCodec();
4445
}

samples/client/petstore/typescript-angular-v4/npm/api/pet.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@ export class PetService {
3535
public encoder: QueryEncoder;
3636

3737
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
38-
3938
if (configuration) {
4039
this.configuration = configuration;
41-
this.configuration.basePath = configuration.basePath || basePath || this.basePath;
42-
43-
} else {
44-
this.configuration.basePath = basePath || this.basePath;
40+
}
41+
if (typeof this.configuration.basePath !== 'string') {
42+
if (typeof basePath !== 'string') {
43+
basePath = this.basePath;
44+
}
45+
this.configuration.basePath = basePath;
4546
}
4647
this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper();
4748
}

samples/client/petstore/typescript-angular-v4/npm/api/store.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ export class StoreService {
3434
public encoder: QueryEncoder;
3535

3636
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
37-
3837
if (configuration) {
3938
this.configuration = configuration;
40-
this.configuration.basePath = configuration.basePath || basePath || this.basePath;
41-
42-
} else {
43-
this.configuration.basePath = basePath || this.basePath;
39+
}
40+
if (typeof this.configuration.basePath !== 'string') {
41+
if (typeof basePath !== 'string') {
42+
basePath = this.basePath;
43+
}
44+
this.configuration.basePath = basePath;
4445
}
4546
this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper();
4647
}

samples/client/petstore/typescript-angular-v4/npm/api/user.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ export class UserService {
3434
public encoder: QueryEncoder;
3535

3636
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
37-
3837
if (configuration) {
3938
this.configuration = configuration;
40-
this.configuration.basePath = configuration.basePath || basePath || this.basePath;
41-
42-
} else {
43-
this.configuration.basePath = basePath || this.basePath;
39+
}
40+
if (typeof this.configuration.basePath !== 'string') {
41+
if (typeof basePath !== 'string') {
42+
basePath = this.basePath;
43+
}
44+
this.configuration.basePath = basePath;
4445
}
4546
this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper();
4647
}

samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/pet.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ export class PetService {
3333
public encoder: HttpParameterCodec;
3434

3535
constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
36-
3736
if (configuration) {
3837
this.configuration = configuration;
39-
this.configuration.basePath = configuration.basePath || basePath || this.basePath;
40-
41-
} else {
42-
this.configuration.basePath = basePath || this.basePath;
38+
}
39+
if (typeof this.configuration.basePath !== 'string') {
40+
if (typeof basePath !== 'string') {
41+
basePath = this.basePath;
42+
}
43+
this.configuration.basePath = basePath;
4344
}
4445
this.encoder = this.configuration.encoder || new CustomHttpParameterCodec();
4546
}

samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/store.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ export class StoreService {
3232
public encoder: HttpParameterCodec;
3333

3434
constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
35-
3635
if (configuration) {
3736
this.configuration = configuration;
38-
this.configuration.basePath = configuration.basePath || basePath || this.basePath;
39-
40-
} else {
41-
this.configuration.basePath = basePath || this.basePath;
37+
}
38+
if (typeof this.configuration.basePath !== 'string') {
39+
if (typeof basePath !== 'string') {
40+
basePath = this.basePath;
41+
}
42+
this.configuration.basePath = basePath;
4243
}
4344
this.encoder = this.configuration.encoder || new CustomHttpParameterCodec();
4445
}

samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/user.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ export class UserService {
3232
public encoder: HttpParameterCodec;
3333

3434
constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
35-
3635
if (configuration) {
3736
this.configuration = configuration;
38-
this.configuration.basePath = configuration.basePath || basePath || this.basePath;
39-
40-
} else {
41-
this.configuration.basePath = basePath || this.basePath;
37+
}
38+
if (typeof this.configuration.basePath !== 'string') {
39+
if (typeof basePath !== 'string') {
40+
basePath = this.basePath;
41+
}
42+
this.configuration.basePath = basePath;
4243
}
4344
this.encoder = this.configuration.encoder || new CustomHttpParameterCodec();
4445
}

samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/pet.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ export class PetService {
3333
public encoder: HttpParameterCodec;
3434

3535
constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
36-
3736
if (configuration) {
3837
this.configuration = configuration;
39-
this.configuration.basePath = configuration.basePath || basePath || this.basePath;
40-
41-
} else {
42-
this.configuration.basePath = basePath || this.basePath;
38+
}
39+
if (typeof this.configuration.basePath !== 'string') {
40+
if (typeof basePath !== 'string') {
41+
basePath = this.basePath;
42+
}
43+
this.configuration.basePath = basePath;
4344
}
4445
this.encoder = this.configuration.encoder || new CustomHttpParameterCodec();
4546
}

0 commit comments

Comments
 (0)