diff --git a/.circleci/config.yml b/.circleci/config.yml
index b1c5957943e..b610ceeb2bb 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -42,24 +42,6 @@ jobs:
command: |-
printf '127.0.0.1 petstore.swagger.io
' | sudo tee -a /etc/hosts
- # Dependencies
- # Install latest stable node for angular 6
- - run:
- name: Install node@stable (for angular 6)
- command: |
- set +e
- curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
- export NVM_DIR="/opt/circleci/.nvm"
- [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
- #nvm install stable
- # install v16 instead of the latest stable version
- nvm install 16
- nvm alias default 16
-
- # Each step uses the same `$BASH_ENV`, so need to modify it
- echo 'export NVM_DIR="/opt/circleci/.nvm"' >> $BASH_ENV
- echo "[ -s \"$NVM_DIR/nvm.sh\" ] && . \"$NVM_DIR/nvm.sh\"" >> $BASH_ENV
- - run: node --version
# - run: docker pull openapitools/openapi-petstore
# - run: docker run -d -e OPENAPI_BASE_PATH=/v3 -e DISABLE_API_KEY=1 -e DISABLE_OAUTH=1 -p 80:8080 openapitools/openapi-petstore
- run: docker pull swaggerapi/petstore
diff --git a/CI/circle_parallel.sh b/CI/circle_parallel.sh
index 6e231909d61..697009699a3 100755
--- a/CI/circle_parallel.sh
+++ b/CI/circle_parallel.sh
@@ -40,6 +40,13 @@ elif [ "$NODE_INDEX" = "2" ]; then
sudo apt-get -y build-dep libcurl4-gnutls-dev
sudo apt-get -y install libcurl4-gnutls-dev
+ # Install golang version 1.14
+ go version
+ sudo mkdir /usr/local/go1.14
+ wget -c https://dl.google.com/go/go1.14.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local/go1.14
+ export PATH="/usr/local/go1.14/go/bin:$PATH"
+ go version
+
# run integration tests
mvn --no-snapshot-updates --quiet verify -Psamples.misc -Dorg.slf4j.simpleLogger.defaultLogLevel=error
elif [ "$NODE_INDEX" = "3" ]; then
@@ -55,6 +62,21 @@ elif [ "$NODE_INDEX" = "3" ]; then
pyenv global 3.6.3
python3 --version
+ # Install node@stable (for angular 6)
+ set +e
+ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
+ export NVM_DIR="/opt/circleci/.nvm"
+ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
+ #nvm install stable
+ # install v16 instead of the latest stable version
+ nvm install 16
+ nvm alias default 16
+ node --version
+
+ # Each step uses the same `$BASH_ENV`, so need to modify it
+ echo 'export NVM_DIR="/opt/circleci/.nvm"' >> $BASH_ENV
+ echo "[ -s \"$NVM_DIR/nvm.sh\" ] && . \"$NVM_DIR/nvm.sh\"" >> $BASH_ENV
+
mvn --no-snapshot-updates --quiet verify -Psamples.circleci.node3 -Dorg.slf4j.simpleLogger.defaultLogLevel=error
else
@@ -62,13 +84,6 @@ else
#sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
java -version
- # Install golang version 1.14
- go version
- sudo mkdir /usr/local/go1.14
- wget -c https://dl.google.com/go/go1.14.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local/go1.14
- export PATH="/usr/local/go1.14/go/bin:$PATH"
- go version
-
mvn --no-snapshot-updates --quiet verify -Psamples.circleci.others -Dorg.slf4j.simpleLogger.defaultLogLevel=error
mvn --no-snapshot-updates --quiet javadoc:javadoc -Psamples.circleci -Dorg.slf4j.simpleLogger.defaultLogLevel=error
fi
diff --git a/README.md b/README.md
index 397802a8bdd..e993fdf0fb2 100644
--- a/README.md
+++ b/README.md
@@ -833,6 +833,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- 2021-05-31 - [FlutterでOpen Api Generator(Swagger)を使う](https://aakira.app/blog/2021/05/flutter-open-api/) by [AAkira](https://twitter.com/_a_akira)
- 2021-06-22 - [Rest API Documentation and Client Generation With OpenAPI](https://dzone.com/articles/rest-api-documentation-and-client-generation-with) by [Prasanth Gullapalli](https://dzone.com/users/1011797/prasanthnath.g@gmail.com.html)
- 2021-07-16 - [銀行事業のサーバーサイド開発について / LINE 京都開発室 エンジニア採用説明会](https://www.youtube.com/watch?v=YrrKQHxLPpQ) by 野田誠人, Robert Mitchell
+- 2021-07-19 - [OpenAPI code generation with kotlin](https://sylhare.github.io/2021/07/19/Openapi-swagger-codegen-with-kotlin.html) by [sylhare](https://github.com/sylhare)
- 2021-07-29 - [How To Rewrite a Huge Codebase](https://dzone.com/articles/how-to-rewrite-a-huge-code-base) by [Curtis Poe](https://dzone.com/users/4565446/publiusovidius.html)
- 2021-08-21 - [Generating Client APIs using Swagger Part 1](https://medium.com/@flowsquad/generating-client-apis-using-swagger-part-1-2d46f13f5e92) by [FlowSquad.io](https://medium.com/@flowsquad)
- 2021-09-11 - [Invoking AWS ParallelCluster API](https://docs.aws.amazon.com/parallelcluster/latest/ug/api-reference-v3.html) at [AWS ParallelCluster API official documentation](https://docs.aws.amazon.com/parallelcluster/latest/ug/api-reference-v3.html)
diff --git a/bin/configs/cpp-restsdk-client.yaml b/bin/configs/cpp-restsdk-client.yaml
index 87bce881bbd..fedc628a69e 100644
--- a/bin/configs/cpp-restsdk-client.yaml
+++ b/bin/configs/cpp-restsdk-client.yaml
@@ -2,3 +2,5 @@ generatorName: cpp-restsdk
outputDir: samples/client/petstore/cpp-restsdk/client
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/cpp-rest-sdk-client
+additionalProperties:
+ packageName: CppRestPetstoreClient
diff --git a/bin/configs/java-microprofile-rest-client.yaml b/bin/configs/java-microprofile-rest-client.yaml
index 2d9796db540..384a6aa7f30 100644
--- a/bin/configs/java-microprofile-rest-client.yaml
+++ b/bin/configs/java-microprofile-rest-client.yaml
@@ -5,3 +5,4 @@ inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
artifactId: microprofile-rest-client
+ configKey: petstore
diff --git a/docs/generators/cpp-restsdk.md b/docs/generators/cpp-restsdk.md
index 9dfbb390514..4fc97b939ae 100644
--- a/docs/generators/cpp-restsdk.md
+++ b/docs/generators/cpp-restsdk.md
@@ -12,6 +12,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|defaultInclude|The default include statement that should be placed in all headers for including things like the declspec (convention: #include "Commons.h" | ||
|generateGMocksForApis|Generate Google Mock classes for APIs.| |null|
|modelPackage|C++ namespace for models (convention: name.space.model).| |org.openapitools.client.model|
+|packageName|C++ package (library) name.| |CppRestOpenAPIClient|
|packageVersion|C++ package version.| |1.0.0|
|reservedWordPrefix|Prefix to prepend to reserved words in order to avoid conflicts| |r_|
|variableNameFirstCharacterUppercase|Make first character of variable name uppercase (eg. value -> Value)| |true|
diff --git a/docs/generators/java.md b/docs/generators/java.md
index 0cb76c15409..8b360b4b427 100644
--- a/docs/generators/java.md
+++ b/docs/generators/java.md
@@ -19,6 +19,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|booleanGetterPrefix|Set booleanGetterPrefix| |get|
|caseInsensitiveResponseHeaders|Make API response's headers case-insensitive. Available on okhttp-gson, jersey2 libraries| |false|
+|configKey|Config key in @RegisterRestClient. Default to none. Only `microprofile` supports this option.| |null|
|dateLibrary|Option. Date library to use|
**joda**
Joda (for legacy app only)
**legacy**
Legacy java.util.Date (if you really have a good reason not to use threetenbp
**java8-localdatetime**
Java 8 using LocalDateTime (for legacy app only)
**java8**
Java 8 native JSR310 (preferred for jdk 1.8+) - note: this also sets "java8" to true
**threetenbp**
Backport of JSR310 (preferred for jdk < 1.8)
|threetenbp|
|developerEmail|developer email in generated pom.xml| |team@openapitools.org|
|developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors|
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenComposedSchemas.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenComposedSchemas.java
new file mode 100644
index 00000000000..f801853dafc
--- /dev/null
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenComposedSchemas.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openapitools.codegen;
+
+import java.util.*;
+
+public class CodegenComposedSchemas {
+ private List allOf;
+ private List oneOf;
+ private List anyOf;
+
+ public CodegenComposedSchemas(List allOf, List oneOf, List anyOf) {
+ this.allOf = allOf;
+ this.oneOf = oneOf;
+ this.anyOf = anyOf;
+ }
+
+ public List getAllOf() {
+ return allOf;
+ }
+
+ public List getOneOf() {
+ return oneOf;
+ }
+
+ public List getAnyOf() {
+ return anyOf;
+ }
+
+ public String toString() {
+ final StringBuilder sb = new StringBuilder("CodegenComposedSchemas{");
+ sb.append("oneOf=").append(oneOf);
+ sb.append(", anyOf=").append(anyOf);
+ sb.append(", allOf=").append(allOf);
+ sb.append('}');
+ return sb.toString();
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ CodegenComposedSchemas that = (CodegenComposedSchemas) o;
+ return Objects.equals(oneOf, that.oneOf) &&
+ Objects.equals(anyOf, that.anyOf) &&
+ Objects.equals(allOf, that.allOf);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(oneOf, anyOf, allOf);
+ }
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java
index ab9f23fba67..0a44812ceac 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java
@@ -49,11 +49,6 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
public Set oneOf = new TreeSet();
public Set allOf = new TreeSet();
- // anyOf, oneOf, allOf with full properties/tags (e.g. isString, etc)
- public List anyOfProps = new ArrayList<>();
- public List allOfProps = new ArrayList<>();
- public List oneOfProps = new ArrayList<>();
-
// The schema name as written in the OpenAPI document.
public String name;
// The language-specific name of the class that implements this schema.
@@ -110,6 +105,8 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
public ExternalDocumentation externalDocumentation;
public Map vendorExtensions = new HashMap();
+ private CodegenComposedSchemas composedSchemas;
+ private boolean hasMultipleTypes = false;
/**
* The type of the value for the additionalProperties keyword in the OAS document.
@@ -810,6 +807,22 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
this.isAnyType = isAnyType;
}
+ @Override
+ public void setComposedSchemas(CodegenComposedSchemas composedSchemas) {
+ this.composedSchemas = composedSchemas;
+ }
+
+ @Override
+ public CodegenComposedSchemas getComposedSchemas() {
+ return composedSchemas;
+ }
+
+ @Override
+ public boolean getHasMultipleTypes() {return hasMultipleTypes; }
+
+ @Override
+ public void setHasMultipleTypes(boolean hasMultipleTypes) { this.hasMultipleTypes = hasMultipleTypes; }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -843,12 +856,14 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
hasOnlyReadOnly == that.hasOnlyReadOnly &&
isNull == that.isNull &&
hasValidation == that.hasValidation &&
+ hasMultipleTypes == that.getHasMultipleTypes() &&
hasDiscriminatorWithNonEmptyMapping == that.getHasDiscriminatorWithNonEmptyMapping() &&
getIsAnyType() == that.getIsAnyType() &&
getAdditionalPropertiesIsAnyType() == that.getAdditionalPropertiesIsAnyType() &&
getUniqueItems() == that.getUniqueItems() &&
getExclusiveMinimum() == that.getExclusiveMinimum() &&
getExclusiveMaximum() == that.getExclusiveMaximum() &&
+ Objects.equals(composedSchemas, that.composedSchemas) &&
Objects.equals(parent, that.parent) &&
Objects.equals(parentSchema, that.parentSchema) &&
Objects.equals(interfaces, that.interfaces) &&
@@ -856,9 +871,6 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
Objects.equals(parentModel, that.parentModel) &&
Objects.equals(interfaceModels, that.interfaceModels) &&
Objects.equals(children, that.children) &&
- Objects.equals(anyOf, that.anyOfProps) &&
- Objects.equals(oneOf, that.oneOfProps) &&
- Objects.equals(allOf, that.allOfProps) &&
Objects.equals(anyOf, that.anyOf) &&
Objects.equals(oneOf, that.oneOf) &&
Objects.equals(allOf, that.allOf) &&
@@ -921,8 +933,8 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
getAdditionalPropertiesType(), getMaxProperties(), getMinProperties(), getUniqueItems(), getMaxItems(),
getMinItems(), getMaxLength(), getMinLength(), getExclusiveMinimum(), getExclusiveMaximum(), getMinimum(),
getMaximum(), getPattern(), getMultipleOf(), getItems(), getAdditionalProperties(), getIsModel(),
- getAdditionalPropertiesIsAnyType(), hasDiscriminatorWithNonEmptyMapping, anyOfProps, oneOfProps, allOfProps,
- isAnyType);
+ getAdditionalPropertiesIsAnyType(), hasDiscriminatorWithNonEmptyMapping,
+ isAnyType, getComposedSchemas(), hasMultipleTypes);
}
@Override
@@ -938,9 +950,6 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
sb.append(", anyOf=").append(anyOf);
sb.append(", oneOf=").append(oneOf);
sb.append(", allOf=").append(allOf);
- sb.append(", anyOf=").append(anyOfProps);
- sb.append(", oneOf=").append(oneOfProps);
- sb.append(", allOf=").append(allOfProps);
sb.append(", name='").append(name).append('\'');
sb.append(", classname='").append(classname).append('\'');
sb.append(", title='").append(title).append('\'');
@@ -1017,6 +1026,8 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
sb.append(", getAdditionalPropertiesIsAnyType=").append(getAdditionalPropertiesIsAnyType());
sb.append(", getHasDiscriminatorWithNonEmptyMapping=").append(hasDiscriminatorWithNonEmptyMapping);
sb.append(", getIsAnyType=").append(getIsAnyType());
+ sb.append(", composedSchemas=").append(composedSchemas);
+ sb.append(", hasMultipleTypes=").append(hasMultipleTypes);
sb.append('}');
return sb.toString();
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java
index ebd01afdfd2..38eb785410e 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java
@@ -107,6 +107,8 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
public boolean isNull;
private boolean hasRequired;
private boolean hasDiscriminatorWithNonEmptyMapping;
+ private CodegenComposedSchemas composedSchemas;
+ private boolean hasMultipleTypes = false;
public CodegenParameter copy() {
CodegenParameter output = new CodegenParameter();
@@ -158,7 +160,11 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
output.setHasVars(this.hasVars);
output.setHasRequired(this.hasRequired);
output.setHasDiscriminatorWithNonEmptyMapping(this.hasDiscriminatorWithNonEmptyMapping);
+ output.setHasMultipleTypes(this.hasMultipleTypes);
+ if (this.composedSchemas != null) {
+ output.setComposedSchemas(this.getComposedSchemas());
+ }
if (this._enum != null) {
output._enum = new ArrayList(this._enum);
}
@@ -216,7 +222,7 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
@Override
public int hashCode() {
- return Objects.hash(isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, isContainer, isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, baseName, paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description, unescapedDescription, baseType, defaultValue, enumName, style, isDeepObject, isAllowEmptyValue, example, jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject, isAnyType, isArray, isMap, isFile, isEnum, _enum, allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars, vendorExtensions, hasValidation, getMaxProperties(), getMinProperties(), isNullable, isDeprecated, required, getMaximum(), getExclusiveMaximum(), getMinimum(), getExclusiveMinimum(), getMaxLength(), getMinLength(), getPattern(), getMaxItems(), getMinItems(), getUniqueItems(), contentType, multipleOf, isNull, additionalPropertiesIsAnyType, hasVars, hasRequired, isShort, isUnboundedInteger, hasDiscriminatorWithNonEmptyMapping);
+ return Objects.hash(isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, isContainer, isCollectionFormatMulti, isPrimitiveType, isModel, isExplode, baseName, paramName, dataType, datatypeWithEnum, dataFormat, collectionFormat, description, unescapedDescription, baseType, defaultValue, enumName, style, isDeepObject, isAllowEmptyValue, example, jsonSchema, isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject, isAnyType, isArray, isMap, isFile, isEnum, _enum, allowableValues, items, mostInnerItems, additionalProperties, vars, requiredVars, vendorExtensions, hasValidation, getMaxProperties(), getMinProperties(), isNullable, isDeprecated, required, getMaximum(), getExclusiveMaximum(), getMinimum(), getExclusiveMinimum(), getMaxLength(), getMinLength(), getPattern(), getMaxItems(), getMinItems(), getUniqueItems(), contentType, multipleOf, isNull, additionalPropertiesIsAnyType, hasVars, hasRequired, isShort, isUnboundedInteger, hasDiscriminatorWithNonEmptyMapping, composedSchemas, hasMultipleTypes);
}
@Override
@@ -264,13 +270,15 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
isDeprecated == that.isDeprecated &&
required == that.required &&
isNull == that.isNull &&
- hasDiscriminatorWithNonEmptyMapping && that.getHasDiscriminatorWithNonEmptyMapping() &&
+ hasDiscriminatorWithNonEmptyMapping == that.getHasDiscriminatorWithNonEmptyMapping() &&
getAdditionalPropertiesIsAnyType() == that.getAdditionalPropertiesIsAnyType() &&
+ hasMultipleTypes == that.getHasMultipleTypes() &&
getHasVars() == that.getHasVars() &&
getHasRequired() == that.getHasRequired() &&
getExclusiveMaximum() == that.getExclusiveMaximum() &&
getExclusiveMinimum() == that.getExclusiveMinimum() &&
getUniqueItems() == that.getUniqueItems() &&
+ Objects.equals(composedSchemas, that.getComposedSchemas()) &&
Objects.equals(baseName, that.baseName) &&
Objects.equals(paramName, that.paramName) &&
Objects.equals(dataType, that.dataType) &&
@@ -393,6 +401,8 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
sb.append(", getHasVars=").append(hasVars);
sb.append(", getHasRequired=").append(hasRequired);
sb.append(", getHasDiscriminatorWithNonEmptyMapping=").append(hasDiscriminatorWithNonEmptyMapping);
+ sb.append(", composedSchemas=").append(composedSchemas);
+ sb.append(", hasMultipleTypes=").append(hasMultipleTypes);
sb.append('}');
return sb.toString();
}
@@ -706,5 +716,21 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
public void setIsAnyType(boolean isAnyType) {
this.isAnyType = isAnyType;
}
+
+ @Override
+ public void setComposedSchemas(CodegenComposedSchemas composedSchemas) {
+ this.composedSchemas = composedSchemas;
+ }
+
+ @Override
+ public CodegenComposedSchemas getComposedSchemas() {
+ return composedSchemas;
+ }
+
+ @Override
+ public boolean getHasMultipleTypes() {return hasMultipleTypes; }
+
+ @Override
+ public void setHasMultipleTypes(boolean hasMultipleTypes) { this.hasMultipleTypes = hasMultipleTypes; }
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java
index ed1636fc6d5..c7a22915dbf 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java
@@ -191,6 +191,8 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
private boolean hasVars;
private boolean hasRequired;
private boolean hasDiscriminatorWithNonEmptyMapping;
+ private CodegenComposedSchemas composedSchemas = null;
+ private boolean hasMultipleTypes = false;
public String getBaseName() {
return baseName;
@@ -614,6 +616,16 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
this.xmlNamespace = xmlNamespace;
}
+ @Override
+ public void setComposedSchemas(CodegenComposedSchemas composedSchemas) {
+ this.composedSchemas = composedSchemas;
+ }
+
+ @Override
+ public CodegenComposedSchemas getComposedSchemas() {
+ return composedSchemas;
+ }
+
@Override
public CodegenProperty clone() {
try {
@@ -642,6 +654,9 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
if (this.vendorExtensions != null) {
cp.vendorExtensions = new HashMap(this.vendorExtensions);
}
+ if (this.composedSchemas != null) {
+ cp.composedSchemas = this.composedSchemas;
+ }
return cp;
} catch (CloneNotSupportedException e) {
@@ -787,6 +802,12 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
this.isAnyType = isAnyType;
}
+ @Override
+ public boolean getHasMultipleTypes() {return hasMultipleTypes; }
+
+ @Override
+ public void setHasMultipleTypes(boolean hasMultipleTypes) { this.hasMultipleTypes = hasMultipleTypes; }
+
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("CodegenProperty{");
@@ -882,6 +903,8 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
sb.append(", getHasVars=").append(getHasVars());
sb.append(", getHasRequired=").append(getHasRequired());
sb.append(", getHasDiscriminatorWithNonEmptyMapping=").append(hasDiscriminatorWithNonEmptyMapping);
+ sb.append(", composedSchemas=").append(composedSchemas);
+ sb.append(", hasMultipleTypes=").append(hasMultipleTypes);
sb.append('}');
return sb.toString();
}
@@ -933,10 +956,12 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
isXmlAttribute == that.isXmlAttribute &&
isXmlWrapped == that.isXmlWrapped &&
isNull == that.isNull &&
+ hasMultipleTypes == that.getHasMultipleTypes() &&
hasDiscriminatorWithNonEmptyMapping == that.hasDiscriminatorWithNonEmptyMapping &&
getAdditionalPropertiesIsAnyType() == that.getAdditionalPropertiesIsAnyType() &&
getHasVars() == that.getHasVars() &&
getHasRequired() ==that.getHasRequired() &&
+ Objects.equals(composedSchemas, that.composedSchemas) &&
Objects.equals(openApiType, that.openApiType) &&
Objects.equals(baseName, that.baseName) &&
Objects.equals(complexType, that.complexType) &&
@@ -999,6 +1024,6 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
vendorExtensions, hasValidation, isInherited, discriminatorValue, nameInCamelCase,
nameInSnakeCase, enumName, maxItems, minItems, isXmlAttribute, xmlPrefix, xmlName,
xmlNamespace, isXmlWrapped, isNull, additionalPropertiesIsAnyType, hasVars, hasRequired,
- hasDiscriminatorWithNonEmptyMapping);
+ hasDiscriminatorWithNonEmptyMapping, composedSchemas, hasMultipleTypes);
}
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java
index 1a99e774e59..b81bda5f583 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java
@@ -85,6 +85,8 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
private boolean hasVars;
private boolean hasRequired;
private boolean hasDiscriminatorWithNonEmptyMapping;
+ private CodegenComposedSchemas composedSchemas;
+ private boolean hasMultipleTypes = false;
@Override
public int hashCode() {
@@ -96,7 +98,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
getMaxProperties(), getMinProperties(), uniqueItems, getMaxItems(), getMinItems(), getMaxLength(),
getMinLength(), exclusiveMinimum, exclusiveMaximum, getMinimum(), getMaximum(), getPattern(),
is1xx, is2xx, is3xx, is4xx, is5xx, additionalPropertiesIsAnyType, hasVars, hasRequired,
- hasDiscriminatorWithNonEmptyMapping);
+ hasDiscriminatorWithNonEmptyMapping, composedSchemas, hasMultipleTypes);
}
@Override
@@ -141,9 +143,11 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
is4xx == that.is4xx &&
is5xx == that.is5xx &&
hasDiscriminatorWithNonEmptyMapping == that.getHasDiscriminatorWithNonEmptyMapping() &&
+ hasMultipleTypes == that.getHasMultipleTypes() &&
getAdditionalPropertiesIsAnyType() == that.getAdditionalPropertiesIsAnyType() &&
getHasVars() == that.getHasVars() &&
getHasRequired() == that.getHasRequired() &&
+ Objects.equals(composedSchemas, that.getComposedSchemas()) &&
Objects.equals(vars, that.vars) &&
Objects.equals(requiredVars, that.requiredVars) &&
Objects.equals(headers, that.headers) &&
@@ -482,6 +486,8 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
sb.append(", getHasVars=").append(hasVars);
sb.append(", getHasRequired=").append(hasRequired);
sb.append(", getHasDiscriminatorWithNonEmptyMapping=").append(hasDiscriminatorWithNonEmptyMapping);
+ sb.append(", composedSchemas=").append(composedSchemas);
+ sb.append(", hasMultipleTypes=").append(hasMultipleTypes);
sb.append('}');
return sb.toString();
}
@@ -570,4 +576,20 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
public void setIsAnyType(boolean isAnyType) {
this.isAnyType = isAnyType;
}
+
+ @Override
+ public void setComposedSchemas(CodegenComposedSchemas composedSchemas) {
+ this.composedSchemas = composedSchemas;
+ }
+
+ @Override
+ public CodegenComposedSchemas getComposedSchemas() {
+ return composedSchemas;
+ }
+
+ @Override
+ public boolean getHasMultipleTypes() {return hasMultipleTypes; }
+
+ @Override
+ public void setHasMultipleTypes(boolean hasMultipleTypes) { this.hasMultipleTypes = hasMultipleTypes; }
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
index d5920a2abc7..2c530aeaffe 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
@@ -2440,9 +2440,6 @@ public class DefaultCodegen implements CodegenConfig {
// interfaces (schemas defined in allOf, anyOf, oneOf)
List interfaces = ModelUtils.getInterfaces(composed);
- List anyOfProps = new ArrayList<>();
- List allOfProps = new ArrayList<>();
- List oneOfProps = new ArrayList<>();
if (!interfaces.isEmpty()) {
// m.interfaces is for backward compatibility
if (m.interfaces == null)
@@ -2467,7 +2464,6 @@ public class DefaultCodegen implements CodegenConfig {
LOGGER.warn("{} (anyOf schema) already has `{}` defined and therefore it's skipped.", m.name, languageType);
} else {
m.anyOf.add(languageType);
- anyOfProps.add(interfaceProperty);
}
} else if (composed.getOneOf() != null) {
@@ -2475,7 +2471,6 @@ public class DefaultCodegen implements CodegenConfig {
LOGGER.warn("{} (oneOf schema) already has `{}` defined and therefore it's skipped.", m.name, languageType);
} else {
m.oneOf.add(languageType);
- oneOfProps.add(interfaceProperty);
}
} else if (composed.getAllOf() != null) {
// no need to add primitive type to allOf, which should comprise of schemas (models) only
@@ -2511,23 +2506,16 @@ public class DefaultCodegen implements CodegenConfig {
if (composed.getAnyOf() != null) {
m.anyOf.add(modelName);
- anyOfProps.add(interfaceProperty);
} else if (composed.getOneOf() != null) {
m.oneOf.add(modelName);
- oneOfProps.add(interfaceProperty);
} else if (composed.getAllOf() != null) {
m.allOf.add(modelName);
- allOfProps.add(interfaceProperty);
} else {
LOGGER.error("Composed schema has incorrect anyOf, allOf, oneOf defined: {}", composed);
}
}
}
- m.oneOfProps = oneOfProps;
- m.allOfProps = allOfProps;
- m.anyOfProps = anyOfProps;
-
if (parent != null && composed.getAllOf() != null) { // set parent for allOf only
m.parentSchema = parentName;
m.parent = toModelName(parentName);
@@ -2696,6 +2684,7 @@ public class DefaultCodegen implements CodegenConfig {
}
m.setTypeProperties(schema);
+ m.setComposedSchemas(getComposedSchemas(schema));
if (ModelUtils.isArraySchema(schema)) {
CodegenProperty arrayProperty = fromProperty(name, schema);
m.setItems(arrayProperty.items);
@@ -3514,6 +3503,7 @@ public class DefaultCodegen implements CodegenConfig {
}
property.setTypeProperties(p);
+ property.setComposedSchemas(getComposedSchemas(p));
if (ModelUtils.isIntegerSchema(p)) { // integer type
property.isNumeric = Boolean.TRUE;
if (ModelUtils.isLongSchema(p)) { // int64/long format
@@ -4265,6 +4255,7 @@ public class DefaultCodegen implements CodegenConfig {
}
r.setTypeProperties(responseSchema);
+ r.setComposedSchemas(getComposedSchemas(responseSchema));
if (ModelUtils.isArraySchema(responseSchema)) {
r.simpleType = false;
r.containerType = cp.containerType;
@@ -4547,6 +4538,7 @@ public class DefaultCodegen implements CodegenConfig {
}
ModelUtils.syncValidationProperties(parameterSchema, codegenParameter);
codegenParameter.setTypeProperties(parameterSchema);
+ codegenParameter.setComposedSchemas(getComposedSchemas(parameterSchema));
if (Boolean.TRUE.equals(parameterSchema.getNullable())) { // use nullable defined in the spec
codegenParameter.isNullable = true;
@@ -6156,6 +6148,7 @@ public class DefaultCodegen implements CodegenConfig {
Schema ps = unaliasSchema(propertySchema, importMapping);
ModelUtils.syncValidationProperties(ps, codegenParameter);
codegenParameter.setTypeProperties(ps);
+ codegenParameter.setComposedSchemas(getComposedSchemas(ps));
if (ps.getPattern() != null) {
codegenParameter.pattern = toRegularExpression(ps.getPattern());
}
@@ -6590,6 +6583,7 @@ public class DefaultCodegen implements CodegenConfig {
ModelUtils.syncValidationProperties(unaliasedSchema, codegenParameter);
codegenParameter.setTypeProperties(unaliasedSchema);
+ codegenParameter.setComposedSchemas(getComposedSchemas(unaliasedSchema));
// TODO in the future switch al the below schema usages to unaliasedSchema
// because it keeps models as refs and will not get their referenced schemas
if (ModelUtils.isArraySchema(schema)) {
@@ -7154,4 +7148,30 @@ public class DefaultCodegen implements CodegenConfig {
protected String getCollectionFormat(CodegenParameter codegenParameter) {
return null;
}
+
+ private CodegenComposedSchemas getComposedSchemas(Schema schema) {
+ if (!(schema instanceof ComposedSchema)) {
+ return null;
+ }
+ ComposedSchema cs = (ComposedSchema) schema;
+ return new CodegenComposedSchemas(
+ getComposedProperties(cs.getAllOf(), "allOf"),
+ getComposedProperties(cs.getOneOf(), "oneOf"),
+ getComposedProperties(cs.getAnyOf(), "anyOf")
+ );
+ }
+
+ private List getComposedProperties(List xOfCollection, String collectionName) {
+ if (xOfCollection == null) {
+ return null;
+ }
+ List xOf = new ArrayList<>();
+ int i = 0;
+ for (Schema xOfSchema: xOfCollection) {
+ CodegenProperty cp = fromProperty(collectionName + "_" + String.valueOf(i), xOfSchema);
+ xOf.add(cp);
+ i += 1;
+ }
+ return xOf;
+ }
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java
index b3833e47f6f..eb95821d6f3 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java
@@ -145,6 +145,14 @@ public interface IJsonSchemaValidationProperties {
void setIsAnyType(boolean isAnyType);
+ CodegenComposedSchemas getComposedSchemas();
+
+ void setComposedSchemas(CodegenComposedSchemas composedSchemas);
+
+ boolean getHasMultipleTypes();
+
+ void setHasMultipleTypes(boolean hasMultipleTypes);
+
/**
* Syncs all the schema's type properties into the IJsonSchemaValidationProperties instance
* for now this only supports types without format information
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java
index f6b62cdd144..a72388d4226 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java
@@ -38,10 +38,13 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
public static final String DECLSPEC = "declspec";
public static final String DEFAULT_INCLUDE = "defaultInclude";
public static final String GENERATE_GMOCKS_FOR_APIS = "generateGMocksForApis";
+ public static final String DEFAULT_PACKAGE_NAME = "CppRestOpenAPIClient";
+ protected String packageName = "";
protected String packageVersion = "1.0.0";
protected String declspec = "";
protected String defaultInclude = "";
+ protected String modelDirName = "model";
private final Set parentModels = new HashSet<>();
private final Multimap childrenByParent = ArrayListMultimap.create();
@@ -119,6 +122,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
cliOptions.clear();
// CLI options
+ addOption(CodegenConstants.PACKAGE_NAME, "C++ package (library) name.", DEFAULT_PACKAGE_NAME);
addOption(CodegenConstants.MODEL_PACKAGE, "C++ namespace for models (convention: name.space.model).",
this.modelPackage);
addOption(CodegenConstants.API_PACKAGE, "C++ namespace for apis (convention: name.space.api).",
@@ -159,6 +163,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
supportingFiles.add(new SupportingFile("cmake-lists.mustache", "", "CMakeLists.txt"));
+ supportingFiles.add(new SupportingFile("cmake-config.mustache", "", "Config.cmake.in"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
languageSpecificPrimitives = new HashSet(
@@ -195,6 +200,8 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
public void processOpts() {
super.processOpts();
+ packageName = (String) additionalProperties.getOrDefault(CodegenConstants.PACKAGE_NAME, DEFAULT_PACKAGE_NAME);
+
if (additionalProperties.containsKey(DECLSPEC)) {
declspec = additionalProperties.get(DECLSPEC).toString();
}
@@ -212,6 +219,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
additionalProperties.put("gmockApis", "true");
}
+ additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
additionalProperties.put("modelNamespaceDeclarations", modelPackage.split("\\."));
additionalProperties.put("modelNamespace", modelPackage.replaceAll("\\.", "::"));
additionalProperties.put("modelHeaderGuardPrefix", modelPackage.replaceAll("\\.", "_").toUpperCase(Locale.ROOT));
@@ -229,7 +237,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
*/
@Override
public String modelFileFolder() {
- return outputFolder + "/model";
+ return outputFolder + "/" + modelDirName;
}
/**
@@ -246,7 +254,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
if (importMapping.containsKey(name)) {
return importMapping.get(name);
} else {
- return "#include \"" + toModelFilename(name) + ".h\"";
+ return "#include \"" + modelDirName + "/" + toModelFilename(name) + ".h\"";
}
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
index 328a4b089b2..1e2740f1858 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
@@ -56,6 +56,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
public static final String USE_PLAY_WS = "usePlayWS";
public static final String PLAY_VERSION = "playVersion";
public static final String ASYNC_NATIVE = "asyncNative";
+ public static final String CONFIG_KEY = "configKey";
public static final String PARCELABLE_MODEL = "parcelableModel";
public static final String USE_RUNTIME_EXCEPTION = "useRuntimeException";
public static final String USE_REFLECTION_EQUALS_HASHCODE = "useReflectionEqualsHashCode";
@@ -102,6 +103,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
protected boolean usePlayWS = false;
protected String playVersion = PLAY_26;
protected String microprofileFramework = MICROPROFILE_DEFAULT;
+ protected String configKey = null;
protected boolean asyncNative = false;
protected boolean parcelableModel = false;
@@ -160,6 +162,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
cliOptions.add(CliOption.newBoolean(DYNAMIC_OPERATIONS, "Generate operations dynamically at runtime from an OAS", this.dynamicOperations));
cliOptions.add(CliOption.newBoolean(SUPPORT_STREAMING, "Support streaming endpoint (beta)", this.supportStreaming));
cliOptions.add(CliOption.newString(GRADLE_PROPERTIES, "Append additional Gradle proeprties to the gradle.properties file"));
+ cliOptions.add(CliOption.newString(CONFIG_KEY, "Config key in @RegisterRestClient. Default to none. Only `microprofile` supports this option."));
supportedLibraries.put(JERSEY1, "HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libraries instead.");
supportedLibraries.put(JERSEY2, "HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x");
@@ -281,6 +284,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen
}
additionalProperties.put(MICROPROFILE_FRAMEWORK, microprofileFramework);
+ if (additionalProperties.containsKey(CONFIG_KEY)) {
+ this.setConfigKey(additionalProperties.get(CONFIG_KEY).toString());
+ }
+
if (additionalProperties.containsKey(ASYNC_NATIVE)) {
this.setAsyncNative(convertPropertyToBooleanAndWriteBack(ASYNC_NATIVE));
}
@@ -964,6 +971,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen
this.microprofileFramework = microprofileFramework;
}
+ public void setConfigKey(String configKey) {
+ this.configKey = configKey;
+ }
+
public void setParcelableModel(boolean parcelableModel) {
this.parcelableModel = parcelableModel;
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java
index c08ecec4e23..93d7428c236 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java
@@ -379,7 +379,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
} else if (interfaceOnly) {
apiTemplateFiles.put("apiInterface.mustache", ".kt");
} else {
- apiTemplateFiles.put("api.mustache", ".kt");
+ apiTemplateFiles.put("api.mustache", "Controller.kt");
apiTestTemplateFiles.put("api_test.mustache", ".kt");
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java
index a00b28395f6..f2c8033a233 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java
@@ -44,6 +44,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
public static enum PROVIDED_IN_LEVEL {none, root, any, platform}
private static final String DEFAULT_IMPORT_PREFIX = "./";
+ private static final String DEFAULT_MODEL_IMPORT_DIRECTORY_PREFIX = "../";
public static final String NPM_REPOSITORY = "npmRepository";
public static final String WITH_INTERFACES = "withInterfaces";
@@ -634,7 +635,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
if (importMapping.containsKey(name)) {
return importMapping.get(name);
}
- return modelPackage() + "/" + toModelFilename(name).substring(DEFAULT_IMPORT_PREFIX.length());
+ return DEFAULT_MODEL_IMPORT_DIRECTORY_PREFIX + modelPackage() + "/" + toModelFilename(name).substring(DEFAULT_IMPORT_PREFIX.length());
}
public String getNpmRepository() {
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java
index ed922219016..71d53818647 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java
@@ -708,15 +708,22 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
var.dataTypeAlternate = var.dataType;
if (var.isArray) {
+ var.isUniqueId = var.isUniqueId || var.itemsAreUniqueId();
var.dataTypeAlternate = var.dataType.replace("Array<", "List<");
+ String newItemsDataType = var.getItemsDataType();
if (var.items.isModel) {
- String itemsDataType = var.items.dataType + "Record";
- var.dataTypeAlternate = var.dataTypeAlternate.replace(var.items.dataType, itemsDataType);
+ newItemsDataType = var.items.dataType + "Record";
+ var.dataTypeAlternate = var.dataTypeAlternate.replace(var.items.dataType, newItemsDataType);
} else if (var.items.isEnum) {
- var.dataTypeAlternate = var.dataTypeAlternate.replace(var.items.dataType, var.items.datatypeWithEnum);
+ newItemsDataType = var.items.datatypeWithEnum;
+ var.dataTypeAlternate = var.dataTypeAlternate.replace(var.items.dataType, newItemsDataType);
+ } else if (var.isUniqueId) {
+ newItemsDataType = "string";
+ var.dataTypeAlternate = var.dataTypeAlternate.replace("number", newItemsDataType);
}
- if (var.isUniqueId) {
- var.dataTypeAlternate = var.dataTypeAlternate.replace("number", "string");
+
+ if (var.itemsAreNullable()) {
+ var.dataTypeAlternate = var.dataTypeAlternate.replace(newItemsDataType, newItemsDataType + " | null");
}
} else if (var.isEnum) {
var.dataTypeAlternate = var.datatypeWithEnum;
@@ -724,6 +731,9 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
var.dataTypeAlternate = var.dataType + "Record";
} else if (var.isUniqueId) {
var.dataTypeAlternate = "string";
+ if (var.isNullable) {
+ var.dataTypeAlternate = var.dataTypeAlternate + " | null";
+ }
}
if (var.defaultValue == null || var.defaultValue.equals("undefined")) {
this.autoSetDefaultValueForProperty(var);
@@ -732,6 +742,10 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
return parentIsEntity;
}
+ private boolean itemsAreNullable(ExtendedCodegenProperty var) {
+ return var.items.isNullable || (var.items.items != null && var.items.items.isNullable);
+ }
+
private void escapeOperationIds(Map operations) {
Map _operations = (Map) operations.get("operations");
List operationList = (List) _operations.get("operation");
@@ -816,19 +830,25 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
param.isUniqueId = this.isUniqueIdAccordingToNameSuffix(param.paramName);
}
+
param.dataTypeAlternate = param.dataType;
if (param.isArray) {
+ param.isUniqueId = param.isUniqueId || param.itemsAreUniqueId();
+ param.dataTypeAlternate = param.dataType.replace("Array<", "List<");
+ String newItemsDataType = param.getItemsDataType();
if (param.items.isModel) {
- String itemsDataType = param.items.dataType + "Record";
- param.dataTypeAlternate = param.dataType.replace("Array<", "List<");
- param.dataTypeAlternate = param.dataTypeAlternate.replace(param.items.dataType, itemsDataType);
+ newItemsDataType = param.items.dataType + "Record";
+ param.dataTypeAlternate = param.dataTypeAlternate.replace(param.items.dataType, newItemsDataType);
} else if (param.items.isEnum) {
+ newItemsDataType = param.datatypeWithEnum.substring(param.datatypeWithEnum.lastIndexOf("<") + 1, param.datatypeWithEnum.indexOf(">"));
param.dataTypeAlternate = param.datatypeWithEnum.replace("Array<", "List<");
- } else {
- param.dataTypeAlternate = param.dataType.replace("Array<", "List<");
+ } else if (param.isUniqueId) {
+ newItemsDataType = "string";
+ param.dataTypeAlternate = param.dataTypeAlternate.replace("number", newItemsDataType);
}
- if (param.isUniqueId) {
- param.dataTypeAlternate = param.dataTypeAlternate.replace("number", "string");
+
+ if (param.itemsAreNullable()) {
+ param.dataTypeAlternate = param.dataTypeAlternate.replace(newItemsDataType, newItemsDataType + " | null");
}
} else if (param.isEnum) {
param.dataTypeAlternate = param.datatypeWithEnum;
@@ -836,6 +856,9 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
param.dataTypeAlternate = param.dataType + "Record";
} else if (param.isUniqueId) {
param.dataTypeAlternate = "string";
+ if (param.isNullable) {
+ param.dataTypeAlternate = param.dataTypeAlternate + " | null";
+ }
}
}
}
@@ -912,10 +935,46 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
this.prefixParameterInterfaces = prefixParameterInterfaces;
}
+ private static boolean itemsAreUniqueId(CodegenProperty items) {
+ if (items.items != null) {
+ return itemsAreUniqueId(items.items);
+ };
+ if (items.vendorExtensions.get(X_IS_UNIQUE_ID) instanceof Boolean) {
+ return Boolean.TRUE.equals(items.vendorExtensions.get(X_IS_UNIQUE_ID));
+ }
+ return false;
+ }
+
+ private static boolean itemsAreNullable(CodegenProperty items) {
+ if (items.items != null) {
+ return itemsAreNullable(items.items);
+ };
+ return items.isNullable;
+ }
+
+ private static String getItemsDataType(CodegenProperty items) {
+ if (items.items != null) {
+ return getItemsDataType(items.items);
+ };
+ return items.dataType;
+ }
+
class ExtendedCodegenParameter extends CodegenParameter {
public String dataTypeAlternate;
public boolean isUniqueId; // this parameter represents a unique id (x-isUniqueId: true)
+ public boolean itemsAreUniqueId() {
+ return TypeScriptFetchClientCodegen.itemsAreUniqueId(this.items);
+ }
+
+ public boolean itemsAreNullable() {
+ return TypeScriptFetchClientCodegen.itemsAreNullable(this.items);
+ }
+
+ public String getItemsDataType() {
+ return TypeScriptFetchClientCodegen.getItemsDataType(this.items);
+ }
+
public ExtendedCodegenParameter(CodegenParameter cp) {
super();
@@ -1035,6 +1094,18 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
public boolean keepAsJSObject;
public boolean isReservedRecordField;
+ public boolean itemsAreUniqueId() {
+ return TypeScriptFetchClientCodegen.itemsAreUniqueId(this.items);
+ }
+
+ public boolean itemsAreNullable() {
+ return TypeScriptFetchClientCodegen.itemsAreNullable(this.items);
+ }
+
+ public String getItemsDataType() {
+ return TypeScriptFetchClientCodegen.getItemsDataType(this.items);
+ }
+
public ExtendedCodegenProperty(CodegenProperty cp) {
super();
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/HandlebarsEngineAdapter.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/HandlebarsEngineAdapter.java
index 54d27dc47a7..ef9178e610d 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/HandlebarsEngineAdapter.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/HandlebarsEngineAdapter.java
@@ -23,6 +23,7 @@ import com.github.jknack.handlebars.Template;
import com.github.jknack.handlebars.context.FieldValueResolver;
import com.github.jknack.handlebars.context.JavaBeanValueResolver;
import com.github.jknack.handlebars.context.MapValueResolver;
+import com.github.jknack.handlebars.context.MethodValueResolver;
import com.github.jknack.handlebars.helper.ConditionalHelpers;
import com.github.jknack.handlebars.helper.StringHelpers;
import com.github.jknack.handlebars.io.AbstractTemplateLoader;
@@ -46,6 +47,7 @@ public class HandlebarsEngineAdapter extends AbstractTemplatingEngineAdapter {
// We use this as a simple lookup for valid file name extensions. This adapter will inspect .mustache (built-in) and infer the relevant handlebars filename
private final String[] canCompileFromExtensions = new String[]{".handlebars",".hbs",".mustache"};
private boolean infiniteLoops = false;
+ private boolean prettyPrint = false;
/**
* Provides an identifier used to load the adapter. This could be a name, uuid, or any other string.
@@ -71,7 +73,8 @@ public class HandlebarsEngineAdapter extends AbstractTemplatingEngineAdapter {
.resolver(
MapValueResolver.INSTANCE,
JavaBeanValueResolver.INSTANCE,
- FieldValueResolver.INSTANCE)
+ FieldValueResolver.INSTANCE,
+ MethodValueResolver.INSTANCE)
.build();
Handlebars handlebars = new Handlebars(loader);
@@ -84,6 +87,7 @@ public class HandlebarsEngineAdapter extends AbstractTemplatingEngineAdapter {
handlebars.registerHelpers(ConditionalHelpers.class);
handlebars.registerHelpers(org.openapitools.codegen.templating.handlebars.StringHelpers.class);
handlebars.setInfiniteLoops(infiniteLoops);
+ handlebars.setPrettyPrint(prettyPrint);
Template tmpl = handlebars.compile(templateFile);
return tmpl.apply(context);
}
@@ -134,5 +138,9 @@ public class HandlebarsEngineAdapter extends AbstractTemplatingEngineAdapter {
this.infiniteLoops = infiniteLoops;
return this;
}
+
+ public void setPrettyPrint(boolean prettyPrint) {
+ this.prettyPrint = prettyPrint;
+ }
}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/feign/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/feign/build.gradle.mustache
index 93944f967e2..3ce02e7a06e 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/feign/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/feign/build.gradle.mustache
@@ -6,8 +6,7 @@ version = '{{artifactVersion}}'
buildscript {
repositories {
- maven { url "https://repo1.maven.org/maven2" }
- jcenter()
+ mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.+'
@@ -16,7 +15,7 @@ buildscript {
}
repositories {
- jcenter()
+ mavenCentral()
}
@@ -77,14 +76,17 @@ if(hasProperty('target') && target == 'android') {
} else {
apply plugin: 'java'
- apply plugin: 'maven'
+ apply plugin: 'maven-publish'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
- install {
- repositories.mavenInstaller {
- pom.artifactId = '{{artifactId}}'
+ publishing {
+ publications {
+ maven(MavenPublication) {
+ artifactId = '{{artifactId}}'
+ from components.java
+ }
}
}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/build.gradle.mustache
index 766ddb5c52d..b705c38ff8d 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/build.gradle.mustache
@@ -6,8 +6,7 @@ version = '{{artifactVersion}}'
buildscript {
repositories {
- maven { url "https://repo1.maven.org/maven2" }
- jcenter()
+ mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.+'
@@ -16,7 +15,7 @@ buildscript {
}
repositories {
- jcenter()
+ mavenCentral()
}
@@ -83,7 +82,7 @@ if(hasProperty('target') && target == 'android') {
} else {
apply plugin: 'java'
- apply plugin: 'maven'
+ apply plugin: 'maven-publish'
{{#java8}}
sourceCompatibility = JavaVersion.VERSION_1_8
@@ -94,9 +93,12 @@ if(hasProperty('target') && target == 'android') {
targetCompatibility = JavaVersion.VERSION_1_7
{{/java8}}
- install {
- repositories.mavenInstaller {
- pom.artifactId = '{{artifactId}}'
+ publishing {
+ publications {
+ maven(MavenPublication) {
+ artifactId = '{{artifactId}}'
+ from components.java
+ }
}
}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/JSON.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/JSON.mustache
index 3297c77e49b..5d9692610ee 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/JSON.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/JSON.mustache
@@ -5,6 +5,7 @@ import org.threeten.bp.*;
{{/threetenbp}}
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.databind.json.JsonMapper;
{{#openApiNullable}}
import org.openapitools.jackson.nullable.JsonNullableModule;
{{/openApiNullable}}
@@ -36,7 +37,7 @@ public class JSON implements ContextResolver {
public JSON() {
mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
- mapper.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false);
+ JsonMapper.builder().configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.gradle.mustache
index fcc366f710d..37d60273dee 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.gradle.mustache
@@ -121,7 +121,7 @@ ext {
threetenbp_version = "2.9.10"
{{/threetenbp}}
{{#hasOAuthMethods}}
- scribejava_apis_version = "6.9.0"
+ scribejava_apis_version = "8.3.1"
{{/hasOAuthMethods}}
{{#hasHttpSignatureMethods}}
tomitribe_http_signatures_version = "1.7"
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.sbt.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.sbt.mustache
index f2c624f6799..3b16db61065 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.sbt.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/build.sbt.mustache
@@ -32,7 +32,7 @@ lazy val root = (project in file(".")).
"org.openapitools" % "jackson-databind-nullable" % "0.2.1" % "compile",
{{/openApiNullable}}
{{#hasOAuthMethods}}
- "com.github.scribejava" % "scribejava-apis" % "6.9.0" % "compile",
+ "com.github.scribejava" % "scribejava-apis" % "8.3.1" % "compile",
{{/hasOAuthMethods}}
{{#hasHttpSignatureMethods}}
"org.tomitribe" % "tomitribe-http-signatures" % "1.7" % "compile",
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/pom.mustache
index 50303b928e1..bd148d89abd 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/pom.mustache
@@ -43,7 +43,7 @@
org.apache.maven.pluginsmaven-enforcer-plugin
- 3.0.0-M1
+ 3.0.0enforce-maven
@@ -63,7 +63,7 @@
org.apache.maven.pluginsmaven-surefire-plugin
- 3.0.0-M4
+ 3.0.0-M5
@@ -91,16 +91,14 @@
-
org.apache.maven.pluginsmaven-jar-plugin
- 2.6
+ 3.2.0
- jartest-jar
@@ -108,11 +106,10 @@
-
org.codehaus.mojobuild-helper-maven-plugin
- 1.10
+ 3.2.0add_sources
@@ -145,14 +142,8 @@
maven-compiler-plugin3.8.1
- {{#java8}}
- 1.8
- 1.8
- {{/java8}}
- {{^java8}}
- 1.7
- 1.7
- {{/java8}}
+ 1.8
+ 1.8true128m512m
@@ -165,7 +156,7 @@
org.apache.maven.pluginsmaven-javadoc-plugin
- 3.1.1
+ 3.3.1attach-javadocs
@@ -176,12 +167,7 @@
none
- {{#java8}}
- 1.8
- {{/java8}}
- {{^java8}}
- 1.7
- {{/java8}}
+ 1.8http.response.details
@@ -194,7 +180,7 @@
org.apache.maven.pluginsmaven-source-plugin
- 2.2.1
+ 3.2.0attach-sources
@@ -305,13 +291,11 @@
${jackson-version}
{{/joda}}
- {{#java8}}
com.fasterxml.jackson.datatypejackson-datatype-jsr310${jackson-version}
- {{/java8}}
{{#threetenbp}}
com.github.joschi.jackson
@@ -319,14 +303,6 @@
${threetenbp-version}
{{/threetenbp}}
- {{^java8}}
-
-
- com.brsanthu
- migbase64
- 2.2
-
- {{/java8}}
{{#hasHttpSignatureMethods}}
org.tomitribe
@@ -388,7 +364,7 @@
1.7
{{/hasHttpSignatureMethods}}
{{#hasOAuthMethods}}
- 6.9.0
+ 8.3.1
{{/hasOAuthMethods}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/microprofile/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/microprofile/api.mustache
index f6a69ff6a7c..119494e54d3 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/microprofile/api.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/microprofile/api.mustache
@@ -30,7 +30,7 @@ import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
*/
{{/appName}}
-@RegisterRestClient
+@RegisterRestClient{{#configKey}}(configKey="{{configKey}}"){{/configKey}}
@RegisterProvider(ApiExceptionMapper.class)
@Path("{{#useAnnotatedBasePath}}{{contextPath}}{{/useAnnotatedBasePath}}{{commonPath}}")
public interface {{classname}} {
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/microprofile/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/microprofile/pom.mustache
index 642e02c21c3..3d5f941907b 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/microprofile/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/microprofile/pom.mustache
@@ -77,7 +77,7 @@
org.eclipse.microprofile.rest.clientmicroprofile-rest-client-api
- 1.2.1
+ 1.4.1
@@ -189,7 +189,7 @@
{{/useBeanValidation}}
3.2.72.9.7
- 1.2.2
+ 1.2.21.3.51.0.21.1.6
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/native/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/native/build.gradle.mustache
index 46d8966d431..03d303d0dfb 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/native/build.gradle.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/native/build.gradle.mustache
@@ -6,18 +6,16 @@ version = '{{artifactVersion}}'
buildscript {
repositories {
- maven { url "https://repo1.maven.org/maven2" }
- jcenter()
+ mavenCentral()
}
}
repositories {
- maven { url "https://repo1.maven.org/maven2" }
- jcenter()
+ mavenCentral()
}
apply plugin: 'java'
-apply plugin: 'maven'
+apply plugin: 'maven-publish'
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
@@ -33,9 +31,12 @@ javadoc {
options.encoding = 'UTF-8'
}
-install {
- repositories.mavenInstaller {
- pom.artifactId = '{{artifactId}}'
+publishing {
+ publications {
+ maven(MavenPublication) {
+ artifactId = '{{artifactId}}'
+ from components.java
+ }
}
}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache
index 0dc43ca4a86..829ff0b519e 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache
@@ -72,6 +72,9 @@ import {{invokerPackage}}.auth.RetryingOAuth;
import {{invokerPackage}}.auth.OAuthFlow;
{{/hasOAuthMethods}}
+/**
+ *
ApiClient class.
+ */
public class ApiClient {
private String basePath = "{{{basePath}}}";
@@ -100,7 +103,7 @@ public class ApiClient {
private Map operationLookupMap = new HashMap<>();
{{/dynamicOperations}}
- /*
+ /**
* Basic constructor for ApiClient
*/
public ApiClient() {
@@ -116,8 +119,10 @@ public class ApiClient {
authentications = Collections.unmodifiableMap(authentications);
}
- /*
+ /**
* Basic constructor with custom OkHttpClient
+ *
+ * @param client a {@link okhttp3.OkHttpClient} object
*/
public ApiClient(OkHttpClient client) {
init();
@@ -136,28 +141,28 @@ public class ApiClient {
{{#hasOAuthMethods}}
{{#oauthMethods}}
{{#-first}}
- /*
+ /**
* Constructor for ApiClient to support access token retry on 401/403 configured with client ID
*/
public ApiClient(String clientId) {
this(clientId, null, null);
}
- /*
+ /**
* Constructor for ApiClient to support access token retry on 401/403 configured with client ID and additional parameters
*/
public ApiClient(String clientId, Map parameters) {
this(clientId, null, parameters);
}
- /*
+ /**
* Constructor for ApiClient to support access token retry on 401/403 configured with client ID, secret, and additional parameters
*/
public ApiClient(String clientId, String clientSecret, Map parameters) {
this(null, clientId, clientSecret, parameters);
}
- /*
+ /**
* Constructor for ApiClient to support access token retry on 401/403 configured with base path, client ID, secret, and additional parameters
*/
public ApiClient(String basePath, String clientId, String clientSecret, Map parameters) {
@@ -264,7 +269,7 @@ public class ApiClient {
*
* @param newHttpClient An instance of OkHttpClient
* @return Api Client
- * @throws NullPointerException when newHttpClient is null
+ * @throws java.lang.NullPointerException when newHttpClient is null
*/
public ApiClient setHttpClient(OkHttpClient newHttpClient) {
this.httpClient = Objects.requireNonNull(newHttpClient, "HttpClient must not be null!");
@@ -336,6 +341,11 @@ public class ApiClient {
return this;
}
+ /**
+ *
Getter for the field keyManagers.
+ *
+ * @return an array of {@link javax.net.ssl.KeyManager} objects
+ */
public KeyManager[] getKeyManagers() {
return keyManagers;
}
@@ -353,15 +363,32 @@ public class ApiClient {
return this;
}
+ /**
+ *
+ *
+ * @param lenientOnJson a boolean
+ * @return a {@link org.openapitools.client.ApiClient} object
+ */
public ApiClient setLenientOnJson(boolean lenientOnJson) {
this.json.setLenientOnJson(lenientOnJson);
return this;
@@ -610,7 +655,7 @@ public class ApiClient {
/**
* Sets the connect timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and
- * {@link Integer#MAX_VALUE}.
+ * {@link java.lang.Integer#MAX_VALUE}.
*
* @param connectionTimeout connection timeout in milliseconds
* @return Api client
@@ -632,7 +677,7 @@ public class ApiClient {
/**
* Sets the read timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and
- * {@link Integer#MAX_VALUE}.
+ * {@link java.lang.Integer#MAX_VALUE}.
*
* @param readTimeout read timeout in milliseconds
* @return Api client
@@ -654,7 +699,7 @@ public class ApiClient {
/**
* Sets the write timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and
- * {@link Integer#MAX_VALUE}.
+ * {@link java.lang.Integer#MAX_VALUE}.
*
* @param writeTimeout connection timeout in milliseconds
* @return Api client
@@ -945,7 +990,7 @@ public class ApiClient {
* @param response HTTP response
* @param returnType The type of the Java object
* @return The deserialized Java object
- * @throws ApiException If fail to deserialize response body, i.e. cannot read response body
+ * @throws org.openapitools.client.ApiException If fail to deserialize response body, i.e. cannot read response body
* or the Content-Type of the response is not supported.
*/
@SuppressWarnings("unchecked")
@@ -1006,7 +1051,7 @@ public class ApiClient {
* @param obj The Java object
* @param contentType The request Content-Type
* @return The serialized request body
- * @throws ApiException If fail to serialize the given object
+ * @throws org.openapitools.client.ApiException If fail to serialize the given object
*/
public RequestBody serialize(Object obj, String contentType) throws ApiException {
if (obj instanceof byte[]) {
@@ -1032,7 +1077,7 @@ public class ApiClient {
* Download file from the given response.
*
* @param response An instance of the Response object
- * @throws ApiException If fail to read file content from response and write to disk
+ * @throws org.openapitools.client.ApiException If fail to read file content from response and write to disk
* @return Downloaded file
*/
public File downloadFileFromResponse(Response response) throws ApiException {
@@ -1052,7 +1097,7 @@ public class ApiClient {
*
* @param response An instance of the Response object
* @return Prepared file for the download
- * @throws IOException If fail to prepare file for download
+ * @throws java.io.IOException If fail to prepare file for download
*/
public File prepareDownloadFile(Response response) throws IOException {
String filename = null;
@@ -1096,7 +1141,7 @@ public class ApiClient {
* @param Type
* @param call An instance of the Call object
* @return ApiResponse<T>
- * @throws ApiException If fail to execute the call
+ * @throws org.openapitools.client.ApiException If fail to execute the call
*/
public ApiResponse execute(Call call) throws ApiException {
return execute(call, null);
@@ -1111,7 +1156,7 @@ public class ApiClient {
* @return ApiResponse object containing response status, headers and
* data, which is a Java object deserialized from response body and would be null
* when returnType is null.
- * @throws ApiException If fail to execute the call
+ * @throws org.openapitools.client.ApiException If fail to execute the call
*/
public ApiResponse execute(Call call, Type returnType) throws ApiException {
try {
@@ -1124,6 +1169,14 @@ public class ApiClient {
}
{{#supportStreaming}}
+ /**
+ *
Execute stream.
+ *
+ * @param call a {@link okhttp3.Call} object
+ * @param returnType a {@link java.lang.reflect.Type} object
+ * @return a {@link java.io.InputStream} object
+ * @throws org.openapitools.client.ApiException if any.
+ */
public InputStream executeStream(Call call, Type returnType) throws ApiException {
try {
Response response = call.execute();
@@ -1192,7 +1245,7 @@ public class ApiClient {
* @param response Response
* @param returnType Return type
* @return Type
- * @throws ApiException If the response has an unsuccessful status code or
+ * @throws org.openapitools.client.ApiException If the response has an unsuccessful status code or
* fail to deserialize the response body
*/
public T handleResponse(Response response, Type returnType) throws ApiException {
@@ -1238,7 +1291,7 @@ public class ApiClient {
* @param authNames The authentications to apply
* @param callback Callback for upload/download progress
* @return The HTTP call
- * @throws ApiException If fail to serialize the request body object
+ * @throws org.openapitools.client.ApiException If fail to serialize the request body object
*/
public Call buildCall(String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException {
Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, authNames, callback);
@@ -1260,7 +1313,7 @@ public class ApiClient {
* @param authNames The authentications to apply
* @param callback Callback for upload/download progress
* @return The HTTP request
- * @throws ApiException If fail to serialize the request body object
+ * @throws org.openapitools.client.ApiException If fail to serialize the request body object
*/
public Request buildRequest(String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException {
updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiResponse.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiResponse.mustache
index 1e277319a93..cecbaac1df2 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiResponse.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiResponse.mustache
@@ -11,8 +11,6 @@ import java.util.TreeMap;
/**
* API response returned by API call.
- *
- * @param The type of data that is deserialized from response body
*/
public class ApiResponse {
final private int statusCode;
@@ -20,6 +18,8 @@ public class ApiResponse {
final private T data;
/**
+ *
Constructor for ApiResponse.
+ *
* @param statusCode The status code of HTTP response
* @param headers The headers of HTTP response
*/
@@ -28,6 +28,8 @@ public class ApiResponse {
}
/**
+ *
Constructor for ApiResponse.
+ *
* @param statusCode The status code of HTTP response
* @param headers The headers of HTTP response
* @param data The object deserialized from response bod
@@ -44,14 +46,29 @@ public class ApiResponse {
this.data = data;
}
+ /**
+ *
Get the status code.
+ *
+ * @return the status code
+ */
public int getStatusCode() {
return statusCode;
}
+ /**
+ *
Get the headers.
+ *
+ * @return a {@link java.util.Map} of headers
+ */
public Map> getHeaders() {
return headers;
}
+ /**
+ *
Get the data.
+ *
+ * @return the data
+ */
public T getData() {
return data;
}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/README.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/README.mustache
index dd21bcad45f..a1a142bd488 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/README.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/README.mustache
@@ -19,7 +19,7 @@
Building the API client library requires:
1. Java {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}+
-2. Maven/Gradle
+2. Maven (3.8.3+)/Gradle (7.2+)
## Installation
@@ -55,7 +55,14 @@ Add this dependency to your project's POM:
Add this dependency to your project's build file:
```groovy
-compile "{{{groupId}}}:{{{artifactId}}}:{{{artifactVersion}}}"
+ repositories {
+ mavenCentral() // Needed if the '{{{artifactId}}}' jar has been published to maven central.
+ mavenLocal() // Needed if the '{{{artifactId}}}' jar has been published to the local maven repo.
+ }
+
+ dependencies {
+ implementation "{{{groupId}}}:{{{artifactId}}}:{{{artifactVersion}}}"
+ }
```
### Others
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/apiException.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/apiException.mustache
index d28b1bd9630..68d872ceff8 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/apiException.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/apiException.mustache
@@ -9,22 +9,47 @@ import java.util.Map.Entry;
import java.util.TreeMap;
{{/caseInsensitiveResponseHeaders}}
+/**
+ *
+ *
+ * @param lenientOnJson a boolean
+ * @return a {@link org.openapitools.client.ApiClient} object
+ */
public ApiClient setLenientOnJson(boolean lenientOnJson) {
this.json.setLenientOnJson(lenientOnJson);
return this;
@@ -471,7 +516,7 @@ public class ApiClient {
/**
* Sets the connect timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and
- * {@link Integer#MAX_VALUE}.
+ * {@link java.lang.Integer#MAX_VALUE}.
*
* @param connectionTimeout connection timeout in milliseconds
* @return Api client
@@ -493,7 +538,7 @@ public class ApiClient {
/**
* Sets the read timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and
- * {@link Integer#MAX_VALUE}.
+ * {@link java.lang.Integer#MAX_VALUE}.
*
* @param readTimeout read timeout in milliseconds
* @return Api client
@@ -515,7 +560,7 @@ public class ApiClient {
/**
* Sets the write timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and
- * {@link Integer#MAX_VALUE}.
+ * {@link java.lang.Integer#MAX_VALUE}.
*
* @param writeTimeout connection timeout in milliseconds
* @return Api client
@@ -749,7 +794,7 @@ public class ApiClient {
* @param response HTTP response
* @param returnType The type of the Java object
* @return The deserialized Java object
- * @throws ApiException If fail to deserialize response body, i.e. cannot read response body
+ * @throws org.openapitools.client.ApiException If fail to deserialize response body, i.e. cannot read response body
* or the Content-Type of the response is not supported.
*/
@SuppressWarnings("unchecked")
@@ -810,7 +855,7 @@ public class ApiClient {
* @param obj The Java object
* @param contentType The request Content-Type
* @return The serialized request body
- * @throws ApiException If fail to serialize the given object
+ * @throws org.openapitools.client.ApiException If fail to serialize the given object
*/
public RequestBody serialize(Object obj, String contentType) throws ApiException {
if (obj instanceof byte[]) {
@@ -836,7 +881,7 @@ public class ApiClient {
* Download file from the given response.
*
* @param response An instance of the Response object
- * @throws ApiException If fail to read file content from response and write to disk
+ * @throws org.openapitools.client.ApiException If fail to read file content from response and write to disk
* @return Downloaded file
*/
public File downloadFileFromResponse(Response response) throws ApiException {
@@ -856,7 +901,7 @@ public class ApiClient {
*
* @param response An instance of the Response object
* @return Prepared file for the download
- * @throws IOException If fail to prepare file for download
+ * @throws java.io.IOException If fail to prepare file for download
*/
public File prepareDownloadFile(Response response) throws IOException {
String filename = null;
@@ -900,7 +945,7 @@ public class ApiClient {
* @param Type
* @param call An instance of the Call object
* @return ApiResponse<T>
- * @throws ApiException If fail to execute the call
+ * @throws org.openapitools.client.ApiException If fail to execute the call
*/
public ApiResponse execute(Call call) throws ApiException {
return execute(call, null);
@@ -915,7 +960,7 @@ public class ApiClient {
* @return ApiResponse object containing response status, headers and
* data, which is a Java object deserialized from response body and would be null
* when returnType is null.
- * @throws ApiException If fail to execute the call
+ * @throws org.openapitools.client.ApiException If fail to execute the call
*/
public ApiResponse execute(Call call, Type returnType) throws ApiException {
try {
@@ -927,6 +972,14 @@ public class ApiClient {
}
}
+ /**
+ *
Execute stream.
+ *
+ * @param call a {@link okhttp3.Call} object
+ * @param returnType a {@link java.lang.reflect.Type} object
+ * @return a {@link java.io.InputStream} object
+ * @throws org.openapitools.client.ApiException if any.
+ */
public InputStream executeStream(Call call, Type returnType) throws ApiException {
try {
Response response = call.execute();
@@ -994,7 +1047,7 @@ public class ApiClient {
* @param response Response
* @param returnType Return type
* @return Type
- * @throws ApiException If the response has an unsuccessful status code or
+ * @throws org.openapitools.client.ApiException If the response has an unsuccessful status code or
* fail to deserialize the response body
*/
public T handleResponse(Response response, Type returnType) throws ApiException {
@@ -1040,7 +1093,7 @@ public class ApiClient {
* @param authNames The authentications to apply
* @param callback Callback for upload/download progress
* @return The HTTP call
- * @throws ApiException If fail to serialize the request body object
+ * @throws org.openapitools.client.ApiException If fail to serialize the request body object
*/
public Call buildCall(String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException {
Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, authNames, callback);
@@ -1062,7 +1115,7 @@ public class ApiClient {
* @param authNames The authentications to apply
* @param callback Callback for upload/download progress
* @return The HTTP request
- * @throws ApiException If fail to serialize the request body object
+ * @throws org.openapitools.client.ApiException If fail to serialize the request body object
*/
public Request buildRequest(String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException {
updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiException.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiException.java
index 8e7eb0faf90..cf5905d28ec 100644
--- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiException.java
+++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiException.java
@@ -16,22 +16,47 @@ package org.openapitools.client;
import java.util.Map;
import java.util.List;
+/**
+ *
+ *
+ * @param code HTTP status code
+ * @param message the error message
+ * @param responseHeaders a {@link java.util.Map} of HTTP response headers
+ * @param responseBody the response body
+ */
public ApiException(int code, String message, Map> responseHeaders, String responseBody) {
this(code, message);
this.responseHeaders = responseHeaders;
diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiResponse.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiResponse.java
index 7cf4cb9fdef..386fc57c438 100644
--- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiResponse.java
+++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiResponse.java
@@ -18,8 +18,6 @@ import java.util.Map;
/**
* API response returned by API call.
- *
- * @param The type of data that is deserialized from response body
*/
public class ApiResponse {
final private int statusCode;
@@ -27,6 +25,8 @@ public class ApiResponse {
final private T data;
/**
+ *
Constructor for ApiResponse.
+ *
* @param statusCode The status code of HTTP response
* @param headers The headers of HTTP response
*/
@@ -35,6 +35,8 @@ public class ApiResponse {
}
/**
+ *
Constructor for ApiResponse.
+ *
* @param statusCode The status code of HTTP response
* @param headers The headers of HTTP response
* @param data The object deserialized from response bod
@@ -45,14 +47,29 @@ public class ApiResponse {
this.data = data;
}
+ /**
+ *
Get the status code.
+ *
+ * @return the status code
+ */
public int getStatusCode() {
return statusCode;
}
+ /**
+ *
Get the headers.
+ *
+ * @return a {@link java.util.Map} of headers
+ */
public Map> getHeaders() {
return headers;
}
+ /**
+ *