Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export enum {{classname}}ApiKeys {
export class {{classname}} {
protected basePath = defaultBasePath;
protected defaultHeaders : any = {};
protected _useQuerystring : boolean = false;

protected authentications = {
'default': <Authentication>new VoidAuth(),
Expand Down Expand Up @@ -151,12 +152,15 @@ export class {{classname}} {
}
}

set useQuerystring(value: boolean) {
this._useQuerystring = value;
}

public setApiKey(key: {{classname}}ApiKeys, value: string) {
this.authentications[{{classname}}ApiKeys[key]].apiKey = value;
}
{{#authMethods}}
{{#isBasic}}

set username(username: string) {
this.authentications.{{name}}.username = username;
}
Expand Down Expand Up @@ -225,6 +229,7 @@ export class {{classname}} {
qs: queryParameters,
headers: headerParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
{{#bodyParam}}
body: {{paramName}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
"repository": "{{gitUserId}}/{{gitRepoId}}",
"main": "api.js",
"scripts": {
"postinstall": "typings install",
"clean": "rm -Rf node_modules/ typings/ *.js",
"build": "typings install && tsc"
"build": "tsc",
"test": "npm run build && node client.js"
},
"author": "Swagger Codegen Contributors",
"license": "Apache-2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
"noLib": false,
"declaration": true
},
"files": [
"api.ts",
"typings/main.d.ts"
"exclude": [
"node_modules",
"typings/browser",
"typings/browser.d.ts"
]
}

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"ambientDependencies": {
"bluebird": "registry:dt/bluebird#2.0.0+20160319051630",
"core-js": "registry:dt/core-js#0.0.0+20160317120654",
"node": "registry:dt/node#4.0.0+20160423143914"
},
"dependencies": {
"bluebird": "registry:npm/bluebird#3.3.4+20160515010139",
"request": "registry:npm/request#2.69.0+20160304121250"
}
}
45 changes: 40 additions & 5 deletions samples/client/petstore/typescript-node/default/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,12 @@ export enum PetApiApiKeys {
export class PetApi {
protected basePath = defaultBasePath;
protected defaultHeaders : any = {};
protected _useQuerystring : boolean = false;

protected authentications = {
'default': <Authentication>new VoidAuth(),
'api_key': new ApiKeyAuth('header', 'api_key'),
'petstore_auth': new OAuth(),
'api_key': new ApiKeyAuth('header', 'api_key'),
}

constructor(basePath?: string);
Expand All @@ -148,6 +149,10 @@ export class PetApi {
}
}

set useQuerystring(value: boolean) {
this._useQuerystring = value;
}

public setApiKey(key: PetApiApiKeys, value: string) {
this.authentications[PetApiApiKeys[key]].apiKey = value;
}
Expand Down Expand Up @@ -183,6 +188,7 @@ export class PetApi {
qs: queryParameters,
headers: headerParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
body: body,
};
Expand Down Expand Up @@ -240,6 +246,7 @@ export class PetApi {
qs: queryParameters,
headers: headerParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};

Expand Down Expand Up @@ -291,6 +298,7 @@ export class PetApi {
qs: queryParameters,
headers: headerParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};

Expand Down Expand Up @@ -342,6 +350,7 @@ export class PetApi {
qs: queryParameters,
headers: headerParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};

Expand Down Expand Up @@ -395,13 +404,14 @@ export class PetApi {
qs: queryParameters,
headers: headerParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};

this.authentications.api_key.applyToRequest(requestOptions);

this.authentications.petstore_auth.applyToRequest(requestOptions);

this.authentications.api_key.applyToRequest(requestOptions);

this.authentications.default.applyToRequest(requestOptions);

if (Object.keys(formParams).length) {
Expand Down Expand Up @@ -444,6 +454,7 @@ export class PetApi {
qs: queryParameters,
headers: headerParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
body: body,
};
Expand Down Expand Up @@ -508,6 +519,7 @@ export class PetApi {
qs: queryParameters,
headers: headerParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};

Expand Down Expand Up @@ -572,6 +584,7 @@ export class PetApi {
qs: queryParameters,
headers: headerParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};

Expand Down Expand Up @@ -607,11 +620,12 @@ export enum StoreApiApiKeys {
export class StoreApi {
protected basePath = defaultBasePath;
protected defaultHeaders : any = {};
protected _useQuerystring : boolean = false;

protected authentications = {
'default': <Authentication>new VoidAuth(),
'api_key': new ApiKeyAuth('header', 'api_key'),
'petstore_auth': new OAuth(),
'api_key': new ApiKeyAuth('header', 'api_key'),
}

constructor(basePath?: string);
Expand All @@ -627,6 +641,10 @@ export class StoreApi {
}
}

set useQuerystring(value: boolean) {
this._useQuerystring = value;
}

public setApiKey(key: StoreApiApiKeys, value: string) {
this.authentications[StoreApiApiKeys[key]].apiKey = value;
}
Expand Down Expand Up @@ -668,6 +686,7 @@ export class StoreApi {
qs: queryParameters,
headers: headerParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};

Expand Down Expand Up @@ -712,6 +731,7 @@ export class StoreApi {
qs: queryParameters,
headers: headerParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};

Expand Down Expand Up @@ -765,6 +785,7 @@ export class StoreApi {
qs: queryParameters,
headers: headerParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};

Expand Down Expand Up @@ -810,6 +831,7 @@ export class StoreApi {
qs: queryParameters,
headers: headerParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
body: body,
};
Expand Down Expand Up @@ -844,11 +866,12 @@ export enum UserApiApiKeys {
export class UserApi {
protected basePath = defaultBasePath;
protected defaultHeaders : any = {};
protected _useQuerystring : boolean = false;

protected authentications = {
'default': <Authentication>new VoidAuth(),
'api_key': new ApiKeyAuth('header', 'api_key'),
'petstore_auth': new OAuth(),
'api_key': new ApiKeyAuth('header', 'api_key'),
}

constructor(basePath?: string);
Expand All @@ -864,6 +887,10 @@ export class UserApi {
}
}

set useQuerystring(value: boolean) {
this._useQuerystring = value;
}

public setApiKey(key: UserApiApiKeys, value: string) {
this.authentications[UserApiApiKeys[key]].apiKey = value;
}
Expand Down Expand Up @@ -899,6 +926,7 @@ export class UserApi {
qs: queryParameters,
headers: headerParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
body: body,
};
Expand Down Expand Up @@ -945,6 +973,7 @@ export class UserApi {
qs: queryParameters,
headers: headerParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
body: body,
};
Expand Down Expand Up @@ -991,6 +1020,7 @@ export class UserApi {
qs: queryParameters,
headers: headerParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
body: body,
};
Expand Down Expand Up @@ -1043,6 +1073,7 @@ export class UserApi {
qs: queryParameters,
headers: headerParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};

Expand Down Expand Up @@ -1094,6 +1125,7 @@ export class UserApi {
qs: queryParameters,
headers: headerParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};

Expand Down Expand Up @@ -1148,6 +1180,7 @@ export class UserApi {
qs: queryParameters,
headers: headerParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};

Expand Down Expand Up @@ -1192,6 +1225,7 @@ export class UserApi {
qs: queryParameters,
headers: headerParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
};

Expand Down Expand Up @@ -1244,6 +1278,7 @@ export class UserApi {
qs: queryParameters,
headers: headerParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
body: body,
};
Expand Down
2 changes: 2 additions & 0 deletions samples/client/petstore/typescript-node/npm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.js
*.map
7 changes: 7 additions & 0 deletions samples/client/petstore/typescript-node/npm/api.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import request = require('request');
import http = require('http');
import Promise = require('bluebird');
export declare class Category {
'id': number;
'name': string;
Expand Down Expand Up @@ -78,12 +79,14 @@ export declare enum PetApiApiKeys {
export declare class PetApi {
protected basePath: string;
protected defaultHeaders: any;
protected _useQuerystring: boolean;
protected authentications: {
'default': Authentication;
'petstore_auth': OAuth;
'api_key': ApiKeyAuth;
};
constructor(basePath?: string);
useQuerystring: boolean;
setApiKey(key: PetApiApiKeys, value: string): void;
accessToken: string;
private extendObj<T1, T2>(objA, objB);
Expand Down Expand Up @@ -126,12 +129,14 @@ export declare enum StoreApiApiKeys {
export declare class StoreApi {
protected basePath: string;
protected defaultHeaders: any;
protected _useQuerystring: boolean;
protected authentications: {
'default': Authentication;
'petstore_auth': OAuth;
'api_key': ApiKeyAuth;
};
constructor(basePath?: string);
useQuerystring: boolean;
setApiKey(key: StoreApiApiKeys, value: string): void;
accessToken: string;
private extendObj<T1, T2>(objA, objB);
Expand Down Expand Up @@ -160,12 +165,14 @@ export declare enum UserApiApiKeys {
export declare class UserApi {
protected basePath: string;
protected defaultHeaders: any;
protected _useQuerystring: boolean;
protected authentications: {
'default': Authentication;
'petstore_auth': OAuth;
'api_key': ApiKeyAuth;
};
constructor(basePath?: string);
useQuerystring: boolean;
setApiKey(key: UserApiApiKeys, value: string): void;
accessToken: string;
private extendObj<T1, T2>(objA, objB);
Expand Down
Loading