Skip to content

Commit

Permalink
this.baseUrl to cater for empty strings (#3065)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyreilly authored Sep 28, 2020
1 parent 75c690f commit 79108da
Show file tree
Hide file tree
Showing 18 changed files with 38 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
{% endif -%}
this.http = http;
{% if UseGetBaseUrlMethod -%}
this.baseUrl = baseUrl ? baseUrl : this.getBaseUrl("{{ BaseUrl }}");
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : this.getBaseUrl("{{ BaseUrl }}");
{% else -%}
this.baseUrl = baseUrl ? baseUrl : "{{ BaseUrl }}";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "{{ BaseUrl }}";
{% endif -%}
}
{% endif -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
this.http = $http;
this.q = $q;
{% if UseGetBaseUrlMethod -%}
this.baseUrl = baseUrl ? baseUrl : this.getBaseUrl("{{ BaseUrl }}");
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : this.getBaseUrl("{{ BaseUrl }}");
{% else -%}
this.baseUrl = baseUrl ? baseUrl : "{{ BaseUrl }}";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "{{ BaseUrl }}";
{% endif -%}
}
{% endif -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
{% endif -%}
this.instance = instance ? instance : axios.create();
{% if UseGetBaseUrlMethod -%}
this.baseUrl = baseUrl ? baseUrl : this.getBaseUrl("{{ BaseUrl }}");
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : this.getBaseUrl("{{ BaseUrl }}");
{% else -%}
this.baseUrl = baseUrl ? baseUrl : "{{ BaseUrl }}";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "{{ BaseUrl }}";
{% endif -%}
}
{% endif -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
{% if UseGetBaseUrlMethod -%}
this.baseUrl = this.getBaseUrl("{{ BaseUrl }}", baseUrl);
{% else -%}
this.baseUrl = baseUrl ? baseUrl : "{{ BaseUrl }}";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "{{ BaseUrl }}";
{% endif -%}
}
{% endif -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
super({% if HasConfigurationClass %}configuration{% endif %});
{% endif -%}
{% if UseGetBaseUrlMethod -%}
this.baseUrl = baseUrl ? baseUrl : this.getBaseUrl("{{ BaseUrl }}");
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : this.getBaseUrl("{{ BaseUrl }}");
{% else -%}
this.baseUrl = baseUrl ? baseUrl : "{{ BaseUrl }}";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "{{ BaseUrl }}";
{% endif -%}
}
{% endif -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
super({% if HasConfigurationClass %}configuration{% endif %});
{% endif -%}
{% if UseGetBaseUrlMethod -%}
this.baseUrl = baseUrl ? baseUrl : this.getBaseUrl("{{ BaseUrl }}");
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : this.getBaseUrl("{{ BaseUrl }}");
{% else -%}
this.baseUrl = baseUrl ? baseUrl : "{{ BaseUrl }}";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "{{ BaseUrl }}";
{% endif -%}
}
{% endif -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class GeoClient extends MyBaseClass {
constructor(@Inject(HttpClient) http: HttpClient, @Optional() @Inject(API_BASE_URL) baseUrl?: string) {
super();
this.http = http;
this.baseUrl = baseUrl ? baseUrl : "http://localhost:13452";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "http://localhost:13452";
}

fromBodyTest(location: GeoPoint | null): Observable<void> {
Expand Down Expand Up @@ -621,7 +621,7 @@ export class PersonsClient extends MyBaseClass {
constructor(@Inject(HttpClient) http: HttpClient, @Optional() @Inject(API_BASE_URL) baseUrl?: string) {
super();
this.http = http;
this.baseUrl = baseUrl ? baseUrl : "http://localhost:13452";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "http://localhost:13452";
}

getAll(): Observable<Person[] | null> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class GeoClient {
constructor($http: ng.IHttpService, $q: ng.IQService, baseUrl?: string) {
this.http = $http;
this.q = $q;
this.baseUrl = baseUrl ? baseUrl : "http://localhost:13452";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "http://localhost:13452";
}

fromBodyTest(location: GeoPoint | null): ng.IPromise<void> {
Expand Down Expand Up @@ -486,7 +486,7 @@ export class PersonsClient {
constructor($http: ng.IHttpService, $q: ng.IQService, baseUrl?: string) {
this.http = $http;
this.q = $q;
this.baseUrl = baseUrl ? baseUrl : "http://localhost:13452";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "http://localhost:13452";
}

getAll(): ng.IPromise<Person[] | null> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class GeoClient {

constructor(baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
this.http = http ? http : <any>window;
this.baseUrl = baseUrl ? baseUrl : "http://localhost:13452";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "http://localhost:13452";
}

fromBodyTest(location: GeoPoint | null): Promise<void> {
Expand Down Expand Up @@ -428,7 +428,7 @@ export class PersonsClient {

constructor(baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
this.http = http ? http : <any>window;
this.baseUrl = baseUrl ? baseUrl : "http://localhost:13452";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "http://localhost:13452";
}

getAll(): Promise<Person[] | null> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ export class PersonsClient {

constructor(baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
this.http = http ? http : <any>window;
this.baseUrl = baseUrl ? baseUrl : "http://localhost:13452";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "http://localhost:13452";
}

getAll(): Promise<Person[] | null> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class GeoClient {
protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

constructor(baseUrl?: string) {
this.baseUrl = baseUrl ? baseUrl : "http://localhost:13452";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "http://localhost:13452";
}

fromBodyTest(location: GeoPoint | null, onSuccess?: () => void, onFail?: (exception: string, reason: string) => void): JQueryXHR {
Expand Down Expand Up @@ -613,7 +613,7 @@ export class PersonsClient {
protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

constructor(baseUrl?: string) {
this.baseUrl = baseUrl ? baseUrl : "http://localhost:13452";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "http://localhost:13452";
}

getAll(onSuccess?: (result: Person[] | null) => void, onFail?: (exception: string, reason: string) => void): JQueryXHR {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class GeoClient {
protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

constructor(baseUrl?: string) {
this.baseUrl = baseUrl ? baseUrl : "http://localhost:13452";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "http://localhost:13452";
}

fromBodyTest(location: GeoPoint | null) {
Expand Down Expand Up @@ -635,7 +635,7 @@ export class PersonsClient {
protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

constructor(baseUrl?: string) {
this.baseUrl = baseUrl ? baseUrl : "http://localhost:13452";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "http://localhost:13452";
}

getAll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class GeoClient {
protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

constructor(baseUrl?: string) {
this.baseUrl = baseUrl ? baseUrl : "http://localhost:13452";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "http://localhost:13452";
}

fromBodyTest(location: GeoPoint | null) {
Expand Down Expand Up @@ -637,7 +637,7 @@ export class PersonsClient {
protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

constructor(baseUrl?: string) {
this.baseUrl = baseUrl ? baseUrl : "http://localhost:13452";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "http://localhost:13452";
}

getAll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class Client {

constructor(baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
this.http = http ? http : <any>window;
this.baseUrl = baseUrl ? baseUrl : "https://petstore.swagger.io/v2";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "https://petstore.swagger.io/v2";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class Client {

constructor(baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
this.http = http ? http : <any>window;
this.baseUrl = baseUrl ? baseUrl : "https://api.uber.com/v1";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "https://api.uber.com/v1";
}

/**
Expand Down
14 changes: 7 additions & 7 deletions src/NSwag.Sample.NetCoreAngular/ClientApp/app/githubServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class GitHubClient {

constructor(@Inject(Http) http: Http, @Optional() @Inject(API_BASE_URL) baseUrl?: string) {
this.http = http;
this.baseUrl = baseUrl ? baseUrl : "https://api.github.com";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "https://api.github.com";
}

/**
Expand Down Expand Up @@ -15551,7 +15551,7 @@ export class PublicGitHubClient {

constructor(@Inject(Http) http: Http, @Optional() @Inject(API_BASE_URL) baseUrl?: string) {
this.http = http;
this.baseUrl = baseUrl ? baseUrl : "https://api.github.com";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "https://api.github.com";
}

/**
Expand Down Expand Up @@ -15813,7 +15813,7 @@ export class RateGitHubClient {

constructor(@Inject(Http) http: Http, @Optional() @Inject(API_BASE_URL) baseUrl?: string) {
this.http = http;
this.baseUrl = baseUrl ? baseUrl : "https://api.github.com";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "https://api.github.com";
}

/**
Expand Down Expand Up @@ -15881,7 +15881,7 @@ export class CodeGitHubClient {

constructor(@Inject(Http) http: Http, @Optional() @Inject(API_BASE_URL) baseUrl?: string) {
this.http = http;
this.baseUrl = baseUrl ? baseUrl : "https://api.github.com";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "https://api.github.com";
}

/**
Expand Down Expand Up @@ -15961,7 +15961,7 @@ export class CommitGitHubClient {

constructor(@Inject(Http) http: Http, @Optional() @Inject(API_BASE_URL) baseUrl?: string) {
this.http = http;
this.baseUrl = baseUrl ? baseUrl : "https://api.github.com";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "https://api.github.com";
}

/**
Expand Down Expand Up @@ -16041,7 +16041,7 @@ export class PunchGitHubClient {

constructor(@Inject(Http) http: Http, @Optional() @Inject(API_BASE_URL) baseUrl?: string) {
this.http = http;
this.baseUrl = baseUrl ? baseUrl : "https://api.github.com";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "https://api.github.com";
}

/**
Expand Down Expand Up @@ -16121,7 +16121,7 @@ export class ReceivedGitHubClient {

constructor(@Inject(Http) http: Http, @Optional() @Inject(API_BASE_URL) baseUrl?: string) {
this.http = http;
this.baseUrl = baseUrl ? baseUrl : "https://api.github.com";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "https://api.github.com";
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/NSwag.Sample.NetCoreAngular/ClientApp/app/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class DateService extends ServiceBase {
constructor(@Inject(HttpClient) http: HttpClient, @Optional() @Inject(API_BASE_URL) baseUrl?: string) {
super();
this.http = http;
this.baseUrl = baseUrl ? baseUrl : "";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "";
}

addDays(date: moment.Moment, days: number): Observable<moment.Moment> {
Expand Down Expand Up @@ -168,7 +168,7 @@ export class EnumerationService extends ServiceBase {
constructor(@Inject(HttpClient) http: HttpClient, @Optional() @Inject(API_BASE_URL) baseUrl?: string) {
super();
this.http = http;
this.baseUrl = baseUrl ? baseUrl : "";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "";
}

reverseQueryEnumList(fileTypes: FileType[] | null | undefined): Observable<FileType[] | null> {
Expand Down Expand Up @@ -238,7 +238,7 @@ export class FileService extends ServiceBase {
constructor(@Inject(HttpClient) http: HttpClient, @Optional() @Inject(API_BASE_URL) baseUrl?: string) {
super();
this.http = http;
this.baseUrl = baseUrl ? baseUrl : "";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "";
}

getFile(fileName: string | null): Observable<FileResponse | null> {
Expand Down Expand Up @@ -304,7 +304,7 @@ export class SampleDataService extends ServiceBase {
constructor(@Inject(HttpClient) http: HttpClient, @Optional() @Inject(API_BASE_URL) baseUrl?: string) {
super();
this.http = http;
this.baseUrl = baseUrl ? baseUrl : "";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "";
}

weatherForecasts(): Observable<WeatherForecast[] | null> {
Expand Down
2 changes: 1 addition & 1 deletion src/NSwag.Sample.NetCoreAurelia/ClientApp/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class SampleDataClient {
protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

constructor(baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
this.baseUrl = baseUrl ? baseUrl : "";
this.baseUrl !== undefined && baseUrl !== null ? baseUrl : "";
this.http = http ? http : <any>window;
}

Expand Down

0 comments on commit 79108da

Please sign in to comment.