use String() to convert num, update TS angular samples

This commit is contained in:
wing328 2017-09-30 17:28:07 +08:00
parent f3e19e0fdc
commit 82b6e81897
13 changed files with 51 additions and 70 deletions

View File

@ -248,7 +248,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
}
// Convert path to TypeScript template string, applying URI encoding
op.path = op.path.replaceAll("\\{(.*?)\\}", "\\$\\{encodeURIComponent($1)\\}");
op.path = op.path.replaceAll("\\{(.*?)\\}", "\\$\\{encodeURIComponent(String($1))\\}");
}
// Add additional filename information for model imports in the services

View File

@ -269,7 +269,7 @@ export class PetService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(petId)}`, requestOptions);
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, requestOptions);
}
/**
@ -377,7 +377,7 @@ export class PetService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(petId)}`, requestOptions);
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, requestOptions);
}
/**
@ -447,7 +447,6 @@ export class PetService {
let formParams = new (useForm ? FormData : URLSearchParams as any)() as {
set(param: string, value: any): void;
};
if (name !== undefined) {
formParams.set('name', <any>name);
}
@ -466,7 +465,7 @@ export class PetService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(petId)}`, requestOptions);
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, requestOptions);
}
/**
@ -501,7 +500,6 @@ export class PetService {
let formParams = new (useForm ? FormData : URLSearchParams as any)() as {
set(param: string, value: any): void;
};
if (additionalMetadata !== undefined) {
formParams.set('additionalMetadata', <any>additionalMetadata);
}
@ -520,7 +518,7 @@ export class PetService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(petId)}/uploadImage`, requestOptions);
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`, requestOptions);
}
}

View File

@ -58,6 +58,7 @@ export class StoreService {
return false;
}
public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
@ -149,7 +150,7 @@ export class StoreService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/store/order/${encodeURIComponent(orderId)}`, requestOptions);
return this.http.request(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`, requestOptions);
}
/**
@ -200,7 +201,7 @@ export class StoreService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/store/order/${encodeURIComponent(orderId)}`, requestOptions);
return this.http.request(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`, requestOptions);
}
/**

View File

@ -300,7 +300,7 @@ export class UserService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/user/${encodeURIComponent(username)}`, requestOptions);
return this.http.request(`${this.basePath}/user/${encodeURIComponent(String(username))}`, requestOptions);
}
/**
@ -325,7 +325,7 @@ export class UserService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/user/${encodeURIComponent(username)}`, requestOptions);
return this.http.request(`${this.basePath}/user/${encodeURIComponent(String(username))}`, requestOptions);
}
/**
@ -416,7 +416,7 @@ export class UserService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/user/${encodeURIComponent(username)}`, requestOptions);
return this.http.request(`${this.basePath}/user/${encodeURIComponent(String(username))}`, requestOptions);
}
}

View File

@ -59,6 +59,7 @@ export class PetService {
return false;
}
public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
@ -268,7 +269,7 @@ export class PetService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(petId)}`, requestOptions);
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, requestOptions);
}
/**
@ -376,7 +377,7 @@ export class PetService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(petId)}`, requestOptions);
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, requestOptions);
}
/**
@ -446,7 +447,6 @@ export class PetService {
let formParams = new (useForm ? FormData : URLSearchParams as any)() as {
set(param: string, value: any): void;
};
if (name !== undefined) {
formParams.set('name', <any>name);
}
@ -465,7 +465,7 @@ export class PetService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(petId)}`, requestOptions);
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, requestOptions);
}
/**
@ -500,7 +500,6 @@ export class PetService {
let formParams = new (useForm ? FormData : URLSearchParams as any)() as {
set(param: string, value: any): void;
};
if (additionalMetadata !== undefined) {
formParams.set('additionalMetadata', <any>additionalMetadata);
}
@ -519,7 +518,7 @@ export class PetService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(petId)}/uploadImage`, requestOptions);
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`, requestOptions);
}
}

View File

@ -58,6 +58,7 @@ export class StoreService {
return false;
}
public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
@ -149,7 +150,7 @@ export class StoreService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/store/order/${encodeURIComponent(orderId)}`, requestOptions);
return this.http.request(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`, requestOptions);
}
/**
@ -200,7 +201,7 @@ export class StoreService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/store/order/${encodeURIComponent(orderId)}`, requestOptions);
return this.http.request(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`, requestOptions);
}
/**

View File

@ -58,6 +58,7 @@ export class UserService {
return false;
}
public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
@ -299,7 +300,7 @@ export class UserService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/user/${encodeURIComponent(username)}`, requestOptions);
return this.http.request(`${this.basePath}/user/${encodeURIComponent(String(username))}`, requestOptions);
}
/**
@ -324,7 +325,7 @@ export class UserService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/user/${encodeURIComponent(username)}`, requestOptions);
return this.http.request(`${this.basePath}/user/${encodeURIComponent(String(username))}`, requestOptions);
}
/**
@ -351,16 +352,6 @@ export class UserService {
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
// to determine the Accept header
let produces: string[] = [
'application/xml',
'application/json'
];
if (produces != null && produces.length > 0) {
headers.set('Accept', produces.filter(item => this.isJsonMime(item)).join(';'));
}
let requestOptions: RequestOptionsArgs = new RequestOptions({
method: RequestMethod.Get,
headers: headers,
@ -383,16 +374,6 @@ export class UserService {
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
// to determine the Accept header
let produces: string[] = [
'application/xml',
'application/json'
];
if (produces != null && produces.length > 0) {
headers.set('Accept', produces.filter(item => this.isJsonMime(item)).join(';'));
}
let requestOptions: RequestOptionsArgs = new RequestOptions({
method: RequestMethod.Get,
headers: headers,
@ -435,7 +416,7 @@ export class UserService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/user/${encodeURIComponent(username)}`, requestOptions);
return this.http.request(`${this.basePath}/user/${encodeURIComponent(String(username))}`, requestOptions);
}
}

View File

@ -60,6 +60,7 @@ export class PetService implements PetServiceInterface {
return false;
}
public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
@ -269,7 +270,7 @@ export class PetService implements PetServiceInterface {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(petId)}`, requestOptions);
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, requestOptions);
}
/**
@ -377,7 +378,7 @@ export class PetService implements PetServiceInterface {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(petId)}`, requestOptions);
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, requestOptions);
}
/**
@ -447,7 +448,6 @@ export class PetService implements PetServiceInterface {
let formParams = new (useForm ? FormData : URLSearchParams as any)() as {
set(param: string, value: any): void;
};
if (name !== undefined) {
formParams.set('name', <any>name);
}
@ -466,7 +466,7 @@ export class PetService implements PetServiceInterface {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(petId)}`, requestOptions);
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, requestOptions);
}
/**
@ -501,7 +501,6 @@ export class PetService implements PetServiceInterface {
let formParams = new (useForm ? FormData : URLSearchParams as any)() as {
set(param: string, value: any): void;
};
if (additionalMetadata !== undefined) {
formParams.set('additionalMetadata', <any>additionalMetadata);
}
@ -520,7 +519,7 @@ export class PetService implements PetServiceInterface {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(petId)}/uploadImage`, requestOptions);
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`, requestOptions);
}
}

View File

@ -59,6 +59,7 @@ export class StoreService implements StoreServiceInterface {
return false;
}
public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
@ -150,7 +151,7 @@ export class StoreService implements StoreServiceInterface {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/store/order/${encodeURIComponent(orderId)}`, requestOptions);
return this.http.request(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`, requestOptions);
}
/**
@ -201,7 +202,7 @@ export class StoreService implements StoreServiceInterface {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/store/order/${encodeURIComponent(orderId)}`, requestOptions);
return this.http.request(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`, requestOptions);
}
/**

View File

@ -59,6 +59,7 @@ export class UserService implements UserServiceInterface {
return false;
}
public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
@ -300,7 +301,7 @@ export class UserService implements UserServiceInterface {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/user/${encodeURIComponent(username)}`, requestOptions);
return this.http.request(`${this.basePath}/user/${encodeURIComponent(String(username))}`, requestOptions);
}
/**
@ -325,7 +326,7 @@ export class UserService implements UserServiceInterface {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/user/${encodeURIComponent(username)}`, requestOptions);
return this.http.request(`${this.basePath}/user/${encodeURIComponent(String(username))}`, requestOptions);
}
/**
@ -416,7 +417,7 @@ export class UserService implements UserServiceInterface {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/user/${encodeURIComponent(username)}`, requestOptions);
return this.http.request(`${this.basePath}/user/${encodeURIComponent(String(username))}`, requestOptions);
}
}

View File

@ -59,6 +59,7 @@ export class PetService {
return false;
}
public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
@ -258,7 +259,6 @@ export class PetService {
headers.set('Authorization', 'Bearer ' + accessToken);
}
let requestOptions: RequestOptionsArgs = new RequestOptions({
method: RequestMethod.Delete,
headers: headers,
@ -269,7 +269,7 @@ export class PetService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(petId)}`, requestOptions);
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, requestOptions);
}
/**
@ -377,7 +377,7 @@ export class PetService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(petId)}`, requestOptions);
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, requestOptions);
}
/**
@ -447,7 +447,6 @@ export class PetService {
let formParams = new (useForm ? FormData : URLSearchParams as any)() as {
set(param: string, value: any): void;
};
if (name !== undefined) {
formParams.set('name', <any>name);
}
@ -466,7 +465,7 @@ export class PetService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(petId)}`, requestOptions);
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`, requestOptions);
}
/**
@ -501,7 +500,6 @@ export class PetService {
let formParams = new (useForm ? FormData : URLSearchParams as any)() as {
set(param: string, value: any): void;
};
if (additionalMetadata !== undefined) {
formParams.set('additionalMetadata', <any>additionalMetadata);
}
@ -520,7 +518,7 @@ export class PetService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(petId)}/uploadImage`, requestOptions);
return this.http.request(`${this.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`, requestOptions);
}
}

View File

@ -58,6 +58,7 @@ export class StoreService {
return false;
}
public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
@ -83,7 +84,7 @@ export class StoreService {
* Returns a map of status codes to quantities
* @summary Returns pet inventories by status
*/
public getInventory(, extraHttpRequestParams?: RequestOptionsArgs): Observable<{ [key: string]: number; }> {
public getInventory(extraHttpRequestParams?: RequestOptionsArgs): Observable<{ [key: string]: number; }> {
return this.getInventoryWithHttpInfo(extraHttpRequestParams)
.map((response: Response) => {
if (response.status === 204) {
@ -149,14 +150,14 @@ export class StoreService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/store/order/${encodeURIComponent(orderId)}`, requestOptions);
return this.http.request(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`, requestOptions);
}
/**
* Returns pet inventories by status
* Returns a map of status codes to quantities
*/
public getInventoryWithHttpInfo(, extraHttpRequestParams?: RequestOptionsArgs): Observable<Response> {
public getInventoryWithHttpInfo(extraHttpRequestParams?: RequestOptionsArgs): Observable<Response> {
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
@ -200,7 +201,7 @@ export class StoreService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/store/order/${encodeURIComponent(orderId)}`, requestOptions);
return this.http.request(`${this.basePath}/store/order/${encodeURIComponent(String(orderId))}`, requestOptions);
}
/**

View File

@ -58,6 +58,7 @@ export class UserService {
return false;
}
public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
@ -164,7 +165,7 @@ export class UserService {
*
* @summary Logs out current logged in user session
*/
public logoutUser(, extraHttpRequestParams?: RequestOptionsArgs): Observable<{}> {
public logoutUser(extraHttpRequestParams?: RequestOptionsArgs): Observable<{}> {
return this.logoutUserWithHttpInfo(extraHttpRequestParams)
.map((response: Response) => {
if (response.status === 204) {
@ -299,7 +300,7 @@ export class UserService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/user/${encodeURIComponent(username)}`, requestOptions);
return this.http.request(`${this.basePath}/user/${encodeURIComponent(String(username))}`, requestOptions);
}
/**
@ -324,7 +325,7 @@ export class UserService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/user/${encodeURIComponent(username)}`, requestOptions);
return this.http.request(`${this.basePath}/user/${encodeURIComponent(String(username))}`, requestOptions);
}
/**
@ -369,7 +370,7 @@ export class UserService {
* Logs out current logged in user session
*
*/
public logoutUserWithHttpInfo(, extraHttpRequestParams?: RequestOptionsArgs): Observable<Response> {
public logoutUserWithHttpInfo(extraHttpRequestParams?: RequestOptionsArgs): Observable<Response> {
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
@ -415,7 +416,7 @@ export class UserService {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
}
return this.http.request(`${this.basePath}/user/${encodeURIComponent(username)}`, requestOptions);
return this.http.request(`${this.basePath}/user/${encodeURIComponent(String(username))}`, requestOptions);
}
}