Merge pull request #2910 from wing328/typescript_better_ci

[TypeScript] Add CI for typescript API clients
This commit is contained in:
wing328 2016-05-20 16:02:46 +08:00
commit 6c71dc3d18
24 changed files with 512 additions and 35 deletions

2
.gitignore vendored
View File

@ -117,6 +117,8 @@ samples/client/petstore/python/.venv/
# ts # ts
samples/client/petstore/typescript-node/npm/node_modules samples/client/petstore/typescript-node/npm/node_modules
samples/client/petstore/typescript-node/**/typings
samples/client/petstore/typescript-angular/**/typings
samples/client/petstore/typescript-fetch/**/dist/ samples/client/petstore/typescript-fetch/**/dist/
samples/client/petstore/typescript-fetch/**/typings samples/client/petstore/typescript-fetch/**/typings

View File

@ -10,6 +10,7 @@ services:
before_install: before_install:
# required when sudo: required for the Ruby petstore tests # required when sudo: required for the Ruby petstore tests
- gem install bundler - gem install bundler
- npm install -g typescript
install: install:

View File

@ -2,12 +2,14 @@
"name": "{{npmName}}", "name": "{{npmName}}",
"version": "{{npmVersion}}", "version": "{{npmVersion}}",
"description": "NodeJS client for {{npmName}}", "description": "NodeJS client for {{npmName}}",
"repository": "{{gitUserId}}/{{gitRepoId}}",
"main": "api.js", "main": "api.js",
"scripts": { "scripts": {
"clean": "rm -Rf node_modules/ typings/ *.js",
"build": "typings install && tsc" "build": "typings install && tsc"
}, },
"author": "Swagger Codegen Contributors", "author": "Swagger Codegen Contributors",
"license": "MIT", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"bluebird": "^3.3.5", "bluebird": "^3.3.5",
"request": "^2.72.0" "request": "^2.72.0"

82
pom.xml
View File

@ -438,6 +438,78 @@
<module>samples/server/petstore/jaxrs</module> <module>samples/server/petstore/jaxrs</module>
</modules> </modules>
</profile> </profile>
<profile>
<id>typescript-fetch-client-tests-default</id>
<activation>
<property>
<name>env</name>
<value>java</value>
</property>
</activation>
<modules>
<module>samples/client/petstore/typescript-fetch/tests/default</module>
</modules>
</profile>
<profile>
<id>typescript-fetch-client-builds-default</id>
<activation>
<property>
<name>env</name>
<value>java</value>
</property>
</activation>
<modules>
<module>samples/client/petstore/typescript-fetch/builds/default</module>
</modules>
</profile>
<profile>
<id>typescript-fetch-client-builds-es6-target</id>
<activation>
<property>
<name>env</name>
<value>java</value>
</property>
</activation>
<modules>
<module>samples/client/petstore/typescript-fetch/builds/es6-target</module>
</modules>
</profile>
<profile>
<id>typescript-fetch-client-builds-with-npm-version</id>
<activation>
<property>
<name>env</name>
<value>java</value>
</property>
</activation>
<modules>
<module>samples/client/petstore/typescript-fetch/builds/with-npm-version</module>
</modules>
</profile>
<profile>
<id>typescript-angular-client</id>
<activation>
<property>
<name>env</name>
<value>java</value>
</property>
</activation>
<modules>
<module>samples/client/petstore/typescript-angular/npm</module>
</modules>
</profile>
<profile>
<id>typescript-node-npm-client</id>
<activation>
<property>
<name>env</name>
<value>java</value>
</property>
</activation>
<modules>
<module>samples/client/petstore/typescript-node/npm</module>
</modules>
</profile>
<profile> <profile>
<id>ruby-client</id> <id>ruby-client</id>
<activation> <activation>
@ -471,6 +543,15 @@
</property> </property>
</activation> </activation>
<modules> <modules>
<!--<module>samples/client/petstore/typescript-fetch/tests/default</module>
<module>samples/client/petstore/typescript-fetch/builds/default</module>
<module>samples/client/petstore/typescript-fetch/builds/es6-target</module>
<module>samples/client/petstore/typescript-fetch/builds/with-npm-version</module>-->
<!-- run ruby test first which has a random delay script to
avoid issues with running 2 CI jobs in parallel. -->
<module>samples/client/petstore/ruby</module>
<module>samples/client/petstore/typescript-angular</module>
<module>samples/client/petstore/typescript-node/npm</module>
<module>samples/client/petstore/android/volley</module> <module>samples/client/petstore/android/volley</module>
<module>samples/client/petstore/clojure</module> <module>samples/client/petstore/clojure</module>
<module>samples/client/petstore/java/default</module> <module>samples/client/petstore/java/default</module>
@ -483,7 +564,6 @@
<module>samples/client/petstore/javascript</module> <module>samples/client/petstore/javascript</module>
<module>samples/client/petstore/scala</module> <module>samples/client/petstore/scala</module>
<module>samples/server/petstore/spring-mvc</module> <module>samples/server/petstore/spring-mvc</module>
<module>samples/client/petstore/ruby</module>
<module>samples/server/petstore/jaxrs</module> <module>samples/server/petstore/jaxrs</module>
<module>samples/server/petstore/jaxrs-resteasy</module> <module>samples/server/petstore/jaxrs-resteasy</module>
<!--module>samples/client/petstore/objc/SwaggerClientTests</module--> <!--module>samples/client/petstore/objc/SwaggerClientTests</module-->

View File

@ -1,6 +1,7 @@
{ {
"name": "petstore-typescript-node-sample", "name": "petstore-typescript-node-sample",
"version": "1.0.0", "version": "1.0.0",
"repository": "GIT_USER_ID/GIT_REPO_ID",
"description": "Sample of generated TypeScript petstore client", "description": "Sample of generated TypeScript petstore client",
"main": "api.js", "main": "api.js",
"scripts": { "scripts": {
@ -8,8 +9,8 @@
"test": "tsc --target ES6 && node client.js", "test": "tsc --target ES6 && node client.js",
"clean": "rm -Rf node_modules/ typings/ *.js" "clean": "rm -Rf node_modules/ typings/ *.js"
}, },
"author": "Mads M. Tandrup", "author": "Swagger Codegen Contributors & Mads M. Tandrup",
"license": "Apache 2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"request": "^2.60.0", "request": "^2.60.0",
"angular": "^1.4.3" "angular": "^1.4.3"

View File

@ -0,0 +1,59 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.wordnik</groupId>
<artifactId>TypeScriptAngularPestoreClientTests</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>TS Angular Petstore Client</name>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>npm-install</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>npm-test</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>test</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,46 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.wordnik</groupId>
<artifactId>TypeScriptAngularBuildPestoreClientTests</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>TS Angular Build Petstore Client</name>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>npm-install</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,46 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.wordnik</groupId>
<artifactId>TypeScriptAngularBuildES6PestoreClientTests</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>TS Angular Build ES6 Petstore Client</name>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>npm-install</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,46 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.wordnik</groupId>
<artifactId>TypeScriptAngularBuildWithNPMVersionPestoreClientTests</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>TS Angular Build With NPM Version Petstore Client</name>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>npm-install</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -13,6 +13,7 @@
}, },
"scripts": { "scripts": {
"prepublish": "./scripts/prepublish.sh", "prepublish": "./scripts/prepublish.sh",
"pretest": "npm install mocha",
"test": "mocha" "test": "mocha"
}, },
"name": "typescript-fetch-test", "name": "typescript-fetch-test",

View File

@ -0,0 +1,59 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.wordnik</groupId>
<artifactId>TypeScriptFetchPestoreClientTests</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>TS Fetch default Petstore Client</name>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>npm-install</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>npm-test</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>test</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,2 @@
tsconfig.json
package.json

View File

@ -80,8 +80,8 @@ export declare class PetApi {
protected defaultHeaders: any; protected defaultHeaders: any;
protected authentications: { protected authentications: {
'default': Authentication; 'default': Authentication;
'api_key': ApiKeyAuth;
'petstore_auth': OAuth; 'petstore_auth': OAuth;
'api_key': ApiKeyAuth;
}; };
constructor(basePath?: string); constructor(basePath?: string);
setApiKey(key: PetApiApiKeys, value: string): void; setApiKey(key: PetApiApiKeys, value: string): void;
@ -128,8 +128,8 @@ export declare class StoreApi {
protected defaultHeaders: any; protected defaultHeaders: any;
protected authentications: { protected authentications: {
'default': Authentication; 'default': Authentication;
'api_key': ApiKeyAuth;
'petstore_auth': OAuth; 'petstore_auth': OAuth;
'api_key': ApiKeyAuth;
}; };
constructor(basePath?: string); constructor(basePath?: string);
setApiKey(key: StoreApiApiKeys, value: string): void; setApiKey(key: StoreApiApiKeys, value: string): void;
@ -162,8 +162,8 @@ export declare class UserApi {
protected defaultHeaders: any; protected defaultHeaders: any;
protected authentications: { protected authentications: {
'default': Authentication; 'default': Authentication;
'api_key': ApiKeyAuth;
'petstore_auth': OAuth; 'petstore_auth': OAuth;
'api_key': ApiKeyAuth;
}; };
constructor(basePath?: string); constructor(basePath?: string);
setApiKey(key: UserApiApiKeys, value: string): void; setApiKey(key: UserApiApiKeys, value: string): void;

View File

@ -1,3 +1,4 @@
"use strict";
var request = require('request'); var request = require('request');
var promise = require('bluebird'); var promise = require('bluebird');
var defaultBasePath = 'http://petstore.swagger.io/v2'; var defaultBasePath = 'http://petstore.swagger.io/v2';
@ -5,13 +6,13 @@ var Category = (function () {
function Category() { function Category() {
} }
return Category; return Category;
})(); }());
exports.Category = Category; exports.Category = Category;
var Order = (function () { var Order = (function () {
function Order() { function Order() {
} }
return Order; return Order;
})(); }());
exports.Order = Order; exports.Order = Order;
var Order; var Order;
(function (Order) { (function (Order) {
@ -26,7 +27,7 @@ var Pet = (function () {
function Pet() { function Pet() {
} }
return Pet; return Pet;
})(); }());
exports.Pet = Pet; exports.Pet = Pet;
var Pet; var Pet;
(function (Pet) { (function (Pet) {
@ -41,13 +42,13 @@ var Tag = (function () {
function Tag() { function Tag() {
} }
return Tag; return Tag;
})(); }());
exports.Tag = Tag; exports.Tag = Tag;
var User = (function () { var User = (function () {
function User() { function User() {
} }
return User; return User;
})(); }());
exports.User = User; exports.User = User;
var HttpBasicAuth = (function () { var HttpBasicAuth = (function () {
function HttpBasicAuth() { function HttpBasicAuth() {
@ -58,7 +59,7 @@ var HttpBasicAuth = (function () {
}; };
}; };
return HttpBasicAuth; return HttpBasicAuth;
})(); }());
exports.HttpBasicAuth = HttpBasicAuth; exports.HttpBasicAuth = HttpBasicAuth;
var ApiKeyAuth = (function () { var ApiKeyAuth = (function () {
function ApiKeyAuth(location, paramName) { function ApiKeyAuth(location, paramName) {
@ -74,7 +75,7 @@ var ApiKeyAuth = (function () {
} }
}; };
return ApiKeyAuth; return ApiKeyAuth;
})(); }());
exports.ApiKeyAuth = ApiKeyAuth; exports.ApiKeyAuth = ApiKeyAuth;
var OAuth = (function () { var OAuth = (function () {
function OAuth() { function OAuth() {
@ -83,7 +84,7 @@ var OAuth = (function () {
requestOptions.headers["Authorization"] = "Bearer " + this.accessToken; requestOptions.headers["Authorization"] = "Bearer " + this.accessToken;
}; };
return OAuth; return OAuth;
})(); }());
exports.OAuth = OAuth; exports.OAuth = OAuth;
var VoidAuth = (function () { var VoidAuth = (function () {
function VoidAuth() { function VoidAuth() {
@ -91,7 +92,7 @@ var VoidAuth = (function () {
VoidAuth.prototype.applyToRequest = function (requestOptions) { VoidAuth.prototype.applyToRequest = function (requestOptions) {
}; };
return VoidAuth; return VoidAuth;
})(); }());
exports.VoidAuth = VoidAuth; exports.VoidAuth = VoidAuth;
(function (PetApiApiKeys) { (function (PetApiApiKeys) {
PetApiApiKeys[PetApiApiKeys["api_key"] = 0] = "api_key"; PetApiApiKeys[PetApiApiKeys["api_key"] = 0] = "api_key";
@ -103,8 +104,8 @@ var PetApi = (function () {
this.defaultHeaders = {}; this.defaultHeaders = {};
this.authentications = { this.authentications = {
'default': new VoidAuth(), 'default': new VoidAuth(),
'api_key': new ApiKeyAuth('header', 'api_key'),
'petstore_auth': new OAuth(), 'petstore_auth': new OAuth(),
'api_key': new ApiKeyAuth('header', 'api_key'),
}; };
if (password) { if (password) {
if (basePath) { if (basePath) {
@ -321,8 +322,8 @@ var PetApi = (function () {
uri: localVarPath, uri: localVarPath,
json: true, json: true,
}; };
this.authentications.api_key.applyToRequest(requestOptions);
this.authentications.petstore_auth.applyToRequest(requestOptions); this.authentications.petstore_auth.applyToRequest(requestOptions);
this.authentications.api_key.applyToRequest(requestOptions);
this.authentications.default.applyToRequest(requestOptions); this.authentications.default.applyToRequest(requestOptions);
if (Object.keys(formParams).length) { if (Object.keys(formParams).length) {
if (useFormData) { if (useFormData) {
@ -487,7 +488,7 @@ var PetApi = (function () {
return localVarDeferred.promise; return localVarDeferred.promise;
}; };
return PetApi; return PetApi;
})(); }());
exports.PetApi = PetApi; exports.PetApi = PetApi;
(function (StoreApiApiKeys) { (function (StoreApiApiKeys) {
StoreApiApiKeys[StoreApiApiKeys["api_key"] = 0] = "api_key"; StoreApiApiKeys[StoreApiApiKeys["api_key"] = 0] = "api_key";
@ -499,8 +500,8 @@ var StoreApi = (function () {
this.defaultHeaders = {}; this.defaultHeaders = {};
this.authentications = { this.authentications = {
'default': new VoidAuth(), 'default': new VoidAuth(),
'api_key': new ApiKeyAuth('header', 'api_key'),
'petstore_auth': new OAuth(), 'petstore_auth': new OAuth(),
'api_key': new ApiKeyAuth('header', 'api_key'),
}; };
if (password) { if (password) {
if (basePath) { if (basePath) {
@ -694,7 +695,7 @@ var StoreApi = (function () {
return localVarDeferred.promise; return localVarDeferred.promise;
}; };
return StoreApi; return StoreApi;
})(); }());
exports.StoreApi = StoreApi; exports.StoreApi = StoreApi;
(function (UserApiApiKeys) { (function (UserApiApiKeys) {
UserApiApiKeys[UserApiApiKeys["api_key"] = 0] = "api_key"; UserApiApiKeys[UserApiApiKeys["api_key"] = 0] = "api_key";
@ -706,8 +707,8 @@ var UserApi = (function () {
this.defaultHeaders = {}; this.defaultHeaders = {};
this.authentications = { this.authentications = {
'default': new VoidAuth(), 'default': new VoidAuth(),
'api_key': new ApiKeyAuth('header', 'api_key'),
'petstore_auth': new OAuth(), 'petstore_auth': new OAuth(),
'api_key': new ApiKeyAuth('header', 'api_key'),
}; };
if (password) { if (password) {
if (basePath) { if (basePath) {
@ -1065,6 +1066,6 @@ var UserApi = (function () {
return localVarDeferred.promise; return localVarDeferred.promise;
}; };
return UserApi; return UserApi;
})(); }());
exports.UserApi = UserApi; exports.UserApi = UserApi;
//# sourceMappingURL=api.js.map //# sourceMappingURL=api.js.map

File diff suppressed because one or more lines are too long

View File

@ -131,8 +131,8 @@ export class PetApi {
protected authentications = { protected authentications = {
'default': <Authentication>new VoidAuth(), 'default': <Authentication>new VoidAuth(),
'petstore_auth': new OAuth(),
'api_key': new ApiKeyAuth('header', 'api_key'), 'api_key': new ApiKeyAuth('header', 'api_key'),
'petstore_auth': new OAuth(),
} }
constructor(basePath?: string); constructor(basePath?: string);
@ -398,10 +398,10 @@ export class PetApi {
json: true, json: true,
}; };
this.authentications.petstore_auth.applyToRequest(requestOptions);
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) {
@ -610,8 +610,8 @@ export class StoreApi {
protected authentications = { protected authentications = {
'default': <Authentication>new VoidAuth(), 'default': <Authentication>new VoidAuth(),
'petstore_auth': new OAuth(),
'api_key': new ApiKeyAuth('header', 'api_key'), 'api_key': new ApiKeyAuth('header', 'api_key'),
'petstore_auth': new OAuth(),
} }
constructor(basePath?: string); constructor(basePath?: string);
@ -847,8 +847,8 @@ export class UserApi {
protected authentications = { protected authentications = {
'default': <Authentication>new VoidAuth(), 'default': <Authentication>new VoidAuth(),
'petstore_auth': new OAuth(),
'api_key': new ApiKeyAuth('header', 'api_key'), 'api_key': new ApiKeyAuth('header', 'api_key'),
'petstore_auth': new OAuth(),
} }
constructor(basePath?: string); constructor(basePath?: string);

View File

@ -0,0 +1,53 @@
"use strict";
var api = require('./api');
var fs = require('fs');
var petApi = new api.PetApi();
petApi.setApiKey(api.PetApiApiKeys.api_key, 'special-key');
var tag1 = new api.Tag();
tag1.id = 18291;
tag1.name = 'TS tag 1';
var pet = new api.Pet();
pet.name = 'TypeScriptDoggie';
pet.id = 18291;
pet.photoUrls = ["http://url1", "http://url2"];
pet.tags = [tag1];
var petId;
var exitCode = 0;
petApi.addPet(pet)
.then(function (res) {
var newPet = res.body;
petId = newPet.id;
console.log("Created pet with ID " + petId);
newPet.status = api.Pet.StatusEnum.StatusEnum_available;
return petApi.updatePet(newPet);
})
.then(function (res) {
console.log('Updated pet using POST body');
return petApi.updatePetWithForm(petId, undefined, "pending");
})
.then(function (res) {
console.log('Updated pet using POST form');
return petApi.uploadFile(petId, undefined, fs.createReadStream('sample.png'));
})
.then(function (res) {
console.log('Uploaded image');
return petApi.getPetById(petId);
})
.then(function (res) {
console.log('Got pet by ID: ' + JSON.stringify(res.body));
if (res.body.status != api.Pet.StatusEnum.StatusEnum_pending) {
throw new Error("Unexpected pet status");
}
})
.catch(function (err) {
console.error(err);
exitCode = 1;
})
.finally(function () {
return petApi.deletePet(petId);
})
.then(function (res) {
console.log('Deleted pet');
process.exit(ex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-3,7 +3,7 @@ import fs = require('fs');
var petApi = new api.PetApi(); var petApi = new api.PetApi();
petApi.setApiKey(api.PetApiApiKeys.api_key, 'special-key'); petApi.setApiKey(api.PetApiApiKeys.api_key, 'special-key');
petApi.setApiKey(api.PetApiApiKeys.test_api_key_header, 'query-key'); //petApi.setApiKey(api.PetApiApiKeys.test_api_key_header, 'query-key');
var tag1 = new api.Tag(); var tag1 = new api.Tag();
tag1.id = 18291; tag1.id = 18291;
@ -25,7 +25,7 @@ petApi.addPet(pet)
var newPet = <api.Pet>res.body; var newPet = <api.Pet>res.body;
petId = newPet.id; petId = newPet.id;
console.log(`Created pet with ID ${petId}`); console.log(`Created pet with ID ${petId}`);
newPet.status = api.Pet.StatusEnum.available; newPet.status = api.Pet.StatusEnum.StatusEnum_available;
return petApi.updatePet(newPet); return petApi.updatePet(newPet);
}) })
.then((res) => { .then((res) => {
@ -42,7 +42,7 @@ petApi.addPet(pet)
}) })
.then((res) => { .then((res) => {
console.log('Got pet by ID: ' + JSON.stringify(res.body)); console.log('Got pet by ID: ' + JSON.stringify(res.body));
if (res.body.status != api.Pet.StatusEnum.pending) { if (res.body.status != api.Pet.StatusEnum.StatusEnum_pending) {
throw new Error("Unexpected pet status"); throw new Error("Unexpected pet status");
} }
}) })

View File

@ -1,13 +1,16 @@
{ {
"name": "@swagger/angular2-typescript-petstore", "name": "@swagger/angular2-typescript-petstore",
"version": "0.0.1-SNAPSHOT.201605031634", "version": "0.0.1-SNAPSHOT.201605191812",
"description": "NodeJS client for @swagger/angular2-typescript-petstore", "description": "NodeJS client for @swagger/angular2-typescript-petstore",
"repository": "GIT_USER_ID/GIT_REPO_ID",
"main": "api.js", "main": "api.js",
"scripts": { "scripts": {
"build": "typings install && tsc" "clean": "rm -Rf node_modules/ typings/ *.js",
"build": "typings install && tsc",
"test": "tsc && node client.js"
}, },
"author": "Swagger Codegen Contributors", "author": "Swagger Codegen Contributors",
"license": "MIT", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"bluebird": "^3.3.5", "bluebird": "^3.3.5",
"request": "^2.72.0" "request": "^2.72.0"

View File

@ -0,0 +1,73 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.wordnik</groupId>
<artifactId>TypeScriptNodeNPMPestoreClientTests</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>TS Node npm Petstore Client</name>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>npm-install</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>npm-run-build</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>run</argument>
<argument>build</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>npm-test</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>npm</executable>
<arguments>
<argument>test</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 B

View File

@ -12,6 +12,7 @@
}, },
"files": [ "files": [
"api.ts", "api.ts",
"client.ts",
"typings/main.d.ts" "typings/main.d.ts"
] ]
} }