diff --git a/bin/typescript-axios-petstore-all.sh b/bin/typescript-axios-petstore-all.sh index e3dfe396226..c66b3eba307 100755 --- a/bin/typescript-axios-petstore-all.sh +++ b/bin/typescript-axios-petstore-all.sh @@ -6,4 +6,5 @@ ./bin/typescript-axios-petstore-with-complex-headers.sh ./bin/typescript-axios-petstore-with-single-request-parameters.sh ./bin/typescript-axios-petstore-interfaces.sh +./bin/typescript-axios-petstore-composed-schemas.sh ./bin/typescript-axios-petstore.sh diff --git a/bin/typescript-axios-petstore-composed-schemas.sh b/bin/typescript-axios-petstore-composed-schemas.sh new file mode 100755 index 00000000000..8ed378b6f34 --- /dev/null +++ b/bin/typescript-axios-petstore-composed-schemas.sh @@ -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 diff --git a/bin/windows/typescript-axios-petstore-all.bat b/bin/windows/typescript-axios-petstore-all.bat index c3b82892732..8e9a25ddaf1 100644 --- a/bin/windows/typescript-axios-petstore-all.bat +++ b/bin/windows/typescript-axios-petstore-all.bat @@ -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-npm-version.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 \ No newline at end of file diff --git a/bin/windows/typescript-axios-petstore-composed-schemas.bat b/bin/windows/typescript-axios-petstore-composed-schemas.bat new file mode 100644 index 00000000000..ae70255c20b --- /dev/null +++ b/bin/windows/typescript-axios-petstore-composed-schemas.bat @@ -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% diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java index a9394802f0b..95767640988 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java @@ -164,6 +164,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp typeMapping.put("UUID", "string"); typeMapping.put("URI", "string"); 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_PROPERTY_NAMING, CodegenConstants.ENUM_PROPERTY_NAMING_DESC).defaultValue(this.enumPropertyNaming.name())); @@ -808,35 +809,38 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp @Override public String toAnyOfName(List names, ComposedSchema composedSchema) { - List types = composedSchema.getAnyOf().stream().map(schema -> { - 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()); + List types = getTypesFromSchemas(composedSchema.getAnyOf()); + return String.join(" | ", types); } @Override public String toOneOfName(List names, ComposedSchema composedSchema) { - List types = composedSchema.getOneOf().stream().map(schema -> { - 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()); + List types = getTypesFromSchemas(composedSchema.getOneOf()); + return String.join(" | ", types); } @Override public String toAllOfName(List names, ComposedSchema composedSchema) { - List types = composedSchema.getAllOf().stream().map(schema -> { + List 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 getTypesFromSchemas(List schemas) { + List 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); if (ModelUtils.isArraySchema(schema)) { ArraySchema ap = (ArraySchema) schema; @@ -845,6 +849,5 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp } return schemaType; }).distinct().collect(Collectors.toList()); - return String.join(" & ", types); } } diff --git a/modules/openapi-generator/src/test/resources/3_0/composed-schemas.yaml b/modules/openapi-generator/src/test/resources/3_0/composed-schemas.yaml new file mode 100644 index 00000000000..08e73f1d2ee --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/composed-schemas.yaml @@ -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 \ No newline at end of file diff --git a/samples/client/petstore/typescript-axios/builds/composed-schemas/.gitignore b/samples/client/petstore/typescript-axios/builds/composed-schemas/.gitignore new file mode 100644 index 00000000000..205d8013f46 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/composed-schemas/.gitignore @@ -0,0 +1,4 @@ +wwwroot/*.js +node_modules +typings +dist \ No newline at end of file diff --git a/samples/client/petstore/typescript-axios/builds/composed-schemas/.npmignore b/samples/client/petstore/typescript-axios/builds/composed-schemas/.npmignore new file mode 100644 index 00000000000..999d88df693 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/composed-schemas/.npmignore @@ -0,0 +1 @@ +# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm \ No newline at end of file diff --git a/samples/client/petstore/typescript-axios/builds/composed-schemas/.openapi-generator-ignore b/samples/client/petstore/typescript-axios/builds/composed-schemas/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/composed-schemas/.openapi-generator-ignore @@ -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 diff --git a/samples/client/petstore/typescript-axios/builds/composed-schemas/.openapi-generator/VERSION b/samples/client/petstore/typescript-axios/builds/composed-schemas/.openapi-generator/VERSION new file mode 100644 index 00000000000..d99e7162d01 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/composed-schemas/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/typescript-axios/builds/composed-schemas/api.ts b/samples/client/petstore/typescript-axios/builds/composed-schemas/api.ts new file mode 100644 index 00000000000..9bfc1ba1f17 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/composed-schemas/api.ts @@ -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 => { + 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 => { + 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 => { + 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> { + 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> { + 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> { + 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 { + 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 { + 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 { + 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)); + } +} + + diff --git a/samples/client/petstore/typescript-axios/builds/composed-schemas/base.ts b/samples/client/petstore/typescript-axios/builds/composed-schemas/base.ts new file mode 100644 index 00000000000..46e25c2e6de --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/composed-schemas/base.ts @@ -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); + } +} diff --git a/samples/client/petstore/typescript-axios/builds/composed-schemas/configuration.ts b/samples/client/petstore/typescript-axios/builds/composed-schemas/configuration.ts new file mode 100644 index 00000000000..96f755e21cd --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/composed-schemas/configuration.ts @@ -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 | ((name: string) => string) | ((name: string) => Promise); + 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 | ((name: string) => string) | ((name: string) => Promise); + /** + * 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; + } +} diff --git a/samples/client/petstore/typescript-axios/builds/composed-schemas/git_push.sh b/samples/client/petstore/typescript-axios/builds/composed-schemas/git_push.sh new file mode 100644 index 00000000000..ced3be2b0c7 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/composed-schemas/git_push.sh @@ -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' + diff --git a/samples/client/petstore/typescript-axios/builds/composed-schemas/index.ts b/samples/client/petstore/typescript-axios/builds/composed-schemas/index.ts new file mode 100644 index 00000000000..435b97b80db --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/composed-schemas/index.ts @@ -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";