forked from loafle/openapi-generator-original
Merge pull request #2738 from Vrolijkx/master
Adding generation of packaging information for typescript nodeJs app.
This commit is contained in:
commit
92d39ec0ab
@ -790,6 +790,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you
|
||||
- [uShip](https://www.uship.com/)
|
||||
- [Zalando](https://tech.zalando.com)
|
||||
- [ZEEF.com](https://zeef.com/)
|
||||
- [REstore](https://www.restore.eu)
|
||||
|
||||
License
|
||||
-------
|
||||
|
@ -49,5 +49,6 @@ cd $APP_DIR
|
||||
./bin/tizen-petstore.sh
|
||||
./bin/typescript-angular-petstore.sh
|
||||
./bin/typescript-angular2-petstore.sh
|
||||
./bin/typescript-angular2-petstore-with-npm.sh
|
||||
./bin/typescript-node-petstore.sh
|
||||
./bin/lumen-petstore-server.sh
|
@ -26,6 +26,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-angular2 -c bin/typescript-angular2-petstore-with-npm.json -o samples/client/petstore/typescript-angular2-with-npm"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-angular2 -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-angular2/npm"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
@ -26,6 +26,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-angular2 -o samples/client/petstore/typescript-angular2"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-angular2 -o samples/client/petstore/typescript-angular2/default"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
31
bin/typescript-node-petstore-with-npm.sh
Executable file
31
bin/typescript-node-petstore-with-npm.sh
Executable file
@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-node -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-node/npm"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
@ -26,6 +26,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-node -o samples/client/petstore/typescript-node"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-node -o samples/client/petstore/typescript-node/default"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
10
bin/windows/typescript-angular2-with-npm.bat
Normal file
10
bin/windows/typescript-angular2-with-npm.bat
Normal file
@ -0,0 +1,10 @@
|
||||
set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||
set ags=generate -t modules\swagger-codegen\src\main\resources\typescript-angular -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -c bin/typescript-petstore-npm.json -l typescript-angular2 -o samples\client\petstore\typescript-angular2\npm
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
@ -5,6 +5,6 @@ If Not Exist %executable% (
|
||||
)
|
||||
|
||||
set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||
set ags=generate -t modules\swagger-codegen\src\main\resources\typescript-angular -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l typescript-angular2 -o samples\client\petstore\typescript-angular
|
||||
set ags=generate -t modules\swagger-codegen\src\main\resources\typescript-angular -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l typescript-angular2 -o samples\client\petstore\typescript-angular2\default
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
10
bin/windows/typescript-node-with-npm.bat
Executable file
10
bin/windows/typescript-node-with-npm.bat
Executable file
@ -0,0 +1,10 @@
|
||||
set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||
set ags=generate -t modules\swagger-codegen\src\main\resources\typescript-node -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -c bin/typescript-petstore-npm.json -l typescript-node -o samples\client\petstore\typescript-node\npm
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
@ -5,6 +5,6 @@ If Not Exist %executable% (
|
||||
)
|
||||
|
||||
set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||
set ags=generate -t modules\swagger-codegen\src\main\resources\typescript-node -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l typescript-node -o samples\client\petstore\typescript-node
|
||||
set ags=generate -t modules\swagger-codegen\src\main\resources\typescript-node -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l typescript-node -o samples\client\petstore\typescript-node\default
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
@ -30,7 +30,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
outputFolder = "generated-code/typescript-angular";
|
||||
modelTemplateFiles.put("model.mustache", ".ts");
|
||||
apiTemplateFiles.put("api.mustache", ".ts");
|
||||
embeddedTemplateDir = templateDir = "TypeScript-Angular";
|
||||
embeddedTemplateDir = templateDir = "typescript-angular";
|
||||
apiPackage = "API.Client";
|
||||
modelPackage = "API.Client";
|
||||
}
|
||||
|
@ -1,8 +1,82 @@
|
||||
package io.swagger.codegen.languages;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import io.swagger.codegen.CliOption;
|
||||
import io.swagger.codegen.SupportingFile;
|
||||
import io.swagger.models.properties.BooleanProperty;
|
||||
|
||||
public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TypeScriptNodeClientCodegen.class);
|
||||
private static final SimpleDateFormat SNAPSHOT_SUFFIX_FORMAT = new SimpleDateFormat("yyyyMMddHHmm");
|
||||
|
||||
public static final String NPM_NAME = "npmName";
|
||||
public static final String NPM_VERSION = "npmVersion";
|
||||
public static final String NPM_REPOSITORY = "npmRepository";
|
||||
public static final String SNAPSHOT = "snapshot";
|
||||
|
||||
protected String npmName = null;
|
||||
protected String npmVersion = "1.0.0";
|
||||
protected String npmRepository = null;
|
||||
|
||||
public TypeScriptNodeClientCodegen() {
|
||||
super();
|
||||
outputFolder = "generated-code/typescript-node";
|
||||
embeddedTemplateDir = templateDir = "typescript-node";
|
||||
|
||||
this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package"));
|
||||
this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package"));
|
||||
this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json"));
|
||||
this.cliOptions.add(new CliOption(SNAPSHOT, "When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm", BooleanProperty.TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
supportingFiles.add(new SupportingFile("api.mustache", null, "api.ts"));
|
||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||
//supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
||||
|
||||
LOGGER.warn("check additionals: " + additionalProperties.get(NPM_NAME));
|
||||
if(additionalProperties.containsKey(NPM_NAME)) {
|
||||
addNpmPackageGeneration();
|
||||
}
|
||||
}
|
||||
|
||||
private void addNpmPackageGeneration() {
|
||||
if(additionalProperties.containsKey(NPM_NAME)) {
|
||||
this.setNpmName(additionalProperties.get(NPM_NAME).toString());
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(NPM_VERSION)) {
|
||||
this.setNpmVersion(additionalProperties.get(NPM_VERSION).toString());
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) {
|
||||
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
|
||||
}
|
||||
additionalProperties.put(NPM_VERSION, npmVersion);
|
||||
|
||||
if (additionalProperties.containsKey(NPM_REPOSITORY)) {
|
||||
this.setNpmRepository(additionalProperties.get(NPM_REPOSITORY).toString());
|
||||
}
|
||||
|
||||
//Files for building our lib
|
||||
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"));
|
||||
}
|
||||
|
||||
private String getPackageRootDirectory() {
|
||||
String indexPackage = modelPackage.substring(0, Math.max(0, modelPackage.lastIndexOf('.')));
|
||||
return indexPackage.replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
@ -14,18 +88,24 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
|
||||
return "Generates a TypeScript nodejs client library.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
supportingFiles.add(new SupportingFile("api.mustache", null, "api.ts"));
|
||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||
//supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
||||
|
||||
public void setNpmName(String npmName) {
|
||||
this.npmName = npmName;
|
||||
}
|
||||
|
||||
public TypeScriptNodeClientCodegen() {
|
||||
super();
|
||||
outputFolder = "generated-code/typescript-node";
|
||||
embeddedTemplateDir = templateDir = "TypeScript-node";
|
||||
public void setNpmVersion(String npmVersion) {
|
||||
this.npmVersion = npmVersion;
|
||||
}
|
||||
|
||||
public String getNpmVersion() {
|
||||
return npmVersion;
|
||||
}
|
||||
|
||||
public String getNpmRepository() {
|
||||
return npmRepository;
|
||||
}
|
||||
|
||||
public void setNpmRepository(String npmRepository) {
|
||||
this.npmRepository = npmRepository;
|
||||
}
|
||||
}
|
||||
|
@ -40,14 +40,14 @@ export namespace {{classname}} {
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
|
||||
interface Authentication {
|
||||
export interface Authentication {
|
||||
/**
|
||||
* Apply authentication settings to header and query params.
|
||||
*/
|
||||
applyToRequest(requestOptions: request.Options): void;
|
||||
}
|
||||
|
||||
class HttpBasicAuth implements Authentication {
|
||||
export class HttpBasicAuth implements Authentication {
|
||||
public username: string;
|
||||
public password: string;
|
||||
applyToRequest(requestOptions: request.Options): void {
|
||||
@ -57,7 +57,7 @@ class HttpBasicAuth implements Authentication {
|
||||
}
|
||||
}
|
||||
|
||||
class ApiKeyAuth implements Authentication {
|
||||
export class ApiKeyAuth implements Authentication {
|
||||
public apiKey: string;
|
||||
|
||||
constructor(private location: string, private paramName: string) {
|
||||
@ -72,7 +72,7 @@ class ApiKeyAuth implements Authentication {
|
||||
}
|
||||
}
|
||||
|
||||
class OAuth implements Authentication {
|
||||
export class OAuth implements Authentication {
|
||||
public accessToken: string;
|
||||
|
||||
applyToRequest(requestOptions: request.Options): void {
|
||||
@ -80,7 +80,7 @@ class OAuth implements Authentication {
|
||||
}
|
||||
}
|
||||
|
||||
class VoidAuth implements Authentication {
|
||||
export class VoidAuth implements Authentication {
|
||||
public username: string;
|
||||
public password: string;
|
||||
applyToRequest(requestOptions: request.Options): void {
|
||||
|
@ -2,6 +2,7 @@
|
||||
"name": "{{npmName}}",
|
||||
"version": "{{npmVersion}}",
|
||||
"description": "swagger client for {{npmName}}",
|
||||
"author": "Swagger Codegen Contributors",
|
||||
"keywords": [
|
||||
"swagger-client"
|
||||
],
|
||||
@ -31,5 +32,4 @@
|
||||
"registry":"{{npmRepository}}"
|
||||
}
|
||||
{{/npmRepository}}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "{{npmName}}",
|
||||
"version": "{{npmVersion}}",
|
||||
"description": "NodeJS client for {{npmName}}",
|
||||
"main": "api.js",
|
||||
"scripts": {
|
||||
"build": "typings install && tsc"
|
||||
},
|
||||
"author": "Swagger Codegen Contributors",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bluebird": "^3.3.5",
|
||||
"request": "^2.72.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^1.8.10",
|
||||
"typings": "^0.8.1"
|
||||
}{{#npmRepository}},
|
||||
"publishConfig":{
|
||||
"registry":"{{npmRepository}}"
|
||||
}{{/npmRepository}}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"noImplicitAny": false,
|
||||
"suppressImplicitAnyIndexErrors": true,
|
||||
"target": "ES5",
|
||||
"moduleResolution": "node",
|
||||
"removeComments": true,
|
||||
"sourceMap": true,
|
||||
"noLib": false,
|
||||
"declaration": true
|
||||
},
|
||||
"files": [
|
||||
"api.ts",
|
||||
"typings/main.d.ts"
|
||||
]
|
||||
}
|
||||
|
@ -0,0 +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": {
|
||||
"request": "registry:npm/request#2.69.0+20160304121250"
|
||||
}
|
||||
}
|
@ -10,8 +10,8 @@ import io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen;
|
||||
public class TypeScriptAngular2ClientOptionsProvider implements OptionsProvider {
|
||||
public static final String SORT_PARAMS_VALUE = "false";
|
||||
public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
|
||||
public static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase";
|
||||
public static final String NMP_NAME = "npmName";
|
||||
private static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase";
|
||||
private static final String NMP_NAME = "npmName";
|
||||
private static final String NMP_VERSION = "1.1.2";
|
||||
private static final String NPM_REPOSITORY = "https://registry.npmjs.org";
|
||||
|
||||
|
@ -1,16 +1,22 @@
|
||||
package io.swagger.codegen.options;
|
||||
|
||||
import io.swagger.codegen.CodegenConstants;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.swagger.codegen.CodegenConstants;
|
||||
import io.swagger.codegen.languages.TypeScriptAngular2ClientCodegen;
|
||||
|
||||
|
||||
public class TypeScriptNodeClientOptionsProvider implements OptionsProvider {
|
||||
public static final String SORT_PARAMS_VALUE = "false";
|
||||
public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
|
||||
public static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase";
|
||||
|
||||
private static final String NMP_NAME = "npmName";
|
||||
private static final String NMP_VERSION = "1.1.2";
|
||||
private static final String NPM_REPOSITORY = "https://registry.npmjs.org";
|
||||
|
||||
@Override
|
||||
public String getLanguage() {
|
||||
return "typescript-node";
|
||||
@ -22,6 +28,10 @@ public class TypeScriptNodeClientOptionsProvider implements OptionsProvider {
|
||||
return builder.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
|
||||
.put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)
|
||||
.put(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING_VALUE)
|
||||
.put(TypeScriptAngular2ClientCodegen.NPM_NAME, NMP_NAME)
|
||||
.put(TypeScriptAngular2ClientCodegen.NPM_VERSION, NMP_VERSION)
|
||||
.put(TypeScriptAngular2ClientCodegen.SNAPSHOT, Boolean.FALSE.toString())
|
||||
.put(TypeScriptAngular2ClientCodegen.NPM_REPOSITORY, NPM_REPOSITORY)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201604211551
|
||||
## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201604282253
|
||||
|
||||
### Building
|
||||
|
||||
@ -19,7 +19,7 @@ navigate to the folder of your consuming project and run one of next commando's.
|
||||
_published:_
|
||||
|
||||
```
|
||||
npm install @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201604211551 --save
|
||||
npm install @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201604282253 --save
|
||||
```
|
||||
|
||||
_unPublished (not recommended):_
|
@ -1,7 +1,8 @@
|
||||
{
|
||||
"name": "@swagger/angular2-typescript-petstore",
|
||||
"version": "0.0.1-SNAPSHOT.201604211551",
|
||||
"version": "0.0.1-SNAPSHOT.201604282253",
|
||||
"description": "swagger client for @swagger/angular2-typescript-petstore",
|
||||
"author": "Swagger Codegen Contributors",
|
||||
"keywords": [
|
||||
"swagger-client"
|
||||
],
|
||||
@ -30,5 +31,4 @@
|
||||
"publishConfig":{
|
||||
"registry":"https://skimdb.npmjs.com/registry"
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
/node_modules
|
||||
/typings
|
||||
/*.js
|
@ -1,22 +0,0 @@
|
||||
# SwaggerClient
|
||||
|
||||
Sample of TypeScript Node.js petstore client
|
||||
|
||||
## Testing the generated code
|
||||
|
||||
```
|
||||
npm install
|
||||
npm test
|
||||
```
|
||||
|
||||
This will compile the code and run a small test application that will do some simple test calls to the Swagger Petstore API.
|
||||
|
||||
To clean the workspace run:
|
||||
```
|
||||
npm run clean
|
||||
```
|
||||
|
||||
|
||||
## Author
|
||||
|
||||
mads@maetzke-tandrup.dk, Swagger-Codegen community
|
@ -1,59 +0,0 @@
|
||||
import api = require('./api');
|
||||
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');
|
||||
|
||||
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: any;
|
||||
|
||||
var exitCode = 0;
|
||||
|
||||
// Test various API calls to the petstore
|
||||
petApi.addPet(pet)
|
||||
.then((res) => {
|
||||
var newPet = <api.Pet>res.body;
|
||||
petId = newPet.id;
|
||||
console.log(`Created pet with ID ${petId}`);
|
||||
newPet.status = api.Pet.StatusEnum.available;
|
||||
return petApi.updatePet(newPet);
|
||||
})
|
||||
.then((res) => {
|
||||
console.log('Updated pet using POST body');
|
||||
return petApi.updatePetWithForm(petId, undefined, "pending");
|
||||
})
|
||||
.then((res) => {
|
||||
console.log('Updated pet using POST form');
|
||||
return petApi.uploadFile(petId, undefined, fs.createReadStream('sample.png'));
|
||||
})
|
||||
.then((res) => {
|
||||
console.log('Uploaded image');
|
||||
return petApi.getPetById(petId);
|
||||
})
|
||||
.then((res) => {
|
||||
console.log('Got pet by ID: ' + JSON.stringify(res.body));
|
||||
if (res.body.status != api.Pet.StatusEnum.pending) {
|
||||
throw new Error("Unexpected pet status");
|
||||
}
|
||||
})
|
||||
.catch((err: any) => {
|
||||
console.error(err);
|
||||
exitCode = 1;
|
||||
})
|
||||
.finally(() => {
|
||||
return petApi.deletePet(petId);
|
||||
})
|
||||
.then((res) => {
|
||||
console.log('Deleted pet');
|
||||
process.exit(exitCode);
|
||||
});
|
@ -8,78 +8,11 @@ import http = require('http');
|
||||
|
||||
/* tslint:disable:no-unused-variable */
|
||||
|
||||
export class Animal {
|
||||
"className": string;
|
||||
}
|
||||
|
||||
export class Cat extends Animal {
|
||||
"declawed": boolean;
|
||||
}
|
||||
|
||||
export class Category {
|
||||
"id": number;
|
||||
"name": string;
|
||||
}
|
||||
|
||||
export class Dog extends Animal {
|
||||
"breed": string;
|
||||
}
|
||||
|
||||
export class FormatTest {
|
||||
"integer": number;
|
||||
"int32": number;
|
||||
"int64": number;
|
||||
"number": number;
|
||||
"float": number;
|
||||
"double": number;
|
||||
"string": string;
|
||||
"byte": string;
|
||||
"binary": string;
|
||||
"date": Date;
|
||||
"dateTime": string;
|
||||
}
|
||||
|
||||
export class InlineResponse200 {
|
||||
"tags": Array<Tag>;
|
||||
"id": number;
|
||||
"category": any;
|
||||
/**
|
||||
* pet status in the store
|
||||
*/
|
||||
"status": InlineResponse200.StatusEnum;
|
||||
"name": string;
|
||||
"photoUrls": Array<string>;
|
||||
}
|
||||
|
||||
export namespace InlineResponse200 {
|
||||
export enum StatusEnum {
|
||||
available = <any> 'available',
|
||||
pending = <any> 'pending',
|
||||
sold = <any> 'sold'
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Model for testing model name starting with number
|
||||
*/
|
||||
export class Model200Response {
|
||||
"name": number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model for testing reserved words
|
||||
*/
|
||||
export class ModelReturn {
|
||||
"return": number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model for testing model name same as property name
|
||||
*/
|
||||
export class Name {
|
||||
"name": number;
|
||||
"snakeCase": number;
|
||||
}
|
||||
|
||||
export class Order {
|
||||
"id": number;
|
||||
"petId": number;
|
||||
@ -118,10 +51,6 @@ export namespace Pet {
|
||||
sold = <any> 'sold'
|
||||
}
|
||||
}
|
||||
export class SpecialModelName {
|
||||
"$Special[propertyName]": number;
|
||||
}
|
||||
|
||||
export class Tag {
|
||||
"id": number;
|
||||
"name": string;
|
||||
@ -142,14 +71,14 @@ export class User {
|
||||
}
|
||||
|
||||
|
||||
interface Authentication {
|
||||
export interface Authentication {
|
||||
/**
|
||||
* Apply authentication settings to header and query params.
|
||||
*/
|
||||
applyToRequest(requestOptions: request.Options): void;
|
||||
}
|
||||
|
||||
class HttpBasicAuth implements Authentication {
|
||||
export class HttpBasicAuth implements Authentication {
|
||||
public username: string;
|
||||
public password: string;
|
||||
applyToRequest(requestOptions: request.Options): void {
|
||||
@ -159,7 +88,7 @@ class HttpBasicAuth implements Authentication {
|
||||
}
|
||||
}
|
||||
|
||||
class ApiKeyAuth implements Authentication {
|
||||
export class ApiKeyAuth implements Authentication {
|
||||
public apiKey: string;
|
||||
|
||||
constructor(private location: string, private paramName: string) {
|
||||
@ -174,7 +103,7 @@ class ApiKeyAuth implements Authentication {
|
||||
}
|
||||
}
|
||||
|
||||
class OAuth implements Authentication {
|
||||
export class OAuth implements Authentication {
|
||||
public accessToken: string;
|
||||
|
||||
applyToRequest(requestOptions: request.Options): void {
|
||||
@ -182,7 +111,7 @@ class OAuth implements Authentication {
|
||||
}
|
||||
}
|
||||
|
||||
class VoidAuth implements Authentication {
|
||||
export class VoidAuth implements Authentication {
|
||||
public username: string;
|
||||
public password: string;
|
||||
applyToRequest(requestOptions: request.Options): void {
|
||||
@ -191,11 +120,7 @@ class VoidAuth implements Authentication {
|
||||
}
|
||||
|
||||
export enum PetApiApiKeys {
|
||||
test_api_key_header,
|
||||
api_key,
|
||||
test_api_client_secret,
|
||||
test_api_client_id,
|
||||
test_api_key_query,
|
||||
}
|
||||
|
||||
export class PetApi {
|
||||
@ -204,21 +129,13 @@ export class PetApi {
|
||||
|
||||
protected authentications = {
|
||||
'default': <Authentication>new VoidAuth(),
|
||||
'test_api_key_header': new ApiKeyAuth('header', 'test_api_key_header'),
|
||||
'api_key': new ApiKeyAuth('header', 'api_key'),
|
||||
'test_http_basic': new HttpBasicAuth(),
|
||||
'test_api_client_secret': new ApiKeyAuth('header', 'x-test_api_client_secret'),
|
||||
'test_api_client_id': new ApiKeyAuth('header', 'x-test_api_client_id'),
|
||||
'test_api_key_query': new ApiKeyAuth('query', 'test_api_key_query'),
|
||||
'petstore_auth': new OAuth(),
|
||||
'api_key': new ApiKeyAuth('header', 'api_key'),
|
||||
}
|
||||
|
||||
constructor(basePath?: string);
|
||||
constructor(username: string, password: string, basePath?: string);
|
||||
constructor(basePathOrUsername: string, password?: string, basePath?: string) {
|
||||
if (password) {
|
||||
this.username = basePathOrUsername;
|
||||
this.password = password
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
@ -233,14 +150,6 @@ export class PetApi {
|
||||
this.authentications[PetApiApiKeys[key]].apiKey = value;
|
||||
}
|
||||
|
||||
set username(username: string) {
|
||||
this.authentications.test_http_basic.username = username;
|
||||
}
|
||||
|
||||
set password(password: string) {
|
||||
this.authentications.test_http_basic.password = password;
|
||||
}
|
||||
|
||||
set accessToken(token: string) {
|
||||
this.authentications.petstore_auth.accessToken = token;
|
||||
}
|
||||
@ -264,57 +173,6 @@ export class PetApi {
|
||||
let formParams: any = {};
|
||||
|
||||
|
||||
let useFormData = false;
|
||||
|
||||
let localVarDeferred = promise.defer<{ response: http.ClientResponse; body?: any; }>();
|
||||
|
||||
let requestOptions: request.Options = {
|
||||
method: 'POST',
|
||||
qs: queryParameters,
|
||||
headers: headerParams,
|
||||
uri: localVarPath,
|
||||
json: true,
|
||||
body: body,
|
||||
}
|
||||
|
||||
this.authentications.petstore_auth.applyToRequest(requestOptions);
|
||||
|
||||
this.authentications.default.applyToRequest(requestOptions);
|
||||
|
||||
if (Object.keys(formParams).length) {
|
||||
if (useFormData) {
|
||||
(<any>requestOptions).formData = formParams;
|
||||
} else {
|
||||
requestOptions.form = formParams;
|
||||
}
|
||||
}
|
||||
|
||||
request(requestOptions, (error, response, body) => {
|
||||
if (error) {
|
||||
localVarDeferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
localVarDeferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
localVarDeferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return localVarDeferred.promise;
|
||||
}
|
||||
/**
|
||||
* Fake endpoint to test byte array in body parameter for adding a new pet to the store
|
||||
*
|
||||
* @param body Pet object in the form of byte array
|
||||
*/
|
||||
public addPetUsingByteArray (body?: string) : Promise<{ response: http.ClientResponse; body?: any; }> {
|
||||
const localVarPath = this.basePath + '/pet?testing_byte_array=true';
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
let formParams: any = {};
|
||||
|
||||
|
||||
let useFormData = false;
|
||||
|
||||
let localVarDeferred = promise.defer<{ response: http.ClientResponse; body?: any; }>();
|
||||
@ -415,8 +273,8 @@ export class PetApi {
|
||||
}
|
||||
/**
|
||||
* Finds Pets by status
|
||||
* Multiple status values can be provided with comma separated strings
|
||||
* @param status Status values that need to be considered for query
|
||||
* Multiple status values can be provided with comma seperated strings
|
||||
* @param status Status values that need to be considered for filter
|
||||
*/
|
||||
public findPetsByStatus (status?: Array<string>) : Promise<{ response: http.ClientResponse; body: Array<Pet>; }> {
|
||||
const localVarPath = this.basePath + '/pet/findByStatus';
|
||||
@ -551,126 +409,10 @@ export class PetApi {
|
||||
json: true,
|
||||
}
|
||||
|
||||
this.authentications.api_key.applyToRequest(requestOptions);
|
||||
|
||||
this.authentications.petstore_auth.applyToRequest(requestOptions);
|
||||
|
||||
this.authentications.default.applyToRequest(requestOptions);
|
||||
|
||||
if (Object.keys(formParams).length) {
|
||||
if (useFormData) {
|
||||
(<any>requestOptions).formData = formParams;
|
||||
} else {
|
||||
requestOptions.form = formParams;
|
||||
}
|
||||
}
|
||||
|
||||
request(requestOptions, (error, response, body) => {
|
||||
if (error) {
|
||||
localVarDeferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
localVarDeferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
localVarDeferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return localVarDeferred.promise;
|
||||
}
|
||||
/**
|
||||
* Fake endpoint to test inline arbitrary object return by 'Find pet by ID'
|
||||
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||
* @param petId ID of pet that needs to be fetched
|
||||
*/
|
||||
public getPetByIdInObject (petId: number) : Promise<{ response: http.ClientResponse; body: InlineResponse200; }> {
|
||||
const localVarPath = this.basePath + '/pet/{petId}?response=inline_arbitrary_object'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
let formParams: any = {};
|
||||
|
||||
|
||||
// verify required parameter 'petId' is not null or undefined
|
||||
if (petId === null || petId === undefined) {
|
||||
throw new Error('Required parameter petId was null or undefined when calling getPetByIdInObject.');
|
||||
}
|
||||
|
||||
let useFormData = false;
|
||||
|
||||
let localVarDeferred = promise.defer<{ response: http.ClientResponse; body: InlineResponse200; }>();
|
||||
|
||||
let requestOptions: request.Options = {
|
||||
method: 'GET',
|
||||
qs: queryParameters,
|
||||
headers: headerParams,
|
||||
uri: localVarPath,
|
||||
json: true,
|
||||
}
|
||||
|
||||
this.authentications.api_key.applyToRequest(requestOptions);
|
||||
|
||||
this.authentications.petstore_auth.applyToRequest(requestOptions);
|
||||
|
||||
this.authentications.default.applyToRequest(requestOptions);
|
||||
|
||||
if (Object.keys(formParams).length) {
|
||||
if (useFormData) {
|
||||
(<any>requestOptions).formData = formParams;
|
||||
} else {
|
||||
requestOptions.form = formParams;
|
||||
}
|
||||
}
|
||||
|
||||
request(requestOptions, (error, response, body) => {
|
||||
if (error) {
|
||||
localVarDeferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
localVarDeferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
localVarDeferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return localVarDeferred.promise;
|
||||
}
|
||||
/**
|
||||
* Fake endpoint to test byte array return by 'Find pet by ID'
|
||||
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||
* @param petId ID of pet that needs to be fetched
|
||||
*/
|
||||
public petPetIdtestingByteArraytrueGet (petId: number) : Promise<{ response: http.ClientResponse; body: string; }> {
|
||||
const localVarPath = this.basePath + '/pet/{petId}?testing_byte_array=true'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
let formParams: any = {};
|
||||
|
||||
|
||||
// verify required parameter 'petId' is not null or undefined
|
||||
if (petId === null || petId === undefined) {
|
||||
throw new Error('Required parameter petId was null or undefined when calling petPetIdtestingByteArraytrueGet.');
|
||||
}
|
||||
|
||||
let useFormData = false;
|
||||
|
||||
let localVarDeferred = promise.defer<{ response: http.ClientResponse; body: string; }>();
|
||||
|
||||
let requestOptions: request.Options = {
|
||||
method: 'GET',
|
||||
qs: queryParameters,
|
||||
headers: headerParams,
|
||||
uri: localVarPath,
|
||||
json: true,
|
||||
}
|
||||
|
||||
this.authentications.api_key.applyToRequest(requestOptions);
|
||||
|
||||
this.authentications.petstore_auth.applyToRequest(requestOptions);
|
||||
|
||||
this.authentications.default.applyToRequest(requestOptions);
|
||||
|
||||
if (Object.keys(formParams).length) {
|
||||
@ -881,11 +623,7 @@ export class PetApi {
|
||||
}
|
||||
}
|
||||
export enum StoreApiApiKeys {
|
||||
test_api_key_header,
|
||||
api_key,
|
||||
test_api_client_secret,
|
||||
test_api_client_id,
|
||||
test_api_key_query,
|
||||
}
|
||||
|
||||
export class StoreApi {
|
||||
@ -894,21 +632,13 @@ export class StoreApi {
|
||||
|
||||
protected authentications = {
|
||||
'default': <Authentication>new VoidAuth(),
|
||||
'test_api_key_header': new ApiKeyAuth('header', 'test_api_key_header'),
|
||||
'api_key': new ApiKeyAuth('header', 'api_key'),
|
||||
'test_http_basic': new HttpBasicAuth(),
|
||||
'test_api_client_secret': new ApiKeyAuth('header', 'x-test_api_client_secret'),
|
||||
'test_api_client_id': new ApiKeyAuth('header', 'x-test_api_client_id'),
|
||||
'test_api_key_query': new ApiKeyAuth('query', 'test_api_key_query'),
|
||||
'petstore_auth': new OAuth(),
|
||||
'api_key': new ApiKeyAuth('header', 'api_key'),
|
||||
}
|
||||
|
||||
constructor(basePath?: string);
|
||||
constructor(username: string, password: string, basePath?: string);
|
||||
constructor(basePathOrUsername: string, password?: string, basePath?: string) {
|
||||
if (password) {
|
||||
this.username = basePathOrUsername;
|
||||
this.password = password
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
@ -923,14 +653,6 @@ export class StoreApi {
|
||||
this.authentications[StoreApiApiKeys[key]].apiKey = value;
|
||||
}
|
||||
|
||||
set username(username: string) {
|
||||
this.authentications.test_http_basic.username = username;
|
||||
}
|
||||
|
||||
set password(password: string) {
|
||||
this.authentications.test_http_basic.password = password;
|
||||
}
|
||||
|
||||
set accessToken(token: string) {
|
||||
this.authentications.petstore_auth.accessToken = token;
|
||||
}
|
||||
@ -996,62 +718,6 @@ export class StoreApi {
|
||||
|
||||
return localVarDeferred.promise;
|
||||
}
|
||||
/**
|
||||
* Finds orders by status
|
||||
* A single status value can be provided as a string
|
||||
* @param status Status value that needs to be considered for query
|
||||
*/
|
||||
public findOrdersByStatus (status?: string) : Promise<{ response: http.ClientResponse; body: Array<Order>; }> {
|
||||
const localVarPath = this.basePath + '/store/findByStatus';
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
let formParams: any = {};
|
||||
|
||||
|
||||
if (status !== undefined) {
|
||||
queryParameters['status'] = status;
|
||||
}
|
||||
|
||||
let useFormData = false;
|
||||
|
||||
let localVarDeferred = promise.defer<{ response: http.ClientResponse; body: Array<Order>; }>();
|
||||
|
||||
let requestOptions: request.Options = {
|
||||
method: 'GET',
|
||||
qs: queryParameters,
|
||||
headers: headerParams,
|
||||
uri: localVarPath,
|
||||
json: true,
|
||||
}
|
||||
|
||||
this.authentications.test_api_client_id.applyToRequest(requestOptions);
|
||||
|
||||
this.authentications.test_api_client_secret.applyToRequest(requestOptions);
|
||||
|
||||
this.authentications.default.applyToRequest(requestOptions);
|
||||
|
||||
if (Object.keys(formParams).length) {
|
||||
if (useFormData) {
|
||||
(<any>requestOptions).formData = formParams;
|
||||
} else {
|
||||
requestOptions.form = formParams;
|
||||
}
|
||||
}
|
||||
|
||||
request(requestOptions, (error, response, body) => {
|
||||
if (error) {
|
||||
localVarDeferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
localVarDeferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
localVarDeferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return localVarDeferred.promise;
|
||||
}
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
* Returns a map of status codes to quantities
|
||||
@ -1101,55 +767,6 @@ export class StoreApi {
|
||||
|
||||
return localVarDeferred.promise;
|
||||
}
|
||||
/**
|
||||
* Fake endpoint to test arbitrary object return by 'Get inventory'
|
||||
* Returns an arbitrary object which is actually a map of status codes to quantities
|
||||
*/
|
||||
public getInventoryInObject () : Promise<{ response: http.ClientResponse; body: any; }> {
|
||||
const localVarPath = this.basePath + '/store/inventory?response=arbitrary_object';
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
let formParams: any = {};
|
||||
|
||||
|
||||
let useFormData = false;
|
||||
|
||||
let localVarDeferred = promise.defer<{ response: http.ClientResponse; body: any; }>();
|
||||
|
||||
let requestOptions: request.Options = {
|
||||
method: 'GET',
|
||||
qs: queryParameters,
|
||||
headers: headerParams,
|
||||
uri: localVarPath,
|
||||
json: true,
|
||||
}
|
||||
|
||||
this.authentications.api_key.applyToRequest(requestOptions);
|
||||
|
||||
this.authentications.default.applyToRequest(requestOptions);
|
||||
|
||||
if (Object.keys(formParams).length) {
|
||||
if (useFormData) {
|
||||
(<any>requestOptions).formData = formParams;
|
||||
} else {
|
||||
requestOptions.form = formParams;
|
||||
}
|
||||
}
|
||||
|
||||
request(requestOptions, (error, response, body) => {
|
||||
if (error) {
|
||||
localVarDeferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
localVarDeferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
localVarDeferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return localVarDeferred.promise;
|
||||
}
|
||||
/**
|
||||
* Find purchase order by ID
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
@ -1180,10 +797,6 @@ export class StoreApi {
|
||||
json: true,
|
||||
}
|
||||
|
||||
this.authentications.test_api_key_header.applyToRequest(requestOptions);
|
||||
|
||||
this.authentications.test_api_key_query.applyToRequest(requestOptions);
|
||||
|
||||
this.authentications.default.applyToRequest(requestOptions);
|
||||
|
||||
if (Object.keys(formParams).length) {
|
||||
@ -1233,10 +846,6 @@ export class StoreApi {
|
||||
body: body,
|
||||
}
|
||||
|
||||
this.authentications.test_api_client_id.applyToRequest(requestOptions);
|
||||
|
||||
this.authentications.test_api_client_secret.applyToRequest(requestOptions);
|
||||
|
||||
this.authentications.default.applyToRequest(requestOptions);
|
||||
|
||||
if (Object.keys(formParams).length) {
|
||||
@ -1263,11 +872,7 @@ export class StoreApi {
|
||||
}
|
||||
}
|
||||
export enum UserApiApiKeys {
|
||||
test_api_key_header,
|
||||
api_key,
|
||||
test_api_client_secret,
|
||||
test_api_client_id,
|
||||
test_api_key_query,
|
||||
}
|
||||
|
||||
export class UserApi {
|
||||
@ -1276,21 +881,13 @@ export class UserApi {
|
||||
|
||||
protected authentications = {
|
||||
'default': <Authentication>new VoidAuth(),
|
||||
'test_api_key_header': new ApiKeyAuth('header', 'test_api_key_header'),
|
||||
'api_key': new ApiKeyAuth('header', 'api_key'),
|
||||
'test_http_basic': new HttpBasicAuth(),
|
||||
'test_api_client_secret': new ApiKeyAuth('header', 'x-test_api_client_secret'),
|
||||
'test_api_client_id': new ApiKeyAuth('header', 'x-test_api_client_id'),
|
||||
'test_api_key_query': new ApiKeyAuth('query', 'test_api_key_query'),
|
||||
'petstore_auth': new OAuth(),
|
||||
'api_key': new ApiKeyAuth('header', 'api_key'),
|
||||
}
|
||||
|
||||
constructor(basePath?: string);
|
||||
constructor(username: string, password: string, basePath?: string);
|
||||
constructor(basePathOrUsername: string, password?: string, basePath?: string) {
|
||||
if (password) {
|
||||
this.username = basePathOrUsername;
|
||||
this.password = password
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
@ -1305,14 +902,6 @@ export class UserApi {
|
||||
this.authentications[UserApiApiKeys[key]].apiKey = value;
|
||||
}
|
||||
|
||||
set username(username: string) {
|
||||
this.authentications.test_http_basic.username = username;
|
||||
}
|
||||
|
||||
set password(password: string) {
|
||||
this.authentications.test_http_basic.password = password;
|
||||
}
|
||||
|
||||
set accessToken(token: string) {
|
||||
this.authentications.petstore_auth.accessToken = token;
|
||||
}
|
||||
@ -1501,8 +1090,6 @@ export class UserApi {
|
||||
json: true,
|
||||
}
|
||||
|
||||
this.authentications.test_http_basic.applyToRequest(requestOptions);
|
||||
|
||||
this.authentications.default.applyToRequest(requestOptions);
|
||||
|
||||
if (Object.keys(formParams).length) {
|
1331
samples/client/petstore/typescript-node/npm/api.ts
Normal file
1331
samples/client/petstore/typescript-node/npm/api.ts
Normal file
File diff suppressed because it is too large
Load Diff
52
samples/client/petstore/typescript-node/npm/git_push.sh
Normal file
52
samples/client/petstore/typescript-node/npm/git_push.sh
Normal file
@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="YOUR_GIT_USR_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||
fi
|
||||
|
||||
if [ "$git_repo_id" = "" ]; then
|
||||
git_repo_id="YOUR_GIT_REPO_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||
fi
|
||||
|
||||
if [ "$release_note" = "" ]; then
|
||||
release_note="Minor update"
|
||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||
fi
|
||||
|
||||
# Initialize the local directory as a Git repository
|
||||
git init
|
||||
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
git_remote=`git remote`
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
|
||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
|
22
samples/client/petstore/typescript-node/npm/package.json
Normal file
22
samples/client/petstore/typescript-node/npm/package.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "@swagger/angular2-typescript-petstore",
|
||||
"version": "0.0.1-SNAPSHOT.201604282147",
|
||||
"description": "NodeJS client for @swagger/angular2-typescript-petstore",
|
||||
"main": "api.js",
|
||||
"scripts": {
|
||||
"build": "typings install && tsc"
|
||||
},
|
||||
"author": "Swagger Codegen Contributors",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bluebird": "^3.3.5",
|
||||
"request": "^2.72.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^1.8.10",
|
||||
"typings": "^0.8.1"
|
||||
},
|
||||
"publishConfig":{
|
||||
"registry":"https://skimdb.npmjs.com/registry"
|
||||
}
|
||||
}
|
18
samples/client/petstore/typescript-node/npm/tsconfig.json
Normal file
18
samples/client/petstore/typescript-node/npm/tsconfig.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"noImplicitAny": false,
|
||||
"suppressImplicitAnyIndexErrors": true,
|
||||
"target": "ES5",
|
||||
"moduleResolution": "node",
|
||||
"removeComments": true,
|
||||
"sourceMap": true,
|
||||
"noLib": false,
|
||||
"declaration": true
|
||||
},
|
||||
"files": [
|
||||
"api.ts",
|
||||
"typings/main.d.ts"
|
||||
]
|
||||
}
|
||||
|
10
samples/client/petstore/typescript-node/npm/typings.json
Normal file
10
samples/client/petstore/typescript-node/npm/typings.json
Normal file
@ -0,0 +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": {
|
||||
"request": "registry:npm/request#2.69.0+20160304121250"
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
{
|
||||
"name": "petstore-typescript-node-sample",
|
||||
"version": "1.0.0",
|
||||
"description": "Sample of generated TypeScript petstore client",
|
||||
"main": "api.js",
|
||||
"scripts": {
|
||||
"postinstall": "tsd reinstall --overwrite",
|
||||
"test": "tsc && node client.js",
|
||||
"clean": "rm -Rf node_modules/ typings/ *.js"
|
||||
},
|
||||
"author": "Mads M. Tandrup",
|
||||
"license": "Apache 2.0",
|
||||
"dependencies": {
|
||||
"bluebird": "^2.9.34",
|
||||
"request": "^2.60.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tsd": "^0.6.3",
|
||||
"typescript": "^1.5.3"
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 95 B |
@ -1,13 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"noImplicitAny": true,
|
||||
"suppressImplicitAnyIndexErrors": true,
|
||||
"target": "ES5"
|
||||
},
|
||||
"files": [
|
||||
"api.ts",
|
||||
"client.ts",
|
||||
"typings/tsd.d.ts"
|
||||
]
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
{
|
||||
"version": "v4",
|
||||
"repo": "borisyankov/DefinitelyTyped",
|
||||
"ref": "master",
|
||||
"path": "typings",
|
||||
"bundle": "typings/tsd.d.ts",
|
||||
"installed": {
|
||||
"bluebird/bluebird.d.ts": {
|
||||
"commit": "f6c8ca47193fb67947944a3170912672ac3e908e"
|
||||
},
|
||||
"request/request.d.ts": {
|
||||
"commit": "f6c8ca47193fb67947944a3170912672ac3e908e"
|
||||
},
|
||||
"form-data/form-data.d.ts": {
|
||||
"commit": "f6c8ca47193fb67947944a3170912672ac3e908e"
|
||||
},
|
||||
"node/node.d.ts": {
|
||||
"commit": "f6c8ca47193fb67947944a3170912672ac3e908e"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* ApiResponse
|
||||
*/
|
||||
namespace SwaggerServer\lib\models;
|
||||
|
||||
/*
|
||||
* ApiResponse
|
||||
*/
|
||||
class ApiResponse {
|
||||
/* @var int $code */
|
||||
private $code;
|
||||
/* @var string $type */
|
||||
private $type;
|
||||
/* @var string $message */
|
||||
private $message;
|
||||
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Category
|
||||
*/
|
||||
namespace SwaggerServer\lib\models;
|
||||
|
||||
/*
|
||||
* Category
|
||||
*/
|
||||
class Category {
|
||||
/* @var int $id */
|
||||
private $id;
|
||||
/* @var string $name */
|
||||
private $name;
|
||||
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Order
|
||||
*/
|
||||
namespace SwaggerServer\lib\models;
|
||||
|
||||
/*
|
||||
* Order
|
||||
*/
|
||||
class Order {
|
||||
/* @var int $id */
|
||||
private $id;
|
||||
/* @var int $pet_id */
|
||||
private $pet_id;
|
||||
/* @var int $quantity */
|
||||
private $quantity;
|
||||
/* @var DateTime $ship_date */
|
||||
private $ship_date;
|
||||
/* @var string $status Order Status */
|
||||
private $status;
|
||||
/* @var boolean $complete */
|
||||
private $complete;
|
||||
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Pet
|
||||
*/
|
||||
namespace SwaggerServer\lib\models;
|
||||
|
||||
/*
|
||||
* Pet
|
||||
*/
|
||||
class Pet {
|
||||
/* @var int $id */
|
||||
private $id;
|
||||
/* @var Category $category */
|
||||
private $category;
|
||||
/* @var string $name */
|
||||
private $name;
|
||||
/* @var array[string] $photo_urls */
|
||||
private $photo_urls;
|
||||
/* @var array[Tag] $tags */
|
||||
private $tags;
|
||||
/* @var string $status pet status in the store */
|
||||
private $status;
|
||||
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Tag
|
||||
*/
|
||||
namespace SwaggerServer\lib\models;
|
||||
|
||||
/*
|
||||
* Tag
|
||||
*/
|
||||
class Tag {
|
||||
/* @var int $id */
|
||||
private $id;
|
||||
/* @var string $name */
|
||||
private $name;
|
||||
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* User
|
||||
*/
|
||||
namespace SwaggerServer\lib\models;
|
||||
|
||||
/*
|
||||
* User
|
||||
*/
|
||||
class User {
|
||||
/* @var int $id */
|
||||
private $id;
|
||||
/* @var string $username */
|
||||
private $username;
|
||||
/* @var string $first_name */
|
||||
private $first_name;
|
||||
/* @var string $last_name */
|
||||
private $last_name;
|
||||
/* @var string $email */
|
||||
private $email;
|
||||
/* @var string $password */
|
||||
private $password;
|
||||
/* @var string $phone */
|
||||
private $phone;
|
||||
/* @var int $user_status User Status */
|
||||
private $user_status;
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user