Merge pull request #1525 from wing328/ts-reserved-word

[TypeScript] add reserved word handling for OperationId (method name)
This commit is contained in:
wing328 2015-11-07 10:42:24 +08:00
commit f19a8d41e4
10 changed files with 343 additions and 961 deletions

View File

@ -6,6 +6,8 @@ import io.swagger.models.properties.*;
import java.util.*; import java.util.*;
import java.io.File; import java.io.File;
import org.apache.commons.lang.StringUtils;
public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen implements CodegenConfig { public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override @Override
public CodegenType getTag() { public CodegenType getTag() {
@ -15,14 +17,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
public AbstractTypeScriptClientCodegen() { public AbstractTypeScriptClientCodegen() {
super(); super();
supportsInheritance = true; supportsInheritance = true;
reservedWords = new HashSet<String>(Arrays.asList("abstract", reservedWords = new HashSet<String>(Arrays.asList("abstract", "await", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default", "delete", "do", "double", "else", "enum", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "let", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "transient", "true", "try", "typeof", "var", "void", "volatile", "while", "with", "yield"));
"continue", "for", "new", "switch", "assert", "default", "if",
"package", "synchronized", "do", "goto", "private",
"this", "break", "double", "implements", "protected", "throw",
"byte", "else", "import", "public", "throws", "case", "enum",
"instanceof", "return", "transient", "catch", "extends", "int",
"short", "try", "char", "final", "interface", "static", "void",
"class", "finally", "const", "super", "while"));
languageSpecificPrimitives = new HashSet<String>(Arrays.asList( languageSpecificPrimitives = new HashSet<String>(Arrays.asList(
"String", "String",
@ -79,7 +74,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
return name; return name;
// camelize the variable name // camelize the variable name
// pet_id => PetId // pet_id => petId
name = camelize(name, true); name = camelize(name, true);
// for reserved word or word starting with number, append _ // for reserved word or word starting with number, append _
@ -141,4 +136,20 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
type = swaggerType; type = swaggerType;
return type; return type;
} }
@Override
public String toOperationId(String operationId) {
// throw exception if method name is empty
if (StringUtils.isEmpty(operationId)) {
throw new RuntimeException("Empty method name (operationId) not allowed");
}
// method name cannot use reserved keyword, e.g. return
// append _ at the beginning, e.g. _return
if (reservedWords.contains(operationId)) {
return escapeReservedWord(camelize(sanitizeName(operationId), true));
}
return camelize(sanitizeName(operationId), true);
}
} }

View File

@ -3,22 +3,11 @@
namespace API.Client { namespace API.Client {
'use strict'; 'use strict';
export interface Category { export interface Category {
id: number; id: number;
name: string; name: string;
} }
} }

View File

@ -3,65 +3,30 @@
namespace API.Client { namespace API.Client {
'use strict'; 'use strict';
export interface Order { export interface Order {
id: number; id: number;
petId: number; petId: number;
quantity: number; quantity: number;
shipDate: Date; shipDate: Date;
/** /**
* Order Status * Order Status
*/ */
status: Order.StatusEnum; status: Order.StatusEnum;
complete: boolean; complete: boolean;
} }
export namespace Order { export namespace Order {
export enum StatusEnum { export enum StatusEnum {
placed = <any> 'placed', placed = <any> 'placed',
approved = <any> 'approved', approved = <any> 'approved',
delivered = <any> 'delivered', delivered = <any> 'delivered',
} }
} }
} }

View File

@ -3,65 +3,30 @@
namespace API.Client { namespace API.Client {
'use strict'; 'use strict';
export interface Pet { export interface Pet {
id: number; id: number;
category: Category; category: Category;
name: string; name: string;
photoUrls: Array<string>; photoUrls: Array<string>;
tags: Array<Tag>; tags: Array<Tag>;
/** /**
* pet status in the store * pet status in the store
*/ */
status: Pet.StatusEnum; status: Pet.StatusEnum;
} }
export namespace Pet { export namespace Pet {
export enum StatusEnum { export enum StatusEnum {
available = <any> 'available', available = <any> 'available',
pending = <any> 'pending', pending = <any> 'pending',
sold = <any> 'sold', sold = <any> 'sold',
} }
} }
} }

View File

@ -2,11 +2,9 @@
/* tslint:disable:no-unused-variable member-ordering */ /* tslint:disable:no-unused-variable member-ordering */
namespace API.Client { namespace API.Client {
'use strict'; 'use strict';
export class PetApi { export class PetApi {
protected basePath = 'http://petstore.swagger.io/v2'; protected basePath = 'http://petstore.swagger.io/v2';
public defaultHeaders : any = {}; public defaultHeaders : any = {};
@ -29,20 +27,11 @@ namespace API.Client {
} }
public updatePet (body?: Pet, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { public updatePet (body?: Pet, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const path = this.basePath + '/pet'; const path = this.basePath + '/pet';
let queryParameters: any = {}; let queryParameters: any = {};
let headerParams: any = this.extendObj({}, this.defaultHeaders); let headerParams: any = this.extendObj({}, this.defaultHeaders);
let httpRequestParams: any = { let httpRequestParams: any = {
method: 'PUT', method: 'PUT',
url: path, url: path,
@ -61,20 +50,11 @@ namespace API.Client {
return this.$http(httpRequestParams); return this.$http(httpRequestParams);
} }
public addPet (body?: Pet, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { public addPet (body?: Pet, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const path = this.basePath + '/pet'; const path = this.basePath + '/pet';
let queryParameters: any = {}; let queryParameters: any = {};
let headerParams: any = this.extendObj({}, this.defaultHeaders); let headerParams: any = this.extendObj({}, this.defaultHeaders);
let httpRequestParams: any = { let httpRequestParams: any = {
method: 'POST', method: 'POST',
url: path, url: path,
@ -93,25 +73,15 @@ namespace API.Client {
return this.$http(httpRequestParams); return this.$http(httpRequestParams);
} }
public findPetsByStatus (status?: Array<string>, extraHttpRequestParams?: any ) : ng.IHttpPromise<Array<Pet>> { public findPetsByStatus (status?: Array<string>, extraHttpRequestParams?: any ) : ng.IHttpPromise<Array<Pet>> {
const path = this.basePath + '/pet/findByStatus'; const path = this.basePath + '/pet/findByStatus';
let queryParameters: any = {}; let queryParameters: any = {};
let headerParams: any = this.extendObj({}, this.defaultHeaders); let headerParams: any = this.extendObj({}, this.defaultHeaders);
if (status !== undefined) { if (status !== undefined) {
queryParameters['status'] = status; queryParameters['status'] = status;
} }
let httpRequestParams: any = { let httpRequestParams: any = {
method: 'GET', method: 'GET',
url: path, url: path,
@ -129,25 +99,15 @@ namespace API.Client {
return this.$http(httpRequestParams); return this.$http(httpRequestParams);
} }
public findPetsByTags (tags?: Array<string>, extraHttpRequestParams?: any ) : ng.IHttpPromise<Array<Pet>> { public findPetsByTags (tags?: Array<string>, extraHttpRequestParams?: any ) : ng.IHttpPromise<Array<Pet>> {
const path = this.basePath + '/pet/findByTags'; const path = this.basePath + '/pet/findByTags';
let queryParameters: any = {}; let queryParameters: any = {};
let headerParams: any = this.extendObj({}, this.defaultHeaders); let headerParams: any = this.extendObj({}, this.defaultHeaders);
if (tags !== undefined) { if (tags !== undefined) {
queryParameters['tags'] = tags; queryParameters['tags'] = tags;
} }
let httpRequestParams: any = { let httpRequestParams: any = {
method: 'GET', method: 'GET',
url: path, url: path,
@ -165,26 +125,16 @@ namespace API.Client {
return this.$http(httpRequestParams); return this.$http(httpRequestParams);
} }
public getPetById (petId: number, extraHttpRequestParams?: any ) : ng.IHttpPromise<Pet> { public getPetById (petId: number, extraHttpRequestParams?: any ) : ng.IHttpPromise<Pet> {
const path = this.basePath + '/pet/{petId}' const path = this.basePath + '/pet/{petId}'
.replace('{' + 'petId' + '}', String(petId)); .replace('{' + 'petId' + '}', String(petId));
let queryParameters: any = {}; let queryParameters: any = {};
let headerParams: any = this.extendObj({}, this.defaultHeaders); let headerParams: any = this.extendObj({}, this.defaultHeaders);
// verify required parameter 'petId' is set // verify required parameter 'petId' is set
if (!petId) { if (!petId) {
throw new Error('Missing required parameter petId when calling getPetById'); throw new Error('Missing required parameter petId when calling getPetById');
} }
let httpRequestParams: any = { let httpRequestParams: any = {
method: 'GET', method: 'GET',
url: path, url: path,
@ -202,42 +152,24 @@ namespace API.Client {
return this.$http(httpRequestParams); return this.$http(httpRequestParams);
} }
public updatePetWithForm (petId: string, name?: string, status?: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { public updatePetWithForm (petId: string, name?: string, status?: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const path = this.basePath + '/pet/{petId}' const path = this.basePath + '/pet/{petId}'
.replace('{' + 'petId' + '}', String(petId)); .replace('{' + 'petId' + '}', String(petId));
let queryParameters: any = {}; let queryParameters: any = {};
let headerParams: any = this.extendObj({}, this.defaultHeaders); let headerParams: any = this.extendObj({}, this.defaultHeaders);
let formParams: any = {}; let formParams: any = {};
// verify required parameter 'petId' is set // verify required parameter 'petId' is set
if (!petId) { if (!petId) {
throw new Error('Missing required parameter petId when calling updatePetWithForm'); throw new Error('Missing required parameter petId when calling updatePetWithForm');
} }
headerParams['Content-Type'] = 'application/x-www-form-urlencoded'; headerParams['Content-Type'] = 'application/x-www-form-urlencoded';
formParams['name'] = name; formParams['name'] = name;
formParams['status'] = status; formParams['status'] = status;
let httpRequestParams: any = { let httpRequestParams: any = {
method: 'POST', method: 'POST',
url: path, url: path,
@ -256,31 +188,18 @@ namespace API.Client {
return this.$http(httpRequestParams); return this.$http(httpRequestParams);
} }
public deletePet (petId: number, apiKey?: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { public deletePet (petId: number, apiKey?: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const path = this.basePath + '/pet/{petId}' const path = this.basePath + '/pet/{petId}'
.replace('{' + 'petId' + '}', String(petId)); .replace('{' + 'petId' + '}', String(petId));
let queryParameters: any = {}; let queryParameters: any = {};
let headerParams: any = this.extendObj({}, this.defaultHeaders); let headerParams: any = this.extendObj({}, this.defaultHeaders);
// verify required parameter 'petId' is set // verify required parameter 'petId' is set
if (!petId) { if (!petId) {
throw new Error('Missing required parameter petId when calling deletePet'); throw new Error('Missing required parameter petId when calling deletePet');
} }
headerParams['api_key'] = apiKey; headerParams['api_key'] = apiKey;
let httpRequestParams: any = { let httpRequestParams: any = {
method: 'DELETE', method: 'DELETE',
url: path, url: path,
@ -298,42 +217,24 @@ namespace API.Client {
return this.$http(httpRequestParams); return this.$http(httpRequestParams);
} }
public uploadFile (petId: number, additionalMetadata?: string, file?: any, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { public uploadFile (petId: number, additionalMetadata?: string, file?: any, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const path = this.basePath + '/pet/{petId}/uploadImage' const path = this.basePath + '/pet/{petId}/uploadImage'
.replace('{' + 'petId' + '}', String(petId)); .replace('{' + 'petId' + '}', String(petId));
let queryParameters: any = {}; let queryParameters: any = {};
let headerParams: any = this.extendObj({}, this.defaultHeaders); let headerParams: any = this.extendObj({}, this.defaultHeaders);
let formParams: any = {}; let formParams: any = {};
// verify required parameter 'petId' is set // verify required parameter 'petId' is set
if (!petId) { if (!petId) {
throw new Error('Missing required parameter petId when calling uploadFile'); throw new Error('Missing required parameter petId when calling uploadFile');
} }
headerParams['Content-Type'] = 'application/x-www-form-urlencoded'; headerParams['Content-Type'] = 'application/x-www-form-urlencoded';
formParams['additionalMetadata'] = additionalMetadata; formParams['additionalMetadata'] = additionalMetadata;
formParams['file'] = file; formParams['file'] = file;
let httpRequestParams: any = { let httpRequestParams: any = {
method: 'POST', method: 'POST',
url: path, url: path,
@ -351,7 +252,5 @@ namespace API.Client {
return this.$http(httpRequestParams); return this.$http(httpRequestParams);
} }
} }
} }

View File

@ -2,26 +2,37 @@
/* tslint:disable:no-unused-variable member-ordering */ /* tslint:disable:no-unused-variable member-ordering */
module API.Client { namespace API.Client {
'use strict'; 'use strict';
export class StoreApi { export class StoreApi {
private basePath = 'http://petstore.swagger.io/v2'; protected basePath = 'http://petstore.swagger.io/v2';
public defaultHeaders : any = {};
static $inject: string[] = ['$http', '$httpParamSerializer']; static $inject: string[] = ['$http', '$httpParamSerializer'];
constructor(private $http: ng.IHttpService, basePath?: string, private $httpParamSerializer?: (any) => any) { constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) {
if (basePath) { if (basePath) {
this.basePath = basePath; this.basePath = basePath;
} }
} }
public getInventory (extraHttpRequestParams?: any ) : ng.IHttpPromise<{ [key: string]: number; }> { private extendObj<T1,T2>(objA: T1, objB: T2) {
var path = this.basePath + '/store/inventory'; for(let key in objB){
if(objB.hasOwnProperty(key)){
objA[key] = objB[key];
}
}
return <T1&T2>objA;
}
var queryParameters: any = {};
var headerParams: any = {}; public getInventory (extraHttpRequestParams?: any ) : ng.IHttpPromise<{ [key: string]: number; }> {
var httpRequestParams: any = { const path = this.basePath + '/store/inventory';
let queryParameters: any = {};
let headerParams: any = this.extendObj({}, this.defaultHeaders);
let httpRequestParams: any = {
method: 'GET', method: 'GET',
url: path, url: path,
json: true, json: true,
@ -32,22 +43,18 @@ module API.Client {
}; };
if (extraHttpRequestParams) { if (extraHttpRequestParams) {
for (var k in extraHttpRequestParams) { httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams);
if (extraHttpRequestParams.hasOwnProperty(k)) {
httpRequestParams[k] = extraHttpRequestParams[k];
}
}
} }
return this.$http(httpRequestParams); return this.$http(httpRequestParams);
} }
public placeOrder (body?: Order, extraHttpRequestParams?: any ) : ng.IHttpPromise<Order> { public placeOrder (body?: Order, extraHttpRequestParams?: any ) : ng.IHttpPromise<Order> {
var path = this.basePath + '/store/order'; const path = this.basePath + '/store/order';
var queryParameters: any = {}; let queryParameters: any = {};
var headerParams: any = {}; let headerParams: any = this.extendObj({}, this.defaultHeaders);
var httpRequestParams: any = { let httpRequestParams: any = {
method: 'POST', method: 'POST',
url: path, url: path,
json: true, json: true,
@ -59,29 +66,23 @@ module API.Client {
}; };
if (extraHttpRequestParams) { if (extraHttpRequestParams) {
for (var k in extraHttpRequestParams) { httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams);
if (extraHttpRequestParams.hasOwnProperty(k)) {
httpRequestParams[k] = extraHttpRequestParams[k];
}
}
} }
return this.$http(httpRequestParams); return this.$http(httpRequestParams);
} }
public getOrderById (orderId: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<Order> { public getOrderById (orderId: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<Order> {
var path = this.basePath + '/store/order/{orderId}'; const path = this.basePath + '/store/order/{orderId}'
.replace('{' + 'orderId' + '}', String(orderId));
path = path.replace('{' + 'orderId' + '}', String(orderId)); let queryParameters: any = {};
let headerParams: any = this.extendObj({}, this.defaultHeaders);
var queryParameters: any = {};
var headerParams: any = {};
// verify required parameter 'orderId' is set // verify required parameter 'orderId' is set
if (!orderId) { if (!orderId) {
throw new Error('Missing required parameter orderId when calling getOrderById'); throw new Error('Missing required parameter orderId when calling getOrderById');
} }
let httpRequestParams: any = {
var httpRequestParams: any = {
method: 'GET', method: 'GET',
url: path, url: path,
json: true, json: true,
@ -92,29 +93,23 @@ module API.Client {
}; };
if (extraHttpRequestParams) { if (extraHttpRequestParams) {
for (var k in extraHttpRequestParams) { httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams);
if (extraHttpRequestParams.hasOwnProperty(k)) {
httpRequestParams[k] = extraHttpRequestParams[k];
}
}
} }
return this.$http(httpRequestParams); return this.$http(httpRequestParams);
} }
public deleteOrder (orderId: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { public deleteOrder (orderId: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
var path = this.basePath + '/store/order/{orderId}'; const path = this.basePath + '/store/order/{orderId}'
.replace('{' + 'orderId' + '}', String(orderId));
path = path.replace('{' + 'orderId' + '}', String(orderId)); let queryParameters: any = {};
let headerParams: any = this.extendObj({}, this.defaultHeaders);
var queryParameters: any = {};
var headerParams: any = {};
// verify required parameter 'orderId' is set // verify required parameter 'orderId' is set
if (!orderId) { if (!orderId) {
throw new Error('Missing required parameter orderId when calling deleteOrder'); throw new Error('Missing required parameter orderId when calling deleteOrder');
} }
let httpRequestParams: any = {
var httpRequestParams: any = {
method: 'DELETE', method: 'DELETE',
url: path, url: path,
json: true, json: true,
@ -125,11 +120,7 @@ module API.Client {
}; };
if (extraHttpRequestParams) { if (extraHttpRequestParams) {
for (var k in extraHttpRequestParams) { httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams);
if (extraHttpRequestParams.hasOwnProperty(k)) {
httpRequestParams[k] = extraHttpRequestParams[k];
}
}
} }
return this.$http(httpRequestParams); return this.$http(httpRequestParams);

View File

@ -3,22 +3,11 @@
namespace API.Client { namespace API.Client {
'use strict'; 'use strict';
export interface Tag { export interface Tag {
id: number; id: number;
name: string; name: string;
} }
} }

View File

@ -3,50 +3,26 @@
namespace API.Client { namespace API.Client {
'use strict'; 'use strict';
export interface User { export interface User {
id: number; id: number;
username: string; username: string;
firstName: string; firstName: string;
lastName: string; lastName: string;
email: string; email: string;
password: string; password: string;
phone: string; phone: string;
/** /**
* User Status * User Status
*/ */
userStatus: number; userStatus: number;
} }
} }

View File

@ -2,26 +2,37 @@
/* tslint:disable:no-unused-variable member-ordering */ /* tslint:disable:no-unused-variable member-ordering */
module API.Client { namespace API.Client {
'use strict'; 'use strict';
export class UserApi { export class UserApi {
private basePath = 'http://petstore.swagger.io/v2'; protected basePath = 'http://petstore.swagger.io/v2';
public defaultHeaders : any = {};
static $inject: string[] = ['$http', '$httpParamSerializer']; static $inject: string[] = ['$http', '$httpParamSerializer'];
constructor(private $http: ng.IHttpService, basePath?: string, private $httpParamSerializer?: (any) => any) { constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) {
if (basePath) { if (basePath) {
this.basePath = basePath; this.basePath = basePath;
} }
} }
public createUser (body?: User, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { private extendObj<T1,T2>(objA: T1, objB: T2) {
var path = this.basePath + '/user'; for(let key in objB){
if(objB.hasOwnProperty(key)){
objA[key] = objB[key];
}
}
return <T1&T2>objA;
}
var queryParameters: any = {};
var headerParams: any = {}; public createUser (body?: User, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
var httpRequestParams: any = { const path = this.basePath + '/user';
let queryParameters: any = {};
let headerParams: any = this.extendObj({}, this.defaultHeaders);
let httpRequestParams: any = {
method: 'POST', method: 'POST',
url: path, url: path,
json: true, json: true,
@ -33,22 +44,18 @@ module API.Client {
}; };
if (extraHttpRequestParams) { if (extraHttpRequestParams) {
for (var k in extraHttpRequestParams) { httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams);
if (extraHttpRequestParams.hasOwnProperty(k)) {
httpRequestParams[k] = extraHttpRequestParams[k];
}
}
} }
return this.$http(httpRequestParams); return this.$http(httpRequestParams);
} }
public createUsersWithArrayInput (body?: Array<User>, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { public createUsersWithArrayInput (body?: Array<User>, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
var path = this.basePath + '/user/createWithArray'; const path = this.basePath + '/user/createWithArray';
var queryParameters: any = {}; let queryParameters: any = {};
var headerParams: any = {}; let headerParams: any = this.extendObj({}, this.defaultHeaders);
var httpRequestParams: any = { let httpRequestParams: any = {
method: 'POST', method: 'POST',
url: path, url: path,
json: true, json: true,
@ -60,22 +67,18 @@ module API.Client {
}; };
if (extraHttpRequestParams) { if (extraHttpRequestParams) {
for (var k in extraHttpRequestParams) { httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams);
if (extraHttpRequestParams.hasOwnProperty(k)) {
httpRequestParams[k] = extraHttpRequestParams[k];
}
}
} }
return this.$http(httpRequestParams); return this.$http(httpRequestParams);
} }
public createUsersWithListInput (body?: Array<User>, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { public createUsersWithListInput (body?: Array<User>, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
var path = this.basePath + '/user/createWithList'; const path = this.basePath + '/user/createWithList';
var queryParameters: any = {}; let queryParameters: any = {};
var headerParams: any = {}; let headerParams: any = this.extendObj({}, this.defaultHeaders);
var httpRequestParams: any = { let httpRequestParams: any = {
method: 'POST', method: 'POST',
url: path, url: path,
json: true, json: true,
@ -87,21 +90,17 @@ module API.Client {
}; };
if (extraHttpRequestParams) { if (extraHttpRequestParams) {
for (var k in extraHttpRequestParams) { httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams);
if (extraHttpRequestParams.hasOwnProperty(k)) {
httpRequestParams[k] = extraHttpRequestParams[k];
}
}
} }
return this.$http(httpRequestParams); return this.$http(httpRequestParams);
} }
public loginUser (username?: string, password?: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<string> { public loginUser (username?: string, password?: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<string> {
var path = this.basePath + '/user/login'; const path = this.basePath + '/user/login';
var queryParameters: any = {}; let queryParameters: any = {};
var headerParams: any = {}; let headerParams: any = this.extendObj({}, this.defaultHeaders);
if (username !== undefined) { if (username !== undefined) {
queryParameters['username'] = username; queryParameters['username'] = username;
} }
@ -110,7 +109,7 @@ module API.Client {
queryParameters['password'] = password; queryParameters['password'] = password;
} }
var httpRequestParams: any = { let httpRequestParams: any = {
method: 'GET', method: 'GET',
url: path, url: path,
json: true, json: true,
@ -121,22 +120,18 @@ module API.Client {
}; };
if (extraHttpRequestParams) { if (extraHttpRequestParams) {
for (var k in extraHttpRequestParams) { httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams);
if (extraHttpRequestParams.hasOwnProperty(k)) {
httpRequestParams[k] = extraHttpRequestParams[k];
}
}
} }
return this.$http(httpRequestParams); return this.$http(httpRequestParams);
} }
public logoutUser (extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { public logoutUser (extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
var path = this.basePath + '/user/logout'; const path = this.basePath + '/user/logout';
var queryParameters: any = {}; let queryParameters: any = {};
var headerParams: any = {}; let headerParams: any = this.extendObj({}, this.defaultHeaders);
var httpRequestParams: any = { let httpRequestParams: any = {
method: 'GET', method: 'GET',
url: path, url: path,
json: true, json: true,
@ -147,29 +142,23 @@ module API.Client {
}; };
if (extraHttpRequestParams) { if (extraHttpRequestParams) {
for (var k in extraHttpRequestParams) { httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams);
if (extraHttpRequestParams.hasOwnProperty(k)) {
httpRequestParams[k] = extraHttpRequestParams[k];
}
}
} }
return this.$http(httpRequestParams); return this.$http(httpRequestParams);
} }
public getUserByName (username: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<User> { public getUserByName (username: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<User> {
var path = this.basePath + '/user/{username}'; const path = this.basePath + '/user/{username}'
.replace('{' + 'username' + '}', String(username));
path = path.replace('{' + 'username' + '}', String(username)); let queryParameters: any = {};
let headerParams: any = this.extendObj({}, this.defaultHeaders);
var queryParameters: any = {};
var headerParams: any = {};
// verify required parameter 'username' is set // verify required parameter 'username' is set
if (!username) { if (!username) {
throw new Error('Missing required parameter username when calling getUserByName'); throw new Error('Missing required parameter username when calling getUserByName');
} }
let httpRequestParams: any = {
var httpRequestParams: any = {
method: 'GET', method: 'GET',
url: path, url: path,
json: true, json: true,
@ -180,29 +169,23 @@ module API.Client {
}; };
if (extraHttpRequestParams) { if (extraHttpRequestParams) {
for (var k in extraHttpRequestParams) { httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams);
if (extraHttpRequestParams.hasOwnProperty(k)) {
httpRequestParams[k] = extraHttpRequestParams[k];
}
}
} }
return this.$http(httpRequestParams); return this.$http(httpRequestParams);
} }
public updateUser (username: string, body?: User, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { public updateUser (username: string, body?: User, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
var path = this.basePath + '/user/{username}'; const path = this.basePath + '/user/{username}'
.replace('{' + 'username' + '}', String(username));
path = path.replace('{' + 'username' + '}', String(username)); let queryParameters: any = {};
let headerParams: any = this.extendObj({}, this.defaultHeaders);
var queryParameters: any = {};
var headerParams: any = {};
// verify required parameter 'username' is set // verify required parameter 'username' is set
if (!username) { if (!username) {
throw new Error('Missing required parameter username when calling updateUser'); throw new Error('Missing required parameter username when calling updateUser');
} }
let httpRequestParams: any = {
var httpRequestParams: any = {
method: 'PUT', method: 'PUT',
url: path, url: path,
json: true, json: true,
@ -214,29 +197,23 @@ module API.Client {
}; };
if (extraHttpRequestParams) { if (extraHttpRequestParams) {
for (var k in extraHttpRequestParams) { httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams);
if (extraHttpRequestParams.hasOwnProperty(k)) {
httpRequestParams[k] = extraHttpRequestParams[k];
}
}
} }
return this.$http(httpRequestParams); return this.$http(httpRequestParams);
} }
public deleteUser (username: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> { public deleteUser (username: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
var path = this.basePath + '/user/{username}'; const path = this.basePath + '/user/{username}'
.replace('{' + 'username' + '}', String(username));
path = path.replace('{' + 'username' + '}', String(username)); let queryParameters: any = {};
let headerParams: any = this.extendObj({}, this.defaultHeaders);
var queryParameters: any = {};
var headerParams: any = {};
// verify required parameter 'username' is set // verify required parameter 'username' is set
if (!username) { if (!username) {
throw new Error('Missing required parameter username when calling deleteUser'); throw new Error('Missing required parameter username when calling deleteUser');
} }
let httpRequestParams: any = {
var httpRequestParams: any = {
method: 'DELETE', method: 'DELETE',
url: path, url: path,
json: true, json: true,
@ -247,11 +224,7 @@ module API.Client {
}; };
if (extraHttpRequestParams) { if (extraHttpRequestParams) {
for (var k in extraHttpRequestParams) { httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams);
if (extraHttpRequestParams.hasOwnProperty(k)) {
httpRequestParams[k] = extraHttpRequestParams[k];
}
}
} }
return this.$http(httpRequestParams); return this.$http(httpRequestParams);

File diff suppressed because it is too large Load Diff