diff --git a/CI/circle_parallel.sh b/CI/circle_parallel.sh
index 51d81a2afaf..cda481a62fd 100755
--- a/CI/circle_parallel.sh
+++ b/CI/circle_parallel.sh
@@ -15,7 +15,7 @@ elif [ "$NODE_INDEX" = "2" ]; then
java -version
#export GO_POST_PROCESS_FILE="/usr/local/bin/gofmt -w"
# not formatting the code as different go versions may format the code a bit different
- #./bin/utils/ensure-up-to-date
+ ./bin/utils/ensure-up-to-date
else
echo "Running node $NODE_INDEX to test 'samples.circleci.jdk7' defined in pom.xml ..."
sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index fe33fdcb1ea..c73173c36db 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -12,6 +12,7 @@
- Search the [open issue](https://github.com/openapitools/openapi-generator/issues) to ensure no one else has reported something similar and no one is actively working on similar proposed change.
- If no one has suggested something similar, open an ["issue"](https://github.com/openapitools/openapi-generator/issues) with your suggestion to gather feedback from the community.
+ - If you're adding a new option to a generator, please consider using the `-t` option with customized templates instead or start a discussion first by opening an issue as we want to avoid adding too many options to the generator.
- It's recommended to **create a new git branch** for the change so that the merge commit message looks nicer in the commit history.
## How to contribute
@@ -86,6 +87,7 @@ To test the templates, please perform the following:
- Run the tests in the sample folder, e.g. in `samples/client/petstore/ruby`, run `mvn integration-test -rf :RubyPetstoreClientTests`. (some languages may not contain unit testing for Petstore and we're looking for contribution from the community to implement those tests)
- Finally, git commit the updated samples files: `git commit -a`
(`git add -A` if added files with new test cases)
+- For new test cases, please add to the [Fake Petstore spec](https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml)
To start the CI tests, you can run `mvn verify -Psamples` (assuming you've all the required tools installed to run tests for different languages) or you can leverage http://travis-ci.org to run the CI tests by adding your own openapi-generator repository.
diff --git a/README.md b/README.md
index bdb4d625e2e..2117ebd0d2d 100644
--- a/README.md
+++ b/README.md
@@ -668,7 +668,7 @@ If you want to join the committee, please kindly apply by sending an email to te
| Perl | @wing328 (2017/07) |
| PHP | @jebentier (2017/07) @dkarlovi (2017/07) @mandrean (2017/08) @jfastnacht (2017/09) @ackintosh (2017/09) @ybelenko (2018/07) |
| PowerShell | |
-| Python | @taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11)|
+| Python | @taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11) @tomplus (2018/10) |
| R | |
| Ruby | @cliffano (2017/07) @zlx (2017/09) |
| Rust | @frol (2017/07) @farcaller (2017/08) @bjgill (2017/12) |
diff --git a/bin/openapi3/elm-petstore.sh b/bin/openapi3/elm-petstore.sh
index 9090d50a87f..da073a5ea5c 100755
--- a/bin/openapi3/elm-petstore.sh
+++ b/bin/openapi3/elm-petstore.sh
@@ -27,6 +27,6 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
-ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g elm -o samples/client/petstore/elm $@"
+ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g elm -t modules/openapi-generator/src/main/resources/elm -o samples/openapi3/client/petstore/elm --additional-properties elmPrefixCustomTypeVariants=true $@"
java $JAVA_OPTS -jar $executable $ags
diff --git a/bin/openapi3/jaxrs-jersey-petstore.sh b/bin/openapi3/jaxrs-jersey-petstore.sh
index 86487d172cc..08d88d9b9c1 100755
--- a/bin/openapi3/jaxrs-jersey-petstore.sh
+++ b/bin/openapi3/jaxrs-jersey-petstore.sh
@@ -27,6 +27,6 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
-ags="generate --artifact-id "openapiv3-jaxrs-jersey-petstore-server" -t modules/openapi-generator/src/main/resources/JavaJaxRS/ -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g jaxrs-jersey -o samples/server/petstore/jaxrs-jersey $@"
+ags="generate --artifact-id "openapiv3-jaxrs-jersey-petstore-server" -t modules/openapi-generator/src/main/resources/JavaJaxRS/ -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g jaxrs-jersey -o samples/server/petstore/jaxrs-jersey -DhideGenerationTimestamp=true $@"
java $JAVA_OPTS -jar $executable $ags
diff --git a/bin/openapi3/ruby-client-petstore.sh b/bin/openapi3/ruby-client-petstore.sh
index 76c321582b0..67420ee1df5 100755
--- a/bin/openapi3/ruby-client-petstore.sh
+++ b/bin/openapi3/ruby-client-petstore.sh
@@ -27,6 +27,6 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
-ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby $@"
+ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby -DskipFormModel=true $@"
java $JAVA_OPTS -jar $executable $ags
diff --git a/bin/rust-petstore.sh b/bin/rust-petstore.sh
index ffab5a47afb..b58d3de7dd6 100755
--- a/bin/rust-petstore.sh
+++ b/bin/rust-petstore.sh
@@ -26,7 +26,7 @@ then
fi
# if you've executed sbt assembly previously it will use that instead.
-export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
-ags="generate -t modules/openapi-generator/src/main/resources/rust -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g rust -o samples/client/petstore/rust -DpackageName=petstore_client $@"
+export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
+ags="generate -t modules/openapi-generator/src/main/resources/rust -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g rust -o samples/client/petstore/rust -DpackageName=petstore_client --library=hyper $@"
java ${JAVA_OPTS} -jar ${executable} ${ags}
diff --git a/bin/rust-reqwest-petstore.sh b/bin/rust-reqwest-petstore.sh
new file mode 100755
index 00000000000..054a757c5fa
--- /dev/null
+++ b/bin/rust-reqwest-petstore.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 -t modules/openapi-generator/src/main/resources/rust -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g rust -o samples/client/petstore/rust-reqwest -DpackageName=petstore_client --library=reqwest $@"
+
+java ${JAVA_OPTS} -jar ${executable} ${ags}
diff --git a/bin/utils/ensure-up-to-date b/bin/utils/ensure-up-to-date
index 7ce762d807e..2411f06e42a 100755
--- a/bin/utils/ensure-up-to-date
+++ b/bin/utils/ensure-up-to-date
@@ -10,9 +10,10 @@ echo "Please press CTRL+C to stop or the script will continue in 5 seconds."
sleep 5
# LIST OF SCRIPTS:
-./bin/ruby-client-petstore.sh > /dev/null 2>&1
+./bin/openapi3/ruby-client-petstore.sh > /dev/null 2>&1
./bin/java-petstore-all.sh > /dev/null 2>&1
./bin/java-jaxrs-petstore-server-all.sh > /dev/null 2>&1
+./bin/openapi3/jaxrs-jersey-petstore.sh > /dev/null 2>&1
./bin/spring-all-pestore.sh > /dev/null 2>&1
./bin/kotlin-client-petstore.sh > /dev/null 2>&1
./bin/kotlin-client-string.sh > /dev/null 2>&1
diff --git a/bin/windows/erlang-petstore-server.bat b/bin/windows/erlang-petstore-server.bat
index dc28c8c0fae..dbae5bf9faf 100755
--- a/bin/windows/erlang-petstore-server.bat
+++ b/bin/windows/erlang-petstore-server.bat
@@ -5,6 +5,6 @@ If Not Exist %executable% (
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
-set ags=generate -t modules\openapi-generator\src\main\resources\erlang-server -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g erlang-server -o samples\client\petstore\erlang-server
+set ags=generate -t modules\openapi-generator\src\main\resources\erlang-server -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g erlang-server -o samples\server\petstore\erlang-server
java %JAVA_OPTS% -jar %executable% %ags%
diff --git a/docs/generators/README.md b/docs/generators/README.md
index 3a1869f4c37..73a2d132d65 100644
--- a/docs/generators/README.md
+++ b/docs/generators/README.md
@@ -12,6 +12,7 @@ The following generators are available:
- [csharp](csharp.md)
- [csharp-dotnet2](csharp-dotnet2.md)
- [dart](dart.md)
+ - [dart-jaguar](dart-jaguar.md)
- [eiffel](eiffel.md)
- [elixir](elixir.md)
- [elm](elm.md)
@@ -46,6 +47,7 @@ The following generators are available:
- [typescript-angular](typescript-angular.md)
- [typescript-angularjs](typescript-angularjs.md)
- [typescript-aurelia](typescript-aurelia.md)
+ - [typescript-axios](typescript-axios.md)
- [typescript-fetch](typescript-fetch.md)
- [typescript-inversify](typescript-inversify.md)
- [typescript-jquery](typescript-jquery.md)
@@ -60,8 +62,8 @@ The following generators are available:
- [cpp-restbed-server](cpp-restbed-server.md)
- [csharp-nancyfx](csharp-nancyfx.md)
- [erlang-server](erlang-server.md)
- - [go-server](go-server.md)
- [go-gin-server](go-gin-server.md)
+ - [go-server](go-server.md)
- [haskell](haskell.md)
- [java-inflector](java-inflector.md)
- [java-msf4j](java-msf4j.md)
@@ -103,6 +105,10 @@ The following generators are available:
- [openapi-yaml](openapi-yaml.md)
+* SCHEMA generators:
+ - [mysql-schema](mysql-schema.md)
+
+
* CONFIG generators:
- [apache2](apache2.md)
diff --git a/docs/generators/elm.md b/docs/generators/elm.md
index 891a281d1eb..bab23d8acf6 100644
--- a/docs/generators/elm.md
+++ b/docs/generators/elm.md
@@ -6,4 +6,7 @@ CONFIG OPTIONS for elm
0.19 - Elm 0.19
0.18 - Elm 0.18
+ elmPrefixCustomTypeVariants
+ Prefix custom type variants (Default: false)
+
Back to the [generators list](README.md)
diff --git a/docs/generators/erlang-server.md b/docs/generators/erlang-server.md
index 29c7d51313d..51fc0c2d971 100644
--- a/docs/generators/erlang-server.md
+++ b/docs/generators/erlang-server.md
@@ -4,4 +4,7 @@ CONFIG OPTIONS for erlang-server
packageName
Erlang package name (convention: lowercase). (Default: openapi)
+ openAPISpecName
+ Openapi Spec Name. (Default: openapi)
+
Back to the [generators list](README.md)
diff --git a/docs/generators/lua.md b/docs/generators/lua.md
index d35fb4f2cd3..baf2a6d5544 100644
--- a/docs/generators/lua.md
+++ b/docs/generators/lua.md
@@ -2,7 +2,7 @@
CONFIG OPTIONS for lua
packageName
- Lua package name (convention: lowercase). (Default: openapir-client)
+ Lua package name (convention: single word). (Default: openapiclient)
packageVersion
Lua package version. (Default: 1.0.0-1)
diff --git a/docs/generators/rust.md b/docs/generators/rust.md
index c8779939a30..c126505e981 100644
--- a/docs/generators/rust.md
+++ b/docs/generators/rust.md
@@ -10,4 +10,9 @@ CONFIG OPTIONS for rust
hideGenerationTimestamp
Hides the generation timestamp when files are generated. (Default: true)
+ library
+ library template (sub-template) to use. (Default: hyper)
+ hyper - HTTP client: Hyper.
+ reqwest - HTTP client: Reqwest.
+
Back to the [generators list](README.md)
diff --git a/docs/generators/spring.md b/docs/generators/spring.md
index ab0e1ad15a6..e7d64807746 100644
--- a/docs/generators/spring.md
+++ b/docs/generators/spring.md
@@ -152,6 +152,9 @@ CONFIG OPTIONS for spring
useBeanValidation
Use BeanValidation API annotations (Default: true)
+ performBeanValidation
+ Use Bean Validation Impl. to perform BeanValidation (Default: false)
+
implicitHeaders
Use of @ApiImplicitParams for headers. (Default: false)
@@ -164,6 +167,9 @@ CONFIG OPTIONS for spring
useOptional
Use Optional container for optional parameters (Default: false)
+ hateoas
+ Use Spring HATEOAS library to allow adding HATEOAS links (Default: false)
+
library
library template (sub-template) to use (Default: spring-boot)
spring-boot - Spring-boot Server application using the SpringFox integration.
diff --git a/docs/migration-from-swagger-codegen.md b/docs/migration-from-swagger-codegen.md
index f2452b3bbbc..d40976c9667 100644
--- a/docs/migration-from-swagger-codegen.md
+++ b/docs/migration-from-swagger-codegen.md
@@ -247,9 +247,10 @@ If your API client is using named parameters in the function call (e.g. Perl req
The following gnereators are not yet fully migrated and tested
- ~~rust-server~~ (migrated)
-- `apex` (migration scheduled in Jul/Aug 2018)
+- ~~`apex`~~ (migrated)
-and we welcome contributions from the community to help with the migration
+and we welcome contributions from the community to help with the migration.
+UPDATE: all generators have been successfullly migrated.
[Back to OpenAPI-Generator's README page](../README.md)
diff --git a/modules/openapi-generator-cli/pom.xml b/modules/openapi-generator-cli/pom.xml
index 40621f3614d..1dc7713ad08 100644
--- a/modules/openapi-generator-cli/pom.xml
+++ b/modules/openapi-generator-cli/pom.xml
@@ -88,7 +88,7 @@
io.airlift
airline
- 0.7
+ 0.8
com.googlecode.lambdaj
diff --git a/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/CompletionCommand.java b/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/CompletionCommand.java
index 4116fe5c1d6..2ffa1208359 100644
--- a/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/CompletionCommand.java
+++ b/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/CompletionCommand.java
@@ -84,7 +84,8 @@ public class CompletionCommand
null,
null,
suggesterMetadata.getMetadataInjections(),
- bindings.build());
+ bindings.build(),
+ new DefaultCommandFactory());
return suggester.suggest();
}
diff --git a/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java b/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java
index ffc4c843300..a46e58849d7 100644
--- a/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java
+++ b/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java
@@ -35,6 +35,7 @@ import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
@@ -571,6 +572,7 @@ public class CodeGenMojo extends AbstractMojo {
}
return;
}
+ adjustAdditionalProperties(config);
try {
new DefaultGenerator().opts(input).generate();
} catch (Exception e) {
@@ -608,4 +610,30 @@ public class CodeGenMojo extends AbstractMojo {
}
}
}
+ /**
+ * This method enables conversion of true/false strings in
+ * config.additionalProperties (configuration/configOptions) to proper booleans.
+ * This enables mustache files to handle the properties better.
+ *
+ * @param config
+ */
+ private void adjustAdditionalProperties(final CodegenConfig config) {
+ Map configAdditionalProperties = config.additionalProperties();
+ Set keySet = configAdditionalProperties.keySet();
+ for (String key : keySet) {
+ Object value = configAdditionalProperties.get(key);
+ if (value != null) {
+ if (value instanceof String) {
+ String stringValue = (String) value;
+ if (stringValue.equalsIgnoreCase("true")) {
+ configAdditionalProperties.put(key, Boolean.TRUE);
+ } else if (stringValue.equalsIgnoreCase("false")) {
+ configAdditionalProperties.put(key, Boolean.FALSE);
+ }
+ }
+ } else {
+ configAdditionalProperties.put(key, Boolean.FALSE);
+ }
+ }
+ }
}
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java
index 7bcfb843538..1b7500c831e 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java
@@ -278,4 +278,5 @@ public class CodegenConstants {
public static final String ENABLE_POST_PROCESS_FILE = "enablePostProcessFile";
public static final String ENABLE_POST_PROCESS_FILE_DESC = "Enable post-processing file using environment variables.";
+ public static final String OPEN_API_SPEC_NAME = "openAPISpecName";
}
\ No newline at end of file
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 d290aa5c6ab..62aa1f22b8b 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
@@ -25,13 +25,13 @@ import java.util.Map;
public class CodegenParameter {
public boolean isFormParam, isQueryParam, isPathParam, isHeaderParam,
isCookieParam, isBodyParam, hasMore, isContainer,
- secondaryParam, isCollectionFormatMulti, isPrimitiveType;
+ secondaryParam, isCollectionFormatMulti, isPrimitiveType, isModel;
public String baseName, paramName, dataType, datatypeWithEnum, dataFormat,
collectionFormat, description, unescapedDescription, baseType, defaultValue, enumName;
public String example; // example value (x-example)
public String jsonSchema;
- public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid;
+ public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isEmail;
public boolean isListContainer, isMapContainer;
public boolean isFile;
public boolean isEnum;
@@ -110,6 +110,7 @@ public class CodegenParameter {
output.collectionFormat = this.collectionFormat;
output.isCollectionFormatMulti = this.isCollectionFormatMulti;
output.isPrimitiveType = this.isPrimitiveType;
+ output.isModel = this.isModel;
output.description = this.description;
output.unescapedDescription = this.unescapedDescription;
output.baseType = this.baseType;
@@ -165,6 +166,7 @@ public class CodegenParameter {
output.isDate = this.isDate;
output.isDateTime = this.isDateTime;
output.isUuid = this.isUuid;
+ output.isEmail = this.isEmail;
output.isListContainer = this.isListContainer;
output.isMapContainer = this.isMapContainer;
@@ -201,6 +203,8 @@ public class CodegenParameter {
return false;
if (isPrimitiveType != that.isPrimitiveType)
return false;
+ if (isModel != that.isModel)
+ return false;
if (baseName != null ? !baseName.equals(that.baseName) : that.baseName != null)
return false;
if (paramName != null ? !paramName.equals(that.paramName) : that.paramName != null)
@@ -253,6 +257,8 @@ public class CodegenParameter {
return false;
if (isUuid != that.isUuid)
return false;
+ if (isEmail != that.isEmail)
+ return false;
if (isListContainer != that.isListContainer)
return false;
if (isMapContainer != that.isMapContainer)
@@ -312,6 +318,7 @@ public class CodegenParameter {
result = 31 * result + (secondaryParam ? 13:31);
result = 31 * result + (isCollectionFormatMulti ? 13:31);
result = 31 * result + (isPrimitiveType ? 13:31);
+ result = 31 * result + (isModel ? 13:31);
result = 31 * result + (baseName != null ? baseName.hashCode() : 0);
result = 31 * result + (paramName != null ? paramName.hashCode() : 0);
result = 31 * result + (dataType != null ? dataType.hashCode() : 0);
@@ -338,6 +345,7 @@ public class CodegenParameter {
result = 31 * result + (isDate ? 13:31);
result = 31 * result + (isDateTime ? 13:31);
result = 31 * result + (isUuid ? 13:31);
+ result = 31 * result + (isEmail ? 13:31);
result = 31 * result + (isListContainer ? 13:31);
result = 31 * result + (isMapContainer ? 13:31);
result = 31 * result + (isFile ? 13:31);
@@ -378,6 +386,7 @@ public class CodegenParameter {
", secondaryParam=" + secondaryParam +
", isCollectionFormatMulti=" + isCollectionFormatMulti +
", isPrimitiveType=" + isPrimitiveType +
+ ", isModel=" + isModel +
", baseName='" + baseName + '\'' +
", paramName='" + paramName + '\'' +
", dataType='" + dataType + '\'' +
@@ -404,6 +413,7 @@ public class CodegenParameter {
", isDate=" + isDate +
", isDateTime=" + isDateTime +
", isUuid=" + isUuid +
+ ", isEmail=" + isEmail +
", isListContainer=" + isListContainer +
", isMapContainer=" + isMapContainer +
", isFile=" + isFile +
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 de026b2d3e0..3fa796d45f2 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
@@ -55,8 +55,8 @@ public class CodegenProperty implements Cloneable {
public boolean exclusiveMaximum;
public boolean hasMore, required, secondaryParam;
public boolean hasMoreNonReadOnly; // for model constructor, true if next property is not readonly
- public boolean isPrimitiveType, isContainer, isNotContainer;
- public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary, isFile, isBoolean, isDate, isDateTime, isUuid;
+ public boolean isPrimitiveType, isModel, isContainer, isNotContainer;
+ public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary, isFile, isBoolean, isDate, isDateTime, isUuid, isEmail;
public boolean isListContainer, isMapContainer;
public boolean isEnum;
public boolean isReadOnly;
@@ -438,6 +438,7 @@ public class CodegenProperty implements Cloneable {
result = prime * result + (isEnum ? 1231 : 1237);
result = prime * result + ((isNotContainer ? 13:31));
result = prime * result + ((isPrimitiveType ? 13:31));
+ result = prime * result + ((isModel ? 13:31));
result = prime * result + ((isReadOnly ? 13:31));
result = prime * result + ((isWriteOnly ? 13:31));
result = prime * result + ((isNullable ? 13:31));
@@ -472,6 +473,7 @@ public class CodegenProperty implements Cloneable {
result = prime * result + ((isDate ? 13:31));
result = prime * result + ((isDateTime ? 13:31));
result = prime * result + ((isUuid ? 13:31));
+ result = prime * result + ((isEmail ? 13:31));
result = prime * result + ((isMapContainer ? 13:31));
result = prime * result + ((isListContainer ? 13:31));
result = prime * result + Objects.hashCode(isInherited);
@@ -579,6 +581,9 @@ public class CodegenProperty implements Cloneable {
if (this.isPrimitiveType != other.isPrimitiveType) {
return false;
}
+ if (this.isModel != other.isModel) {
+ return false;
+ }
if (this.isContainer != other.isContainer) {
return false;
}
@@ -649,6 +654,9 @@ public class CodegenProperty implements Cloneable {
if (this.isUuid != other.isUuid) {
return false;
}
+ if (this.isEmail != other.isEmail) {
+ return false;
+ }
if (this.isBinary != other.isBinary) {
return false;
}
@@ -759,6 +767,7 @@ public class CodegenProperty implements Cloneable {
", secondaryParam=" + secondaryParam +
", hasMoreNonReadOnly=" + hasMoreNonReadOnly +
", isPrimitiveType=" + isPrimitiveType +
+ ", isModel=" + isModel +
", isContainer=" + isContainer +
", isNotContainer=" + isNotContainer +
", isString=" + isString +
@@ -775,6 +784,7 @@ public class CodegenProperty implements Cloneable {
", isDate=" + isDate +
", isDateTime=" + isDateTime +
", isUuid=" + isUuid +
+ ", isEmail=" + isEmail +
", isListContainer=" + isListContainer +
", isMapContainer=" + isMapContainer +
", isEnum=" + isEnum +
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 aebc0aa9dbc..642e44a810f 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
@@ -30,7 +30,7 @@ public class CodegenResponse {
public List
+{{#hateoas}}
+
+
+ org.springframework.boot
+ spring-boot-starter-hateoas
+
+{{/hateoas}}
diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/pom.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/pom.mustache
index 533ccb9a569..64d4daf2041 100644
--- a/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/pom.mustache
@@ -202,7 +202,6 @@
${jackson-threetenbp-version}
{{/threetenbp}}
-
junit
junit
@@ -223,6 +222,14 @@
provided
{{/useBeanValidation}}
+{{#hateoas}}
+
+
+ org.springframework.hateoas
+ spring-hateoas
+ 0.25.0.RELEASE
+
+{{/hateoas}}
{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}
@@ -238,6 +245,6 @@
{{#useBeanValidation}}
1.1.0.Final
{{/useBeanValidation}}
- 4.3.9.RELEASE
+ 4.3.20.RELEASE
diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/model.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/model.mustache
index 39125314ca7..17abea16f2e 100644
--- a/modules/openapi-generator/src/main/resources/JavaSpring/model.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaSpring/model.mustache
@@ -10,6 +10,9 @@ import java.io.Serializable;
import javax.validation.Valid;
import javax.validation.constraints.*;
{{/useBeanValidation}}
+{{#performBeanValidation}}
+import org.hibernate.validator.constraints.*;
+{{/performBeanValidation}}
{{#jackson}}
{{#withXml}}
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
@@ -19,6 +22,11 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
{{#withXml}}
import javax.xml.bind.annotation.*;
{{/withXml}}
+{{^parent}}
+{{#hateoas}}
+import org.springframework.hateoas.ResourceSupport;
+{{/hateoas}}
+{{/parent}}
{{#models}}
{{#model}}
diff --git a/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache b/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache
index a82f2e40f4c..c5cbafc2595 100644
--- a/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache
@@ -3,7 +3,7 @@
*/{{#description}}
@ApiModel(description = "{{{description}}}"){{/description}}
{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}}
-public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
+public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}}{{^parent}}{{#hateoas}}extends ResourceSupport {{/hateoas}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
{{#serializableModel}}
private static final long serialVersionUID = 1L;
diff --git a/modules/openapi-generator/src/main/resources/Javascript/partial_model_generic.mustache b/modules/openapi-generator/src/main/resources/Javascript/partial_model_generic.mustache
index 74d410ddec8..cc6dab688c4 100644
--- a/modules/openapi-generator/src/main/resources/Javascript/partial_model_generic.mustache
+++ b/modules/openapi-generator/src/main/resources/Javascript/partial_model_generic.mustache
@@ -1,4 +1,3 @@
-
{{#models}}{{#model}}
{{#emitJSDoc}}
/**
@@ -21,11 +20,28 @@
var _this = this;
{{#parent}}{{^parentModel}}{{#vendorExtensions.x-isArray}} _this = new Array();
Object.setPrototypeOf(_this, exports);
-{{/vendorExtensions.x-isArray}}{{/parentModel}}{{/parent}}{{#useInheritance}}{{#parentModel}} {{classname}}.call(_this{{#vendorExtensions.x-all-required}}, {{name}}{{/vendorExtensions.x-all-required}});{{/parentModel}}
-{{#interfaceModels}} {{classname}}.call(_this{{#vendorExtensions.x-all-required}}, {{name}}{{/vendorExtensions.x-all-required}});
-{{/interfaceModels}}{{/useInheritance}}{{#vars}}{{#required}} _this['{{baseName}}'] = {{name}};{{/required}}
-{{/vars}}{{#parent}}{{^parentModel}} return _this;
-{{/parentModel}}{{/parent}} };
+{{/vendorExtensions.x-isArray}}{{/parentModel}}{{/parent}}
+ {{#useInheritance}}
+ {{#parentModel}}
+ {{classname}}.call(_this{{#vendorExtensions.x-all-required}}, {{name}}{{/vendorExtensions.x-all-required}});
+ {{/parentModel}}
+ {{^parentModel}}
+ {{#interfaceModels}}
+ {{classname}}.call(_this{{#vendorExtensions.x-all-required}}, {{name}}{{/vendorExtensions.x-all-required}});
+ {{/interfaceModels}}
+ {{/parentModel}}
+ {{/useInheritance}}
+ {{#vars}}
+ {{#required}}
+ _this['{{baseName}}'] = {{name}};
+ {{/required}}
+ {{/vars}}
+ {{#parent}}
+ {{^parentModel}}
+ return _this;
+ {{/parentModel}}
+ {{/parent}}
+ };
{{#emitJSDoc}}
/**
@@ -45,13 +61,27 @@
exports.constructFromObject = function(data, obj) {
if (data){{! TODO: support polymorphism: discriminator property on data determines class to instantiate.}} {
obj = obj || new exports();
-{{#parent}}{{^parentModel}} ApiClient.constructFromObject(data, obj, '{{vendorExtensions.x-itemType}}');
-{{/parentModel}}{{/parent}}{{#useInheritance}}{{#parentModel}} {{classname}}.constructFromObject(data, obj);{{/parentModel}}
-{{#interfaces}} {{.}}.constructFromObject(data, obj);
-{{/interfaces}}{{/useInheritance}}{{#vars}} if (data.hasOwnProperty('{{baseName}}')) {
+ {{#parent}}
+ {{^parentModel}}
+ ApiClient.constructFromObject(data, obj, '{{vendorExtensions.x-itemType}}');
+ {{/parentModel}}
+ {{/parent}}
+ {{#useInheritance}}
+ {{#parentModel}}
+ {{classname}}.constructFromObject(data, obj);
+ {{/parentModel}}
+ {{^parentModel}}
+ {{#interfaces}}
+ {{.}}.constructFromObject(data, obj);
+ {{/interfaces}}
+ {{/parentModel}}
+ {{/useInheritance}}
+ {{#vars}}
+ if (data.hasOwnProperty('{{baseName}}')) {
obj['{{baseName}}']{{{defaultValueWithParam}}}
}
-{{/vars}} }
+ {{/vars}}
+ }
return obj;
}
{{/vendorExtensions.x-isPrimitive}}
diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/README.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/README.mustache
index 537ae6e826a..e6e1a0b2883 100644
--- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/README.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/README.mustache
@@ -35,7 +35,7 @@ Once compiled run the server:
```bash
cd build
-./server
+./api-server
```
## Libraries required
diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache
index 7ecc6c48a38..85b84385b73 100644
--- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-header.mustache
@@ -9,12 +9,11 @@
#define {{classname}}_H_
{{{defaultInclude}}}
-#include
#include
#include
#include
-
#include
+{{^hasModelImport}}#include "json.hpp"{{/hasModelImport}}
{{#imports}}{{{import}}}
{{/imports}}
@@ -28,11 +27,9 @@ using namespace {{modelNamespace}};{{/hasModelImport}}
class {{declspec}} {{classname}} {
public:
- {{classname}}(Pistache::Address addr);
+ {{classname}}(std::shared_ptr);
virtual ~{{classname}}() {}
- void init(size_t thr);
- void start();
- void shutdown();
+ void init();
const std::string base = "{{basePathWithoutHost}}";
@@ -44,9 +41,7 @@ private:
{{/operation}}
void {{classnameSnakeLowerCase}}_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
- Pistache::Http::Endpoint httpEndpoint;
- Pistache::Rest::Router router;
-
+ std::shared_ptr router;
{{#operation}}
///
diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache
index 357765cf57f..f10e9b3768d 100644
--- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-header.mustache
@@ -31,7 +31,7 @@ using namespace {{modelNamespace}};{{/hasModelImport}}
class {{classname}}Impl : public {{apiNamespace}}::{{classname}} {
public:
- {{classname}}Impl(Pistache::Address addr);
+ {{classname}}Impl(std::shared_ptr);
~{{classname}}Impl() {}
{{#operation}}
diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-source.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-source.mustache
index d6ba91e15af..613a7dbb230 100644
--- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-source.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-impl-source.mustache
@@ -10,8 +10,8 @@ namespace {{this}} {
{{#hasModelImport}}
using namespace {{modelNamespace}};{{/hasModelImport}}
-{{classname}}Impl::{{classname}}Impl(Pistache::Address addr)
- : {{classname}}(addr)
+{{classname}}Impl::{{classname}}Impl(std::shared_ptr rtr)
+ : {{classname}}(rtr)
{ }
{{#operation}}
diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-source.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-source.mustache
index 58104a36223..b8a4e34fad1 100644
--- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-source.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/api-source.mustache
@@ -12,36 +12,23 @@ using namespace {{helpersNamespace}};
{{#hasModelImport}}
using namespace {{modelNamespace}};{{/hasModelImport}}
-{{classname}}::{{classname}}(Pistache::Address addr)
- : httpEndpoint(addr)
-{ };
+{{classname}}::{{classname}}(std::shared_ptr rtr) {
+ router = rtr;
+};
-void {{classname}}::init(size_t thr = 2) {
- auto opts = Pistache::Http::Endpoint::options()
- .threads(thr)
- .flags(Pistache::Tcp::Options::InstallSignalHandler);
- httpEndpoint.init(opts);
+void {{classname}}::init() {
setupRoutes();
}
-void {{classname}}::start() {
- httpEndpoint.setHandler(router.handler());
- httpEndpoint.serve();
-}
-
-void {{classname}}::shutdown() {
- httpEndpoint.shutdown();
-}
-
void {{classname}}::setupRoutes() {
using namespace Pistache::Rest;
{{#operation}}
- Routes::{{httpMethod}}(router, base + "{{{vendorExtensions.x-codegen-pistache-path}}}", Routes::bind(&{{classname}}::{{operationIdSnakeCase}}_handler, this));
+ Routes::{{httpMethod}}(*router, base + "{{{vendorExtensions.x-codegen-pistache-path}}}", Routes::bind(&{{classname}}::{{operationIdSnakeCase}}_handler, this));
{{/operation}}
// Default handler, called when a route is not found
- router.addCustomHandler(Routes::bind(&{{classname}}::{{classnameSnakeLowerCase}}_default_handler, this));
+ router->addCustomHandler(Routes::bind(&{{classname}}::{{classnameSnakeLowerCase}}_default_handler, this));
}
{{#operation}}
diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/cmake.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/cmake.mustache
index 11c7a5c3c52..115fac401ca 100644
--- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/cmake.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/cmake.mustache
@@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.2)
-project(server)
+project(api-server)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pg -g3" )
@@ -24,48 +24,17 @@ include_directories(${EXTERNAL_INSTALL_LOCATION}/include/nlohmann)
link_directories(${EXTERNAL_INSTALL_LOCATION}/lib)
{{/addExternalLibs}}
-link_directories(/usr/local/lib/)
-
-aux_source_directory(model MODEL_SOURCES)
-{{=<% %>=}}
-<%#apiInfo.apis%>
-<%#operations%>
-file(GLOB <%classnameSnakeUpperCase%>_SOURCES
-"api/<%classname%>.h"
-"api/<%classname%>.cpp"
-"impl/<%classname%>Impl.h"
-"impl/<%classname%>Impl.cpp"
-)
-<%/operations%>
-<%/apiInfo.apis%>
-
include_directories(model)
include_directories(api)
include_directories(impl)
-<%#apiInfo.apis%>
-<%#operations%>
-set(<%classnameSnakeUpperCase%>_SERVER_SOURCES
-<%classname%>MainServer.cpp
- ${MODEL_SOURCES}
- ${<%classnameSnakeUpperCase%>_SOURCES})
-<%/operations%>
-<%/apiInfo.apis%>
+file(GLOB SRCS
+ ${CMAKE_CURRENT_SOURCE_DIR}/api/*.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/impl/*.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/model/*.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
+)
-<%#apiInfo.apis%>
-<%#operations%>
-add_executable(<%classnameSnakeLowerCase%>_server
-${<%classnameSnakeUpperCase%>_SERVER_SOURCES})
-<%#addExternalLibs%>
-add_dependencies(<%classnameSnakeLowerCase%>_server PISTACHE NLOHMANN)
-<%/addExternalLibs%>
-<%/operations%>
-<%/apiInfo.apis%>
-
-<%#apiInfo.apis%>
-<%#operations%>
-target_link_libraries(<%classnameSnakeLowerCase%>_server pistache pthread)
-<%/operations%>
-<%/apiInfo.apis%>
-
-<%={{ }}=%>
\ No newline at end of file
+add_executable(${PROJECT_NAME} ${SRCS} )
+add_dependencies(${PROJECT_NAME} PISTACHE NLOHMANN)
+target_link_libraries(${PROJECT_NAME} pistache pthread)
diff --git a/modules/openapi-generator/src/main/resources/cpp-pistache-server/main-api-server.mustache b/modules/openapi-generator/src/main/resources/cpp-pistache-server/main-api-server.mustache
index 302e1c8cd66..7973d2dcb65 100644
--- a/modules/openapi-generator/src/main/resources/cpp-pistache-server/main-api-server.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-pistache-server/main-api-server.mustache
@@ -1,21 +1,74 @@
{{>licenseInfo}}
-{{#operations}}
+
#include "pistache/endpoint.h"
#include "pistache/http.h"
#include "pistache/router.h"
-#include "{{classname}}Impl.h"
+#ifdef __linux__
+#include
+#include
+#include
+#endif
+{{#apiInfo}}{{#apis}}{{#operations}}
+#include "{{classname}}Impl.h"{{/operations}}{{/apis}}{{/apiInfo}}
+
+#define PISTACHE_SERVER_THREADS 2
+
+static Pistache::Http::Endpoint *httpEndpoint;
+#ifdef __linux__
+static void sigHandler(int sig){
+ switch(sig){
+ case SIGINT:
+ case SIGQUIT:
+ case SIGTERM:
+ case SIGHUP:
+ default:
+ httpEndpoint->shutdown();
+ break;
+ }
+ exit(0);
+}
+
+static void setUpUnixSignals(std::vector quitSignals) {
+ sigset_t blocking_mask;
+ sigemptyset(&blocking_mask);
+ for (auto sig : quitSignals)
+ sigaddset(&blocking_mask, sig);
+
+ struct sigaction sa;
+ sa.sa_handler = sigHandler;
+ sa.sa_mask = blocking_mask;
+ sa.sa_flags = 0;
+
+ for (auto sig : quitSignals)
+ sigaction(sig, &sa, nullptr);
+}
+#endif
using namespace {{apiNamespace}};
int main() {
+#ifdef __linux__
+ std::vector sigs{SIGQUIT, SIGINT, SIGTERM, SIGHUP};
+ setUpUnixSignals(sigs);
+#endif
Pistache::Address addr(Pistache::Ipv4::any(), Pistache::Port(8080));
- {{classname}}Impl server(addr);
- server.init(2);
- server.start();
+ httpEndpoint = new Pistache::Http::Endpoint((addr));
+ auto router = std::make_shared();
+
+ auto opts = Pistache::Http::Endpoint::options()
+ .threads(PISTACHE_SERVER_THREADS);
+ httpEndpoint->init(opts);
+
+ {{#apiInfo}}{{#apis}}{{#operations}}
+ {{classname}}Impl {{classname}}server(router);
+ {{classname}}server.init();{{/operations}}{{/apis}}{{/apiInfo}}
+
+ httpEndpoint->setHandler(router->handler());
+ httpEndpoint->serve();
+
+ httpEndpoint->shutdown();
- server.shutdown();
}
-{{/operations}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/api-header.mustache b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/api-header.mustache
index fbf515deb15..1df116498b2 100644
--- a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/api-header.mustache
+++ b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/api-header.mustache
@@ -13,6 +13,7 @@
{{#imports}}{{{import}}}
{{/imports}}
+{{^hasModelImport}}#include "../ModelBase.h"{{/hasModelImport}}
#include
diff --git a/modules/openapi-generator/src/main/resources/csharp/api.mustache b/modules/openapi-generator/src/main/resources/csharp/api.mustache
index 4f0a06f234e..cdbb940d3f5 100644
--- a/modules/openapi-generator/src/main/resources/csharp/api.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/api.mustache
@@ -93,6 +93,17 @@ namespace {{packageName}}.{{apiPackage}}
ExceptionFactory = {{packageName}}.Client.Configuration.DefaultExceptionFactory;
}
+ ///
+ /// Initializes a new instance of the class
+ ///
+ ///
+ public {{classname}}()
+ {
+ this.Configuration = {{packageName}}.Client.Configuration.Default;
+
+ ExceptionFactory = {{packageName}}.Client.Configuration.DefaultExceptionFactory;
+ }
+
///
/// Initializes a new instance of the class
/// using Configuration object
diff --git a/modules/openapi-generator/src/main/resources/elm/fieldDecoder.mustache b/modules/openapi-generator/src/main/resources/elm/fieldDecoder.mustache
index 6f7db61ddbd..c40e55b7390 100644
--- a/modules/openapi-generator/src/main/resources/elm/fieldDecoder.mustache
+++ b/modules/openapi-generator/src/main/resources/elm/fieldDecoder.mustache
@@ -1 +1 @@
-{{#required}}required{{/required}}{{^required}}optional{{/required}} "{{baseName}}" {{^required}}(Decode.nullable {{/required}}{{#isContainer}}(Decode.list {{/isContainer}}{{vendorExtensions.elmDecoder}}{{#isContainer}}){{/isContainer}}{{^required}}){{/required}}{{^required}} {{{defaultValue}}}{{/required}}
\ No newline at end of file
+{{#required}}required{{/required}}{{^required}}optional{{/required}} "{{baseName}}" {{^required}}(Decode.nullable {{/required}}{{#isMapContainer}}(Decode.dict {{/isMapContainer}}{{#isListContainer}}(Decode.list {{/isListContainer}}{{vendorExtensions.elmDecoder}}{{#isContainer}}){{/isContainer}}{{^required}}){{/required}}{{^required}} {{{defaultValue}}}{{/required}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/elm/fieldEncoder.mustache b/modules/openapi-generator/src/main/resources/elm/fieldEncoder.mustache
index df4dc919d6e..58bd131abbf 100644
--- a/modules/openapi-generator/src/main/resources/elm/fieldEncoder.mustache
+++ b/modules/openapi-generator/src/main/resources/elm/fieldEncoder.mustache
@@ -1 +1 @@
-( "{{baseName}}", {{#discriminatorValue}}Encode.string "{{discriminatorValue}}"{{/discriminatorValue}}{{^discriminatorValue}}{{^required}}Maybe.withDefault Encode.null (Maybe.map {{/required}}{{#isContainer}}(Encode.list {{#isElm018}}<< List.map {{/isElm018}}{{/isContainer}}{{vendorExtensions.elmEncoder}}{{#isContainer}}){{/isContainer}} model.{{name}}{{^required}}){{/required}}{{/discriminatorValue}} )
\ No newline at end of file
+( "{{baseName}}", {{#discriminatorValue}}Encode.string "{{discriminatorValue}}"{{/discriminatorValue}}{{^discriminatorValue}}{{^required}}Maybe.withDefault Encode.null (Maybe.map {{/required}}{{#isMapContainer}}(Encode.dict identity {{/isMapContainer}}{{#isListContainer}}(Encode.list {{#isElm018}}<< List.map {{/isElm018}}{{/isListContainer}}{{vendorExtensions.elmEncoder}}{{#isContainer}}){{/isContainer}} model.{{name}}{{^required}}){{/required}}{{/discriminatorValue}} )
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/elm/model.mustache b/modules/openapi-generator/src/main/resources/elm/model.mustache
index 42fa46711d9..4fef4dd19d5 100644
--- a/modules/openapi-generator/src/main/resources/elm/model.mustache
+++ b/modules/openapi-generator/src/main/resources/elm/model.mustache
@@ -2,7 +2,8 @@
module Data.{{classname}} exposing ({{#models}}{{#model}}{{classname}}{{#hasChildren}}(..){{/hasChildren}}{{#isEnum}}(..){{/isEnum}}{{^isEnum}}{{#vars}}{{#isEnum}}, {{vendorExtensions.elmUnionType}}(..){{/isEnum}}{{/vars}}{{/isEnum}}, decoder, encoder{{/model}}{{/models}})
-{{>imports}}import Json.Decode as Decode exposing (Decoder)
+{{>imports}}import Dict exposing (Dict)
+import Json.Decode as Decode exposing (Decoder)
import Json.Decode.Pipeline exposing ({{#isElm018}}decode, {{/isElm018}}optional, required)
import Json.Encode as Encode
{{#models}}
diff --git a/modules/openapi-generator/src/main/resources/elm/modelTypeAlias.mustache b/modules/openapi-generator/src/main/resources/elm/modelTypeAlias.mustache
index 6063ffe8f4b..1a334177900 100644
--- a/modules/openapi-generator/src/main/resources/elm/modelTypeAlias.mustache
+++ b/modules/openapi-generator/src/main/resources/elm/modelTypeAlias.mustache
@@ -1,5 +1,5 @@
type alias {{classname}} =
- { {{#allVars}}{{^-first}} , {{/-first}}{{name}} : {{^required}}Maybe {{#isContainer}}({{/isContainer}}{{/required}}{{#isContainer}}List {{/isContainer}}{{#isEnum}}{{nameInCamelCase}}{{/isEnum}}{{^isEnum}}{{dataType}}{{/isEnum}}{{^required}}{{#isContainer}}){{/isContainer}}{{/required}}
+ { {{#allVars}}{{^-first}} , {{/-first}}{{name}} : {{^required}}Maybe {{#isContainer}}({{/isContainer}}{{/required}}{{#isMapContainer}}Dict String {{/isMapContainer}}{{#isListContainer}}List {{/isListContainer}}{{#isEnum}}{{nameInCamelCase}}{{/isEnum}}{{^isEnum}}{{dataType}}{{/isEnum}}{{^required}}{{#isContainer}}){{/isContainer}}{{/required}}
{{/allVars}} }
{{#vars}}
{{#isEnum}}
diff --git a/modules/openapi-generator/src/main/resources/erlang-server/router.mustache b/modules/openapi-generator/src/main/resources/erlang-server/router.mustache
index 740d85ccd0d..f2c3b66f9c4 100644
--- a/modules/openapi-generator/src/main/resources/erlang-server/router.mustache
+++ b/modules/openapi-generator/src/main/resources/erlang-server/router.mustache
@@ -69,6 +69,6 @@ prepare_validator() ->
get_openapi_path() ->
{ok, AppName} = application:get_application(?MODULE),
- filename:join({{packageName}}_utils:priv_dir(AppName), "openapi.json").
+ filename:join({{packageName}}_utils:priv_dir(AppName), "{{{openAPISpecName}}}.json").
diff --git a/modules/openapi-generator/src/main/resources/go/api.mustache b/modules/openapi-generator/src/main/resources/go/api.mustache
index 19cde5b4458..175962642dd 100644
--- a/modules/openapi-generator/src/main/resources/go/api.mustache
+++ b/modules/openapi-generator/src/main/resources/go/api.mustache
@@ -272,16 +272,6 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, err
}
- {{#returnType}}
- if localVarHttpResponse.StatusCode < 300 {
- // If we succeed, return the data, otherwise pass on to decode error.
- err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
- if err == nil {
- return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, err
- }
- }
-
- {{/returnType}}
if localVarHttpResponse.StatusCode >= 300 {
newErr := GenericOpenAPIError{
body: localVarBody,
@@ -304,6 +294,17 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, newErr
}
+ {{#returnType}}
+ err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
+ if err != nil {
+ newErr := GenericOpenAPIError{
+ body: localVarBody,
+ error: err.Error(),
+ }
+ return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, newErr
+ }
+
+ {{/returnType}}
return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, nil
}
{{/operation}}
diff --git a/modules/openapi-generator/src/main/resources/lua/api.mustache b/modules/openapi-generator/src/main/resources/lua/api.mustache
index d8408da2553..af75e87606e 100644
--- a/modules/openapi-generator/src/main/resources/lua/api.mustache
+++ b/modules/openapi-generator/src/main/resources/lua/api.mustache
@@ -49,14 +49,12 @@ function {{classname}}:{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}},
req.headers:upsert(":method", "{{httpMethod}}")
{{#hasConsumes}}
-- TODO: create a function to select proper accept
- -- ref: https://openapi-generator.tech/pull/6252#issuecomment-321199879
--local var_content_type = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }
req.headers:upsert("accept", {{#consumes}}{{#-first}}"{{{mediaType}}}"{{/-first}}{{/consumes}})
{{/hasConsumes}}
{{#hasProduces}}
-- TODO: create a function to select proper content-type
- -- ref: https://openapi-generator.tech/pull/6252#issuecomment-321199879
--local var_accept = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }
req.headers:upsert("content-type", {{#produces}}{{#-first}}"{{{mediaType}}}"{{/-first}}{{/produces}})
diff --git a/modules/openapi-generator/src/main/resources/ruby-client/configuration.mustache b/modules/openapi-generator/src/main/resources/ruby-client/configuration.mustache
index 7c7e1d82dc5..dcfb0004228 100644
--- a/modules/openapi-generator/src/main/resources/ruby-client/configuration.mustache
+++ b/modules/openapi-generator/src/main/resources/ruby-client/configuration.mustache
@@ -219,5 +219,70 @@ module {{moduleName}}
{{/authMethods}}
}
end
+
+ # Returns an array of Server setting
+ def server_settings
+ [
+ {{#servers}}
+ {
+ url: "{{{url}}}",
+ description: "{{{description}}}{{^description}}No descriptoin provided{{/description}}",
+ {{#variables}}
+ {{#-first}}
+ variables: {
+ {{/-first}}
+ {{{name}}}: {
+ description: "{{{description}}}{{^description}}No descriptoin provided{{/description}}",
+ default_value: "{{{defaultValue}}}",
+ {{#enumValues}}
+ {{#-first}}
+ enum_values: [
+ {{/-first}}
+ "{{{.}}}"{{^-last}},{{/-last}}
+ {{#-last}}
+ ]
+ {{/-last}}
+ {{/enumValues}}
+ }{{^-last}},{{/-last}}
+ {{#-last}}
+ }
+ {{/-last}}
+ {{/variables}}
+ }{{^-last}},{{/-last}}
+ {{/servers}}
+ ]
+ end
+
+ # Returns URL based on server settings
+ #
+ # @param index array index of the server settings
+ # @param variables hash of variable and the corresponding value
+ def server_url(index, variables = {})
+ servers = server_settings
+
+ # check array index out of bound
+ if (index < 0 || index > servers.size)
+ fail ArgumentError "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
+ end
+
+ server = servers[index]
+ url = server[:url]
+
+ # go through variable and assign a value
+ server[:variables].each do |name, variable|
+ if variables.key?(name)
+ if (server[:variables][name][:enum_values].include? variables[name])
+ url.gsub! "{" + name.to_s + "}", variables[name]
+ else
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
+ end
+ else
+ # use default value
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
+ end
+ end
+
+ url
+ end
end
end
diff --git a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache
index 6b524874aad..6fc033fe6c8 100644
--- a/modules/openapi-generator/src/main/resources/rust/Cargo.mustache
+++ b/modules/openapi-generator/src/main/resources/rust/Cargo.mustache
@@ -4,14 +4,21 @@ version = "{{{packageVersion}}}"
authors = ["OpenAPI Generator team and contributors"]
[dependencies]
-serde = "1.0"
-serde_derive = "1.0"
-serde_yaml = "0.7"
-serde_json = "1.0"
-base64 = "~0.7.0"
-futures = "0.1.16"
-hyper = "0.11.6"
+serde = "^1.0"
+serde_derive = "^1.0"
+serde_json = "^1.0"
url = "1.5"
+{{#hyper}}
+hyper = "~0.11"
+serde_yaml = "0.7"
+base64 = "~0.7.0"
+futures = "0.1.23"
+{{/hyper}}
+{{#reqwest}}
+reqwest = "~0.9"
+{{/reqwest}}
[dev-dependencies]
+{{#hyper}}
tokio-core = "*"
+{{/hyper}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/rust/README.mustache b/modules/openapi-generator/src/main/resources/rust/README.mustache
index 823a371d999..712357f80fa 100644
--- a/modules/openapi-generator/src/main/resources/rust/README.mustache
+++ b/modules/openapi-generator/src/main/resources/rust/README.mustache
@@ -1,4 +1,4 @@
-# Rust API client for {{packageName}}
+# Rust API client for {{{packageName}}}
{{#appDescription}}
{{{appDescription}}}
@@ -7,12 +7,12 @@
## Overview
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client.
-- API version: {{appVersion}}
-- Package version: {{packageVersion}}
+- API version: {{{appVersion}}}
+- Package version: {{{packageVersion}}}
{{^hideGenerationTimestamp}}
-- Build date: {{generatedDate}}
+- Build date: {{{generatedDate}}}
{{/hideGenerationTimestamp}}
-- Build package: {{generatorClass}}
+- Build package: {{{generatorClass}}}
{{#infoUrl}}
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
{{/infoUrl}}
@@ -20,21 +20,21 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
## Installation
Put the package under your project folder and add the following in import:
```
- "./{{packageName}}"
+ "./{{{packageName}}}"
```
## Documentation for API Endpoints
-All URIs are relative to *{{basePath}}*
+All URIs are relative to *{{{basePath}}}*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
-{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
+{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{{classname}}}* | [**{{{operationId}}}**]({{{apiDocPath}}}{{classname}}.md#{{{operationIdLowerCase}}}) | **{{{httpMethod}}}** {{{path}}} | {{#summary}}{{{summary}}}{{/summary}}
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
## Documentation For Models
-{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
+{{#models}}{{#model}} - [{{{classname}}}]({{{modelDocPath}}}{{{classname}}}.md)
{{/model}}{{/models}}
## Documentation For Authorization
@@ -92,5 +92,5 @@ Or via OAuth2 module to automatically refresh tokens and perform user authentica
## Author
-{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}}
+{{#apiInfo}}{{#apis}}{{^hasMore}}{{{infoEmail}}}
{{/hasMore}}{{/apis}}{{/apiInfo}}
diff --git a/modules/openapi-generator/src/main/resources/rust/api_doc.mustache b/modules/openapi-generator/src/main/resources/rust/api_doc.mustache
index 29eb3c2e5ec..c6fb6db4664 100644
--- a/modules/openapi-generator/src/main/resources/rust/api_doc.mustache
+++ b/modules/openapi-generator/src/main/resources/rust/api_doc.mustache
@@ -1,17 +1,17 @@
-# {{invokerPackage}}\{{classname}}{{#description}}
-{{description}}{{/description}}
+# {{{invokerPackage}}}\{{{classname}}}{{#description}}
+{{{description}}}{{/description}}
-All URIs are relative to *{{basePath}}*
+All URIs are relative to *{{{basePath}}}*
Method | HTTP request | Description
------------- | ------------- | -------------
-{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
+{{#operations}}{{#operation}}[**{{{operationId}}}**]({{{classname}}}.md#{{{operationId}}}) | **{{{httpMethod}}}** {{{path}}} | {{#summary}}{{{summary}}}{{/summary}}
{{/operation}}{{/operations}}
{{#operations}}
{{#operation}}
# **{{{operationId}}}**
-> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#authMethods}}ctx, {{/authMethods}}{{#allParams}}{{#required}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}optional{{/hasOptionalParams}})
+> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#authMethods}}ctx, {{/authMethods}}{{#allParams}}{{#required}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}optional{{/hasOptionalParams}})
{{{summary}}}{{#notes}}
{{{notes}}}{{/notes}}
@@ -21,7 +21,7 @@ Method | HTTP request | Description
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------{{#authMethods}}
**ctx** | **context.Context** | context containing the authentication | nil if no authentication{{/authMethods}}{{/-last}}{{/allParams}}{{#allParams}}{{#required}}
- **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}| {{description}} | {{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}{{/required}}{{/allParams}}{{#hasOptionalParams}}
+ **{{{paramName}}}** | {{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{{dataType}}}**]({{{baseType}}}.md){{/isPrimitiveType}}| {{{description}}} | {{#defaultValue}}[default to {{{defaultValue}}}]{{/defaultValue}}{{/required}}{{/allParams}}{{#hasOptionalParams}}
**optional** | **map[string]interface{}** | optional parameters | nil if no parameters
### Optional Parameters
@@ -29,11 +29,11 @@ Optional parameters are passed through a map[string]interface{}.
{{#allParams}}{{#-last}}
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}{{#allParams}}
- **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}| {{description}} | {{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}{{/allParams}}{{/hasOptionalParams}}
+ **{{{paramName}}}** | {{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{{dataType}}}**]({{{baseType}}}.md){{/isPrimitiveType}}| {{{description}}} | {{#defaultValue}}[default to {{{defaultValue}}}]{{/defaultValue}}{{/allParams}}{{/hasOptionalParams}}
### Return type
-{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}} (empty response body){{/returnType}}
+{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{{returnBaseType}}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}} (empty response body){{/returnType}}
### Authorization
diff --git a/modules/openapi-generator/src/main/resources/rust/api.mustache b/modules/openapi-generator/src/main/resources/rust/hyper/api.mustache
similarity index 53%
rename from modules/openapi-generator/src/main/resources/rust/api.mustache
rename to modules/openapi-generator/src/main/resources/rust/hyper/api.mustache
index 3e59a5839db..426fee7fe80 100644
--- a/modules/openapi-generator/src/main/resources/rust/api.mustache
+++ b/modules/openapi-generator/src/main/resources/rust/hyper/api.mustache
@@ -21,20 +21,20 @@ impl {{{classname}}}Client {
}
}
-pub trait {{classname}} {
+pub trait {{{classname}}} {
{{#operations}}
{{#operation}}
- fn {{{operationId}}}(&self, {{#allParams}}{{paramName}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Box>>;
+ fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Box>>;
{{/operation}}
{{/operations}}
}
-impl{{classname}} for {{classname}}Client {
+impl{{{classname}}} for {{{classname}}}Client {
{{#operations}}
{{#operation}}
- fn {{{operationId}}}(&self, {{#allParams}}{{paramName}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Box>> {
- __internal_request::Request::new(hyper::Method::{{httpMethod}}, "{{{path}}}".to_string())
+ fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Box>> {
+ __internal_request::Request::new(hyper::Method::{{{httpMethod}}}, "{{{path}}}".to_string())
{{#hasAuthMethods}}
{{#authMethods}}
{{#isApiKey}}
@@ -53,29 +53,29 @@ impl{{classname}} for {{classname}}Client {
{{/authMethods}}
{{/hasAuthMethods}}
{{#queryParams}}
- .with_query_param("{{baseName}}".to_string(), {{paramName}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string())
+ .with_query_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string())
{{/queryParams}}
{{#pathParams}}
- .with_path_param("{{baseName}}".to_string(), {{paramName}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string())
+ .with_path_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string())
{{/pathParams}}
{{#hasHeaderParams}}
{{#headerParams}}
- .with_header_param("{{baseName}}".to_string(), {{paramName}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string())
+ .with_header_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string())
{{/headerParams}}
{{/hasHeaderParams}}
{{#hasFormParams}}
{{#formParams}}
{{#isFile}}
- .with_form_param("{{baseName}}".to_string(), unimplemented!())
+ .with_form_param("{{{baseName}}}".to_string(), unimplemented!())
{{/isFile}}
{{^isFile}}
- .with_form_param("{{baseName}}".to_string(), {{paramName}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string())
+ .with_form_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string())
{{/isFile}}
{{/formParams}}
{{/hasFormParams}}
{{#hasBodyParam}}
{{#bodyParams}}
- .with_body_param({{paramName}})
+ .with_body_param({{{paramName}}})
{{/bodyParams}}
{{/hasBodyParam}}
{{^returnType}}
diff --git a/modules/openapi-generator/src/main/resources/rust/api_mod.mustache b/modules/openapi-generator/src/main/resources/rust/hyper/api_mod.mustache
similarity index 92%
rename from modules/openapi-generator/src/main/resources/rust/api_mod.mustache
rename to modules/openapi-generator/src/main/resources/rust/hyper/api_mod.mustache
index 1f587b0d52f..1deca998a0d 100644
--- a/modules/openapi-generator/src/main/resources/rust/api_mod.mustache
+++ b/modules/openapi-generator/src/main/resources/rust/hyper/api_mod.mustache
@@ -55,11 +55,11 @@ mod request;
{{#apiInfo}}
{{#apis}}
-mod {{classFilename}};
+mod {{{classFilename}}};
{{#operations}}
{{#operation}}
{{#-last}}
-pub use self::{{classFilename}}::{ {{classname}}, {{classname}}Client };
+pub use self::{{{classFilename}}}::{ {{{classname}}}, {{{classname}}}Client };
{{/-last}}
{{/operation}}
{{/operations}}
diff --git a/modules/openapi-generator/src/main/resources/rust/client.mustache b/modules/openapi-generator/src/main/resources/rust/hyper/client.mustache
similarity index 76%
rename from modules/openapi-generator/src/main/resources/rust/client.mustache
rename to modules/openapi-generator/src/main/resources/rust/hyper/client.mustache
index faaea0dbd2f..71b31ccc993 100644
--- a/modules/openapi-generator/src/main/resources/rust/client.mustache
+++ b/modules/openapi-generator/src/main/resources/rust/hyper/client.mustache
@@ -10,7 +10,7 @@ pub struct APIClient {
{{#operations}}
{{#operation}}
{{#-last}}
- {{classFilename}}: Box<::apis::{{classname}}>,
+ {{{classFilename}}}: Box<::apis::{{{classname}}}>,
{{/-last}}
{{/operation}}
{{/operations}}
@@ -29,7 +29,7 @@ impl APIClient {
{{#operations}}
{{#operation}}
{{#-last}}
- {{classFilename}}: Box::new(::apis::{{classname}}Client::new(rc.clone())),
+ {{{classFilename}}}: Box::new(::apis::{{{classname}}}Client::new(rc.clone())),
{{/-last}}
{{/operation}}
{{/operations}}
@@ -43,8 +43,8 @@ impl APIClient {
{{#operations}}
{{#operation}}
{{#-last}}
- pub fn {{classFilename}}(&self) -> &::apis::{{classname}}{
- self.{{classFilename}}.as_ref()
+ pub fn {{{classFilename}}}(&self) -> &::apis::{{{classname}}}{
+ self.{{{classFilename}}}.as_ref()
}
{{/-last}}
diff --git a/modules/openapi-generator/src/main/resources/rust/configuration.mustache b/modules/openapi-generator/src/main/resources/rust/hyper/configuration.mustache
similarity index 88%
rename from modules/openapi-generator/src/main/resources/rust/configuration.mustache
rename to modules/openapi-generator/src/main/resources/rust/hyper/configuration.mustache
index a30f5014e35..8c273278d6b 100644
--- a/modules/openapi-generator/src/main/resources/rust/configuration.mustache
+++ b/modules/openapi-generator/src/main/resources/rust/hyper/configuration.mustache
@@ -23,7 +23,7 @@ impl Configuration {
pub fn new(client: hyper::client::Client) -> Configuration {
Configuration {
base_path: "{{{basePath}}}".to_owned(),
- user_agent: {{#httpUserAgent}}Some("{{{.}}}".to_owned()){{/httpUserAgent}}{{^httpUserAgent}}Some("OpenAPI-Generator/{{version}}/rust".to_owned()){{/httpUserAgent}},
+ user_agent: {{#httpUserAgent}}Some("{{{.}}}".to_owned()){{/httpUserAgent}}{{^httpUserAgent}}Some("OpenAPI-Generator/{{{version}}}/rust".to_owned()){{/httpUserAgent}},
client: client,
basic_auth: None,
oauth_access_token: None,
diff --git a/modules/openapi-generator/src/main/resources/rust/lib.mustache b/modules/openapi-generator/src/main/resources/rust/lib.mustache
new file mode 100644
index 00000000000..cdc5287aae7
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/rust/lib.mustache
@@ -0,0 +1,16 @@
+#[macro_use]
+extern crate serde_derive;
+
+extern crate serde;
+extern crate serde_json;
+extern crate url;
+{{#hyper}}
+extern crate hyper;
+extern crate futures;
+{{/hyper}}
+{{#reqwest}}
+extern crate reqwest;
+{{/reqwest}}
+
+pub mod apis;
+pub mod models;
diff --git a/modules/openapi-generator/src/main/resources/rust/model.mustache b/modules/openapi-generator/src/main/resources/rust/model.mustache
index afb557c3410..6c86c531d36 100644
--- a/modules/openapi-generator/src/main/resources/rust/model.mustache
+++ b/modules/openapi-generator/src/main/resources/rust/model.mustache
@@ -9,45 +9,45 @@
use serde_json::Value;
#[derive(Debug, Serialize, Deserialize)]
-pub struct {{classname}} {
+pub struct {{{classname}}} {
{{#vars}}
{{#description}}
/// {{{description}}}
{{/description}}
- #[serde(rename = "{{baseName}}")]
- {{name}}: {{^required}}Option<{{/required}}{{{dataType}}}{{^required}}>{{/required}}{{#hasMore}},{{/hasMore}}
+ #[serde(rename = "{{{baseName}}}")]
+ {{{name}}}: {{^required}}Option<{{/required}}{{{dataType}}}{{^required}}>{{/required}}{{#hasMore}},{{/hasMore}}
{{/vars}}
}
-impl {{classname}} {
+impl {{{classname}}} {
{{#description}}
/// {{{description}}}
{{/description}}
- pub fn new({{#requiredVars}}{{name}}: {{{dataType}}}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{classname}} {
- {{classname}} {
+ pub fn new({{#requiredVars}}{{{name}}}: {{{dataType}}}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{{classname}}} {
+ {{{classname}}} {
{{#vars}}
- {{name}}: {{#required}}{{name}}{{/required}}{{^required}}{{#isListContainer}}None{{/isListContainer}}{{#isMapContainer}}None{{/isMapContainer}}{{^isContainer}}None{{/isContainer}}{{/required}}{{#hasMore}},{{/hasMore}}
+ {{{name}}}: {{#required}}{{{name}}}{{/required}}{{^required}}{{#isListContainer}}None{{/isListContainer}}{{#isMapContainer}}None{{/isMapContainer}}{{^isContainer}}None{{/isContainer}}{{/required}}{{#hasMore}},{{/hasMore}}
{{/vars}}
}
}
{{#vars}}
- pub fn set_{{name}}(&mut self, {{name}}: {{{dataType}}}) {
- self.{{name}} = {{^required}}Some({{name}}){{/required}}{{#required}}{{name}}{{/required}};
+ pub fn set_{{{name}}}(&mut self, {{{name}}}: {{{dataType}}}) {
+ self.{{{name}}} = {{^required}}Some({{{name}}}){{/required}}{{#required}}{{{name}}}{{/required}};
}
- pub fn with_{{name}}(mut self, {{name}}: {{{dataType}}}) -> {{classname}} {
- self.{{name}} = {{^required}}Some({{name}}){{/required}}{{#required}}{{name}}{{/required}};
+ pub fn with_{{{name}}}(mut self, {{{name}}}: {{{dataType}}}) -> {{{classname}}} {
+ self.{{{name}}} = {{^required}}Some({{{name}}}){{/required}}{{#required}}{{{name}}}{{/required}};
self
}
- pub fn {{name}}(&self) -> {{^required}}Option<{{/required}}&{{{dataType}}}{{^required}}>{{/required}} {
- {{#required}}&{{/required}}self.{{name}}{{^required}}.as_ref(){{/required}}
+ pub fn {{{name}}}(&self) -> {{^required}}Option<{{/required}}&{{{dataType}}}{{^required}}>{{/required}} {
+ {{#required}}&{{/required}}self.{{{name}}}{{^required}}.as_ref(){{/required}}
}
{{^required}}
- pub fn reset_{{name}}(&mut self) {
- self.{{name}} = None;
+ pub fn reset_{{{name}}}(&mut self) {
+ self.{{{name}}} = None;
}
{{/required}}
@@ -60,7 +60,7 @@ impl {{classname}} {
//const (
// {{#allowableValues}}
// {{#enumVars}}
-// {{name}} {{{classname}}} = "{{{value}}}"
+// {{{name}}} {{{classname}}} = "{{{value}}}"
// {{/enumVars}}
// {{/allowableValues}}
//)
diff --git a/modules/openapi-generator/src/main/resources/rust/model_doc.mustache b/modules/openapi-generator/src/main/resources/rust/model_doc.mustache
index ccfd3f8d0de..aeaeb959166 100644
--- a/modules/openapi-generator/src/main/resources/rust/model_doc.mustache
+++ b/modules/openapi-generator/src/main/resources/rust/model_doc.mustache
@@ -1,9 +1,9 @@
-{{#models}}{{#model}}# {{classname}}
+{{#models}}{{#model}}# {{{classname}}}
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
-{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{^isContainer}}{{^isDateTime}}*{{/isDateTime}}{{/isContainer}}{{{dataType}}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
+{{#vars}}**{{{name}}}** | {{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{^isContainer}}{{^isDateTime}}*{{/isDateTime}}{{/isContainer}}{{{dataType}}}**]({{{complexType}}}.md){{/isPrimitiveType}} | {{{description}}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
{{/vars}}
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache
new file mode 100644
index 00000000000..091c40fe625
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache
@@ -0,0 +1,113 @@
+{{>partial_header}}
+use std::rc::Rc;
+use std::borrow::Borrow;
+
+use reqwest;
+
+use super::{Error, configuration};
+
+pub struct {{{classname}}}Client {
+ configuration: Rc,
+}
+
+impl {{{classname}}}Client {
+ pub fn new(configuration: Rc) -> {{{classname}}}Client {
+ {{{classname}}}Client {
+ configuration: configuration,
+ }
+ }
+}
+
+pub trait {{{classname}}} {
+{{#operations}}
+{{#operation}}
+ fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>;
+{{/operation}}
+{{/operations}}
+}
+
+
+impl {{{classname}}} for {{{classname}}}Client {
+{{#operations}}
+{{#operation}}
+ fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> {
+ let configuration: &configuration::Configuration = self.configuration.borrow();
+ let client = &configuration.client;
+
+ let query_string = {
+ let mut query = ::url::form_urlencoded::Serializer::new(String::new());
+{{#queryParams}}
+ query.append_pair("{{{baseName}}}", &{{{paramName}}}{{#isListContainer}}.into_iter().map(|p| p.to_string()).collect::>().join(","){{/isListContainer}}.to_string());
+{{/queryParams}}
+{{#hasAuthMethods}}{{#authMethods}}{{#isApiKey}}{{#isKeyInQuery}}
+ if let Some(ref apikey) = configuration.api_key {
+ let key = apikey.key.clone();
+ let val = match apikey.prefix {
+ Some(ref prefix) => format!("{} {}", prefix, key),
+ None => key,
+ };
+ query.append_pair("{{{keyParamName}}}".to_owned(), val);
+ }
+{{/isKeyInQuery}}{{/isApiKey}}{{/authMethods}}{{/hasAuthMethods}}
+ query.finish()
+ };
+ let uri_str = format!("{}{{{path}}}?{}", configuration.base_path, query_string{{#pathParams}}, {{{baseName}}}={{{paramName}}}{{#isListContainer}}.join(",").as_ref(){{/isListContainer}}{{/pathParams}});
+
+ let mut req_builder = client.{{{httpMethod}}}(uri_str.as_str());
+
+ if let Some(ref user_agent) = configuration.user_agent {
+ req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
+ }
+
+ {{#hasHeaderParams}}
+ {{#headerParams}}
+ req_builder = req_builder.header("{{{baseName}}}", {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}.to_string());
+ {{/headerParams}}
+ {{/hasHeaderParams}}
+
+ {{#hasAuthMethods}}
+ {{#authMethods}}
+ {{#isApiKey}}{{#isKeyInHeader}}
+ if let Some(ref apikey) = configuration.api_key {
+ let key = apikey.key.clone();
+ let val = match apikey.prefix {
+ Some(ref prefix) => format!("{} {}", prefix, key),
+ None => key,
+ };
+ req_builder = req_builder.header("{{{keyParamName}}}", val);
+ };
+ {{/isKeyInHeader}}{{/isApiKey}}
+ {{#isBasic}}
+ if let Some(ref auth_conf) = configuration.basic_auth {
+ req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
+ };
+ {{/isBasic}}
+ {{#isOAuth}}
+ if let Some(ref token) = configuration.oauth_access_token {
+ req_builder = req_builder.bearer_auth(token.to_owned());
+ };
+ {{/isOAuth}}
+ {{/authMethods}}
+ {{/hasAuthMethods}}
+
+ {{#hasBodyParam}}
+ {{#bodyParams}}
+ req_builder = req_builder.json(&{{{paramName}}});
+ {{/bodyParams}}
+ {{/hasBodyParam}}
+
+ // send request
+ let req = req_builder.build()?;
+
+ {{^returnType}}
+ client.execute(req)?.error_for_status()?;
+ Ok(())
+ {{/returnType}}
+ {{#returnType}}
+ Ok(client.execute(req)?.error_for_status()?.json()?)
+ {{/returnType}}
+ }
+
+{{/operation}}
+{{/operations}}
+}
diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/api_mod.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/api_mod.mustache
new file mode 100644
index 00000000000..483e2c388f8
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api_mod.mustache
@@ -0,0 +1,38 @@
+use reqwest;
+use serde_json;
+
+#[derive(Debug)]
+pub enum Error {
+ Reqwest(reqwest::Error),
+ Serde(serde_json::Error),
+}
+
+impl From for Error {
+ fn from(e: reqwest::Error) -> Self {
+ return Error::Reqwest(e)
+ }
+}
+
+impl From for Error {
+ fn from(e: serde_json::Error) -> Self {
+ return Error::Serde(e)
+ }
+}
+
+use super::models::*;
+
+{{#apiInfo}}
+{{#apis}}
+mod {{{classFilename}}};
+{{#operations}}
+{{#operation}}
+{{#-last}}
+pub use self::{{{classFilename}}}::{ {{{classname}}}, {{{classname}}}Client };
+{{/-last}}
+{{/operation}}
+{{/operations}}
+{{/apis}}
+{{/apiInfo}}
+
+pub mod configuration;
+pub mod client;
diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/client.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/client.mustache
new file mode 100644
index 00000000000..61765226a26
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/rust/reqwest/client.mustache
@@ -0,0 +1,55 @@
+use std::rc::Rc;
+
+use super::configuration::Configuration;
+
+pub struct APIClient {
+ configuration: Rc,
+{{#apiInfo}}
+{{#apis}}
+{{#operations}}
+{{#operation}}
+ {{#-last}}
+ {{{classFilename}}}: Box<::apis::{{{classname}}}>,
+ {{/-last}}
+{{/operation}}
+{{/operations}}
+{{/apis}}
+{{/apiInfo}}
+}
+
+impl APIClient {
+ pub fn new(configuration: Configuration) -> APIClient {
+ let rc = Rc::new(configuration);
+
+ APIClient {
+ configuration: rc.clone(),
+{{#apiInfo}}
+{{#apis}}
+{{#operations}}
+{{#operation}}
+ {{#-last}}
+ {{{classFilename}}}: Box::new(::apis::{{{classname}}}Client::new(rc.clone())),
+ {{/-last}}
+{{/operation}}
+{{/operations}}
+{{/apis}}
+{{/apiInfo}}
+ }
+ }
+
+{{#apiInfo}}
+{{#apis}}
+{{#operations}}
+{{#operation}}
+{{#-last}}
+ pub fn {{{classFilename}}}(&self) -> &::apis::{{{classname}}}{
+ self.{{{classFilename}}}.as_ref()
+ }
+
+{{/-last}}
+{{/operation}}
+{{/operations}}
+{{/apis}}
+{{/apiInfo}}
+
+}
diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/configuration.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/configuration.mustache
new file mode 100644
index 00000000000..c50ff814e5d
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/rust/reqwest/configuration.mustache
@@ -0,0 +1,39 @@
+{{>partial_header}}
+
+use reqwest;
+
+pub struct Configuration {
+ pub base_path: String,
+ pub user_agent: Option,
+ pub client: reqwest::Client,
+ pub basic_auth: Option,
+ pub oauth_access_token: Option,
+ pub api_key: Option,
+ // TODO: take an oauth2 token source, similar to the go one
+}
+
+pub type BasicAuth = (String, Option);
+
+pub struct ApiKey {
+ pub prefix: Option,
+ pub key: String,
+}
+
+impl Configuration {
+ pub fn new() -> Configuration {
+ Configuration::default()
+ }
+}
+
+impl Default for Configuration {
+ fn default() -> Self {
+ Configuration {
+ base_path: "{{{basePath}}}".to_owned(),
+ user_agent: {{#httpUserAgent}}Some("{{{.}}}".to_owned()){{/httpUserAgent}}{{^httpUserAgent}}Some("Swagger-Codegen/{{{version}}}/rust".to_owned()){{/httpUserAgent}},
+ client: reqwest::Client::new(),
+ basic_auth: None,
+ oauth_access_token: None,
+ api_key: None,
+ }
+ }
+}
diff --git a/modules/openapi-generator/src/main/resources/scala-akka-client/build.sbt.mustache b/modules/openapi-generator/src/main/resources/scala-akka-client/build.sbt.mustache
index 971bc97364b..265a9791dbb 100644
--- a/modules/openapi-generator/src/main/resources/scala-akka-client/build.sbt.mustache
+++ b/modules/openapi-generator/src/main/resources/scala-akka-client/build.sbt.mustache
@@ -5,12 +5,12 @@ scalaVersion := "2.11.12"
libraryDependencies ++= Seq(
"com.typesafe" % "config" % "1.3.2",
- "com.typesafe.akka" %% "akka-actor" % "2.5.8",
+ "com.typesafe.akka" %% "akka-actor" % "2.5.17",
"io.spray" % "spray-client" % "1.3.1",
"joda-time" % "joda-time" % "2.9.9",
- "org.json4s" %% "json4s-jackson" % "3.5.3",
+ "org.json4s" %% "json4s-jackson" % "3.5.4",
// test dependencies
- "org.scalatest" %% "scalatest" % "3.0.4" % "test",
+ "org.scalatest" %% "scalatest" % "3.0.5" % "test",
"junit" % "junit" % "4.12" % "test"
)
diff --git a/modules/openapi-generator/src/main/resources/scala-akka-client/pom.mustache b/modules/openapi-generator/src/main/resources/scala-akka-client/pom.mustache
index 0cc69bdc424..e984593572b 100644
--- a/modules/openapi-generator/src/main/resources/scala-akka-client/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/scala-akka-client/pom.mustache
@@ -16,14 +16,14 @@
1.8
2.11.12
- 3.5.3
+ 3.5.4
3.2.11
1.3.1
- 2.5.8
+ 2.5.17
2.9.9
4.12
- 3.0.4
+ 3.0.5
3.3.1
@@ -240,4 +240,4 @@
-
\ No newline at end of file
+
diff --git a/modules/openapi-generator/src/main/resources/typescript-axios/api.mustache b/modules/openapi-generator/src/main/resources/typescript-axios/api.mustache
index 7d11e17ea03..7e2ed1c5f3f 100644
--- a/modules/openapi-generator/src/main/resources/typescript-axios/api.mustache
+++ b/modules/openapi-generator/src/main/resources/typescript-axios/api.mustache
@@ -4,7 +4,7 @@
import * as url from "url";
import { Configuration } from "./configuration";
-import axios, { AxiosPromise } from 'axios';
+import globalAxios, { AxiosPromise, AxiosInstance } from 'axios';
const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, "");
@@ -37,7 +37,7 @@ export interface RequestArgs {
export class BaseAPI {
protected configuration: Configuration | undefined;
- constructor(configuration?: Configuration, protected basePath: string = BASE_PATH) {
+ constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
if (configuration) {
this.configuration = configuration;
this.basePath = configuration.basePath || this.basePath;
@@ -255,9 +255,9 @@ export const {{classname}}Fp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
- {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): (basePath?: string) => AxiosPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}> {
+ {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}> {
const localVarAxiosArgs = {{classname}}AxiosParamCreator(configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options);
- return (basePath: string = BASE_PATH) => {
+ return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs = Object.assign(localVarAxiosArgs.options, {url: basePath + localVarAxiosArgs.url})
return axios.request(axiosRequestArgs);
};
@@ -271,7 +271,7 @@ export const {{classname}}Fp = function(configuration?: Configuration) {
* {{&description}}{{/description}}
* @export
*/
-export const {{classname}}Factory = function (configuration?: Configuration, basePath?: string) {
+export const {{classname}}Factory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
return {
{{#operation}}
/**
@@ -286,7 +286,7 @@ export const {{classname}}Factory = function (configuration?: Configuration, bas
* @throws {RequiredError}
*/
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any) {
- return {{classname}}Fp(configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options)(basePath);
+ return {{classname}}Fp(configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options)(axios, basePath);
},
{{/operation}}
};
@@ -346,7 +346,7 @@ export class {{classname}} extends BaseAPI {
* @memberof {{classname}}
*/
public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any) {
- return {{classname}}Fp(this.configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options)(this.basePath);
+ return {{classname}}Fp(this.configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options)(this.axios, this.basePath);
}
{{/operation}}
diff --git a/modules/openapi-generator/src/main/resources/undertow/pom.mustache b/modules/openapi-generator/src/main/resources/undertow/pom.mustache
index c3c1e51d95d..2faeb6f1ddf 100644
--- a/modules/openapi-generator/src/main/resources/undertow/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/undertow/pom.mustache
@@ -16,7 +16,8 @@
1.8
UTF-8
0.1.1
- 2.8.2
+ 2.8.11
+ 2.8.11.2
1.7.21
0.5.2
4.5.3
@@ -80,7 +81,7 @@
com.fasterxml.jackson.core
jackson-databind
- ${version.jackson}
+ ${version.jackson.databind}
com.fasterxml.jackson.core
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/utils/ModelUtilsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/utils/ModelUtilsTest.java
index e09d27dbb95..e024897e231 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/utils/ModelUtilsTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/utils/ModelUtilsTest.java
@@ -19,7 +19,11 @@ package org.openapitools.codegen.utils;
import io.swagger.parser.OpenAPIParser;
import io.swagger.v3.oas.models.OpenAPI;
-import io.swagger.v3.oas.models.media.*;
+import io.swagger.v3.oas.models.media.ComposedSchema;
+import io.swagger.v3.oas.models.media.IntegerSchema;
+import io.swagger.v3.oas.models.media.ObjectSchema;
+import io.swagger.v3.oas.models.media.Schema;
+import io.swagger.v3.oas.models.media.StringSchema;
import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.parameters.RequestBody;
import io.swagger.v3.oas.models.responses.ApiResponse;
@@ -40,7 +44,7 @@ public class ModelUtilsTest {
public void testGetAllUsedSchemas() {
final OpenAPI openAPI = new OpenAPIParser().readLocation("src/test/resources/3_0/unusedSchemas.yaml", null, new ParseOptions()).getOpenAPI();
List allUsedSchemas = ModelUtils.getAllUsedSchemas(openAPI);
- Assert.assertEquals(allUsedSchemas.size(), 28);
+ Assert.assertEquals(allUsedSchemas.size(), 30);
Assert.assertTrue(allUsedSchemas.contains("SomeObjShared"), "contains 'SomeObjShared'");
Assert.assertTrue(allUsedSchemas.contains("SomeObj1"), "contains 'UnusedObj1'");
@@ -70,6 +74,8 @@ public class ModelUtilsTest {
Assert.assertTrue(allUsedSchemas.contains("Obj19ByType"), "contains 'Obj19ByType'");
Assert.assertTrue(allUsedSchemas.contains("SomeObj20"), "contains 'SomeObj20'");
Assert.assertTrue(allUsedSchemas.contains("OtherObj20"), "contains 'OtherObj20'");
+ Assert.assertTrue(allUsedSchemas.contains("PingDataInput21"), "contains 'PingDataInput21'");
+ Assert.assertTrue(allUsedSchemas.contains("PingDataOutput21"), "contains 'PingDataOutput21'");
}
@Test
diff --git a/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
index 5fc7ebf0709..8315914ce14 100644
--- a/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
+++ b/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
@@ -1049,12 +1049,15 @@ definitions:
name: Order
Category:
type: object
+ required:
+ - name
properties:
id:
type: integer
format: int64
name:
type: string
+ default: default-name
xml:
name: Category
User:
diff --git a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
index 78ba11aaebc..10f904b50ef 100644
--- a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
@@ -17,6 +17,18 @@ tags:
- name: user
description: Operations about user
paths:
+ /foo:
+ get:
+ responses:
+ default:
+ description: response
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ string:
+ $ref: '#/components/schemas/Foo'
/pet:
post:
tags:
@@ -968,7 +980,28 @@ paths:
required:
- requiredFile
servers:
- - url: 'http://petstore.swagger.io:80/v2'
+ - url: 'http://{server}.swagger.io:{port}/v2'
+ description: petstore server
+ variables:
+ server:
+ enum:
+ - 'petstore'
+ - 'qa-petstore'
+ - 'dev-petstore'
+ default: 'petstore'
+ port:
+ enum:
+ - 80
+ - 8080
+ default: 80
+ - url: https://localhost:8080/{version}
+ description: The local server
+ variables:
+ version:
+ enum:
+ - 'v1'
+ - 'v2'
+ default: 'v2'
components:
requestBodies:
UserArray:
@@ -1018,6 +1051,14 @@ components:
type: http
scheme: basic
schemas:
+ Foo:
+ type: object
+ properties:
+ bar:
+ $ref: '#/components/schemas/Bar'
+ Bar:
+ type: string
+ default: bar
Order:
type: object
properties:
@@ -1047,12 +1088,15 @@ components:
name: Order
Category:
type: object
+ required:
+ - name
properties:
id:
type: integer
format: int64
name:
type: string
+ default: default-name
xml:
name: Category
User:
diff --git a/modules/openapi-generator/src/test/resources/3_0/unusedSchemas.yaml b/modules/openapi-generator/src/test/resources/3_0/unusedSchemas.yaml
index a01797944af..3df4d6e1321 100644
--- a/modules/openapi-generator/src/test/resources/3_0/unusedSchemas.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/unusedSchemas.yaml
@@ -233,6 +233,36 @@ paths:
text/plain:
schema:
$ref: '#/components/schemas/SomeObj20'
+ /some/p21:
+ post:
+ operationId: op21
+ parameters:
+ - name: callbackUrl
+ in: query
+ required: true
+ schema:
+ type: string
+ format: uri
+ example: https://some-server.com
+ responses:
+ '201':
+ description: OK
+ callbacks:
+ onPing:
+ '{$request.query.callbackUrl}/ping':
+ post:
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/PingDataInput21'
+ responses:
+ '200':
+ description: Ok
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/PingDataOutput21'
components:
schemas:
UnusedObj1:
@@ -463,6 +493,20 @@ components:
OtherObj20:
type: string
enum: [A, B, C]
+ PingDataInput21:
+ type: object
+ properties:
+ id:
+ type: integer
+ data:
+ type: String
+ PingDataOutput21:
+ type: object
+ properties:
+ id:
+ type: integer
+ reply:
+ type: String
SomeObjShared:
type: object
properties:
@@ -515,4 +559,5 @@ components:
name: id
in: query
schema:
- $ref: '#/components/schemas/SomeObj11'
\ No newline at end of file
+ $ref: '#/components/schemas/SomeObj11'
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 6d2039f5129..ab9ff7d7b13 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1025,6 +1025,7 @@
samples/client/petstore/elm-0.18
samples/client/petstore/groovy
samples/client/petstore/rust
+ samples/client/petstore/rust-reqwest
samples/client/petstore/php/OpenAPIClient-php
samples/openapi3/client/petstore/php/OpenAPIClient-php
diff --git a/samples/client/petstore/cpp-restsdk/api/PetApi.h b/samples/client/petstore/cpp-restsdk/api/PetApi.h
index 0313da30395..a4b37987816 100644
--- a/samples/client/petstore/cpp-restsdk/api/PetApi.h
+++ b/samples/client/petstore/cpp-restsdk/api/PetApi.h
@@ -26,6 +26,7 @@
#include "Pet.h"
#include
+
#include
namespace org {
diff --git a/samples/client/petstore/cpp-restsdk/api/StoreApi.h b/samples/client/petstore/cpp-restsdk/api/StoreApi.h
index 507756dee1d..3a2a1ac3b32 100644
--- a/samples/client/petstore/cpp-restsdk/api/StoreApi.h
+++ b/samples/client/petstore/cpp-restsdk/api/StoreApi.h
@@ -25,6 +25,7 @@
#include