forked from loafle/openapi-generator-original
Merge pull request #2910 from wing328/typescript_better_ci
[TypeScript] Add CI for typescript API clients
This commit is contained in:
commit
6c71dc3d18
2
.gitignore
vendored
2
.gitignore
vendored
@ -117,6 +117,8 @@ samples/client/petstore/python/.venv/
|
||||
|
||||
# ts
|
||||
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/**/typings
|
||||
|
||||
|
@ -10,6 +10,7 @@ services:
|
||||
before_install:
|
||||
# required when sudo: required for the Ruby petstore tests
|
||||
- gem install bundler
|
||||
- npm install -g typescript
|
||||
|
||||
install:
|
||||
|
||||
|
@ -2,12 +2,14 @@
|
||||
"name": "{{npmName}}",
|
||||
"version": "{{npmVersion}}",
|
||||
"description": "NodeJS client for {{npmName}}",
|
||||
"repository": "{{gitUserId}}/{{gitRepoId}}",
|
||||
"main": "api.js",
|
||||
"scripts": {
|
||||
"clean": "rm -Rf node_modules/ typings/ *.js",
|
||||
"build": "typings install && tsc"
|
||||
},
|
||||
"author": "Swagger Codegen Contributors",
|
||||
"license": "MIT",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"bluebird": "^3.3.5",
|
||||
"request": "^2.72.0"
|
||||
|
82
pom.xml
82
pom.xml
@ -438,6 +438,78 @@
|
||||
<module>samples/server/petstore/jaxrs</module>
|
||||
</modules>
|
||||
</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>
|
||||
<id>ruby-client</id>
|
||||
<activation>
|
||||
@ -471,6 +543,15 @@
|
||||
</property>
|
||||
</activation>
|
||||
<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/clojure</module>
|
||||
<module>samples/client/petstore/java/default</module>
|
||||
@ -483,7 +564,6 @@
|
||||
<module>samples/client/petstore/javascript</module>
|
||||
<module>samples/client/petstore/scala</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-resteasy</module>
|
||||
<!--module>samples/client/petstore/objc/SwaggerClientTests</module-->
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "petstore-typescript-node-sample",
|
||||
"version": "1.0.0",
|
||||
"repository": "GIT_USER_ID/GIT_REPO_ID",
|
||||
"description": "Sample of generated TypeScript petstore client",
|
||||
"main": "api.js",
|
||||
"scripts": {
|
||||
@ -8,8 +9,8 @@
|
||||
"test": "tsc --target ES6 && node client.js",
|
||||
"clean": "rm -Rf node_modules/ typings/ *.js"
|
||||
},
|
||||
"author": "Mads M. Tandrup",
|
||||
"license": "Apache 2.0",
|
||||
"author": "Swagger Codegen Contributors & Mads M. Tandrup",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"request": "^2.60.0",
|
||||
"angular": "^1.4.3"
|
||||
|
59
samples/client/petstore/typescript-angular/pom.xml
Normal file
59
samples/client/petstore/typescript-angular/pom.xml
Normal 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>
|
@ -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>
|
@ -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>
|
@ -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>
|
@ -13,6 +13,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": "./scripts/prepublish.sh",
|
||||
"pretest": "npm install mocha",
|
||||
"test": "mocha"
|
||||
},
|
||||
"name": "typescript-fetch-test",
|
||||
|
@ -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>
|
@ -0,0 +1,2 @@
|
||||
tsconfig.json
|
||||
package.json
|
@ -80,8 +80,8 @@ export declare class PetApi {
|
||||
protected defaultHeaders: any;
|
||||
protected authentications: {
|
||||
'default': Authentication;
|
||||
'api_key': ApiKeyAuth;
|
||||
'petstore_auth': OAuth;
|
||||
'api_key': ApiKeyAuth;
|
||||
};
|
||||
constructor(basePath?: string);
|
||||
setApiKey(key: PetApiApiKeys, value: string): void;
|
||||
@ -128,8 +128,8 @@ export declare class StoreApi {
|
||||
protected defaultHeaders: any;
|
||||
protected authentications: {
|
||||
'default': Authentication;
|
||||
'api_key': ApiKeyAuth;
|
||||
'petstore_auth': OAuth;
|
||||
'api_key': ApiKeyAuth;
|
||||
};
|
||||
constructor(basePath?: string);
|
||||
setApiKey(key: StoreApiApiKeys, value: string): void;
|
||||
@ -162,8 +162,8 @@ export declare class UserApi {
|
||||
protected defaultHeaders: any;
|
||||
protected authentications: {
|
||||
'default': Authentication;
|
||||
'api_key': ApiKeyAuth;
|
||||
'petstore_auth': OAuth;
|
||||
'api_key': ApiKeyAuth;
|
||||
};
|
||||
constructor(basePath?: string);
|
||||
setApiKey(key: UserApiApiKeys, value: string): void;
|
||||
|
@ -1,3 +1,4 @@
|
||||
"use strict";
|
||||
var request = require('request');
|
||||
var promise = require('bluebird');
|
||||
var defaultBasePath = 'http://petstore.swagger.io/v2';
|
||||
@ -5,13 +6,13 @@ var Category = (function () {
|
||||
function Category() {
|
||||
}
|
||||
return Category;
|
||||
})();
|
||||
}());
|
||||
exports.Category = Category;
|
||||
var Order = (function () {
|
||||
function Order() {
|
||||
}
|
||||
return Order;
|
||||
})();
|
||||
}());
|
||||
exports.Order = Order;
|
||||
var Order;
|
||||
(function (Order) {
|
||||
@ -26,7 +27,7 @@ var Pet = (function () {
|
||||
function Pet() {
|
||||
}
|
||||
return Pet;
|
||||
})();
|
||||
}());
|
||||
exports.Pet = Pet;
|
||||
var Pet;
|
||||
(function (Pet) {
|
||||
@ -41,13 +42,13 @@ var Tag = (function () {
|
||||
function Tag() {
|
||||
}
|
||||
return Tag;
|
||||
})();
|
||||
}());
|
||||
exports.Tag = Tag;
|
||||
var User = (function () {
|
||||
function User() {
|
||||
}
|
||||
return User;
|
||||
})();
|
||||
}());
|
||||
exports.User = User;
|
||||
var HttpBasicAuth = (function () {
|
||||
function HttpBasicAuth() {
|
||||
@ -58,7 +59,7 @@ var HttpBasicAuth = (function () {
|
||||
};
|
||||
};
|
||||
return HttpBasicAuth;
|
||||
})();
|
||||
}());
|
||||
exports.HttpBasicAuth = HttpBasicAuth;
|
||||
var ApiKeyAuth = (function () {
|
||||
function ApiKeyAuth(location, paramName) {
|
||||
@ -74,7 +75,7 @@ var ApiKeyAuth = (function () {
|
||||
}
|
||||
};
|
||||
return ApiKeyAuth;
|
||||
})();
|
||||
}());
|
||||
exports.ApiKeyAuth = ApiKeyAuth;
|
||||
var OAuth = (function () {
|
||||
function OAuth() {
|
||||
@ -83,7 +84,7 @@ var OAuth = (function () {
|
||||
requestOptions.headers["Authorization"] = "Bearer " + this.accessToken;
|
||||
};
|
||||
return OAuth;
|
||||
})();
|
||||
}());
|
||||
exports.OAuth = OAuth;
|
||||
var VoidAuth = (function () {
|
||||
function VoidAuth() {
|
||||
@ -91,7 +92,7 @@ var VoidAuth = (function () {
|
||||
VoidAuth.prototype.applyToRequest = function (requestOptions) {
|
||||
};
|
||||
return VoidAuth;
|
||||
})();
|
||||
}());
|
||||
exports.VoidAuth = VoidAuth;
|
||||
(function (PetApiApiKeys) {
|
||||
PetApiApiKeys[PetApiApiKeys["api_key"] = 0] = "api_key";
|
||||
@ -103,8 +104,8 @@ var PetApi = (function () {
|
||||
this.defaultHeaders = {};
|
||||
this.authentications = {
|
||||
'default': new VoidAuth(),
|
||||
'api_key': new ApiKeyAuth('header', 'api_key'),
|
||||
'petstore_auth': new OAuth(),
|
||||
'api_key': new ApiKeyAuth('header', 'api_key'),
|
||||
};
|
||||
if (password) {
|
||||
if (basePath) {
|
||||
@ -321,8 +322,8 @@ var PetApi = (function () {
|
||||
uri: localVarPath,
|
||||
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) {
|
||||
if (useFormData) {
|
||||
@ -487,7 +488,7 @@ var PetApi = (function () {
|
||||
return localVarDeferred.promise;
|
||||
};
|
||||
return PetApi;
|
||||
})();
|
||||
}());
|
||||
exports.PetApi = PetApi;
|
||||
(function (StoreApiApiKeys) {
|
||||
StoreApiApiKeys[StoreApiApiKeys["api_key"] = 0] = "api_key";
|
||||
@ -499,8 +500,8 @@ var StoreApi = (function () {
|
||||
this.defaultHeaders = {};
|
||||
this.authentications = {
|
||||
'default': new VoidAuth(),
|
||||
'api_key': new ApiKeyAuth('header', 'api_key'),
|
||||
'petstore_auth': new OAuth(),
|
||||
'api_key': new ApiKeyAuth('header', 'api_key'),
|
||||
};
|
||||
if (password) {
|
||||
if (basePath) {
|
||||
@ -694,7 +695,7 @@ var StoreApi = (function () {
|
||||
return localVarDeferred.promise;
|
||||
};
|
||||
return StoreApi;
|
||||
})();
|
||||
}());
|
||||
exports.StoreApi = StoreApi;
|
||||
(function (UserApiApiKeys) {
|
||||
UserApiApiKeys[UserApiApiKeys["api_key"] = 0] = "api_key";
|
||||
@ -706,8 +707,8 @@ var UserApi = (function () {
|
||||
this.defaultHeaders = {};
|
||||
this.authentications = {
|
||||
'default': new VoidAuth(),
|
||||
'api_key': new ApiKeyAuth('header', 'api_key'),
|
||||
'petstore_auth': new OAuth(),
|
||||
'api_key': new ApiKeyAuth('header', 'api_key'),
|
||||
};
|
||||
if (password) {
|
||||
if (basePath) {
|
||||
@ -1065,6 +1066,6 @@ var UserApi = (function () {
|
||||
return localVarDeferred.promise;
|
||||
};
|
||||
return UserApi;
|
||||
})();
|
||||
}());
|
||||
exports.UserApi = UserApi;
|
||||
//# sourceMappingURL=api.js.map
|
File diff suppressed because one or more lines are too long
@ -131,8 +131,8 @@ export class PetApi {
|
||||
|
||||
protected authentications = {
|
||||
'default': <Authentication>new VoidAuth(),
|
||||
'petstore_auth': new OAuth(),
|
||||
'api_key': new ApiKeyAuth('header', 'api_key'),
|
||||
'petstore_auth': new OAuth(),
|
||||
}
|
||||
|
||||
constructor(basePath?: string);
|
||||
@ -398,10 +398,10 @@ export class PetApi {
|
||||
json: true,
|
||||
};
|
||||
|
||||
this.authentications.petstore_auth.applyToRequest(requestOptions);
|
||||
|
||||
this.authentications.api_key.applyToRequest(requestOptions);
|
||||
|
||||
this.authentications.petstore_auth.applyToRequest(requestOptions);
|
||||
|
||||
this.authentications.default.applyToRequest(requestOptions);
|
||||
|
||||
if (Object.keys(formParams).length) {
|
||||
@ -610,8 +610,8 @@ export class StoreApi {
|
||||
|
||||
protected authentications = {
|
||||
'default': <Authentication>new VoidAuth(),
|
||||
'petstore_auth': new OAuth(),
|
||||
'api_key': new ApiKeyAuth('header', 'api_key'),
|
||||
'petstore_auth': new OAuth(),
|
||||
}
|
||||
|
||||
constructor(basePath?: string);
|
||||
@ -847,8 +847,8 @@ export class UserApi {
|
||||
|
||||
protected authentications = {
|
||||
'default': <Authentication>new VoidAuth(),
|
||||
'petstore_auth': new OAuth(),
|
||||
'api_key': new ApiKeyAuth('header', 'api_key'),
|
||||
'petstore_auth': new OAuth(),
|
||||
}
|
||||
|
||||
constructor(basePath?: string);
|
||||
|
0
samples/client/petstore/typescript-node/npm/client.d.ts
vendored
Normal file
0
samples/client/petstore/typescript-node/npm/client.d.ts
vendored
Normal file
53
samples/client/petstore/typescript-node/npm/client.js
Normal file
53
samples/client/petstore/typescript-node/npm/client.js
Normal 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(exitCode);
|
||||
});
|
||||
//# sourceMappingURL=client.js.map
|
@ -0,0 +1 @@
|
||||
{"version":3,"file":"client.js","sourceRoot":"","sources":["client.ts"],"names":[],"mappings":";AAAA,IAAO,GAAG,WAAW,OAAO,CAAC,CAAC;AAC9B,IAAO,EAAE,WAAW,IAAI,CAAC,CAAC;AAE1B,IAAI,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;AAC9B,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;AAG3D,IAAI,IAAI,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC;AACzB,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC;AAChB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;AAEvB,IAAI,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC;AACxB,GAAG,CAAC,IAAI,GAAG,kBAAkB,CAAC;AAC9B,GAAG,CAAC,EAAE,GAAG,KAAK,CAAC;AACf,GAAG,CAAC,SAAS,GAAG,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AAC/C,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;AAElB,IAAI,KAAU,CAAC;AAEf,IAAI,QAAQ,GAAG,CAAC,CAAC;AAGjB,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;KACb,IAAI,CAAC,UAAC,GAAG;IACN,IAAI,MAAM,GAAY,GAAG,CAAC,IAAI,CAAC;IAC/B,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC;IAClB,OAAO,CAAC,GAAG,CAAC,yBAAuB,KAAO,CAAC,CAAC;IAC5C,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,oBAAoB,CAAC;IACxD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC,CAAC;KACD,IAAI,CAAC,UAAC,GAAG;IACN,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;IAC3C,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AACjE,CAAC,CAAC;KACD,IAAI,CAAC,UAAC,GAAG;IACN,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;IAC3C,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC;AAClF,CAAC,CAAC;KACD,IAAI,CAAC,UAAC,GAAG;IACN,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC9B,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC,CAAC;KACD,IAAI,CAAC,UAAC,GAAG;IACN,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1D,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC;QAC3D,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC7C,CAAC;AACL,CAAC,CAAC;KACD,KAAK,CAAC,UAAC,GAAQ;IACZ,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,QAAQ,GAAG,CAAC,CAAC;AACjB,CAAC,CAAC;KACD,OAAO,CAAC;IACL,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC,CAAC;KACD,IAAI,CAAC,UAAC,GAAG;IACN,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC3B,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC3B,CAAC,CAAC,CAAC"}
|
@ -3,7 +3,7 @@ import fs = require('fs');
|
||||
|
||||
var petApi = new api.PetApi();
|
||||
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();
|
||||
tag1.id = 18291;
|
||||
@ -25,7 +25,7 @@ petApi.addPet(pet)
|
||||
var newPet = <api.Pet>res.body;
|
||||
petId = newPet.id;
|
||||
console.log(`Created pet with ID ${petId}`);
|
||||
newPet.status = api.Pet.StatusEnum.available;
|
||||
newPet.status = api.Pet.StatusEnum.StatusEnum_available;
|
||||
return petApi.updatePet(newPet);
|
||||
})
|
||||
.then((res) => {
|
||||
@ -42,7 +42,7 @@ petApi.addPet(pet)
|
||||
})
|
||||
.then((res) => {
|
||||
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");
|
||||
}
|
||||
})
|
||||
|
@ -1,13 +1,16 @@
|
||||
{
|
||||
"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",
|
||||
"repository": "GIT_USER_ID/GIT_REPO_ID",
|
||||
"main": "api.js",
|
||||
"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",
|
||||
"license": "MIT",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"bluebird": "^3.3.5",
|
||||
"request": "^2.72.0"
|
||||
|
73
samples/client/petstore/typescript-node/npm/pom.xml
Normal file
73
samples/client/petstore/typescript-node/npm/pom.xml
Normal 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>
|
BIN
samples/client/petstore/typescript-node/npm/sample.png
Normal file
BIN
samples/client/petstore/typescript-node/npm/sample.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 95 B |
@ -12,6 +12,7 @@
|
||||
},
|
||||
"files": [
|
||||
"api.ts",
|
||||
"client.ts",
|
||||
"typings/main.d.ts"
|
||||
]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user