mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-06 10:35:25 +00:00
feature: add scaffold for typescript axios template (#892)
* feature: add generator for typescript/axios * feature: add sample scripts and sample code * fix: set request body in data property * feature: add samples and tests for typescript axios client * test: add tests for typescript axios client
This commit is contained in:
parent
24b234bdbb
commit
3027514242
6
bin/typescript-axios-petstore-all.sh
Normal file
6
bin/typescript-axios-petstore-all.sh
Normal file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
./bin/typescript-axios-petstore-target-es6.sh
|
||||
./bin/typescript-axios-petstore-with-npm-version.sh
|
||||
./bin/typescript-axios-petstore-interfaces.sh
|
||||
./bin/typescript-axios-petstore.sh
|
32
bin/typescript-axios-petstore-interfaces.sh
Normal file
32
bin/typescript-axios-petstore-interfaces.sh
Normal file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
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/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B 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/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-axios -o samples/client/petstore/typescript-axios/builds/with-interfaces -D withInterfaces=true $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
7
bin/typescript-axios-petstore-target-es6.json
Normal file
7
bin/typescript-axios-petstore-target-es6.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"npmName": "@swagger/typescript-axios-petstore",
|
||||
"npmVersion": "1.0.0",
|
||||
"npmRepository": "https://skimdb.npmjs.com/registry",
|
||||
"snapshot": false,
|
||||
"supportsES6": true
|
||||
}
|
32
bin/typescript-axios-petstore-target-es6.sh
Normal file
32
bin/typescript-axios-petstore-target-es6.sh
Normal file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
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/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B 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/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-axios -c bin/typescript-axios-petstore-target-es6.json -o samples/client/petstore/typescript-axios/builds/es6-target $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
6
bin/typescript-axios-petstore-with-npm-version.json
Normal file
6
bin/typescript-axios-petstore-with-npm-version.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"npmName": "@swagger/typescript-axios-petstore",
|
||||
"npmVersion": "1.0.0",
|
||||
"npmRepository": "https://skimdb.npmjs.com/registry",
|
||||
"snapshot": false
|
||||
}
|
32
bin/typescript-axios-petstore-with-npm-version.sh
Normal file
32
bin/typescript-axios-petstore-with-npm-version.sh
Normal file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
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/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B 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/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-axios -c bin/typescript-axios-petstore-with-npm-version.json -o samples/client/petstore/typescript-axios/builds/with-npm-version $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
32
bin/typescript-axios-petstore.sh
Normal file
32
bin/typescript-axios-petstore.sh
Normal file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
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/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B 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/openapi-generator/src/test/resources/2_0/petstore.yaml -g typescript-axios -o samples/client/petstore/typescript-axios/builds/default $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
6
bin/windows/typescript-axios-petstore-all.bat
Normal file
6
bin/windows/typescript-axios-petstore-all.bat
Normal file
@ -0,0 +1,6 @@
|
||||
@ECHO OFF
|
||||
|
||||
call bin\windows\typescript-axios-petstore.bat
|
||||
call bin\windows\typescript-axios-petstore-target-es6.bat
|
||||
call bin\windows\typescript-axios-petstore-with-npm-version.bat
|
||||
call bin\windows\typescript-axios-petstore-interfaces.bat
|
12
bin/windows/typescript-axios-petstore-interfaces.bat
Normal file
12
bin/windows/typescript-axios-petstore-interfaces.bat
Normal file
@ -0,0 +1,12 @@
|
||||
@ECHO OFF
|
||||
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-axios -o samples\client\petstore\typescript-axios\builds\with-interfaces -D withInterfaces=true
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
12
bin/windows/typescript-axios-petstore-target-es6.bat
Normal file
12
bin/windows/typescript-axios-petstore-target-es6.bat
Normal file
@ -0,0 +1,12 @@
|
||||
@ECHO OFF
|
||||
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-axios -c bin\typescript-axios-petstore-target-es6.json -o samples\client\petstore\typescript-axios\builds\es6-target
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
12
bin/windows/typescript-axios-petstore-with-npm-version.bat
Normal file
12
bin/windows/typescript-axios-petstore-with-npm-version.bat
Normal file
@ -0,0 +1,12 @@
|
||||
@ECHO OFF
|
||||
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-axios -c bin\typescript-axios-petstore-with-npm-version.json -o samples\client\petstore\typescript-axios\builds\with-npm-version
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
14
bin/windows/typescript-axios-petstore.bat
Normal file
14
bin/windows/typescript-axios-petstore.bat
Normal file
@ -0,0 +1,14 @@
|
||||
@ECHO OFF
|
||||
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
|
||||
echo
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-axios -o samples\client\petstore\typescript-axios\builds\default
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
@ -0,0 +1,159 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
* Copyright 2018 SmartBear Software
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodegen {
|
||||
private static final SimpleDateFormat SNAPSHOT_SUFFIX_FORMAT = new SimpleDateFormat("yyyyMMddHHmm", Locale.ROOT);
|
||||
|
||||
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";
|
||||
public static final String WITH_INTERFACES = "withInterfaces";
|
||||
|
||||
protected String npmName = null;
|
||||
protected String npmVersion = "1.0.0";
|
||||
protected String npmRepository = null;
|
||||
|
||||
public TypeScriptAxiosClientCodegen() {
|
||||
super();
|
||||
|
||||
// clear import mapping (from default generator) as TS does not use it
|
||||
// at the moment
|
||||
importMapping.clear();
|
||||
|
||||
outputFolder = "generated-code/typescript-axios";
|
||||
embeddedTemplateDir = templateDir = "typescript-axios";
|
||||
|
||||
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", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||
this.cliOptions.add(new CliOption(WITH_INTERFACES, "Setting this property to true will generate interfaces next to the default class implementations.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "typescript-axios";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a TypeScript client library using axios.";
|
||||
}
|
||||
|
||||
public String getNpmName() {
|
||||
return npmName;
|
||||
}
|
||||
|
||||
public void setNpmName(String npmName) {
|
||||
this.npmName = npmName;
|
||||
}
|
||||
|
||||
public String getNpmVersion() {
|
||||
return npmVersion;
|
||||
}
|
||||
|
||||
public void setNpmVersion(String npmVersion) {
|
||||
this.npmVersion = npmVersion;
|
||||
}
|
||||
|
||||
public String getNpmRepository() {
|
||||
return npmRepository;
|
||||
}
|
||||
|
||||
public void setNpmRepository(String npmRepository) {
|
||||
this.npmRepository = npmRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
supportingFiles.add(new SupportingFile("index.mustache", "", "index.ts"));
|
||||
supportingFiles.add(new SupportingFile("api.mustache", "", "api.ts"));
|
||||
supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.ts"));
|
||||
supportingFiles.add(new SupportingFile("custom.d.mustache", "", "custom.d.ts"));
|
||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||
supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));
|
||||
|
||||
if (additionalProperties.containsKey(NPM_NAME)) {
|
||||
addNpmPackageGeneration();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
Schema inner;
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
inner = ((ArraySchema) p).getItems();
|
||||
return this.getSchemaType(p) + "<" + this.getTypeDeclaration(inner) + ">";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
inner = ModelUtils.getAdditionalProperties(p);
|
||||
return "{ [key: string]: " + this.getTypeDeclaration(inner) + "; }";
|
||||
} else if (ModelUtils.isFileSchema(p)) {
|
||||
return "any";
|
||||
} else if (ModelUtils.isBinarySchema(p)) {
|
||||
return "any";
|
||||
} else {
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, Schema schema) {
|
||||
codegenModel.additionalPropertiesType = getTypeDeclaration(ModelUtils.getAdditionalProperties(schema));
|
||||
addImport(codegenModel, codegenModel.additionalPropertiesType);
|
||||
}
|
||||
|
||||
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("README.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json"));
|
||||
supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json"));
|
||||
}
|
||||
|
||||
}
|
@ -89,6 +89,7 @@ org.openapitools.codegen.languages.Swift4Codegen
|
||||
org.openapitools.codegen.languages.TypeScriptAngularClientCodegen
|
||||
org.openapitools.codegen.languages.TypeScriptAngularJsClientCodegen
|
||||
org.openapitools.codegen.languages.TypeScriptAureliaClientCodegen
|
||||
org.openapitools.codegen.languages.TypeScriptAxiosClientCodegen
|
||||
org.openapitools.codegen.languages.TypeScriptFetchClientCodegen
|
||||
org.openapitools.codegen.languages.TypeScriptInversifyClientCodegen
|
||||
org.openapitools.codegen.languages.TypeScriptJqueryClientCodegen
|
||||
|
@ -0,0 +1,45 @@
|
||||
## {{npmName}}@{{npmVersion}}
|
||||
|
||||
This generator creates TypeScript/JavaScript client that utilizes [axios](https://github.com/axios/axios). The generated Node module can be used in the following environments:
|
||||
|
||||
Environment
|
||||
* Node.js
|
||||
* Webpack
|
||||
* Browserify
|
||||
|
||||
Language level
|
||||
* ES5 - you must have a Promises/A+ library installed
|
||||
* ES6
|
||||
|
||||
Module system
|
||||
* CommonJS
|
||||
* ES6 module system
|
||||
|
||||
It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html))
|
||||
|
||||
### Building
|
||||
|
||||
To build and compile the typescript sources to javascript use:
|
||||
```
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
### Publishing
|
||||
|
||||
First build the package then run ```npm publish```
|
||||
|
||||
### Consuming
|
||||
|
||||
navigate to the folder of your consuming project and run one of the following commands.
|
||||
|
||||
_published:_
|
||||
|
||||
```
|
||||
npm install {{npmName}}@{{npmVersion}} --save
|
||||
```
|
||||
|
||||
_unPublished (not recommended):_
|
||||
|
||||
```
|
||||
npm install PATH_TO_GENERATED_PACKAGE --save
|
@ -0,0 +1,354 @@
|
||||
// tslint:disable
|
||||
/// <reference path="./custom.d.ts" />
|
||||
{{>licenseInfo}}
|
||||
|
||||
import * as url from "url";
|
||||
import { Configuration } from "./configuration";
|
||||
import axios, { AxiosPromise } from 'axios';
|
||||
|
||||
const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, "");
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const COLLECTION_FORMATS = {
|
||||
csv: ",",
|
||||
ssv: " ",
|
||||
tsv: "\t",
|
||||
pipes: "|",
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @interface RequestArgs
|
||||
*/
|
||||
export interface RequestArgs {
|
||||
url: string;
|
||||
options: any;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @class BaseAPI
|
||||
*/
|
||||
export class BaseAPI {
|
||||
protected configuration: Configuration | undefined;
|
||||
|
||||
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH) {
|
||||
if (configuration) {
|
||||
this.configuration = configuration;
|
||||
this.basePath = configuration.basePath || this.basePath;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @class RequiredError
|
||||
* @extends {Error}
|
||||
*/
|
||||
export class RequiredError extends Error {
|
||||
name: "RequiredError" = "RequiredError";
|
||||
constructor(public field: string, msg?: string) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
|
||||
{{#models}}
|
||||
{{#model}}{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>modelGeneric}}{{/isEnum}}{{/model}}
|
||||
{{/models}}
|
||||
{{#apiInfo}}{{#apis}}{{#operations}}
|
||||
/**
|
||||
* {{classname}} - axios parameter creator{{#description}}
|
||||
* {{&description}}{{/description}}
|
||||
* @export
|
||||
*/
|
||||
export const {{classname}}AxiosParamCreator = function (configuration?: Configuration) {
|
||||
return {
|
||||
{{#operation}}
|
||||
/**
|
||||
* {{¬es}}
|
||||
{{#summary}}
|
||||
* @summary {{&summary}}
|
||||
{{/summary}}
|
||||
{{#allParams}}
|
||||
* @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
|
||||
{{/allParams}}
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options: any = {}): RequestArgs {
|
||||
{{#allParams}}
|
||||
{{#required}}
|
||||
// verify required parameter '{{paramName}}' is not null or undefined
|
||||
if ({{paramName}} === null || {{paramName}} === undefined) {
|
||||
throw new RequiredError('{{paramName}}','Required parameter {{paramName}} was null or undefined when calling {{nickname}}.');
|
||||
}
|
||||
{{/required}}
|
||||
{{/allParams}}
|
||||
const localVarPath = `{{{path}}}`{{#pathParams}}
|
||||
.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String({{paramName}}))){{/pathParams}};
|
||||
const localVarUrlObj = url.parse(localVarPath, true);
|
||||
let baseOptions;
|
||||
if (configuration) {
|
||||
baseOptions = configuration.baseOptions;
|
||||
}
|
||||
const localVarRequestOptions = Object.assign({ method: '{{httpMethod}}' }, baseOptions, options);
|
||||
const localVarHeaderParameter = {} as any;
|
||||
const localVarQueryParameter = {} as any;
|
||||
{{#hasFormParams}}
|
||||
const localVarFormParams = new url.URLSearchParams();
|
||||
{{/hasFormParams}}
|
||||
|
||||
{{#authMethods}}
|
||||
// authentication {{name}} required
|
||||
{{#isApiKey}}
|
||||
{{#isKeyInHeader}}
|
||||
if (configuration && configuration.apiKey) {
|
||||
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
|
||||
? configuration.apiKey("{{keyParamName}}")
|
||||
: configuration.apiKey;
|
||||
localVarHeaderParameter["{{keyParamName}}"] = localVarApiKeyValue;
|
||||
}
|
||||
{{/isKeyInHeader}}
|
||||
{{#isKeyInQuery}}
|
||||
if (configuration && configuration.apiKey) {
|
||||
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
|
||||
? configuration.apiKey("{{keyParamName}}")
|
||||
: configuration.apiKey;
|
||||
localVarQueryParameter["{{keyParamName}}"] = localVarApiKeyValue;
|
||||
}
|
||||
{{/isKeyInQuery}}
|
||||
{{/isApiKey}}
|
||||
{{#isBasic}}
|
||||
// http basic authentication required
|
||||
if (configuration && (configuration.username || configuration.password)) {
|
||||
localVarHeaderParameter["Authorization"] = "Basic " + btoa(configuration.username + ":" + configuration.password);
|
||||
}
|
||||
{{/isBasic}}
|
||||
{{#isOAuth}}
|
||||
// oauth required
|
||||
if (configuration && configuration.accessToken) {
|
||||
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
|
||||
? configuration.accessToken("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}])
|
||||
: configuration.accessToken;
|
||||
localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue;
|
||||
}
|
||||
{{/isOAuth}}
|
||||
|
||||
{{/authMethods}}
|
||||
{{#queryParams}}
|
||||
{{#isListContainer}}
|
||||
if ({{paramName}}) {
|
||||
{{#isCollectionFormatMulti}}
|
||||
localVarQueryParameter['{{baseName}}'] = {{paramName}};
|
||||
{{/isCollectionFormatMulti}}
|
||||
{{^isCollectionFormatMulti}}
|
||||
localVarQueryParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]);
|
||||
{{/isCollectionFormatMulti}}
|
||||
}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
if ({{paramName}} !== undefined) {
|
||||
{{#isDateTime}}
|
||||
localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any).toISOString();
|
||||
{{/isDateTime}}
|
||||
{{^isDateTime}}
|
||||
{{#isDate}}
|
||||
localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any).toISOString();
|
||||
{{/isDate}}
|
||||
{{^isDate}}
|
||||
localVarQueryParameter['{{baseName}}'] = {{paramName}};
|
||||
{{/isDate}}
|
||||
{{/isDateTime}}
|
||||
}
|
||||
{{/isListContainer}}
|
||||
|
||||
{{/queryParams}}
|
||||
{{#headerParams}}
|
||||
{{#isListContainer}}
|
||||
if ({{paramName}}) {
|
||||
localVarHeaderParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]));
|
||||
}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
if ({{paramName}} !== undefined && {{paramName}} !== null) {
|
||||
localVarHeaderParameter['{{baseName}}'] = String({{paramName}});
|
||||
}
|
||||
{{/isListContainer}}
|
||||
|
||||
{{/headerParams}}
|
||||
{{#formParams}}
|
||||
{{#isListContainer}}
|
||||
if ({{paramName}}) {
|
||||
{{#isCollectionFormatMulti}}
|
||||
{{paramName}}.forEach((element) => {
|
||||
localVarFormParams.append('{{baseName}}', element as any);
|
||||
})
|
||||
{{/isCollectionFormatMulti}}
|
||||
{{^isCollectionFormatMulti}}
|
||||
localVarFormParams.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]));
|
||||
{{/isCollectionFormatMulti}}
|
||||
}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
if ({{paramName}} !== undefined) {
|
||||
localVarFormParams.set('{{baseName}}', {{paramName}} as any);
|
||||
}
|
||||
{{/isListContainer}}
|
||||
|
||||
{{/formParams}}
|
||||
{{#hasFormParams}}
|
||||
localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||
|
||||
{{/hasFormParams}}
|
||||
{{#bodyParam}}
|
||||
{{^consumes}}
|
||||
localVarHeaderParameter['Content-Type'] = 'application/json';
|
||||
{{/consumes}}
|
||||
{{#consumes.0}}
|
||||
localVarHeaderParameter['Content-Type'] = '{{{mediaType}}}';
|
||||
{{/consumes.0}}
|
||||
|
||||
{{/bodyParam}}
|
||||
localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query);
|
||||
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
|
||||
delete localVarUrlObj.search;
|
||||
localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
|
||||
{{#hasFormParams}}
|
||||
localVarRequestOptions.data = localVarFormParams.toString();
|
||||
{{/hasFormParams}}
|
||||
{{#bodyParam}}
|
||||
const needsSerialization = (<any>"{{dataType}}" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
|
||||
localVarRequestOptions.data = needsSerialization ? JSON.stringify({{paramName}} || {}) : ({{paramName}} || "");
|
||||
{{/bodyParam}}
|
||||
|
||||
return {
|
||||
url: url.format(localVarUrlObj),
|
||||
options: localVarRequestOptions,
|
||||
};
|
||||
},
|
||||
{{/operation}}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* {{classname}} - functional programming interface{{#description}}
|
||||
* {{{description}}}{{/description}}
|
||||
* @export
|
||||
*/
|
||||
export const {{classname}}Fp = function(configuration?: Configuration) {
|
||||
return {
|
||||
{{#operation}}
|
||||
/**
|
||||
* {{¬es}}
|
||||
{{#summary}}
|
||||
* @summary {{&summary}}
|
||||
{{/summary}}
|
||||
{{#allParams}}
|
||||
* @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
|
||||
{{/allParams}}
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): (basePath?: string) => AxiosPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}> {
|
||||
const localVarAxiosArgs = {{classname}}AxiosParamCreator(configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options);
|
||||
return (basePath: string = BASE_PATH) => {
|
||||
const axiosRequestArgs = Object.assign(localVarAxiosArgs.options, {url: basePath + localVarAxiosArgs.url})
|
||||
return axios.request(axiosRequestArgs);
|
||||
};
|
||||
},
|
||||
{{/operation}}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* {{classname}} - factory interface{{#description}}
|
||||
* {{&description}}{{/description}}
|
||||
* @export
|
||||
*/
|
||||
export const {{classname}}Factory = function (configuration?: Configuration, basePath?: string) {
|
||||
return {
|
||||
{{#operation}}
|
||||
/**
|
||||
* {{¬es}}
|
||||
{{#summary}}
|
||||
* @summary {{&summary}}
|
||||
{{/summary}}
|
||||
{{#allParams}}
|
||||
* @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
|
||||
{{/allParams}}
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any) {
|
||||
return {{classname}}Fp(configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options)(basePath);
|
||||
},
|
||||
{{/operation}}
|
||||
};
|
||||
};
|
||||
|
||||
{{#withInterfaces}}
|
||||
/**
|
||||
* {{classname}} - interface{{#description}}
|
||||
* {{&description}}{{/description}}
|
||||
* @export
|
||||
* @interface {{classname}}
|
||||
*/
|
||||
export interface {{classname}}Interface {
|
||||
{{#operation}}
|
||||
/**
|
||||
* {{¬es}}
|
||||
{{#summary}}
|
||||
* @summary {{&summary}}
|
||||
{{/summary}}
|
||||
{{#allParams}}
|
||||
* @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
|
||||
{{/allParams}}
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
* @memberof {{classname}}Interface
|
||||
*/
|
||||
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}>;
|
||||
|
||||
{{/operation}}
|
||||
}
|
||||
|
||||
{{/withInterfaces}}
|
||||
/**
|
||||
* {{classname}} - object-oriented interface{{#description}}
|
||||
* {{{description}}}{{/description}}
|
||||
* @export
|
||||
* @class {{classname}}
|
||||
* @extends {BaseAPI}
|
||||
*/
|
||||
{{#withInterfaces}}
|
||||
export class {{classname}} extends BaseAPI implements {{classname}}Interface {
|
||||
{{/withInterfaces}}
|
||||
{{^withInterfaces}}
|
||||
export class {{classname}} extends BaseAPI {
|
||||
{{/withInterfaces}}
|
||||
{{#operation}}
|
||||
/**
|
||||
* {{¬es}}
|
||||
{{#summary}}
|
||||
* @summary {{&summary}}
|
||||
{{/summary}}
|
||||
{{#allParams}}
|
||||
* @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
|
||||
{{/allParams}}
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
* @memberof {{classname}}
|
||||
*/
|
||||
public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any) {
|
||||
return {{classname}}Fp(this.configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options)(this.basePath);
|
||||
}
|
||||
|
||||
{{/operation}}
|
||||
}
|
||||
{{/operations}}{{/apis}}{{/apiInfo}}
|
@ -0,0 +1,63 @@
|
||||
// tslint:disable
|
||||
{{>licenseInfo}}
|
||||
|
||||
export interface ConfigurationParameters {
|
||||
apiKey?: string | ((name: string) => string);
|
||||
username?: string;
|
||||
password?: string;
|
||||
accessToken?: string | ((name: string, scopes?: string[]) => string);
|
||||
basePath?: string;
|
||||
baseOptions?: any;
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
/**
|
||||
* parameter for apiKey security
|
||||
* @param name security name
|
||||
* @memberof Configuration
|
||||
*/
|
||||
apiKey?: string | ((name: string) => string);
|
||||
/**
|
||||
* parameter for basic security
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
username?: string;
|
||||
/**
|
||||
* parameter for basic security
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
password?: string;
|
||||
/**
|
||||
* parameter for oauth2 security
|
||||
* @param name security name
|
||||
* @param scopes oauth2 scope
|
||||
* @memberof Configuration
|
||||
*/
|
||||
accessToken?: string | ((name: string, scopes?: string[]) => string);
|
||||
/**
|
||||
* override base path
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
basePath?: string;
|
||||
/**
|
||||
* base options for axios calls
|
||||
*
|
||||
* @type {any}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
baseOptions?: any;
|
||||
|
||||
constructor(param: ConfigurationParameters = {}) {
|
||||
this.apiKey = param.apiKey;
|
||||
this.username = param.username;
|
||||
this.password = param.password;
|
||||
this.accessToken = param.accessToken;
|
||||
this.basePath = param.basePath;
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
declare module 'url';
|
@ -0,0 +1,51 @@
|
||||
#!/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 openapi-pestore-perl "minor update"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="{{{gitUserId}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||
fi
|
||||
|
||||
if [ "$git_repo_id" = "" ]; then
|
||||
git_repo_id="{{{gitRepoId}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||
fi
|
||||
|
||||
if [ "$release_note" = "" ]; then
|
||||
release_note="{{{releaseNote}}}"
|
||||
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 credential 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'
|
@ -0,0 +1,3 @@
|
||||
wwwroot/*.js
|
||||
node_modules
|
||||
typings
|
@ -0,0 +1,5 @@
|
||||
// tslint:disable
|
||||
{{>licenseInfo}}
|
||||
|
||||
export * from "./api";
|
||||
export * from "./configuration";
|
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* {{{appName}}}
|
||||
* {{{appDescription}}}
|
||||
*
|
||||
* {{#version}}OpenAPI spec version: {{{version}}}{{/version}}
|
||||
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
@ -0,0 +1,12 @@
|
||||
/**
|
||||
* {{{description}}}
|
||||
* @export
|
||||
* @enum {string}
|
||||
*/
|
||||
export enum {{classname}} {
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
{{{name}}} = {{{value}}}{{^-last}},{{/-last}}
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* {{{description}}}
|
||||
* @export
|
||||
* @interface {{classname}}
|
||||
*/
|
||||
export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{
|
||||
{{#additionalPropertiesType}}
|
||||
[key: string]: {{{additionalPropertiesType}}}{{#hasVars}} | any{{/hasVars}};
|
||||
|
||||
{{/additionalPropertiesType}}
|
||||
{{#vars}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
* @type {{=<% %>=}}{<%&datatype%>}<%={{ }}=%>
|
||||
* @memberof {{classname}}
|
||||
*/
|
||||
{{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}};
|
||||
{{/vars}}
|
||||
}{{#hasEnums}}
|
||||
|
||||
/**
|
||||
* @export
|
||||
* @namespace {{classname}}
|
||||
*/
|
||||
export namespace {{classname}} {
|
||||
{{#vars}}
|
||||
{{#isEnum}}
|
||||
/**
|
||||
* @export
|
||||
* @enum {string}
|
||||
*/
|
||||
export enum {{enumName}} {
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
{{{name}}} = {{{value}}}{{^-last}},{{/-last}}
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
}
|
||||
{{/isEnum}}
|
||||
{{/vars}}
|
||||
}{{/hasEnums}}
|
@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "{{npmName}}",
|
||||
"version": "{{npmVersion}}",
|
||||
"description": "OpenAPI client for {{npmName}}",
|
||||
"author": "OpenAPI-Generator Contributors",
|
||||
"keywords": [
|
||||
"axios",
|
||||
"typescript",
|
||||
"openapi-client",
|
||||
"openapi-generator",
|
||||
"{{npmName}}"
|
||||
],
|
||||
"license": "Unlicense",
|
||||
"main": "./dist/index.js",
|
||||
"typings": "./dist/index.d.ts",
|
||||
"scripts" : {
|
||||
"build": "tsc --outDir dist/",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.18.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^8.0.9",
|
||||
"typescript": "^2.4"
|
||||
}{{#npmRepository}},{{/npmRepository}}
|
||||
{{#npmRepository}}
|
||||
"publishConfig":{
|
||||
"registry":"{{npmRepository}}"
|
||||
}
|
||||
{{/npmRepository}}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"target": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}es5{{/supportsES6}}",
|
||||
"module": "commonjs",
|
||||
"noImplicitAny": true,
|
||||
"outDir": "dist",
|
||||
"rootDir": "."{{^supportsES6}},
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
]
|
||||
{{/supportsES6}}
|
||||
},
|
||||
"exclude": [
|
||||
"dist",
|
||||
"node_modules"
|
||||
]
|
||||
}
|
1
pom.xml
1
pom.xml
@ -1039,6 +1039,7 @@
|
||||
<module>samples/client/petstore/typescript-fetch/builds/es6-target</module>
|
||||
<module>samples/client/petstore/typescript-fetch/builds/with-npm-version</module>
|
||||
<module>samples/client/petstore/typescript-fetch/tests/default</module>
|
||||
<module>samples/client/petstore/typescript-axios/tests/default</module>
|
||||
<module>samples/client/petstore/typescript-node/npm</module>
|
||||
<!-- comment out due to github rate limit error
|
||||
<module>samples/client/petstore/typescript-angularjs</module>-->
|
||||
|
3
samples/client/petstore/typescript-axios/builds/default/.gitignore
vendored
Normal file
3
samples/client/petstore/typescript-axios/builds/default/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
wwwroot/*.js
|
||||
node_modules
|
||||
typings
|
@ -0,0 +1,23 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
@ -0,0 +1 @@
|
||||
3.2.3-SNAPSHOT
|
1962
samples/client/petstore/typescript-axios/builds/default/api.ts
Normal file
1962
samples/client/petstore/typescript-axios/builds/default/api.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,74 @@
|
||||
// tslint:disable
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface ConfigurationParameters {
|
||||
apiKey?: string | ((name: string) => string);
|
||||
username?: string;
|
||||
password?: string;
|
||||
accessToken?: string | ((name: string, scopes?: string[]) => string);
|
||||
basePath?: string;
|
||||
baseOptions?: any;
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
/**
|
||||
* parameter for apiKey security
|
||||
* @param name security name
|
||||
* @memberof Configuration
|
||||
*/
|
||||
apiKey?: string | ((name: string) => string);
|
||||
/**
|
||||
* parameter for basic security
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
username?: string;
|
||||
/**
|
||||
* parameter for basic security
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
password?: string;
|
||||
/**
|
||||
* parameter for oauth2 security
|
||||
* @param name security name
|
||||
* @param scopes oauth2 scope
|
||||
* @memberof Configuration
|
||||
*/
|
||||
accessToken?: string | ((name: string, scopes?: string[]) => string);
|
||||
/**
|
||||
* override base path
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
basePath?: string;
|
||||
/**
|
||||
* base options for axios calls
|
||||
*
|
||||
* @type {any}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
baseOptions?: any;
|
||||
|
||||
constructor(param: ConfigurationParameters = {}) {
|
||||
this.apiKey = param.apiKey;
|
||||
this.username = param.username;
|
||||
this.password = param.password;
|
||||
this.accessToken = param.accessToken;
|
||||
this.basePath = param.basePath;
|
||||
}
|
||||
}
|
1
samples/client/petstore/typescript-axios/builds/default/custom.d.ts
vendored
Normal file
1
samples/client/petstore/typescript-axios/builds/default/custom.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
declare module 'url';
|
@ -0,0 +1,51 @@
|
||||
#!/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 openapi-pestore-perl "minor update"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="GIT_USER_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="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 credential 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'
|
@ -0,0 +1,16 @@
|
||||
// tslint:disable
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export * from "./api";
|
||||
export * from "./configuration";
|
3
samples/client/petstore/typescript-axios/builds/es6-target/.gitignore
vendored
Normal file
3
samples/client/petstore/typescript-axios/builds/es6-target/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
wwwroot/*.js
|
||||
node_modules
|
||||
typings
|
@ -0,0 +1,23 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
@ -0,0 +1 @@
|
||||
3.2.3-SNAPSHOT
|
@ -0,0 +1,45 @@
|
||||
## @swagger/typescript-axios-petstore@1.0.0
|
||||
|
||||
This generator creates TypeScript/JavaScript client that utilizes [axios](https://github.com/axios/axios). The generated Node module can be used in the following environments:
|
||||
|
||||
Environment
|
||||
* Node.js
|
||||
* Webpack
|
||||
* Browserify
|
||||
|
||||
Language level
|
||||
* ES5 - you must have a Promises/A+ library installed
|
||||
* ES6
|
||||
|
||||
Module system
|
||||
* CommonJS
|
||||
* ES6 module system
|
||||
|
||||
It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html))
|
||||
|
||||
### Building
|
||||
|
||||
To build and compile the typescript sources to javascript use:
|
||||
```
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
### Publishing
|
||||
|
||||
First build the package then run ```npm publish```
|
||||
|
||||
### Consuming
|
||||
|
||||
navigate to the folder of your consuming project and run one of the following commands.
|
||||
|
||||
_published:_
|
||||
|
||||
```
|
||||
npm install @swagger/typescript-axios-petstore@1.0.0 --save
|
||||
```
|
||||
|
||||
_unPublished (not recommended):_
|
||||
|
||||
```
|
||||
npm install PATH_TO_GENERATED_PACKAGE --save
|
1962
samples/client/petstore/typescript-axios/builds/es6-target/api.ts
Normal file
1962
samples/client/petstore/typescript-axios/builds/es6-target/api.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,74 @@
|
||||
// tslint:disable
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface ConfigurationParameters {
|
||||
apiKey?: string | ((name: string) => string);
|
||||
username?: string;
|
||||
password?: string;
|
||||
accessToken?: string | ((name: string, scopes?: string[]) => string);
|
||||
basePath?: string;
|
||||
baseOptions?: any;
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
/**
|
||||
* parameter for apiKey security
|
||||
* @param name security name
|
||||
* @memberof Configuration
|
||||
*/
|
||||
apiKey?: string | ((name: string) => string);
|
||||
/**
|
||||
* parameter for basic security
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
username?: string;
|
||||
/**
|
||||
* parameter for basic security
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
password?: string;
|
||||
/**
|
||||
* parameter for oauth2 security
|
||||
* @param name security name
|
||||
* @param scopes oauth2 scope
|
||||
* @memberof Configuration
|
||||
*/
|
||||
accessToken?: string | ((name: string, scopes?: string[]) => string);
|
||||
/**
|
||||
* override base path
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
basePath?: string;
|
||||
/**
|
||||
* base options for axios calls
|
||||
*
|
||||
* @type {any}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
baseOptions?: any;
|
||||
|
||||
constructor(param: ConfigurationParameters = {}) {
|
||||
this.apiKey = param.apiKey;
|
||||
this.username = param.username;
|
||||
this.password = param.password;
|
||||
this.accessToken = param.accessToken;
|
||||
this.basePath = param.basePath;
|
||||
}
|
||||
}
|
1
samples/client/petstore/typescript-axios/builds/es6-target/custom.d.ts
vendored
Normal file
1
samples/client/petstore/typescript-axios/builds/es6-target/custom.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
declare module 'url';
|
@ -0,0 +1,51 @@
|
||||
#!/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 openapi-pestore-perl "minor update"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="GIT_USER_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="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 credential 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'
|
@ -0,0 +1,16 @@
|
||||
// tslint:disable
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export * from "./api";
|
||||
export * from "./configuration";
|
@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "@swagger/typescript-axios-petstore",
|
||||
"version": "1.0.0",
|
||||
"description": "OpenAPI client for @swagger/typescript-axios-petstore",
|
||||
"author": "OpenAPI-Generator Contributors",
|
||||
"keywords": [
|
||||
"axios",
|
||||
"typescript",
|
||||
"openapi-client",
|
||||
"openapi-generator",
|
||||
"@swagger/typescript-axios-petstore"
|
||||
],
|
||||
"license": "Unlicense",
|
||||
"main": "./dist/index.js",
|
||||
"typings": "./dist/index.d.ts",
|
||||
"scripts" : {
|
||||
"build": "tsc --outDir dist/",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.18.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^8.0.9",
|
||||
"typescript": "^2.4"
|
||||
},
|
||||
"publishConfig":{
|
||||
"registry":"https://skimdb.npmjs.com/registry"
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"target": "es6",
|
||||
"module": "commonjs",
|
||||
"noImplicitAny": true,
|
||||
"outDir": "dist",
|
||||
"rootDir": "." },
|
||||
"exclude": [
|
||||
"dist",
|
||||
"node_modules"
|
||||
]
|
||||
}
|
3
samples/client/petstore/typescript-axios/builds/with-interfaces/.gitignore
vendored
Normal file
3
samples/client/petstore/typescript-axios/builds/with-interfaces/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
wwwroot/*.js
|
||||
node_modules
|
||||
typings
|
@ -0,0 +1,23 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
@ -0,0 +1 @@
|
||||
3.2.3-SNAPSHOT
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,74 @@
|
||||
// tslint:disable
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface ConfigurationParameters {
|
||||
apiKey?: string | ((name: string) => string);
|
||||
username?: string;
|
||||
password?: string;
|
||||
accessToken?: string | ((name: string, scopes?: string[]) => string);
|
||||
basePath?: string;
|
||||
baseOptions?: any;
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
/**
|
||||
* parameter for apiKey security
|
||||
* @param name security name
|
||||
* @memberof Configuration
|
||||
*/
|
||||
apiKey?: string | ((name: string) => string);
|
||||
/**
|
||||
* parameter for basic security
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
username?: string;
|
||||
/**
|
||||
* parameter for basic security
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
password?: string;
|
||||
/**
|
||||
* parameter for oauth2 security
|
||||
* @param name security name
|
||||
* @param scopes oauth2 scope
|
||||
* @memberof Configuration
|
||||
*/
|
||||
accessToken?: string | ((name: string, scopes?: string[]) => string);
|
||||
/**
|
||||
* override base path
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
basePath?: string;
|
||||
/**
|
||||
* base options for axios calls
|
||||
*
|
||||
* @type {any}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
baseOptions?: any;
|
||||
|
||||
constructor(param: ConfigurationParameters = {}) {
|
||||
this.apiKey = param.apiKey;
|
||||
this.username = param.username;
|
||||
this.password = param.password;
|
||||
this.accessToken = param.accessToken;
|
||||
this.basePath = param.basePath;
|
||||
}
|
||||
}
|
1
samples/client/petstore/typescript-axios/builds/with-interfaces/custom.d.ts
vendored
Normal file
1
samples/client/petstore/typescript-axios/builds/with-interfaces/custom.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
declare module 'url';
|
@ -0,0 +1,51 @@
|
||||
#!/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 openapi-pestore-perl "minor update"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="GIT_USER_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="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 credential 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'
|
@ -0,0 +1,16 @@
|
||||
// tslint:disable
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export * from "./api";
|
||||
export * from "./configuration";
|
3
samples/client/petstore/typescript-axios/builds/with-npm-version/.gitignore
vendored
Normal file
3
samples/client/petstore/typescript-axios/builds/with-npm-version/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
wwwroot/*.js
|
||||
node_modules
|
||||
typings
|
@ -0,0 +1,23 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
@ -0,0 +1 @@
|
||||
3.2.3-SNAPSHOT
|
@ -0,0 +1,45 @@
|
||||
## @swagger/typescript-axios-petstore@1.0.0
|
||||
|
||||
This generator creates TypeScript/JavaScript client that utilizes [axios](https://github.com/axios/axios). The generated Node module can be used in the following environments:
|
||||
|
||||
Environment
|
||||
* Node.js
|
||||
* Webpack
|
||||
* Browserify
|
||||
|
||||
Language level
|
||||
* ES5 - you must have a Promises/A+ library installed
|
||||
* ES6
|
||||
|
||||
Module system
|
||||
* CommonJS
|
||||
* ES6 module system
|
||||
|
||||
It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html))
|
||||
|
||||
### Building
|
||||
|
||||
To build and compile the typescript sources to javascript use:
|
||||
```
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
### Publishing
|
||||
|
||||
First build the package then run ```npm publish```
|
||||
|
||||
### Consuming
|
||||
|
||||
navigate to the folder of your consuming project and run one of the following commands.
|
||||
|
||||
_published:_
|
||||
|
||||
```
|
||||
npm install @swagger/typescript-axios-petstore@1.0.0 --save
|
||||
```
|
||||
|
||||
_unPublished (not recommended):_
|
||||
|
||||
```
|
||||
npm install PATH_TO_GENERATED_PACKAGE --save
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,74 @@
|
||||
// tslint:disable
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface ConfigurationParameters {
|
||||
apiKey?: string | ((name: string) => string);
|
||||
username?: string;
|
||||
password?: string;
|
||||
accessToken?: string | ((name: string, scopes?: string[]) => string);
|
||||
basePath?: string;
|
||||
baseOptions?: any;
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
/**
|
||||
* parameter for apiKey security
|
||||
* @param name security name
|
||||
* @memberof Configuration
|
||||
*/
|
||||
apiKey?: string | ((name: string) => string);
|
||||
/**
|
||||
* parameter for basic security
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
username?: string;
|
||||
/**
|
||||
* parameter for basic security
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
password?: string;
|
||||
/**
|
||||
* parameter for oauth2 security
|
||||
* @param name security name
|
||||
* @param scopes oauth2 scope
|
||||
* @memberof Configuration
|
||||
*/
|
||||
accessToken?: string | ((name: string, scopes?: string[]) => string);
|
||||
/**
|
||||
* override base path
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
basePath?: string;
|
||||
/**
|
||||
* base options for axios calls
|
||||
*
|
||||
* @type {any}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
baseOptions?: any;
|
||||
|
||||
constructor(param: ConfigurationParameters = {}) {
|
||||
this.apiKey = param.apiKey;
|
||||
this.username = param.username;
|
||||
this.password = param.password;
|
||||
this.accessToken = param.accessToken;
|
||||
this.basePath = param.basePath;
|
||||
}
|
||||
}
|
1
samples/client/petstore/typescript-axios/builds/with-npm-version/custom.d.ts
vendored
Normal file
1
samples/client/petstore/typescript-axios/builds/with-npm-version/custom.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
declare module 'url';
|
@ -0,0 +1,51 @@
|
||||
#!/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 openapi-pestore-perl "minor update"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="GIT_USER_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="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 credential 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'
|
@ -0,0 +1,16 @@
|
||||
// tslint:disable
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export * from "./api";
|
||||
export * from "./configuration";
|
@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "@swagger/typescript-axios-petstore",
|
||||
"version": "1.0.0",
|
||||
"description": "OpenAPI client for @swagger/typescript-axios-petstore",
|
||||
"author": "OpenAPI-Generator Contributors",
|
||||
"keywords": [
|
||||
"axios",
|
||||
"typescript",
|
||||
"openapi-client",
|
||||
"openapi-generator",
|
||||
"@swagger/typescript-axios-petstore"
|
||||
],
|
||||
"license": "Unlicense",
|
||||
"main": "./dist/index.js",
|
||||
"typings": "./dist/index.d.ts",
|
||||
"scripts" : {
|
||||
"build": "tsc --outDir dist/",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.18.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^8.0.9",
|
||||
"typescript": "^2.4"
|
||||
},
|
||||
"publishConfig":{
|
||||
"registry":"https://skimdb.npmjs.com/registry"
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"noImplicitAny": true,
|
||||
"outDir": "dist",
|
||||
"rootDir": ".",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
]
|
||||
},
|
||||
"exclude": [
|
||||
"dist",
|
||||
"node_modules"
|
||||
]
|
||||
}
|
71
samples/client/petstore/typescript-axios/tests/default/dist/PetApi.js
vendored
Normal file
71
samples/client/petstore/typescript-axios/tests/default/dist/PetApi.js
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var chai_1 = require("chai");
|
||||
var typescript_axios_petstore_1 = require("@swagger/typescript-axios-petstore");
|
||||
describe("PetApi", function () {
|
||||
function runSuite(description, requestOptions) {
|
||||
describe(description, function () {
|
||||
var api;
|
||||
var fixture = createTestFixture();
|
||||
beforeEach(function () {
|
||||
api = new typescript_axios_petstore_1.PetApi();
|
||||
});
|
||||
it("should add and delete Pet", function () {
|
||||
return api.addPet(fixture, requestOptions).then(function () { });
|
||||
});
|
||||
it("should get Pet by ID", function () {
|
||||
return api
|
||||
.getPetById(fixture.id, requestOptions)
|
||||
.then(function (result) {
|
||||
return chai_1.expect(result.data).to.deep.equal(fixture);
|
||||
});
|
||||
});
|
||||
it("should update Pet by ID", function () {
|
||||
return api
|
||||
.getPetById(fixture.id, requestOptions)
|
||||
.then(function (response) {
|
||||
var result = response.data;
|
||||
result.name = "newname";
|
||||
return api.updatePet(result, requestOptions).then(function () {
|
||||
return api
|
||||
.getPetById(fixture.id, requestOptions)
|
||||
.then(function (response) {
|
||||
return chai_1.expect(response.data.name).to.deep.equal("newname");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
it("should delete Pet", function () {
|
||||
return api.deletePet(fixture.id, requestOptions);
|
||||
});
|
||||
it("should not contain deleted Pet", function () {
|
||||
return api.getPetById(fixture.id, requestOptions).then(function (result) {
|
||||
return chai_1.expect(result.data).to.not.exist;
|
||||
}, function (err) {
|
||||
return chai_1.expect(err).to.exist;
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
runSuite("without custom request options");
|
||||
runSuite("with custom request options", {
|
||||
credentials: "include",
|
||||
mode: "cors"
|
||||
});
|
||||
});
|
||||
function createTestFixture(ts) {
|
||||
if (ts === void 0) { ts = Date.now(); }
|
||||
var category = {
|
||||
id: ts,
|
||||
name: "category" + ts
|
||||
};
|
||||
var pet = {
|
||||
id: ts,
|
||||
name: "pet" + ts,
|
||||
category: category,
|
||||
photoUrls: ["http://foo.bar.com/1", "http://foo.bar.com/2"],
|
||||
status: typescript_axios_petstore_1.Pet.StatusEnum.Available,
|
||||
tags: []
|
||||
};
|
||||
return pet;
|
||||
}
|
87
samples/client/petstore/typescript-axios/tests/default/dist/PetApiFactory.js
vendored
Normal file
87
samples/client/petstore/typescript-axios/tests/default/dist/PetApiFactory.js
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var chai_1 = require("chai");
|
||||
var typescript_axios_petstore_1 = require("@swagger/typescript-axios-petstore");
|
||||
var typescript_axios_petstore_2 = require("@swagger/typescript-axios-petstore");
|
||||
var config;
|
||||
before(function () {
|
||||
config = new typescript_axios_petstore_2.Configuration();
|
||||
config.accessToken = "foobar";
|
||||
config.apiKey = function (securityName) {
|
||||
// for multiple apiKey security
|
||||
if (securityName === "api_key") {
|
||||
return "foobar";
|
||||
}
|
||||
return;
|
||||
};
|
||||
config.username = "foo";
|
||||
config.password = "bar";
|
||||
});
|
||||
describe("PetApiFactory", function () {
|
||||
function runSuite(description, requestOptions) {
|
||||
describe(description, function () {
|
||||
var fixture = createTestFixture();
|
||||
it("should add and delete Pet", function () {
|
||||
return typescript_axios_petstore_1.PetApiFactory(config)
|
||||
.addPet(fixture, requestOptions)
|
||||
.then(function () { });
|
||||
});
|
||||
it("should get Pet by ID", function () {
|
||||
return typescript_axios_petstore_1.PetApiFactory(config)
|
||||
.getPetById(fixture.id, requestOptions)
|
||||
.then(function (result) {
|
||||
return chai_1.expect(result.data).to.deep.equal(fixture);
|
||||
});
|
||||
});
|
||||
it("should update Pet by ID", function () {
|
||||
return typescript_axios_petstore_1.PetApiFactory(config)
|
||||
.getPetById(fixture.id, requestOptions)
|
||||
.then(function (result) {
|
||||
result.data.name = "newname";
|
||||
return typescript_axios_petstore_1.PetApiFactory(config)
|
||||
.updatePet(result.data, requestOptions)
|
||||
.then(function () {
|
||||
return typescript_axios_petstore_1.PetApiFactory(config)
|
||||
.getPetById(fixture.id, requestOptions)
|
||||
.then(function (result) {
|
||||
return chai_1.expect(result.data.name).to.deep.equal("newname");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
it("should delete Pet", function () {
|
||||
return typescript_axios_petstore_1.PetApiFactory(config).deletePet(fixture.id, requestOptions);
|
||||
});
|
||||
it("should not contain deleted Pet", function () {
|
||||
return typescript_axios_petstore_1.PetApiFactory(config)
|
||||
.getPetById(fixture.id, requestOptions)
|
||||
.then(function (result) {
|
||||
return chai_1.expect(result.data).to.not.exist;
|
||||
}, function (err) {
|
||||
return chai_1.expect(err).to.exist;
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
runSuite("without custom request options");
|
||||
runSuite("with custom request options", {
|
||||
credentials: "include",
|
||||
mode: "cors"
|
||||
});
|
||||
});
|
||||
function createTestFixture(ts) {
|
||||
if (ts === void 0) { ts = Date.now(); }
|
||||
var category = {
|
||||
id: ts,
|
||||
name: "category" + ts
|
||||
};
|
||||
var pet = {
|
||||
id: ts,
|
||||
name: "pet" + ts,
|
||||
category: category,
|
||||
photoUrls: ["http://foo.bar.com/1", "http://foo.bar.com/2"],
|
||||
status: typescript_axios_petstore_1.Pet.StatusEnum.Available,
|
||||
tags: []
|
||||
};
|
||||
return pet;
|
||||
}
|
26
samples/client/petstore/typescript-axios/tests/default/dist/StoreApi.js
vendored
Normal file
26
samples/client/petstore/typescript-axios/tests/default/dist/StoreApi.js
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var chai_1 = require("chai");
|
||||
var typescript_axios_petstore_1 = require("@swagger/typescript-axios-petstore");
|
||||
describe("StoreApi", function () {
|
||||
function runSuite(description, requestOptions) {
|
||||
describe(description, function () {
|
||||
var api;
|
||||
beforeEach(function () {
|
||||
api = new typescript_axios_petstore_1.StoreApi();
|
||||
});
|
||||
it("should get inventory", function () {
|
||||
return api
|
||||
.getInventory(requestOptions)
|
||||
.then(function (result) {
|
||||
chai_1.expect(Object.keys(result)).to.not.be.empty;
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
runSuite("without custom request options");
|
||||
runSuite("with custom request options", {
|
||||
credentials: "include",
|
||||
mode: "cors"
|
||||
});
|
||||
});
|
37
samples/client/petstore/typescript-axios/tests/default/dist/StoreApiFactory.js
vendored
Normal file
37
samples/client/petstore/typescript-axios/tests/default/dist/StoreApiFactory.js
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var chai_1 = require("chai");
|
||||
var typescript_axios_petstore_1 = require("@swagger/typescript-axios-petstore");
|
||||
var typescript_axios_petstore_2 = require("@swagger/typescript-axios-petstore");
|
||||
var config;
|
||||
before(function () {
|
||||
config = new typescript_axios_petstore_2.Configuration();
|
||||
config.accessToken = "foobar";
|
||||
config.apiKey = function (securityName) {
|
||||
// for multiple apiKey security
|
||||
if (securityName === "api_key") {
|
||||
return "foobar";
|
||||
}
|
||||
return;
|
||||
};
|
||||
config.username = "foo";
|
||||
config.password = "bar";
|
||||
});
|
||||
describe("StoreApiFactory", function () {
|
||||
function runSuite(description, requestOptions) {
|
||||
describe(description, function () {
|
||||
it("should get inventory", function () {
|
||||
return typescript_axios_petstore_1.StoreApiFactory(config)
|
||||
.getInventory(requestOptions)
|
||||
.then(function (result) {
|
||||
chai_1.expect(Object.keys(result.data)).to.not.be.empty;
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
runSuite("without custom request options");
|
||||
runSuite("with custom request options", {
|
||||
credentials: "include",
|
||||
mode: "cors"
|
||||
});
|
||||
});
|
6
samples/client/petstore/typescript-axios/tests/default/dist/index.js
vendored
Normal file
6
samples/client/petstore/typescript-axios/tests/default/dist/index.js
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("./PetApi");
|
||||
require("./StoreApi");
|
||||
require("./PetApiFactory");
|
||||
require("./StoreApiFactory");
|
5458
samples/client/petstore/typescript-axios/tests/default/package-lock.json
generated
Normal file
5458
samples/client/petstore/typescript-axios/tests/default/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,36 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@swagger/typescript-axios-petstore": "file:../../builds/with-npm-version",
|
||||
"axios": "0.18.0",
|
||||
"chai": "^4.1.0",
|
||||
"ts-node": "^3.3.0"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": "npm install ../../builds/with-npm-version && npm run build",
|
||||
"test": "mocha test/*.ts --compilers ts:ts-node/register --timeout 10000",
|
||||
"build": "tsc",
|
||||
"webpack": "webpack",
|
||||
"browserify": "browserify test -p [ tsify ] > ./dist/test.browserify-bundle.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.0.1",
|
||||
"@types/mocha": "^2.2.41",
|
||||
"@types/node": "^8.0.14",
|
||||
"browserify": "^14.4.0",
|
||||
"mocha": "^3.4.2",
|
||||
"ts-loader": "^5.1.0",
|
||||
"tsify": "^3.0.1",
|
||||
"typescript": "^2.4.1",
|
||||
"typings": "^2.1.1",
|
||||
"webpack": "^1.13.0"
|
||||
},
|
||||
"name": "typescript-fetch-test",
|
||||
"version": "1.0.0",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"description": ""
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>TypeScriptAxiosPestoreClientTests</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>TS Axios Petstore Test 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,84 @@
|
||||
import { expect } from "chai";
|
||||
import { PetApi, Pet, Category } from "@swagger/typescript-axios-petstore";
|
||||
import { AxiosResponse } from "axios";
|
||||
|
||||
describe("PetApi", () => {
|
||||
function runSuite(description: string, requestOptions?: any): void {
|
||||
describe(description, () => {
|
||||
let api: PetApi;
|
||||
const fixture: Pet = createTestFixture();
|
||||
|
||||
beforeEach(() => {
|
||||
api = new PetApi();
|
||||
});
|
||||
|
||||
it("should add and delete Pet", () => {
|
||||
return api.addPet(fixture, requestOptions).then(() => {});
|
||||
});
|
||||
|
||||
it("should get Pet by ID", () => {
|
||||
return api
|
||||
.getPetById(fixture.id, requestOptions)
|
||||
.then((result: AxiosResponse<Pet>) => {
|
||||
return expect(result.data).to.deep.equal(fixture);
|
||||
});
|
||||
});
|
||||
|
||||
it("should update Pet by ID", () => {
|
||||
return api
|
||||
.getPetById(fixture.id, requestOptions)
|
||||
.then((response: AxiosResponse<Pet>) => {
|
||||
const result = response.data;
|
||||
result.name = "newname";
|
||||
return api.updatePet(result, requestOptions).then(() => {
|
||||
return api
|
||||
.getPetById(fixture.id, requestOptions)
|
||||
.then((response: AxiosResponse<Pet>) => {
|
||||
return expect(response.data.name).to.deep.equal("newname");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("should delete Pet", () => {
|
||||
return api.deletePet(fixture.id, requestOptions);
|
||||
});
|
||||
|
||||
it("should not contain deleted Pet", () => {
|
||||
return api.getPetById(fixture.id, requestOptions).then(
|
||||
(result: AxiosResponse<Pet>) => {
|
||||
return expect(result.data).to.not.exist;
|
||||
},
|
||||
(err: any) => {
|
||||
return expect(err).to.exist;
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
runSuite("without custom request options");
|
||||
|
||||
runSuite("with custom request options", {
|
||||
credentials: "include",
|
||||
mode: "cors"
|
||||
});
|
||||
});
|
||||
|
||||
function createTestFixture(ts = Date.now()) {
|
||||
const category: Category = {
|
||||
id: ts,
|
||||
name: `category${ts}`
|
||||
};
|
||||
|
||||
const pet: Pet = {
|
||||
id: ts,
|
||||
name: `pet${ts}`,
|
||||
category: category,
|
||||
photoUrls: ["http://foo.bar.com/1", "http://foo.bar.com/2"],
|
||||
status: Pet.StatusEnum.Available,
|
||||
tags: []
|
||||
};
|
||||
|
||||
return pet;
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
import { expect } from "chai";
|
||||
import {
|
||||
PetApiFactory,
|
||||
Pet,
|
||||
Category
|
||||
} from "@swagger/typescript-axios-petstore";
|
||||
import { Configuration } from "@swagger/typescript-axios-petstore";
|
||||
import { AxiosResponse } from "axios";
|
||||
|
||||
let config: Configuration;
|
||||
|
||||
before(function() {
|
||||
config = new Configuration();
|
||||
config.accessToken = "foobar";
|
||||
config.apiKey = (securityName: string) => {
|
||||
// for multiple apiKey security
|
||||
if (securityName === "api_key") {
|
||||
return "foobar";
|
||||
}
|
||||
return;
|
||||
};
|
||||
config.username = "foo";
|
||||
config.password = "bar";
|
||||
});
|
||||
|
||||
describe("PetApiFactory", () => {
|
||||
function runSuite(description: string, requestOptions?: any): void {
|
||||
describe(description, () => {
|
||||
const fixture: Pet = createTestFixture();
|
||||
|
||||
it("should add and delete Pet", () => {
|
||||
return PetApiFactory(config)
|
||||
.addPet(fixture, requestOptions)
|
||||
.then(() => {});
|
||||
});
|
||||
|
||||
it("should get Pet by ID", () => {
|
||||
return PetApiFactory(config)
|
||||
.getPetById(fixture.id, requestOptions)
|
||||
.then((result: AxiosResponse<Pet>) => {
|
||||
return expect(result.data).to.deep.equal(fixture);
|
||||
});
|
||||
});
|
||||
|
||||
it("should update Pet by ID", () => {
|
||||
return PetApiFactory(config)
|
||||
.getPetById(fixture.id, requestOptions)
|
||||
.then((result: AxiosResponse<Pet>) => {
|
||||
result.data.name = "newname";
|
||||
return PetApiFactory(config)
|
||||
.updatePet(result.data, requestOptions)
|
||||
.then(() => {
|
||||
return PetApiFactory(config)
|
||||
.getPetById(fixture.id, requestOptions)
|
||||
.then((result: AxiosResponse<Pet>) => {
|
||||
return expect(result.data.name).to.deep.equal("newname");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("should delete Pet", () => {
|
||||
return PetApiFactory(config).deletePet(fixture.id, requestOptions);
|
||||
});
|
||||
|
||||
it("should not contain deleted Pet", () => {
|
||||
return PetApiFactory(config)
|
||||
.getPetById(fixture.id, requestOptions)
|
||||
.then(
|
||||
(result: AxiosResponse<Pet>) => {
|
||||
return expect(result.data).to.not.exist;
|
||||
},
|
||||
(err: any) => {
|
||||
return expect(err).to.exist;
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
runSuite("without custom request options");
|
||||
|
||||
runSuite("with custom request options", {
|
||||
credentials: "include",
|
||||
mode: "cors"
|
||||
});
|
||||
});
|
||||
|
||||
function createTestFixture(ts = Date.now()) {
|
||||
const category: Category = {
|
||||
id: ts,
|
||||
name: `category${ts}`
|
||||
};
|
||||
|
||||
const pet: Pet = {
|
||||
id: ts,
|
||||
name: `pet${ts}`,
|
||||
category: category,
|
||||
photoUrls: ["http://foo.bar.com/1", "http://foo.bar.com/2"],
|
||||
status: Pet.StatusEnum.Available,
|
||||
tags: []
|
||||
};
|
||||
|
||||
return pet;
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
import { expect } from "chai";
|
||||
import { StoreApi } from "@swagger/typescript-axios-petstore";
|
||||
import { AxiosResponse } from "axios";
|
||||
|
||||
describe("StoreApi", function() {
|
||||
function runSuite(description: string, requestOptions?: any): void {
|
||||
describe(description, () => {
|
||||
let api: StoreApi;
|
||||
|
||||
beforeEach(function() {
|
||||
api = new StoreApi();
|
||||
});
|
||||
|
||||
it("should get inventory", function() {
|
||||
return api
|
||||
.getInventory(requestOptions)
|
||||
.then((result: AxiosResponse<{ [key: string]: number }>) => {
|
||||
expect(Object.keys(result)).to.not.be.empty;
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
runSuite("without custom request options");
|
||||
|
||||
runSuite("with custom request options", {
|
||||
credentials: "include",
|
||||
mode: "cors"
|
||||
});
|
||||
});
|
@ -0,0 +1,41 @@
|
||||
import { expect } from "chai";
|
||||
import { StoreApiFactory } from "@swagger/typescript-axios-petstore";
|
||||
import { Configuration } from "@swagger/typescript-axios-petstore";
|
||||
import { AxiosResponse } from "axios";
|
||||
|
||||
let config: Configuration;
|
||||
|
||||
before(function() {
|
||||
config = new Configuration();
|
||||
config.accessToken = "foobar";
|
||||
config.apiKey = (securityName: string) => {
|
||||
// for multiple apiKey security
|
||||
if (securityName === "api_key") {
|
||||
return "foobar";
|
||||
}
|
||||
return;
|
||||
};
|
||||
config.username = "foo";
|
||||
config.password = "bar";
|
||||
});
|
||||
|
||||
describe("StoreApiFactory", function() {
|
||||
function runSuite(description: string, requestOptions?: any): void {
|
||||
describe(description, () => {
|
||||
it("should get inventory", function() {
|
||||
return StoreApiFactory(config)
|
||||
.getInventory(requestOptions)
|
||||
.then((result: AxiosResponse<{ [key: string]: number }>) => {
|
||||
expect(Object.keys(result.data)).to.not.be.empty;
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
runSuite("without custom request options");
|
||||
|
||||
runSuite("with custom request options", {
|
||||
credentials: "include",
|
||||
mode: "cors"
|
||||
});
|
||||
});
|
@ -0,0 +1,4 @@
|
||||
import './PetApi';
|
||||
import './StoreApi';
|
||||
import './PetApiFactory';
|
||||
import './StoreApiFactory';
|
@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"noImplicitAny": true,
|
||||
"sourceMap": false,
|
||||
"outDir": "dist",
|
||||
"types": [
|
||||
"mocha"
|
||||
],
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
]
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user