From f998e610d94047f317a6d7a14ec1457d44109fd4 Mon Sep 17 00:00:00 2001 From: Jose Camara Date: Sat, 16 May 2020 23:27:45 +0200 Subject: [PATCH 1/6] Include map for `AnyType` in `typescript` --- .../codegen/languages/AbstractTypeScriptClientCodegen.java | 1 + 1 file changed, 1 insertion(+) 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 a9394802f0b4..6938695757e4 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 AbstractTypeScriptClientCodegen() { 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())); From 1e313c7320115603871caa08fa7eec8175d6e160 Mon Sep 17 00:00:00 2001 From: Jose Camara Date: Sat, 16 May 2020 23:30:01 +0200 Subject: [PATCH 2/6] Exclude `any` from the list of types extracted from `anyOf`, `allOf`, `oneOf` Exclude if there are other meaningful types --- .../AbstractTypeScriptClientCodegen.java | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) 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 6938695757e4..10281b5dfdf9 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 @@ -809,35 +809,34 @@ public void postProcessFile(File file, String fileType) { @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 schema list of schemas + * @return list of types + */ + protected List getTypesFromSchemas(List schemas) { + List types = schemas.stream().map(schema -> { String schemaType = getSchemaType(schema); if (ModelUtils.isArraySchema(schema)) { ArraySchema ap = (ArraySchema) schema; @@ -846,6 +845,11 @@ public String toAllOfName(List names, ComposedSchema composedSchema) { } return schemaType; }).distinct().collect(Collectors.toList()); - return String.join(" & ", types); + + if (types.size() > 1 && types.contains("any")) { + types.remove("any"); + } + + return types; } } From aaae08158178443e97af9926fd7b19f4b6c2f004 Mon Sep 17 00:00:00 2001 From: Jose Camara Date: Sat, 16 May 2020 23:37:24 +0200 Subject: [PATCH 3/6] Include new scripts and `yaml` to test the new case --- bin/typescript-axios-petstore-all.sh | 1 + ...axios-petstore-allOf-without-properties.sh | 32 +++++++++ bin/windows/typescript-axios-petstore-all.bat | 1 + ...xios-petstore-allOf-without-properties.bat | 14 ++++ .../3_0/allOf-without-properties.yaml | 69 +++++++++++++++++++ 5 files changed, 117 insertions(+) create mode 100755 bin/typescript-axios-petstore-allOf-without-properties.sh create mode 100644 bin/windows/typescript-axios-petstore-allOf-without-properties.bat create mode 100644 modules/openapi-generator/src/test/resources/3_0/allOf-without-properties.yaml diff --git a/bin/typescript-axios-petstore-all.sh b/bin/typescript-axios-petstore-all.sh index e3dfe3962263..b7c9979ede5b 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-allOf-without-properties.sh ./bin/typescript-axios-petstore.sh diff --git a/bin/typescript-axios-petstore-allOf-without-properties.sh b/bin/typescript-axios-petstore-allOf-without-properties.sh new file mode 100755 index 000000000000..a0c6c62517bf --- /dev/null +++ b/bin/typescript-axios-petstore-allOf-without-properties.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/allOf-without-properties.yaml -g typescript-axios -o samples/client/petstore/typescript-axios/builds/allOf-without-properties $@" + +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 c3b82892732b..648826238ecc 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-allOf-without-properties.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-allOf-without-properties.bat b/bin/windows/typescript-axios-petstore-allOf-without-properties.bat new file mode 100644 index 000000000000..9f08f3c96d72 --- /dev/null +++ b/bin/windows/typescript-axios-petstore-allOf-without-properties.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\allOf-without-properties.yaml -g typescript-axios -o samples\client\petstore\typescript-axios\builds\allOf-without-properties + +java %JAVA_OPTS% -jar %executable% %ags% diff --git a/modules/openapi-generator/src/test/resources/3_0/allOf-without-properties.yaml b/modules/openapi-generator/src/test/resources/3_0/allOf-without-properties.yaml new file mode 100644 index 000000000000..df21f940e25c --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/allOf-without-properties.yaml @@ -0,0 +1,69 @@ + + +openapi: 3.0.1 +info: + version: 1.0.0 + title: Example + license: + name: MIT +servers: + - url: http://api.example.xyz/v1 +paths: + /person/display/{personId}: + get: + parameters: + - name: personId + in: path + required: true + description: The id of the person to retrieve + schema: + type: string + operationId: list + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/Person" +components: + schemas: + Person: + type: object + discriminator: + propertyName: $_type + mapping: + a: '#/components/schemas/Adult' + c: Child + properties: + $_type: + type: string + lastName: + type: string + firstName: + type: string + Adult: + description: A representation of an adult + allOf: + - $ref: '#/components/schemas/Person' + - type: object + properties: + children: + type: array + items: + $ref: "#/components/schemas/Child" + firstChild: + allOf: + - $ref: '#/components/schemas/Child' + # This field doesn't contain properties or ref, so it's not + # possible to determine type, thus it will be `AnyType` + - description: First child + Child: + description: A representation of a child + allOf: + - type: object + properties: + age: + type: integer + format: int32 + - $ref: '#/components/schemas/Person' From 1694b9e44546b492340fa1c38564e191c62c5514 Mon Sep 17 00:00:00 2001 From: Jose Camara Date: Sat, 16 May 2020 23:37:42 +0200 Subject: [PATCH 4/6] Execute the new sample for `typescript-axios` --- .../allOf-without-properties/.gitignore | 4 + .../allOf-without-properties/.npmignore | 1 + .../.openapi-generator-ignore | 23 ++ .../.openapi-generator/VERSION | 1 + .../builds/allOf-without-properties/api.ts | 215 ++++++++++++++++++ .../builds/allOf-without-properties/base.ts | 70 ++++++ .../allOf-without-properties/configuration.ts | 75 ++++++ .../allOf-without-properties/git_push.sh | 58 +++++ .../builds/allOf-without-properties/index.ts | 16 ++ 9 files changed, 463 insertions(+) create mode 100644 samples/client/petstore/typescript-axios/builds/allOf-without-properties/.gitignore create mode 100644 samples/client/petstore/typescript-axios/builds/allOf-without-properties/.npmignore create mode 100644 samples/client/petstore/typescript-axios/builds/allOf-without-properties/.openapi-generator-ignore create mode 100644 samples/client/petstore/typescript-axios/builds/allOf-without-properties/.openapi-generator/VERSION create mode 100644 samples/client/petstore/typescript-axios/builds/allOf-without-properties/api.ts create mode 100644 samples/client/petstore/typescript-axios/builds/allOf-without-properties/base.ts create mode 100644 samples/client/petstore/typescript-axios/builds/allOf-without-properties/configuration.ts create mode 100644 samples/client/petstore/typescript-axios/builds/allOf-without-properties/git_push.sh create mode 100644 samples/client/petstore/typescript-axios/builds/allOf-without-properties/index.ts diff --git a/samples/client/petstore/typescript-axios/builds/allOf-without-properties/.gitignore b/samples/client/petstore/typescript-axios/builds/allOf-without-properties/.gitignore new file mode 100644 index 000000000000..205d8013f46f --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/allOf-without-properties/.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/allOf-without-properties/.npmignore b/samples/client/petstore/typescript-axios/builds/allOf-without-properties/.npmignore new file mode 100644 index 000000000000..999d88df6939 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/allOf-without-properties/.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/allOf-without-properties/.openapi-generator-ignore b/samples/client/petstore/typescript-axios/builds/allOf-without-properties/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/allOf-without-properties/.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/allOf-without-properties/.openapi-generator/VERSION b/samples/client/petstore/typescript-axios/builds/allOf-without-properties/.openapi-generator/VERSION new file mode 100644 index 000000000000..d99e7162d01f --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/allOf-without-properties/.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/allOf-without-properties/api.ts b/samples/client/petstore/typescript-axios/builds/allOf-without-properties/api.ts new file mode 100644 index 000000000000..82b4440e2bdc --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/allOf-without-properties/api.ts @@ -0,0 +1,215 @@ +// 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'; + +/** + * A representation of an adult + * @export + * @interface Adult + */ +export interface Adult extends Person { + /** + * + * @type {Array} + * @memberof Adult + */ + children?: Array; + /** + * + * @type {Child} + * @memberof Adult + */ + firstChild?: Child; +} +/** + * + * @export + * @interface AdultAllOf + */ +export interface AdultAllOf { + /** + * + * @type {Array} + * @memberof AdultAllOf + */ + children?: Array; + /** + * + * @type {Child} + * @memberof AdultAllOf + */ + firstChild?: Child; +} +/** + * A representation of a child + * @export + * @interface Child + */ +export interface Child extends Person { + /** + * + * @type {number} + * @memberof Child + */ + age?: number; +} +/** + * + * @export + * @interface ChildAllOf + */ +export interface ChildAllOf { + /** + * + * @type {number} + * @memberof ChildAllOf + */ + age?: number; +} +/** + * + * @export + * @interface Person + */ +export interface Person { + /** + * + * @type {string} + * @memberof Person + */ + $_type?: string; + /** + * + * @type {string} + * @memberof Person + */ + lastName?: string; + /** + * + * @type {string} + * @memberof Person + */ + firstName?: string; +} + +/** + * DefaultApi - axios parameter creator + * @export + */ +export const DefaultApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * + * @param {string} personId The id of the person to retrieve + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + list: async (personId: string, options: any = {}): Promise => { + // verify required parameter 'personId' is not null or undefined + if (personId === null || personId === undefined) { + throw new RequiredError('personId','Required parameter personId was null or undefined when calling list.'); + } + const localVarPath = `/person/display/{personId}` + .replace(`{${"personId"}}`, encodeURIComponent(String(personId))); + const localVarUrlObj = globalImportUrl.parse(localVarPath, true); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + 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}; + + return { + url: globalImportUrl.format(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * DefaultApi - functional programming interface + * @export + */ +export const DefaultApiFp = function(configuration?: Configuration) { + return { + /** + * + * @param {string} personId The id of the person to retrieve + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async list(personId: string, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await DefaultApiAxiosParamCreator(configuration).list(personId, 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 {string} personId The id of the person to retrieve + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + list(personId: string, options?: any): AxiosPromise { + return DefaultApiFp(configuration).list(personId, options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * DefaultApi - object-oriented interface + * @export + * @class DefaultApi + * @extends {BaseAPI} + */ +export class DefaultApi extends BaseAPI { + /** + * + * @param {string} personId The id of the person to retrieve + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DefaultApi + */ + public list(personId: string, options?: any) { + return DefaultApiFp(this.configuration).list(personId, options).then((request) => request(this.axios, this.basePath)); + } +} + + diff --git a/samples/client/petstore/typescript-axios/builds/allOf-without-properties/base.ts b/samples/client/petstore/typescript-axios/builds/allOf-without-properties/base.ts new file mode 100644 index 000000000000..46e25c2e6de2 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/allOf-without-properties/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/allOf-without-properties/configuration.ts b/samples/client/petstore/typescript-axios/builds/allOf-without-properties/configuration.ts new file mode 100644 index 000000000000..96f755e21cd2 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/allOf-without-properties/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/allOf-without-properties/git_push.sh b/samples/client/petstore/typescript-axios/builds/allOf-without-properties/git_push.sh new file mode 100644 index 000000000000..ced3be2b0c7b --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/allOf-without-properties/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/allOf-without-properties/index.ts b/samples/client/petstore/typescript-axios/builds/allOf-without-properties/index.ts new file mode 100644 index 000000000000..435b97b80dbf --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/allOf-without-properties/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"; From a24bf826396f084230ff8eafe26b38139d12a300 Mon Sep 17 00:00:00 2001 From: Jose Camara Date: Sun, 17 May 2020 13:08:31 +0200 Subject: [PATCH 5/6] Filter out only `AnyType` instead of all `any` types --- .../languages/AbstractTypeScriptClientCodegen.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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 10281b5dfdf9..957676409889 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 @@ -832,11 +832,15 @@ public String toAllOfName(List names, ComposedSchema composedSchema) { * Extracts the list of type names from a list of schemas. * Excludes `AnyType` if there are other valid types extracted. * - * @param schema list of schemas + * @param schemas list of schemas * @return list of types */ protected List getTypesFromSchemas(List schemas) { - List types = schemas.stream().map(schema -> { + 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,11 +849,5 @@ protected List getTypesFromSchemas(List schemas) { } return schemaType; }).distinct().collect(Collectors.toList()); - - if (types.size() > 1 && types.contains("any")) { - types.remove("any"); - } - - return types; } } From 53f099f45247c2d9fc130bb08a81dc0f465346a5 Mon Sep 17 00:00:00 2001 From: Jose Camara Date: Sun, 17 May 2020 13:09:21 +0200 Subject: [PATCH 6/6] Renamed and modified samples - Included more examples using `oneOf, `allOf`, `anyOf` - Includede examples when types that are translated to `any` are involved (`file`) --- bin/typescript-axios-petstore-all.sh | 2 +- ...script-axios-petstore-composed-schemas.sh} | 2 +- bin/windows/typescript-axios-petstore-all.bat | 2 +- ...cript-axios-petstore-composed-schemas.bat} | 2 +- .../3_0/allOf-without-properties.yaml | 69 --- .../test/resources/3_0/composed-schemas.yaml | 107 +++++ .../builds/allOf-without-properties/api.ts | 215 --------- .../.gitignore | 0 .../.npmignore | 0 .../.openapi-generator-ignore | 0 .../.openapi-generator/VERSION | 0 .../builds/composed-schemas/api.ts | 420 ++++++++++++++++++ .../base.ts | 0 .../configuration.ts | 0 .../git_push.sh | 0 .../index.ts | 0 16 files changed, 531 insertions(+), 288 deletions(-) rename bin/{typescript-axios-petstore-allOf-without-properties.sh => typescript-axios-petstore-composed-schemas.sh} (85%) rename bin/windows/{typescript-axios-petstore-allOf-without-properties.bat => typescript-axios-petstore-composed-schemas.bat} (69%) delete mode 100644 modules/openapi-generator/src/test/resources/3_0/allOf-without-properties.yaml create mode 100644 modules/openapi-generator/src/test/resources/3_0/composed-schemas.yaml delete mode 100644 samples/client/petstore/typescript-axios/builds/allOf-without-properties/api.ts rename samples/client/petstore/typescript-axios/builds/{allOf-without-properties => composed-schemas}/.gitignore (100%) rename samples/client/petstore/typescript-axios/builds/{allOf-without-properties => composed-schemas}/.npmignore (100%) rename samples/client/petstore/typescript-axios/builds/{allOf-without-properties => composed-schemas}/.openapi-generator-ignore (100%) rename samples/client/petstore/typescript-axios/builds/{allOf-without-properties => composed-schemas}/.openapi-generator/VERSION (100%) create mode 100644 samples/client/petstore/typescript-axios/builds/composed-schemas/api.ts rename samples/client/petstore/typescript-axios/builds/{allOf-without-properties => composed-schemas}/base.ts (100%) rename samples/client/petstore/typescript-axios/builds/{allOf-without-properties => composed-schemas}/configuration.ts (100%) rename samples/client/petstore/typescript-axios/builds/{allOf-without-properties => composed-schemas}/git_push.sh (100%) rename samples/client/petstore/typescript-axios/builds/{allOf-without-properties => composed-schemas}/index.ts (100%) diff --git a/bin/typescript-axios-petstore-all.sh b/bin/typescript-axios-petstore-all.sh index b7c9979ede5b..c66b3eba3074 100755 --- a/bin/typescript-axios-petstore-all.sh +++ b/bin/typescript-axios-petstore-all.sh @@ -6,5 +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-allOf-without-properties.sh +./bin/typescript-axios-petstore-composed-schemas.sh ./bin/typescript-axios-petstore.sh diff --git a/bin/typescript-axios-petstore-allOf-without-properties.sh b/bin/typescript-axios-petstore-composed-schemas.sh similarity index 85% rename from bin/typescript-axios-petstore-allOf-without-properties.sh rename to bin/typescript-axios-petstore-composed-schemas.sh index a0c6c62517bf..8ed378b6f34f 100755 --- a/bin/typescript-axios-petstore-allOf-without-properties.sh +++ b/bin/typescript-axios-petstore-composed-schemas.sh @@ -27,6 +27,6 @@ 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/allOf-without-properties.yaml -g typescript-axios -o samples/client/petstore/typescript-axios/builds/allOf-without-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 648826238ecc..8e9a25ddaf1a 100644 --- a/bin/windows/typescript-axios-petstore-all.bat +++ b/bin/windows/typescript-axios-petstore-all.bat @@ -6,5 +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-allOf-without-properties.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-allOf-without-properties.bat b/bin/windows/typescript-axios-petstore-composed-schemas.bat similarity index 69% rename from bin/windows/typescript-axios-petstore-allOf-without-properties.bat rename to bin/windows/typescript-axios-petstore-composed-schemas.bat index 9f08f3c96d72..ae70255c20b4 100644 --- a/bin/windows/typescript-axios-petstore-allOf-without-properties.bat +++ b/bin/windows/typescript-axios-petstore-composed-schemas.bat @@ -9,6 +9,6 @@ If Not Exist %executable% ( REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M echo -set ags=generate -i modules\openapi-generator\src\test\resources\3_0\allOf-without-properties.yaml -g typescript-axios -o samples\client\petstore\typescript-axios\builds\allOf-without-properties +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/test/resources/3_0/allOf-without-properties.yaml b/modules/openapi-generator/src/test/resources/3_0/allOf-without-properties.yaml deleted file mode 100644 index df21f940e25c..000000000000 --- a/modules/openapi-generator/src/test/resources/3_0/allOf-without-properties.yaml +++ /dev/null @@ -1,69 +0,0 @@ - - -openapi: 3.0.1 -info: - version: 1.0.0 - title: Example - license: - name: MIT -servers: - - url: http://api.example.xyz/v1 -paths: - /person/display/{personId}: - get: - parameters: - - name: personId - in: path - required: true - description: The id of the person to retrieve - schema: - type: string - operationId: list - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/Person" -components: - schemas: - Person: - type: object - discriminator: - propertyName: $_type - mapping: - a: '#/components/schemas/Adult' - c: Child - properties: - $_type: - type: string - lastName: - type: string - firstName: - type: string - Adult: - description: A representation of an adult - allOf: - - $ref: '#/components/schemas/Person' - - type: object - properties: - children: - type: array - items: - $ref: "#/components/schemas/Child" - firstChild: - allOf: - - $ref: '#/components/schemas/Child' - # This field doesn't contain properties or ref, so it's not - # possible to determine type, thus it will be `AnyType` - - description: First child - Child: - description: A representation of a child - allOf: - - type: object - properties: - age: - type: integer - format: int32 - - $ref: '#/components/schemas/Person' 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 000000000000..08e73f1d2ee6 --- /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/allOf-without-properties/api.ts b/samples/client/petstore/typescript-axios/builds/allOf-without-properties/api.ts deleted file mode 100644 index 82b4440e2bdc..000000000000 --- a/samples/client/petstore/typescript-axios/builds/allOf-without-properties/api.ts +++ /dev/null @@ -1,215 +0,0 @@ -// 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'; - -/** - * A representation of an adult - * @export - * @interface Adult - */ -export interface Adult extends Person { - /** - * - * @type {Array} - * @memberof Adult - */ - children?: Array; - /** - * - * @type {Child} - * @memberof Adult - */ - firstChild?: Child; -} -/** - * - * @export - * @interface AdultAllOf - */ -export interface AdultAllOf { - /** - * - * @type {Array} - * @memberof AdultAllOf - */ - children?: Array; - /** - * - * @type {Child} - * @memberof AdultAllOf - */ - firstChild?: Child; -} -/** - * A representation of a child - * @export - * @interface Child - */ -export interface Child extends Person { - /** - * - * @type {number} - * @memberof Child - */ - age?: number; -} -/** - * - * @export - * @interface ChildAllOf - */ -export interface ChildAllOf { - /** - * - * @type {number} - * @memberof ChildAllOf - */ - age?: number; -} -/** - * - * @export - * @interface Person - */ -export interface Person { - /** - * - * @type {string} - * @memberof Person - */ - $_type?: string; - /** - * - * @type {string} - * @memberof Person - */ - lastName?: string; - /** - * - * @type {string} - * @memberof Person - */ - firstName?: string; -} - -/** - * DefaultApi - axios parameter creator - * @export - */ -export const DefaultApiAxiosParamCreator = function (configuration?: Configuration) { - return { - /** - * - * @param {string} personId The id of the person to retrieve - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - list: async (personId: string, options: any = {}): Promise => { - // verify required parameter 'personId' is not null or undefined - if (personId === null || personId === undefined) { - throw new RequiredError('personId','Required parameter personId was null or undefined when calling list.'); - } - const localVarPath = `/person/display/{personId}` - .replace(`{${"personId"}}`, encodeURIComponent(String(personId))); - const localVarUrlObj = globalImportUrl.parse(localVarPath, true); - let baseOptions; - if (configuration) { - baseOptions = configuration.baseOptions; - } - const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; - const localVarHeaderParameter = {} as any; - const localVarQueryParameter = {} as any; - - - - 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}; - - return { - url: globalImportUrl.format(localVarUrlObj), - options: localVarRequestOptions, - }; - }, - } -}; - -/** - * DefaultApi - functional programming interface - * @export - */ -export const DefaultApiFp = function(configuration?: Configuration) { - return { - /** - * - * @param {string} personId The id of the person to retrieve - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - async list(personId: string, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await DefaultApiAxiosParamCreator(configuration).list(personId, 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 {string} personId The id of the person to retrieve - * @param {*} [options] Override http request option. - * @throws {RequiredError} - */ - list(personId: string, options?: any): AxiosPromise { - return DefaultApiFp(configuration).list(personId, options).then((request) => request(axios, basePath)); - }, - }; -}; - -/** - * DefaultApi - object-oriented interface - * @export - * @class DefaultApi - * @extends {BaseAPI} - */ -export class DefaultApi extends BaseAPI { - /** - * - * @param {string} personId The id of the person to retrieve - * @param {*} [options] Override http request option. - * @throws {RequiredError} - * @memberof DefaultApi - */ - public list(personId: string, options?: any) { - return DefaultApiFp(this.configuration).list(personId, options).then((request) => request(this.axios, this.basePath)); - } -} - - diff --git a/samples/client/petstore/typescript-axios/builds/allOf-without-properties/.gitignore b/samples/client/petstore/typescript-axios/builds/composed-schemas/.gitignore similarity index 100% rename from samples/client/petstore/typescript-axios/builds/allOf-without-properties/.gitignore rename to samples/client/petstore/typescript-axios/builds/composed-schemas/.gitignore diff --git a/samples/client/petstore/typescript-axios/builds/allOf-without-properties/.npmignore b/samples/client/petstore/typescript-axios/builds/composed-schemas/.npmignore similarity index 100% rename from samples/client/petstore/typescript-axios/builds/allOf-without-properties/.npmignore rename to samples/client/petstore/typescript-axios/builds/composed-schemas/.npmignore diff --git a/samples/client/petstore/typescript-axios/builds/allOf-without-properties/.openapi-generator-ignore b/samples/client/petstore/typescript-axios/builds/composed-schemas/.openapi-generator-ignore similarity index 100% rename from samples/client/petstore/typescript-axios/builds/allOf-without-properties/.openapi-generator-ignore rename to samples/client/petstore/typescript-axios/builds/composed-schemas/.openapi-generator-ignore diff --git a/samples/client/petstore/typescript-axios/builds/allOf-without-properties/.openapi-generator/VERSION b/samples/client/petstore/typescript-axios/builds/composed-schemas/.openapi-generator/VERSION similarity index 100% rename from samples/client/petstore/typescript-axios/builds/allOf-without-properties/.openapi-generator/VERSION rename to samples/client/petstore/typescript-axios/builds/composed-schemas/.openapi-generator/VERSION 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 000000000000..9bfc1ba1f178 --- /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/allOf-without-properties/base.ts b/samples/client/petstore/typescript-axios/builds/composed-schemas/base.ts similarity index 100% rename from samples/client/petstore/typescript-axios/builds/allOf-without-properties/base.ts rename to samples/client/petstore/typescript-axios/builds/composed-schemas/base.ts diff --git a/samples/client/petstore/typescript-axios/builds/allOf-without-properties/configuration.ts b/samples/client/petstore/typescript-axios/builds/composed-schemas/configuration.ts similarity index 100% rename from samples/client/petstore/typescript-axios/builds/allOf-without-properties/configuration.ts rename to samples/client/petstore/typescript-axios/builds/composed-schemas/configuration.ts diff --git a/samples/client/petstore/typescript-axios/builds/allOf-without-properties/git_push.sh b/samples/client/petstore/typescript-axios/builds/composed-schemas/git_push.sh similarity index 100% rename from samples/client/petstore/typescript-axios/builds/allOf-without-properties/git_push.sh rename to samples/client/petstore/typescript-axios/builds/composed-schemas/git_push.sh diff --git a/samples/client/petstore/typescript-axios/builds/allOf-without-properties/index.ts b/samples/client/petstore/typescript-axios/builds/composed-schemas/index.ts similarity index 100% rename from samples/client/petstore/typescript-axios/builds/allOf-without-properties/index.ts rename to samples/client/petstore/typescript-axios/builds/composed-schemas/index.ts