forked from loafle/openapi-generator-original
typescript-axios anytype is not defined (#6335)
* Include map for `AnyType` in `typescript` * Exclude `any` from the list of types extracted from `anyOf`, `allOf`, `oneOf` Exclude if there are other meaningful types * Include new scripts and `yaml` to test the new case * Execute the new sample for `typescript-axios` * Filter out only `AnyType` instead of all `any` types * Renamed and modified samples - Included more examples using `oneOf, `allOf`, `anyOf` - Includede examples when types that are translated to `any` are involved (`file`)
This commit is contained in:
parent
205514c455
commit
4dbb5c9e0d
@ -6,4 +6,5 @@
|
|||||||
./bin/typescript-axios-petstore-with-complex-headers.sh
|
./bin/typescript-axios-petstore-with-complex-headers.sh
|
||||||
./bin/typescript-axios-petstore-with-single-request-parameters.sh
|
./bin/typescript-axios-petstore-with-single-request-parameters.sh
|
||||||
./bin/typescript-axios-petstore-interfaces.sh
|
./bin/typescript-axios-petstore-interfaces.sh
|
||||||
|
./bin/typescript-axios-petstore-composed-schemas.sh
|
||||||
./bin/typescript-axios-petstore.sh
|
./bin/typescript-axios-petstore.sh
|
||||||
|
32
bin/typescript-axios-petstore-composed-schemas.sh
Executable file
32
bin/typescript-axios-petstore-composed-schemas.sh
Executable 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} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
|
ags="generate -i modules/openapi-generator/src/test/resources/3_0/composed-schemas.yaml -g typescript-axios -o samples/client/petstore/typescript-axios/builds/composed-schemas $@"
|
||||||
|
|
||||||
|
java $JAVA_OPTS -jar $executable $ags
|
@ -6,4 +6,5 @@ call bin\windows\typescript-axios-petstore-with-complex-headers.bat
|
|||||||
call bin\windows\typescript-axios-petstore-with-single-request-parameters.bat
|
call bin\windows\typescript-axios-petstore-with-single-request-parameters.bat
|
||||||
call bin\windows\typescript-axios-petstore-with-npm-version.bat
|
call bin\windows\typescript-axios-petstore-with-npm-version.bat
|
||||||
call bin\windows\typescript-axios-petstore-interfaces.bat
|
call bin\windows\typescript-axios-petstore-interfaces.bat
|
||||||
|
call bin\windows\typescript-axios-petstore-composed-schemas.bat
|
||||||
call bin\windows\typescript-axios-petstore-with-npm-version-and-separate-models-and-api.bat
|
call bin\windows\typescript-axios-petstore-with-npm-version-and-separate-models-and-api.bat
|
14
bin/windows/typescript-axios-petstore-composed-schemas.bat
Normal file
14
bin/windows/typescript-axios-petstore-composed-schemas.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\3_0\composed-schemas.yaml -g typescript-axios -o samples\client\petstore\typescript-axios\builds\composed-schemas
|
||||||
|
|
||||||
|
java %JAVA_OPTS% -jar %executable% %ags%
|
@ -164,6 +164,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
|||||||
typeMapping.put("UUID", "string");
|
typeMapping.put("UUID", "string");
|
||||||
typeMapping.put("URI", "string");
|
typeMapping.put("URI", "string");
|
||||||
typeMapping.put("Error", "Error");
|
typeMapping.put("Error", "Error");
|
||||||
|
typeMapping.put("AnyType", "any");
|
||||||
|
|
||||||
cliOptions.add(new CliOption(CodegenConstants.ENUM_NAME_SUFFIX, CodegenConstants.ENUM_NAME_SUFFIX_DESC).defaultValue(this.enumSuffix));
|
cliOptions.add(new CliOption(CodegenConstants.ENUM_NAME_SUFFIX, CodegenConstants.ENUM_NAME_SUFFIX_DESC).defaultValue(this.enumSuffix));
|
||||||
cliOptions.add(new CliOption(CodegenConstants.ENUM_PROPERTY_NAMING, CodegenConstants.ENUM_PROPERTY_NAMING_DESC).defaultValue(this.enumPropertyNaming.name()));
|
cliOptions.add(new CliOption(CodegenConstants.ENUM_PROPERTY_NAMING, CodegenConstants.ENUM_PROPERTY_NAMING_DESC).defaultValue(this.enumPropertyNaming.name()));
|
||||||
@ -808,35 +809,38 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toAnyOfName(List<String> names, ComposedSchema composedSchema) {
|
public String toAnyOfName(List<String> names, ComposedSchema composedSchema) {
|
||||||
List<String> types = composedSchema.getAnyOf().stream().map(schema -> {
|
List<String> types = getTypesFromSchemas(composedSchema.getAnyOf());
|
||||||
String schemaType = getSchemaType(schema);
|
|
||||||
if (ModelUtils.isArraySchema(schema)) {
|
|
||||||
ArraySchema ap = (ArraySchema) schema;
|
|
||||||
Schema inner = ap.getItems();
|
|
||||||
schemaType = schemaType + "<" + getSchemaType(inner) + ">";
|
|
||||||
}
|
|
||||||
return schemaType;
|
|
||||||
}).distinct().collect(Collectors.toList());
|
|
||||||
return String.join(" | ", types);
|
return String.join(" | ", types);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toOneOfName(List<String> names, ComposedSchema composedSchema) {
|
public String toOneOfName(List<String> names, ComposedSchema composedSchema) {
|
||||||
List<String> types = composedSchema.getOneOf().stream().map(schema -> {
|
List<String> types = getTypesFromSchemas(composedSchema.getOneOf());
|
||||||
String schemaType = getSchemaType(schema);
|
|
||||||
if (ModelUtils.isArraySchema(schema)) {
|
|
||||||
ArraySchema ap = (ArraySchema) schema;
|
|
||||||
Schema inner = ap.getItems();
|
|
||||||
schemaType = schemaType + "<" + getSchemaType(inner) + ">";
|
|
||||||
}
|
|
||||||
return schemaType;
|
|
||||||
}).distinct().collect(Collectors.toList());
|
|
||||||
return String.join(" | ", types);
|
return String.join(" | ", types);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toAllOfName(List<String> names, ComposedSchema composedSchema) {
|
public String toAllOfName(List<String> names, ComposedSchema composedSchema) {
|
||||||
List<String> types = composedSchema.getAllOf().stream().map(schema -> {
|
List<String> types = getTypesFromSchemas(composedSchema.getAllOf());
|
||||||
|
|
||||||
|
return String.join(" & ", types);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts the list of type names from a list of schemas.
|
||||||
|
* Excludes `AnyType` if there are other valid types extracted.
|
||||||
|
*
|
||||||
|
* @param schemas list of schemas
|
||||||
|
* @return list of types
|
||||||
|
*/
|
||||||
|
protected List<String> getTypesFromSchemas(List<Schema> schemas) {
|
||||||
|
List<Schema> filteredSchemas = schemas.size() > 1
|
||||||
|
? schemas.stream().filter(schema -> super.getSchemaType(schema) != "AnyType").collect(Collectors.toList())
|
||||||
|
: schemas;
|
||||||
|
|
||||||
|
return filteredSchemas.stream().map(schema -> {
|
||||||
String schemaType = getSchemaType(schema);
|
String schemaType = getSchemaType(schema);
|
||||||
if (ModelUtils.isArraySchema(schema)) {
|
if (ModelUtils.isArraySchema(schema)) {
|
||||||
ArraySchema ap = (ArraySchema) schema;
|
ArraySchema ap = (ArraySchema) schema;
|
||||||
@ -845,6 +849,5 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
|||||||
}
|
}
|
||||||
return schemaType;
|
return schemaType;
|
||||||
}).distinct().collect(Collectors.toList());
|
}).distinct().collect(Collectors.toList());
|
||||||
return String.join(" & ", types);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,107 @@
|
|||||||
|
|
||||||
|
|
||||||
|
openapi: 3.0.1
|
||||||
|
info:
|
||||||
|
version: 1.0.0
|
||||||
|
title: Example
|
||||||
|
license:
|
||||||
|
name: MIT
|
||||||
|
servers:
|
||||||
|
- url: http://api.example.xyz/v1
|
||||||
|
paths:
|
||||||
|
/pets:
|
||||||
|
patch:
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
oneOf:
|
||||||
|
- $ref: '#/components/schemas/Cat'
|
||||||
|
- $ref: '#/components/schemas/Dog'
|
||||||
|
# This field will not match to any type.
|
||||||
|
- description: Any kind of pet
|
||||||
|
discriminator:
|
||||||
|
propertyName: pet_type
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Updated
|
||||||
|
|
||||||
|
/pets-filtered:
|
||||||
|
patch:
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
anyOf:
|
||||||
|
- $ref: '#/components/schemas/PetByAge'
|
||||||
|
- $ref: '#/components/schemas/PetByType'
|
||||||
|
# This field will not match to any type.
|
||||||
|
- description: Any kind of filter
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Updated
|
||||||
|
|
||||||
|
/file:
|
||||||
|
post:
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
file:
|
||||||
|
allOf:
|
||||||
|
- type: file
|
||||||
|
# This field will not match to any type.
|
||||||
|
- description: The file to upload
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: File uploaded
|
||||||
|
|
||||||
|
components:
|
||||||
|
schemas:
|
||||||
|
Pet:
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- pet_type
|
||||||
|
Dog:
|
||||||
|
allOf:
|
||||||
|
# This field will not match to any type.
|
||||||
|
- description: Dog information
|
||||||
|
- $ref: '#/components/schemas/Pet'
|
||||||
|
- type: object
|
||||||
|
properties:
|
||||||
|
bark:
|
||||||
|
type: boolean
|
||||||
|
breed:
|
||||||
|
type: string
|
||||||
|
enum: [Dingo, Husky, Retriever, Shepherd]
|
||||||
|
Cat:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/components/schemas/Pet'
|
||||||
|
- type: object
|
||||||
|
properties:
|
||||||
|
hunts:
|
||||||
|
type: boolean
|
||||||
|
age:
|
||||||
|
type: integer
|
||||||
|
PetByAge:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
age:
|
||||||
|
type: integer
|
||||||
|
nickname:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- age
|
||||||
|
|
||||||
|
PetByType:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
pet_type:
|
||||||
|
type: string
|
||||||
|
enum: [Cat, Dog]
|
||||||
|
hunts:
|
||||||
|
type: boolean
|
||||||
|
required:
|
||||||
|
- pet_type
|
4
samples/client/petstore/typescript-axios/builds/composed-schemas/.gitignore
vendored
Normal file
4
samples/client/petstore/typescript-axios/builds/composed-schemas/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
wwwroot/*.js
|
||||||
|
node_modules
|
||||||
|
typings
|
||||||
|
dist
|
@ -0,0 +1 @@
|
|||||||
|
# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm
|
@ -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 @@
|
|||||||
|
5.0.0-SNAPSHOT
|
@ -0,0 +1,420 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* Example
|
||||||
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import * as globalImportUrl from 'url';
|
||||||
|
import { Configuration } from './configuration';
|
||||||
|
import globalAxios, { AxiosPromise, AxiosInstance } from 'axios';
|
||||||
|
// Some imports not used depending on template conditions
|
||||||
|
// @ts-ignore
|
||||||
|
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from './base';
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @interface Cat
|
||||||
|
*/
|
||||||
|
export interface Cat {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {boolean}
|
||||||
|
* @memberof Cat
|
||||||
|
*/
|
||||||
|
hunts?: boolean;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof Cat
|
||||||
|
*/
|
||||||
|
age?: number;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @interface CatAllOf
|
||||||
|
*/
|
||||||
|
export interface CatAllOf {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {boolean}
|
||||||
|
* @memberof CatAllOf
|
||||||
|
*/
|
||||||
|
hunts?: boolean;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof CatAllOf
|
||||||
|
*/
|
||||||
|
age?: number;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @interface Dog
|
||||||
|
*/
|
||||||
|
export interface Dog {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {boolean}
|
||||||
|
* @memberof Dog
|
||||||
|
*/
|
||||||
|
bark?: boolean;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof Dog
|
||||||
|
*/
|
||||||
|
breed?: DogBreedEnum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @export
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
export enum DogBreedEnum {
|
||||||
|
Dingo = 'Dingo',
|
||||||
|
Husky = 'Husky',
|
||||||
|
Retriever = 'Retriever',
|
||||||
|
Shepherd = 'Shepherd'
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @interface DogAllOf
|
||||||
|
*/
|
||||||
|
export interface DogAllOf {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {boolean}
|
||||||
|
* @memberof DogAllOf
|
||||||
|
*/
|
||||||
|
bark?: boolean;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof DogAllOf
|
||||||
|
*/
|
||||||
|
breed?: DogAllOfBreedEnum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @export
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
export enum DogAllOfBreedEnum {
|
||||||
|
Dingo = 'Dingo',
|
||||||
|
Husky = 'Husky',
|
||||||
|
Retriever = 'Retriever',
|
||||||
|
Shepherd = 'Shepherd'
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @interface InlineObject
|
||||||
|
*/
|
||||||
|
export interface InlineObject {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {any}
|
||||||
|
* @memberof InlineObject
|
||||||
|
*/
|
||||||
|
file?: any;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @interface PetByAge
|
||||||
|
*/
|
||||||
|
export interface PetByAge {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof PetByAge
|
||||||
|
*/
|
||||||
|
age: number;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof PetByAge
|
||||||
|
*/
|
||||||
|
nickname?: string;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @interface PetByType
|
||||||
|
*/
|
||||||
|
export interface PetByType {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof PetByType
|
||||||
|
*/
|
||||||
|
pet_type: PetByTypePetTypeEnum;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {boolean}
|
||||||
|
* @memberof PetByType
|
||||||
|
*/
|
||||||
|
hunts?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @export
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
export enum PetByTypePetTypeEnum {
|
||||||
|
Cat = 'Cat',
|
||||||
|
Dog = 'Dog'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DefaultApi - axios parameter creator
|
||||||
|
* @export
|
||||||
|
*/
|
||||||
|
export const DefaultApiAxiosParamCreator = function (configuration?: Configuration) {
|
||||||
|
return {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {InlineObject} [inlineObject]
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
filePost: async (inlineObject?: InlineObject, options: any = {}): Promise<RequestArgs> => {
|
||||||
|
const localVarPath = `/file`;
|
||||||
|
const localVarUrlObj = globalImportUrl.parse(localVarPath, true);
|
||||||
|
let baseOptions;
|
||||||
|
if (configuration) {
|
||||||
|
baseOptions = configuration.baseOptions;
|
||||||
|
}
|
||||||
|
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
|
||||||
|
const localVarHeaderParameter = {} as any;
|
||||||
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
localVarHeaderParameter['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query};
|
||||||
|
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
|
||||||
|
delete localVarUrlObj.search;
|
||||||
|
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||||
|
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||||
|
const needsSerialization = (typeof inlineObject !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
|
||||||
|
localVarRequestOptions.data = needsSerialization ? JSON.stringify(inlineObject !== undefined ? inlineObject : {}) : (inlineObject || "");
|
||||||
|
|
||||||
|
return {
|
||||||
|
url: globalImportUrl.format(localVarUrlObj),
|
||||||
|
options: localVarRequestOptions,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {PetByAge | PetByType} [petByAgePetByType]
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
petsFilteredPatch: async (petByAgePetByType?: PetByAge | PetByType, options: any = {}): Promise<RequestArgs> => {
|
||||||
|
const localVarPath = `/pets-filtered`;
|
||||||
|
const localVarUrlObj = globalImportUrl.parse(localVarPath, true);
|
||||||
|
let baseOptions;
|
||||||
|
if (configuration) {
|
||||||
|
baseOptions = configuration.baseOptions;
|
||||||
|
}
|
||||||
|
const localVarRequestOptions = { method: 'PATCH', ...baseOptions, ...options};
|
||||||
|
const localVarHeaderParameter = {} as any;
|
||||||
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
localVarHeaderParameter['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query};
|
||||||
|
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
|
||||||
|
delete localVarUrlObj.search;
|
||||||
|
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||||
|
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||||
|
const needsSerialization = (typeof petByAgePetByType !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
|
||||||
|
localVarRequestOptions.data = needsSerialization ? JSON.stringify(petByAgePetByType !== undefined ? petByAgePetByType : {}) : (petByAgePetByType || "");
|
||||||
|
|
||||||
|
return {
|
||||||
|
url: globalImportUrl.format(localVarUrlObj),
|
||||||
|
options: localVarRequestOptions,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {Cat | Dog} [catDog]
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
petsPatch: async (catDog?: Cat | Dog, options: any = {}): Promise<RequestArgs> => {
|
||||||
|
const localVarPath = `/pets`;
|
||||||
|
const localVarUrlObj = globalImportUrl.parse(localVarPath, true);
|
||||||
|
let baseOptions;
|
||||||
|
if (configuration) {
|
||||||
|
baseOptions = configuration.baseOptions;
|
||||||
|
}
|
||||||
|
const localVarRequestOptions = { method: 'PATCH', ...baseOptions, ...options};
|
||||||
|
const localVarHeaderParameter = {} as any;
|
||||||
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
localVarHeaderParameter['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
localVarUrlObj.query = {...localVarUrlObj.query, ...localVarQueryParameter, ...options.query};
|
||||||
|
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
|
||||||
|
delete localVarUrlObj.search;
|
||||||
|
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||||
|
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||||
|
const needsSerialization = (typeof catDog !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
|
||||||
|
localVarRequestOptions.data = needsSerialization ? JSON.stringify(catDog !== undefined ? catDog : {}) : (catDog || "");
|
||||||
|
|
||||||
|
return {
|
||||||
|
url: globalImportUrl.format(localVarUrlObj),
|
||||||
|
options: localVarRequestOptions,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DefaultApi - functional programming interface
|
||||||
|
* @export
|
||||||
|
*/
|
||||||
|
export const DefaultApiFp = function(configuration?: Configuration) {
|
||||||
|
return {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {InlineObject} [inlineObject]
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
async filePost(inlineObject?: InlineObject, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
|
||||||
|
const localVarAxiosArgs = await DefaultApiAxiosParamCreator(configuration).filePost(inlineObject, options);
|
||||||
|
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
||||||
|
const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
|
||||||
|
return axios.request(axiosRequestArgs);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {PetByAge | PetByType} [petByAgePetByType]
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
async petsFilteredPatch(petByAgePetByType?: PetByAge | PetByType, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
|
||||||
|
const localVarAxiosArgs = await DefaultApiAxiosParamCreator(configuration).petsFilteredPatch(petByAgePetByType, options);
|
||||||
|
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
||||||
|
const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
|
||||||
|
return axios.request(axiosRequestArgs);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {Cat | Dog} [catDog]
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
async petsPatch(catDog?: Cat | Dog, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
|
||||||
|
const localVarAxiosArgs = await DefaultApiAxiosParamCreator(configuration).petsPatch(catDog, options);
|
||||||
|
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
||||||
|
const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
|
||||||
|
return axios.request(axiosRequestArgs);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DefaultApi - factory interface
|
||||||
|
* @export
|
||||||
|
*/
|
||||||
|
export const DefaultApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
|
||||||
|
return {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {InlineObject} [inlineObject]
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
filePost(inlineObject?: InlineObject, options?: any): AxiosPromise<void> {
|
||||||
|
return DefaultApiFp(configuration).filePost(inlineObject, options).then((request) => request(axios, basePath));
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {PetByAge | PetByType} [petByAgePetByType]
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
petsFilteredPatch(petByAgePetByType?: PetByAge | PetByType, options?: any): AxiosPromise<void> {
|
||||||
|
return DefaultApiFp(configuration).petsFilteredPatch(petByAgePetByType, options).then((request) => request(axios, basePath));
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {Cat | Dog} [catDog]
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
petsPatch(catDog?: Cat | Dog, options?: any): AxiosPromise<void> {
|
||||||
|
return DefaultApiFp(configuration).petsPatch(catDog, options).then((request) => request(axios, basePath));
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DefaultApi - object-oriented interface
|
||||||
|
* @export
|
||||||
|
* @class DefaultApi
|
||||||
|
* @extends {BaseAPI}
|
||||||
|
*/
|
||||||
|
export class DefaultApi extends BaseAPI {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {InlineObject} [inlineObject]
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
* @memberof DefaultApi
|
||||||
|
*/
|
||||||
|
public filePost(inlineObject?: InlineObject, options?: any) {
|
||||||
|
return DefaultApiFp(this.configuration).filePost(inlineObject, options).then((request) => request(this.axios, this.basePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {PetByAge | PetByType} [petByAgePetByType]
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
* @memberof DefaultApi
|
||||||
|
*/
|
||||||
|
public petsFilteredPatch(petByAgePetByType?: PetByAge | PetByType, options?: any) {
|
||||||
|
return DefaultApiFp(this.configuration).petsFilteredPatch(petByAgePetByType, options).then((request) => request(this.axios, this.basePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {Cat | Dog} [catDog]
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
* @memberof DefaultApi
|
||||||
|
*/
|
||||||
|
public petsPatch(catDog?: Cat | Dog, options?: any) {
|
||||||
|
return DefaultApiFp(this.configuration).petsPatch(catDog, options).then((request) => request(this.axios, this.basePath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,70 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* Example
|
||||||
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import { Configuration } from "./configuration";
|
||||||
|
// Some imports not used depending on template conditions
|
||||||
|
// @ts-ignore
|
||||||
|
import globalAxios, { AxiosPromise, AxiosInstance } from 'axios';
|
||||||
|
|
||||||
|
export const BASE_PATH = "http://api.example.xyz/v1".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, protected axios: AxiosInstance = globalAxios) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,75 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* Example
|
||||||
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 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 | Promise<string> | ((name: string) => string) | ((name: string) => Promise<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 | Promise<string> | ((name: string) => string) | ((name: string) => Promise<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;
|
||||||
|
this.baseOptions = param.baseOptions;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
#!/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" "gitlab.com"
|
||||||
|
|
||||||
|
git_user_id=$1
|
||||||
|
git_repo_id=$2
|
||||||
|
release_note=$3
|
||||||
|
git_host=$4
|
||||||
|
|
||||||
|
if [ "$git_host" = "" ]; then
|
||||||
|
git_host="github.com"
|
||||||
|
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||||
|
fi
|
||||||
|
|
||||||
|
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://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||||
|
else
|
||||||
|
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${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://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||||
|
git push origin master 2>&1 | grep -v 'To https'
|
||||||
|
|
@ -0,0 +1,16 @@
|
|||||||
|
// tslint:disable
|
||||||
|
/**
|
||||||
|
* Example
|
||||||
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 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";
|
Loading…
x
Reference in New Issue
Block a user