Ts node angular2 typings (#6178)

* removed typings for typescript-node language and updated typescript version

* updated sample of typescript-node by running .\bin\windows\typescript-node.bat
This commit is contained in:
Duan Shiqiang 2017-07-26 20:29:46 +08:00 committed by wing328
parent e807b81471
commit f9eaef8f24
5 changed files with 132 additions and 41 deletions

View File

@ -77,7 +77,6 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
//Files for building our lib //Files for building our lib
supportingFiles.add(new SupportingFile("package.mustache", getPackageRootDirectory(), "package.json")); supportingFiles.add(new SupportingFile("package.mustache", getPackageRootDirectory(), "package.json"));
supportingFiles.add(new SupportingFile("typings.mustache", getPackageRootDirectory(), "typings.json"));
supportingFiles.add(new SupportingFile("tsconfig.mustache", getPackageRootDirectory(), "tsconfig.json")); supportingFiles.add(new SupportingFile("tsconfig.mustache", getPackageRootDirectory(), "tsconfig.json"));
} }

View File

@ -4,21 +4,22 @@
"description": "NodeJS client for {{npmName}}", "description": "NodeJS client for {{npmName}}",
"repository": "{{gitUserId}}/{{gitRepoId}}", "repository": "{{gitUserId}}/{{gitRepoId}}",
"main": "api.js", "main": "api.js",
"types": "api.d.ts",
"scripts": { "scripts": {
"postinstall": "typings install", "clean": "rm -Rf node_modules/ *.js",
"clean": "rm -Rf node_modules/ typings/ *.js",
"build": "tsc", "build": "tsc",
"test": "npm run build && node client.js" "test": "npm run build && node client.js"
}, },
"author": "Swagger Codegen Contributors", "author": "Swagger Codegen Contributors",
"license": "Unlicense", "license": "Unlicense",
"dependencies": { "dependencies": {
"bluebird": "^3.3.5", "bluebird": "^3.5.0",
"request": "^2.72.0" "request": "^2.81.0",
"@types/bluebird": "*",
"@types/request": "*"
}, },
"devDependencies": { "devDependencies": {
"typescript": "^1.8.10", "typescript": "^2.4.2"
"typings": "^0.8.1"
}{{#npmRepository}}, }{{#npmRepository}},
"publishConfig":{ "publishConfig":{
"registry":"{{npmRepository}}" "registry":"{{npmRepository}}"

View File

@ -8,12 +8,11 @@
"removeComments": true, "removeComments": true,
"sourceMap": true, "sourceMap": true,
"noLib": false, "noLib": false,
"declaration": true "declaration": true,
"lib": ["dom", "es6", "es5", "dom.iterable", "scripthost"]
}, },
"exclude": [ "exclude": [
"node_modules", "node_modules"
"typings/browser",
"typings/browser.d.ts"
] ]
} }

View File

@ -1,10 +0,0 @@
{
"ambientDependencies": {
"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"
}
}

View File

@ -1,9 +1,9 @@
/** /**
* Swagger Petstore * Swagger Petstore
* This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
* *
* OpenAPI spec version: 1.0.0 * OpenAPI spec version: 1.0.0
* Contact: apiteam@wordnik.com * Contact: apiteam@swagger.io
* *
* NOTE: This class is auto generated by the swagger code generator program. * NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
@ -136,6 +136,41 @@ class ObjectSerializer {
} }
} }
/**
* Describes the result of uploading an image resource
*/
export class ApiResponse {
'code': number;
'type': string;
'message': string;
static discriminator = undefined;
static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
{
"name": "code",
"baseName": "code",
"type": "number"
},
{
"name": "type",
"baseName": "type",
"type": "string"
},
{
"name": "message",
"baseName": "message",
"type": "string"
} ];
static getAttributeTypeMap() {
return ApiResponse.attributeTypeMap;
}
}
/**
* A category for a pet
*/
export class Category { export class Category {
'id': number; 'id': number;
'name': string; 'name': string;
@ -159,6 +194,9 @@ export class Category {
} }
} }
/**
* An order for a pets from the pet store
*/
export class Order { export class Order {
'id': number; 'id': number;
'petId': number; 'petId': number;
@ -216,6 +254,9 @@ export namespace Order {
Delivered = <any> 'delivered' Delivered = <any> 'delivered'
} }
} }
/**
* A pet for sale in the pet store
*/
export class Pet { export class Pet {
'id': number; 'id': number;
'category': Category; 'category': Category;
@ -273,6 +314,9 @@ export namespace Pet {
Sold = <any> 'sold' Sold = <any> 'sold'
} }
} }
/**
* A tag for a pet
*/
export class Tag { export class Tag {
'id': number; 'id': number;
'name': string; 'name': string;
@ -296,6 +340,9 @@ export class Tag {
} }
} }
/**
* A User who is purchasing from the pet store
*/
export class User { export class User {
'id': number; 'id': number;
'username': string; 'username': string;
@ -365,6 +412,7 @@ let enumsMap = {
} }
let typeMap = { let typeMap = {
"ApiResponse": ApiResponse,
"Category": Category, "Category": Category,
"Order": Order, "Order": Order,
"Pet": Pet, "Pet": Pet,
@ -478,13 +526,18 @@ export class PetApi {
* @summary Add a new pet to the store * @summary Add a new pet to the store
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
public addPet (body?: Pet) : Promise<{ response: http.ClientResponse; body?: any; }> { public addPet (body: Pet) : Promise<{ response: http.ClientResponse; body?: any; }> {
const localVarPath = this.basePath + '/pet'; const localVarPath = this.basePath + '/pet';
let queryParameters: any = {}; let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders); let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let formParams: any = {}; let formParams: any = {};
// verify required parameter 'body' is not null or undefined
if (body === null || body === undefined) {
throw new Error('Required parameter body was null or undefined when calling addPet.');
}
let useFormData = false; let useFormData = false;
@ -585,13 +638,18 @@ export class PetApi {
* @summary Finds Pets by status * @summary Finds Pets by status
* @param status Status values that need to be considered for filter * @param status Status values that need to be considered for filter
*/ */
public findPetsByStatus (status?: Array<string>) : Promise<{ response: http.ClientResponse; body: Array<Pet>; }> { public findPetsByStatus (status: Array<string>) : Promise<{ response: http.ClientResponse; body: Array<Pet>; }> {
const localVarPath = this.basePath + '/pet/findByStatus'; const localVarPath = this.basePath + '/pet/findByStatus';
let queryParameters: any = {}; let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders); let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let formParams: any = {}; let formParams: any = {};
// verify required parameter 'status' is not null or undefined
if (status === null || status === undefined) {
throw new Error('Required parameter status was null or undefined when calling findPetsByStatus.');
}
if (status !== undefined) { if (status !== undefined) {
queryParameters['status'] = ObjectSerializer.serialize(status, "Array<string>"); queryParameters['status'] = ObjectSerializer.serialize(status, "Array<string>");
} }
@ -639,13 +697,18 @@ export class PetApi {
* @summary Finds Pets by tags * @summary Finds Pets by tags
* @param tags Tags to filter by * @param tags Tags to filter by
*/ */
public findPetsByTags (tags?: Array<string>) : Promise<{ response: http.ClientResponse; body: Array<Pet>; }> { public findPetsByTags (tags: Array<string>) : Promise<{ response: http.ClientResponse; body: Array<Pet>; }> {
const localVarPath = this.basePath + '/pet/findByTags'; const localVarPath = this.basePath + '/pet/findByTags';
let queryParameters: any = {}; let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders); let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let formParams: any = {}; let formParams: any = {};
// verify required parameter 'tags' is not null or undefined
if (tags === null || tags === undefined) {
throw new Error('Required parameter tags was null or undefined when calling findPetsByTags.');
}
if (tags !== undefined) { if (tags !== undefined) {
queryParameters['tags'] = ObjectSerializer.serialize(tags, "Array<string>"); queryParameters['tags'] = ObjectSerializer.serialize(tags, "Array<string>");
} }
@ -689,9 +752,9 @@ export class PetApi {
}); });
} }
/** /**
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * Returns a single pet
* @summary Find pet by ID * @summary Find pet by ID
* @param petId ID of pet that needs to be fetched * @param petId ID of pet to return
*/ */
public getPetById (petId: number) : Promise<{ response: http.ClientResponse; body: Pet; }> { public getPetById (petId: number) : Promise<{ response: http.ClientResponse; body: Pet; }> {
const localVarPath = this.basePath + '/pet/{petId}' const localVarPath = this.basePath + '/pet/{petId}'
@ -720,8 +783,6 @@ export class PetApi {
this.authentications.api_key.applyToRequest(requestOptions); this.authentications.api_key.applyToRequest(requestOptions);
this.authentications.petstore_auth.applyToRequest(requestOptions);
this.authentications.default.applyToRequest(requestOptions); this.authentications.default.applyToRequest(requestOptions);
if (Object.keys(formParams).length) { if (Object.keys(formParams).length) {
@ -751,13 +812,18 @@ export class PetApi {
* @summary Update an existing pet * @summary Update an existing pet
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
public updatePet (body?: Pet) : Promise<{ response: http.ClientResponse; body?: any; }> { public updatePet (body: Pet) : Promise<{ response: http.ClientResponse; body?: any; }> {
const localVarPath = this.basePath + '/pet'; const localVarPath = this.basePath + '/pet';
let queryParameters: any = {}; let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders); let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let formParams: any = {}; let formParams: any = {};
// verify required parameter 'body' is not null or undefined
if (body === null || body === undefined) {
throw new Error('Required parameter body was null or undefined when calling updatePet.');
}
let useFormData = false; let useFormData = false;
@ -803,7 +869,7 @@ export class PetApi {
* @param name Updated name of the pet * @param name Updated name of the pet
* @param status Updated status of the pet * @param status Updated status of the pet
*/ */
public updatePetWithForm (petId: string, name?: string, status?: string) : Promise<{ response: http.ClientResponse; body?: any; }> { public updatePetWithForm (petId: number, name?: string, status?: string) : Promise<{ response: http.ClientResponse; body?: any; }> {
const localVarPath = this.basePath + '/pet/{petId}' const localVarPath = this.basePath + '/pet/{petId}'
.replace('{' + 'petId' + '}', String(petId)); .replace('{' + 'petId' + '}', String(petId));
let queryParameters: any = {}; let queryParameters: any = {};
@ -868,7 +934,7 @@ export class PetApi {
* @param additionalMetadata Additional data to pass to server * @param additionalMetadata Additional data to pass to server
* @param file file to upload * @param file file to upload
*/ */
public uploadFile (petId: number, additionalMetadata?: string, file?: Buffer) : Promise<{ response: http.ClientResponse; body?: any; }> { public uploadFile (petId: number, additionalMetadata?: string, file?: Buffer) : Promise<{ response: http.ClientResponse; body: ApiResponse; }> {
const localVarPath = this.basePath + '/pet/{petId}/uploadImage' const localVarPath = this.basePath + '/pet/{petId}/uploadImage'
.replace('{' + 'petId' + '}', String(petId)); .replace('{' + 'petId' + '}', String(petId));
let queryParameters: any = {}; let queryParameters: any = {};
@ -913,11 +979,12 @@ export class PetApi {
requestOptions.form = formParams; requestOptions.form = formParams;
} }
} }
return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => { return new Promise<{ response: http.ClientResponse; body: ApiResponse; }>((resolve, reject) => {
request(requestOptions, (error, response, body) => { request(requestOptions, (error, response, body) => {
if (error) { if (error) {
reject(error); reject(error);
} else { } else {
body = ObjectSerializer.deserialize(body, "ApiResponse");
if (response.statusCode >= 200 && response.statusCode <= 299) { if (response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body }); resolve({ response: response, body: body });
} else { } else {
@ -1086,7 +1153,7 @@ export class StoreApi {
* @summary Find purchase order by ID * @summary Find purchase order by ID
* @param orderId ID of pet that needs to be fetched * @param orderId ID of pet that needs to be fetched
*/ */
public getOrderById (orderId: string) : Promise<{ response: http.ClientResponse; body: Order; }> { public getOrderById (orderId: number) : Promise<{ response: http.ClientResponse; body: Order; }> {
const localVarPath = this.basePath + '/store/order/{orderId}' const localVarPath = this.basePath + '/store/order/{orderId}'
.replace('{' + 'orderId' + '}', String(orderId)); .replace('{' + 'orderId' + '}', String(orderId));
let queryParameters: any = {}; let queryParameters: any = {};
@ -1140,13 +1207,18 @@ export class StoreApi {
* @summary Place an order for a pet * @summary Place an order for a pet
* @param body order placed for purchasing the pet * @param body order placed for purchasing the pet
*/ */
public placeOrder (body?: Order) : Promise<{ response: http.ClientResponse; body: Order; }> { public placeOrder (body: Order) : Promise<{ response: http.ClientResponse; body: Order; }> {
const localVarPath = this.basePath + '/store/order'; const localVarPath = this.basePath + '/store/order';
let queryParameters: any = {}; let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders); let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let formParams: any = {}; let formParams: any = {};
// verify required parameter 'body' is not null or undefined
if (body === null || body === undefined) {
throw new Error('Required parameter body was null or undefined when calling placeOrder.');
}
let useFormData = false; let useFormData = false;
@ -1241,13 +1313,18 @@ export class UserApi {
* @summary Create user * @summary Create user
* @param body Created user object * @param body Created user object
*/ */
public createUser (body?: User) : Promise<{ response: http.ClientResponse; body?: any; }> { public createUser (body: User) : Promise<{ response: http.ClientResponse; body?: any; }> {
const localVarPath = this.basePath + '/user'; const localVarPath = this.basePath + '/user';
let queryParameters: any = {}; let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders); let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let formParams: any = {}; let formParams: any = {};
// verify required parameter 'body' is not null or undefined
if (body === null || body === undefined) {
throw new Error('Required parameter body was null or undefined when calling createUser.');
}
let useFormData = false; let useFormData = false;
@ -1289,13 +1366,18 @@ export class UserApi {
* @summary Creates list of users with given input array * @summary Creates list of users with given input array
* @param body List of user object * @param body List of user object
*/ */
public createUsersWithArrayInput (body?: Array<User>) : Promise<{ response: http.ClientResponse; body?: any; }> { public createUsersWithArrayInput (body: Array<User>) : Promise<{ response: http.ClientResponse; body?: any; }> {
const localVarPath = this.basePath + '/user/createWithArray'; const localVarPath = this.basePath + '/user/createWithArray';
let queryParameters: any = {}; let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders); let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let formParams: any = {}; let formParams: any = {};
// verify required parameter 'body' is not null or undefined
if (body === null || body === undefined) {
throw new Error('Required parameter body was null or undefined when calling createUsersWithArrayInput.');
}
let useFormData = false; let useFormData = false;
@ -1337,13 +1419,18 @@ export class UserApi {
* @summary Creates list of users with given input array * @summary Creates list of users with given input array
* @param body List of user object * @param body List of user object
*/ */
public createUsersWithListInput (body?: Array<User>) : Promise<{ response: http.ClientResponse; body?: any; }> { public createUsersWithListInput (body: Array<User>) : Promise<{ response: http.ClientResponse; body?: any; }> {
const localVarPath = this.basePath + '/user/createWithList'; const localVarPath = this.basePath + '/user/createWithList';
let queryParameters: any = {}; let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders); let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let formParams: any = {}; let formParams: any = {};
// verify required parameter 'body' is not null or undefined
if (body === null || body === undefined) {
throw new Error('Required parameter body was null or undefined when calling createUsersWithListInput.');
}
let useFormData = false; let useFormData = false;
@ -1493,13 +1580,23 @@ export class UserApi {
* @param username The user name for login * @param username The user name for login
* @param password The password for login in clear text * @param password The password for login in clear text
*/ */
public loginUser (username?: string, password?: string) : Promise<{ response: http.ClientResponse; body: string; }> { public loginUser (username: string, password: string) : Promise<{ response: http.ClientResponse; body: string; }> {
const localVarPath = this.basePath + '/user/login'; const localVarPath = this.basePath + '/user/login';
let queryParameters: any = {}; let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders); let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let formParams: any = {}; let formParams: any = {};
// verify required parameter 'username' is not null or undefined
if (username === null || username === undefined) {
throw new Error('Required parameter username was null or undefined when calling loginUser.');
}
// verify required parameter 'password' is not null or undefined
if (password === null || password === undefined) {
throw new Error('Required parameter password was null or undefined when calling loginUser.');
}
if (username !== undefined) { if (username !== undefined) {
queryParameters['username'] = ObjectSerializer.serialize(username, "string"); queryParameters['username'] = ObjectSerializer.serialize(username, "string");
} }
@ -1596,7 +1693,7 @@ export class UserApi {
* @param username name that need to be deleted * @param username name that need to be deleted
* @param body Updated user object * @param body Updated user object
*/ */
public updateUser (username: string, body?: User) : Promise<{ response: http.ClientResponse; body?: any; }> { public updateUser (username: string, body: User) : Promise<{ response: http.ClientResponse; body?: any; }> {
const localVarPath = this.basePath + '/user/{username}' const localVarPath = this.basePath + '/user/{username}'
.replace('{' + 'username' + '}', String(username)); .replace('{' + 'username' + '}', String(username));
let queryParameters: any = {}; let queryParameters: any = {};
@ -1609,6 +1706,11 @@ export class UserApi {
throw new Error('Required parameter username was null or undefined when calling updateUser.'); throw new Error('Required parameter username was null or undefined when calling updateUser.');
} }
// verify required parameter 'body' is not null or undefined
if (body === null || body === undefined) {
throw new Error('Required parameter body was null or undefined when calling updateUser.');
}
let useFormData = false; let useFormData = false;