forked from loafle/openapi-generator-original
Merge remote-tracking branch 'origin/master' into 5.0.x
This commit is contained in:
commit
0b7d3c4590
@ -28,7 +28,7 @@ WORKDIR ${TARGET_DIR}
|
||||
|
||||
COPY --from=builder ${GEN_DIR}/modules/openapi-generator-online/target/openapi-generator-online.jar ${TARGET_DIR}/openapi-generator-online.jar
|
||||
|
||||
ENV GENERATOR_HOST=http://localhost
|
||||
ENV GENERATOR_HOST=""
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
|
@ -12,6 +12,7 @@ if [ "$NODE_INDEX" = "1" ]; then
|
||||
#cp CI/pom.xml.circleci pom.xml
|
||||
java -version
|
||||
mvn --quiet verify -Psamples.circleci
|
||||
mvn --quiet javadoc:javadoc -Psamples.circleci
|
||||
|
||||
# generate all petstore samples (client, servers, doc)
|
||||
./bin/run-all-petstore
|
||||
|
32
README.md
32
README.md
@ -2,16 +2,11 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`4.0.3`): [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`4.1.0`): [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
||||
|
||||
[`4.1.x`](https://github.com/OpenAPITools/openapi-generator/tree/4.1.x) branch: [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
||||
|
||||
[`5.0.x`](https://github.com/OpenAPITools/openapi-generator/tree/5.0.x) branch: [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
||||
@ -98,9 +93,8 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
|
||||
OpenAPI Generator Version | Release Date | Notes
|
||||
---------------------------- | ------------ | -----
|
||||
5.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/5.0.0-SNAPSHOT/)| 13.05.2020 | Major release with breaking changes (no fallback)
|
||||
4.1.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.1.0-SNAPSHOT/)| 15.07.2019 | Minor release (breaking changes with fallbacks)
|
||||
4.0.3 (upcoming patch release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.0.3-SNAPSHOT/)| 04.07.2019 | Patch release (minor bug fixes, etc)
|
||||
[4.0.2](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.0.2) (latest stable release) | 20.06.2019 | Patch release (bug fixes, minor enhancements, etc)
|
||||
4.1.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.1.0-SNAPSHOT/)| 31.07.2019 | Minor release (breaking changes with fallbacks)
|
||||
[4.0.3](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.0.3) (latest stable release) | 09.07.2019 | Patch release (bug fixes, minor enhancements, etc)
|
||||
|
||||
OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0
|
||||
|
||||
@ -156,16 +150,16 @@ See the different versions of the [openapi-generator-cli](https://mvnrepository.
|
||||
<!-- RELEASE_VERSION -->
|
||||
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum):
|
||||
|
||||
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.2/openapi-generator-cli-4.0.2.jar`
|
||||
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.3/openapi-generator-cli-4.0.3.jar`
|
||||
|
||||
For **Mac/Linux** users:
|
||||
```sh
|
||||
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.2/openapi-generator-cli-4.0.2.jar -O openapi-generator-cli.jar
|
||||
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.3/openapi-generator-cli-4.0.3.jar -O openapi-generator-cli.jar
|
||||
```
|
||||
|
||||
For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
|
||||
```
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.2/openapi-generator-cli-4.0.2.jar
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.3/openapi-generator-cli-4.0.3.jar
|
||||
```
|
||||
|
||||
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
|
||||
@ -281,7 +275,7 @@ Example usage:
|
||||
|
||||
```sh
|
||||
# Start container at port 8888 and save the container id
|
||||
> CID=$(docker run -d -p 8888:8080 -e GENERATOR_HOST=http://localhost:8888 openapitools/openapi-generator-online)
|
||||
> CID=$(docker run -d -p 8888:8080 openapitools/openapi-generator-online)
|
||||
|
||||
# allow for startup
|
||||
> sleep 10
|
||||
@ -369,10 +363,10 @@ openapi-generator version
|
||||
```
|
||||
|
||||
<!-- RELEASE_VERSION -->
|
||||
Or install a particular OpenAPI Generator version (e.g. v4.0.2):
|
||||
Or install a particular OpenAPI Generator version (e.g. v4.0.3):
|
||||
|
||||
```sh
|
||||
npm install @openapitools/openapi-generator-cli@cli-4.0.2 -g
|
||||
npm install @openapitools/openapi-generator-cli@cli-4.0.3 -g
|
||||
```
|
||||
|
||||
Or install it as dev-dependency:
|
||||
@ -396,7 +390,7 @@ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generat
|
||||
(if you're on Windows, replace the last command with `java -jar modules\openapi-generator-cli\target\openapi-generator-cli.jar generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g php -o c:\temp\php_api_client`)
|
||||
|
||||
<!-- RELEASE_VERSION -->
|
||||
You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.2/openapi-generator-cli-4.0.2.jar)
|
||||
You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.3/openapi-generator-cli-4.0.3.jar)
|
||||
<!-- /RELEASE_VERSION -->
|
||||
|
||||
To get a list of **general** options available, please run `java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help generate`
|
||||
@ -538,6 +532,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- [Camptocamp](https://www.camptocamp.com/en)
|
||||
- [codecentric AG](https://www.codecentric.de/)
|
||||
- [Cupix](https://www.cupix.com/)
|
||||
- [DB Systel](https://www.dbsystel.de)
|
||||
- [FormAPI](https://formapi.io/)
|
||||
- [Fuse](https://www.fuse.no/)
|
||||
- [GenFlow](https://github.com/RepreZen/GenFlow)
|
||||
@ -596,6 +591,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- 2019-05-22 - [REST APIs代码生成指南(OpenAPI Generator)](https://gum.co/openapi_generator_ebook_gb) by [William Cheng](https://twitter.com/wing328), [Xin Meng](https://github.com/xmeng1)
|
||||
- 2019-05-24 - [REST API 代碼生成指南 (OpenAPI Generator)](https://gum.co/openapi_generator_ebook_big5) by [William Cheng](https://twitter.com/wing328)
|
||||
- 2019-06-24 - [Kubernetes Clients and OpenAPI Generator](https://speakerdeck.com/wing328/kubernetes-clients-and-openapi-generator) by [William Cheng](https://twitter.com/wing328) at [Kubernetes Contributor Summits Shanghai 2019](https://www.lfasiallc.com/events/contributors-summit-china-2019/)
|
||||
- 2019-07-04 - [REST API のためのコード生成入門 (OpenAPI Generator)](https://gum.co/openapi_generator_ebook_big5) by [William Cheng](https://twitter.com/wing328), [中野暁人](https://github.com/ackintosh), [和田拓朗](https://github.com/taxpon)
|
||||
|
||||
## [6 - About Us](#table-of-contents)
|
||||
|
||||
@ -785,12 +781,12 @@ If you want to join the committee, please kindly apply by sending an email to te
|
||||
| PHP | @jebentier (2017/07), @dkarlovi (2017/07), @mandrean (2017/08), @jfastnacht (2017/09), @ackintosh (2017/09) [:heart:](https://www.patreon.com/ackintosh/overview), @ybelenko (2018/07), @renepardon (2018/12) |
|
||||
| PowerShell | |
|
||||
| Python | @taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11) @tomplus (2018/10) @Jyhess (2019/01) |
|
||||
| R | |
|
||||
| R | @Ramanth (2019/07) @saigiridhar21 (2019/07) |
|
||||
| Ruby | @cliffano (2017/07) @zlx (2017/09) @autopp (2019/02) |
|
||||
| Rust | @frol (2017/07) @farcaller (2017/08) @bjgill (2017/12) |
|
||||
| Scala | @clasnake (2017/07), @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert), @shijinkui (2018/01), @ramzimaalej (2018/03) |
|
||||
| Swift | @jgavris (2017/07) @ehyche (2017/08) @Edubits (2017/09) @jaz-ah (2017/09) @d-date (2018/03) |
|
||||
| TypeScript | @TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @nicokoenig (2018/09) @topce (2018/10) |
|
||||
| TypeScript | @TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @nicokoenig (2018/09) @topce (2018/10) @akehir (2019/07) |
|
||||
|
||||
:heart: = Link to support the contributor directly
|
||||
|
||||
|
39
bin/go-experimental-petstore.sh
Executable file
39
bin/go-experimental-petstore.sh
Executable file
@ -0,0 +1,39 @@
|
||||
#!/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
|
||||
|
||||
SPEC="modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml"
|
||||
GENERATOR="go-experimental"
|
||||
STUB_DIR="samples/client/petstore/go-experimental/go-petstore"
|
||||
|
||||
echo "Removing files and folders under $STUB_DIR"
|
||||
rm -rf $STUB_DIR
|
||||
|
||||
# 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/$GENERATOR -i $SPEC -g $GENERATOR -o $STUB_DIR -DpackageName=petstore $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
39
bin/openapi3/go-experimental-petstore.sh
Executable file
39
bin/openapi3/go-experimental-petstore.sh
Executable file
@ -0,0 +1,39 @@
|
||||
#!/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
|
||||
|
||||
SPEC="modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml"
|
||||
GENERATOR="go-experimental"
|
||||
STUB_DIR="samples/openapi3/client/petstore/go-experimental/go-petstore"
|
||||
|
||||
echo "Removing files and folders under $STUB_DIR"
|
||||
rm -rf $STUB_DIR
|
||||
|
||||
# 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/$GENERATOR -i $SPEC -g $GENERATOR -o $STUB_DIR -DpackageName=petstore $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
@ -26,7 +26,7 @@ then
|
||||
fi
|
||||
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -t modules/openapi-generator/src/main/resources/kotlin-spring -g kotlin-spring -o samples/server/openapi3/petstore/kotlin-springboot-reactive --additional-properties=library=spring-boot,beanValidations=true,swaggerAnnotations=true,serviceImplementation=true,reactive=true"
|
||||
ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -t modules/openapi-generator/src/main/resources/kotlin-spring -g kotlin-spring -o samples/openapi3/server/petstore/kotlin-springboot-reactive --additional-properties=library=spring-boot,beanValidations=true,swaggerAnnotations=true,serviceImplementation=true,reactive=true"
|
||||
|
||||
echo "Cleaning previously generated files if any from samples/server/openapi3/petstore/kotlin-springboot-reactive"
|
||||
rm -rf samples/server/openapi3/petstore/kotlin-springboot-reactive
|
||||
|
@ -26,7 +26,7 @@ then
|
||||
fi
|
||||
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -t modules/openapi-generator/src/main/resources/kotlin-spring -g kotlin-spring -o samples/server/openapi3/petstore/kotlin-springboot --additional-properties=library=spring-boot,beanValidations=true,swaggerAnnotations=true,serviceImplementation=true"
|
||||
ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -t modules/openapi-generator/src/main/resources/kotlin-spring -g kotlin-spring -o samples/openapi3/server/petstore/kotlin-springboot --additional-properties=library=spring-boot,beanValidations=true,swaggerAnnotations=true,serviceImplementation=true"
|
||||
|
||||
echo "Cleaning previously generated files if any from samples/server/openapi3/petstore/kotlin-springboot"
|
||||
rm -rf samples/server/openapi3/petstore/kotlin-springboot
|
||||
|
@ -26,7 +26,7 @@ then
|
||||
fi
|
||||
|
||||
input=modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
out_folder=samples/server/openapi3/petstore/php-ze-ph
|
||||
out_folder=samples/openapi3/server/petstore/php-ze-ph
|
||||
resources=modules/openapi-generator/src/main/resources/php-ze-ph
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
|
@ -27,7 +27,7 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
input=modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
out_folder=samples/server/openapi3/petstore/python-flask-python2
|
||||
out_folder=samples/openapi3/server/petstore/python-flask-python2
|
||||
resources=modules/openapi-generator/src/main/resources/python-flask
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
|
@ -27,7 +27,7 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
input=modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
out_folder=samples/server/openapi3/petstore/python-flask
|
||||
out_folder=samples/openapi3/server/petstore/python-flask
|
||||
resources=modules/openapi-generator/src/main/resources/python-flask
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
|
32
bin/python-experimental-petstore.sh
Executable file
32
bin/python-experimental-petstore.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package $@
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/python -i modules/openapi-generator/src/test/resources/2_0/python-client-experimental/petstore-with-fake-endpoints-models-for-testing.yaml -g python-experimental -o samples/client/petstore/python-experimental -DpackageName=petstore_api $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
@ -5,6 +5,6 @@ If Not Exist %executable% (
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g android -o samples\client\petstore\android\httpclient-Dlibrary=httpclient
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g android -o samples\client\petstore\android\httpclient -Dlibrary=httpclient
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
21
bin/windows/go-experimental-petstore.bat
Executable file
21
bin/windows/go-experimental-petstore.bat
Executable file
@ -0,0 +1,21 @@
|
||||
setlocal
|
||||
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
set SPEC=modules\openapi-generator\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
set GENERATOR=go-experimental
|
||||
set STUB_DIR=samples\client\petstore\go-experimental\go-petstore
|
||||
|
||||
echo Removing files and folders under %STUB_DIR%
|
||||
del /F /S /Q %STUB_DIR%
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||
set ags=generate -t modules\openapi-generator\src\main\resources\%GENERATOR% -i %SPEC% -g %GENERATOR% -o %STUB_DIR% -DpackageName=petstore
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
endlocal
|
@ -5,6 +5,6 @@ If Not Exist %executable% (
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g kotlin-spring -o samples\server\openapi3\petstore\kotlin-springboot --additional-properties=library=spring-boot
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g kotlin-spring -o samples\openapi3\server\petstore\kotlin-springboot --additional-properties=library=spring-boot
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
@ -5,6 +5,6 @@ If Not Exist %executable% (
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g r -o samples\client\petstore\R --additional-properties packageName=petstore
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g r -o samples\client\petstore\R --additional-properties packageName=petstore,returnExceptionOnFailure=false,exceptionPackage=default
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
@ -248,7 +248,7 @@ CONFIG OPTIONS
|
||||
retrofit - HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1 (Retrofit 1.9.0)
|
||||
retrofit2 - HTTP client: OkHttp 2.5.0. JSON processing: Gson 2.4 (Retrofit 2.0.0-beta2)
|
||||
google-api-client - HTTP client: google-api-client 1.23.0. JSON processing: Jackson 2.8.9
|
||||
rest-assured - HTTP client: rest-assured : 3.3.0. JSON processing: Gson 2.8.5. Only for Java8
|
||||
rest-assured - HTTP client: rest-assured : 4.0.0. JSON processing: Gson 2.8.5. Only for Java8
|
||||
```
|
||||
|
||||
Your config file for Java can look like
|
||||
|
@ -27,6 +27,7 @@ The following generators are available:
|
||||
- [erlang-proper](generators/erlang-proper.md)
|
||||
- [flash](generators/flash.md)
|
||||
- [go](generators/go.md)
|
||||
- [go-experimental](generators/go-experimental.md)
|
||||
- [groovy](generators/groovy.md)
|
||||
- [haskell-http-client](generators/haskell-http-client.md)
|
||||
- [java](generators/java.md)
|
||||
@ -42,6 +43,7 @@ The following generators are available:
|
||||
- [php](generators/php.md)
|
||||
- [powershell](generators/powershell.md)
|
||||
- [python](generators/python.md)
|
||||
- [python-experimental](generators/python-experimental.md)
|
||||
- [r](generators/r.md)
|
||||
- [ruby](generators/ruby.md)
|
||||
- [rust](generators/rust.md)
|
||||
|
16
docs/generators/go-experimental.md
Normal file
16
docs/generators/go-experimental.md
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
---
|
||||
id: generator-opts-client-go-experimental
|
||||
title: Config Options for go-experimental
|
||||
sidebar_label: go-experimental
|
||||
---
|
||||
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|packageName|Go package name (convention: lowercase).| |openapi|
|
||||
|packageVersion|Go package version.| |1.0.0|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||
|isGoSubmodule|whether the generated Go module is a submodule| |false|
|
||||
|withGoCodegenComment|whether to include Go codegen comment to disable Go Lint and collapse by default GitHub in PRs and diffs| |false|
|
||||
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
@ -55,4 +55,4 @@ sidebar_label: java
|
||||
|feignVersion|Version of OpenFeign: '10.x', '9.x' (default)| |false|
|
||||
|useReflectionEqualsHashCode|Use org.apache.commons.lang3.builder for equals and hashCode in the models. WARNING: This will fail under a security manager, unless the appropriate permissions are set up correctly and also there's potential performance impact.| |false|
|
||||
|caseInsensitiveResponseHeaders|Make API response's headers case-insensitive. Available on okhttp-gson, jersey2 libraries| |false|
|
||||
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.8.x. Enable Java6 support using '-DsupportJava6=true'. 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 libaries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 9.x or 10.x. JSON processing: Jackson 2.8.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit**</dt><dd>HTTP client: OkHttp 2.x. JSON processing: Gson 2.x (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.8.x</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.8.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.8.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.8.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 3.x. JSON processing: Gson 2.x. Only for Java8</dd><dl>|okhttp-gson|
|
||||
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.8.x. Enable Java6 support using '-DsupportJava6=true'. 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 libaries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.8.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 9.x or 10.x. JSON processing: Jackson 2.8.x. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit**</dt><dd>HTTP client: OkHttp 2.x. JSON processing: Gson 2.x (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.8.x</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.8.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.8.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.8.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x. Only for Java8</dd><dl>|okhttp-gson|
|
||||
|
17
docs/generators/python-experimental.md
Normal file
17
docs/generators/python-experimental.md
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
---
|
||||
id: generator-opts-client-python-experimental
|
||||
title: Config Options for python-experimental
|
||||
sidebar_label: python-experimental
|
||||
---
|
||||
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|packageName|python package name (convention: snake_case).| |openapi_client|
|
||||
|projectName|python project name in setup.py (e.g. petstore-api).| |null|
|
||||
|packageVersion|python package version.| |1.0.0|
|
||||
|packageUrl|python package URL.| |null|
|
||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||
|generateSourceCodeOnly|Specifies that only a library source code is to be generated.| |false|
|
||||
|library|library template (sub-template) to use: asyncio, tornado, urllib3| |urllib3|
|
@ -10,3 +10,5 @@ sidebar_label: r
|
||||
|packageName|R package name (convention: lowercase).| |openapi|
|
||||
|packageVersion|R package version.| |1.0.0|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||
|returnExceptionOnFailure|Throw an exception on non success response codes| |false|
|
||||
|exceptionPackage|Specify the exception handling package|<dl><dt>**default**</dt><dd>Use stop() for raising exceptions.</dd><dt>**rlang**</dt><dd>Use rlang package for exceptions.</dd><dl>|default|
|
||||
|
@ -48,6 +48,7 @@ sidebar_label: spring
|
||||
|interfaceOnly|Whether to generate only API interface stubs without the server files.| |false|
|
||||
|delegatePattern|Whether to generate the server files using the delegate pattern| |false|
|
||||
|singleContentTypes|Whether to select only one produces/consumes content-type by operation.| |false|
|
||||
|skipDefaultInterface|Whether to generate default implementations for java8 interfaces| |false|
|
||||
|async|use async Callable controllers| |false|
|
||||
|reactive|wrap responses in Mono/Flux Reactor types (spring-boot only)| |false|
|
||||
|responseWrapper|wrap the responses in given type (Future,Callable,CompletableFuture,ListenableFuture,DeferredResult,HystrixCommand,RxObservable,RxSingle or fully qualified type)| |null|
|
||||
@ -61,4 +62,5 @@ sidebar_label: spring
|
||||
|useOptional|Use Optional container for optional parameters| |false|
|
||||
|hateoas|Use Spring HATEOAS library to allow adding HATEOAS links| |false|
|
||||
|returnSuccessCode|Generated server returns 2xx code| |false|
|
||||
|unhandledException|Declare operation methods to throw a generic exception and allow unhandled exceptions (useful for Spring `@ControllerAdvice` directives).| |false|
|
||||
|library|library template (sub-template)|<dl><dt>**spring-boot**</dt><dd>Spring-boot Server application using the SpringFox integration.</dd><dt>**spring-mvc**</dt><dd>Spring-MVC Server application using the SpringFox integration.</dd><dt>**spring-cloud**</dt><dd>Spring-Cloud-Feign client with Spring-Boot auto-configured settings.</dd><dl>|spring-boot|
|
||||
|
@ -23,9 +23,7 @@ Example usage:
|
||||
|
||||
```bash
|
||||
# Start container at port 8888 and save the container id
|
||||
CID=$(docker run -d -p 8888:8080 \
|
||||
-e GENERATOR_HOST=http://localhost:8888 \
|
||||
openapitools/openapi-generator-online)
|
||||
CID=$(docker run -d -p 8888:8080 openapitools/openapi-generator-online)
|
||||
|
||||
# allow for startup
|
||||
sleep 10
|
||||
|
@ -45,7 +45,7 @@ compileJava.dependsOn tasks.openApiGenerate
|
||||
[source,group]
|
||||
----
|
||||
plugins {
|
||||
id "org.openapi.generator" version "4.0.3-SNAPSHOT"
|
||||
id "org.openapi.generator" version "4.0.3"
|
||||
}
|
||||
----
|
||||
|
||||
@ -61,7 +61,7 @@ buildscript {
|
||||
// url "https://plugins.gradle.org/m2/"
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:4.0.3-SNAPSHOT"
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:4.0.3"
|
||||
}
|
||||
}
|
||||
|
||||
@ -609,7 +609,7 @@ buildscript {
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||
classpath('org.openapitools:openapi-generator-gradle-plugin:4.0.3-SNAPSHOT') {
|
||||
classpath('org.openapitools:openapi-generator-gradle-plugin:4.0.3') {
|
||||
exclude group: 'com.google.guava'
|
||||
}
|
||||
}
|
||||
|
@ -17,5 +17,5 @@ gradle generateGoWithInvalidSpec
|
||||
The samples can be tested against other versions of the plugin using the `openApiGeneratorVersion` property. For example:
|
||||
|
||||
```bash
|
||||
gradle -PopenApiGeneratorVersion=4.0.3-SNAPSHOT openApiValidate
|
||||
gradle -PopenApiGeneratorVersion=4.0.3 openApiValidate
|
||||
```
|
||||
|
@ -1,3 +1,3 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=4.0.3-SNAPSHOT
|
||||
openApiGeneratorVersion=4.0.3
|
||||
# /RELEASE_VERSION
|
||||
|
@ -12,7 +12,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.0.3-SNAPSHOT</version>
|
||||
<version>4.0.3</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.0.3-SNAPSHOT</version>
|
||||
<version>4.0.3</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
@ -19,7 +19,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.0.3-SNAPSHOT</version>
|
||||
<version>4.0.3</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.0.3-SNAPSHOT</version>
|
||||
<version>4.0.3</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>4.0.3-SNAPSHOT</version>
|
||||
<version>4.0.3</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
@ -4,9 +4,12 @@ WORKDIR /generator
|
||||
|
||||
COPY target/openapi-generator-online.jar /generator/openapi-generator-online.jar
|
||||
|
||||
ENV GENERATOR_HOST=http://localhost
|
||||
# GENERATOR_HOST can be used to determine the target location of a download link.
|
||||
# The default value asumes binding to host via: docker -p 8080:8080 image_name
|
||||
# Generally, this "just works" without GENERATOR_HOST, and this is provided only as
|
||||
# a workaround if all else fails.
|
||||
ENV GENERATOR_HOST=""
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["java", "-jar", "/generator/openapi-generator-online.jar"]
|
||||
|
||||
CMD ["java", "-jar", "/generator/openapi-generator-online.jar" ]
|
||||
|
@ -1,15 +1,57 @@
|
||||
# OpenAPI generated server
|
||||
|
||||
Spring Boot Server
|
||||
A Spring Boot Server application which hosts a client/server generator API.
|
||||
|
||||
|
||||
## Overview
|
||||
|
||||
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
|
||||
By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub.
|
||||
By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub or one of 100+ client packages.
|
||||
|
||||
This is an example of building a OpenAPI-enabled server in Java using the SpringBoot framework.
|
||||
|
||||
The underlying library integrating OpenAPI to SpringBoot is [springfox](https://github.com/springfox/springfox)
|
||||
|
||||
Start your server as a simple java application
|
||||
## Building
|
||||
|
||||
Change default port value in application.properties
|
||||
Refer to [root README](../../README.md) for build directions.
|
||||
|
||||
## Running
|
||||
|
||||
### Via command line
|
||||
|
||||
Running is as simple as:
|
||||
|
||||
```
|
||||
java -jar ./target/openapi-generator-online.jar
|
||||
```
|
||||
|
||||
This exposes the API on local port 8080.
|
||||
|
||||
Springfox supports configuration of the "host" value in the output OpenAPI document by setting the `Host` HTTP header in the request.
|
||||
To set this explicitly, pass the system property `springfox.documentation.swagger.v2.host` with the desired host. For example:
|
||||
|
||||
```
|
||||
java -Dspringfox.documentation.swagger.v2.host=example.com:8888 -jar ./target/openapi-generator-online.jar
|
||||
```
|
||||
|
||||
### Via Docker
|
||||
|
||||
After building from source, change to this module directory (`cd modules/openapi-generator-online`) and build the docker image:
|
||||
|
||||
```
|
||||
docker build -t openapitools/openapi-generator-online:latest .
|
||||
```
|
||||
|
||||
Now, run the docker image:
|
||||
|
||||
```
|
||||
docker run -d -p 8888:8080 openapitools/openapi-generator-online
|
||||
```
|
||||
|
||||
The `GENERATOR_HOST` variable is used here to ensure download links generated by the API refer to the proper API location.
|
||||
|
||||
## Environment
|
||||
|
||||
`GENERATOR_HOST` can be set to force the scheme/host/port used for download link generation. In most cases, this environment variable is not
|
||||
necessary to be set and the download link will be generated to match the originating request. The variable is provided simply as a fallback.
|
@ -52,7 +52,6 @@ public class OpenAPIDocumentationConfig {
|
||||
|
||||
String version = properties.getProperty("version", "unknown");
|
||||
|
||||
|
||||
return new ApiInfoBuilder()
|
||||
.title("OpenAPI Generator Online")
|
||||
.description("This is an online openapi generator server. You can find out more at https://github.com/OpenAPITools/openapi-generator.")
|
||||
@ -66,14 +65,7 @@ public class OpenAPIDocumentationConfig {
|
||||
|
||||
@Bean
|
||||
public Docket customImplementation(){
|
||||
String host;
|
||||
try {
|
||||
host = new URI(System.getProperty("GENERATOR_HOST", "http://localhost")).getHost();
|
||||
} catch (URISyntaxException e) {
|
||||
host = "";
|
||||
}
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.host(host)
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("org.openapitools.codegen.online.api"))
|
||||
.build()
|
||||
|
@ -306,4 +306,6 @@ public class CodegenConstants {
|
||||
public static final String SNAPSHOT_VERSION = "snapshotVersion";
|
||||
public static final String SNAPSHOT_VERSION_DESC = "Uses a SNAPSHOT version.";
|
||||
|
||||
public static final String EXCEPTION_ON_FAILURE = "returnExceptionOnFailure";
|
||||
public static final String EXCEPTION_ON_FAILURE_DESC = "Throw an exception on non success response codes";
|
||||
}
|
||||
|
@ -1475,7 +1475,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* @param schema
|
||||
* @return type
|
||||
*/
|
||||
private static String getPrimitiveType(Schema schema) {
|
||||
private String getPrimitiveType(Schema schema) {
|
||||
if (schema == null) {
|
||||
throw new RuntimeException("schema cannot be null in getPrimitiveType");
|
||||
} else if (ModelUtils.isStringSchema(schema) && "number".equals(schema.getFormat())) {
|
||||
@ -1519,6 +1519,13 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
} else if (ModelUtils.isURISchema(schema)) {
|
||||
return "URI";
|
||||
} else if (ModelUtils.isStringSchema(schema)) {
|
||||
if(typeMapping.containsKey(schema.getFormat())) {
|
||||
// If the format matches a typeMapping (supplied with the --typeMappings flag)
|
||||
// then treat the format as a primitive type.
|
||||
// This allows the typeMapping flag to add a new custom type which can then
|
||||
// be used in the format field.
|
||||
return schema.getFormat();
|
||||
}
|
||||
return "string";
|
||||
} else if (ModelUtils.isFreeFormObject(schema)) {
|
||||
return "object";
|
||||
@ -1860,8 +1867,10 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
discriminator.setMapping(schema.getDiscriminator().getMapping());
|
||||
if (schema.getDiscriminator().getMapping() != null && !schema.getDiscriminator().getMapping().isEmpty()) {
|
||||
for (Entry<String, String> e : schema.getDiscriminator().getMapping().entrySet()) {
|
||||
String name = toModelName(ModelUtils.getSimpleRef(e.getValue())); // e.g e.getValue => #/components/schemas/Dog
|
||||
discriminator.getMappedModels().add(new MappedModel(e.getKey(), name));
|
||||
String nameOrRef = e.getValue();
|
||||
String name = nameOrRef.indexOf('/') >= 0 ? ModelUtils.getSimpleRef(nameOrRef) : nameOrRef;
|
||||
String modelName = toModelName(name);
|
||||
discriminator.getMappedModels().add(new MappedModel(e.getKey(), modelName));
|
||||
}
|
||||
} else {
|
||||
Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI);
|
||||
@ -3668,7 +3677,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* @param schemas The complete set of model definitions (schemas).
|
||||
* @return A mapping from model name to type alias
|
||||
*/
|
||||
static Map<String, String> getAllAliases(Map<String, Schema> schemas) {
|
||||
Map<String, String> getAllAliases(Map<String, Schema> schemas) {
|
||||
if (schemas == null || schemas.isEmpty()) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
@ -446,7 +446,9 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
op.path = ("\"" + path + "\"").replaceAll(" \\+\\+ \"\"", "");
|
||||
} else {
|
||||
final List<String> paths = Arrays.asList(op.path.substring(1).split("/"));
|
||||
String path = paths.stream().map(str -> str.charAt(0) == '{' ? str : "\"" + str + "\"").collect(Collectors.joining(", "));
|
||||
String path = paths.stream()
|
||||
.map(str -> str.startsWith("{") && str.endsWith("}") ? str : "\"" + str + "\"")
|
||||
.collect(Collectors.joining(", "));
|
||||
for (CodegenParameter param : op.pathParams) {
|
||||
String str = paramToString("params", param, false, null);
|
||||
path = path.replace("{" + param.paramName + "}", str);
|
||||
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://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.languages;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class GoClientExperimentalCodegen extends GoClientCodegen {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GoClientExperimentalCodegen.class);
|
||||
|
||||
public GoClientExperimentalCodegen() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures a friendly name for the generator. This will be used by the generator
|
||||
* to select the library with the -g flag.
|
||||
*
|
||||
* @return the friendly name for the generator
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "go-experimental";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns human-friendly help for the generator. Provide the consumer with help
|
||||
* tips, parameters here
|
||||
*
|
||||
* @return A string value for the help message
|
||||
*/
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a Go client library (experimental and may subject to breaking changes without further notice).";
|
||||
}
|
||||
|
||||
}
|
@ -411,6 +411,11 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
for (CodegenParameter param : pathParams) {
|
||||
captureTypes.put(param.baseName, param.dataType);
|
||||
}
|
||||
|
||||
// Properly handle root-only routes (#3256)
|
||||
if (path.contentEquals("/")) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
// Cut off the leading slash, if it is present.
|
||||
if (path.startsWith("/")) {
|
||||
|
@ -138,7 +138,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
supportedLibraries.put(RESTEASY, "HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.8.x");
|
||||
supportedLibraries.put(VERTX, "HTTP client: VertX client 3.x. JSON processing: Jackson 2.8.x");
|
||||
supportedLibraries.put(GOOGLE_API_CLIENT, "HTTP client: Google API client 1.x. JSON processing: Jackson 2.8.x");
|
||||
supportedLibraries.put(REST_ASSURED, "HTTP client: rest-assured : 3.x. JSON processing: Gson 2.x. Only for Java8");
|
||||
supportedLibraries.put(REST_ASSURED, "HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x. Only for Java8");
|
||||
|
||||
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
|
||||
libraryOption.setEnum(supportedLibraries);
|
||||
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://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.languages;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PythonClientExperimentalCodegen.class);
|
||||
|
||||
public PythonClientExperimentalCodegen() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures a friendly name for the generator. This will be used by the
|
||||
* generator to select the library with the -g flag.
|
||||
*
|
||||
* @return the friendly name for the generator
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "python-experimental";
|
||||
}
|
||||
}
|
@ -42,6 +42,18 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String apiDocPath = "docs/";
|
||||
protected String modelDocPath = "docs/";
|
||||
protected String testFolder = "tests/testthat";
|
||||
protected boolean returnExceptionOnFailure = false;
|
||||
protected String exceptionPackage = "default";
|
||||
protected Map<String, String> exceptionPackages = new LinkedHashMap<String, String>();
|
||||
|
||||
public static final String EXCEPTION_PACKAGE = "exceptionPackage";
|
||||
public static final String USE_DEFAULT_EXCEPTION = "useDefaultExceptionHandling";
|
||||
public static final String USE_RLANG_EXCEPTION = "useRlangExceptionHandling";
|
||||
public static final String DEFAULT = "default";
|
||||
public static final String RLANG = "rlang";
|
||||
|
||||
protected boolean useDefaultExceptionHandling = false;
|
||||
protected boolean useRlangExceptionHandling = false;
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
@ -114,7 +126,16 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
.defaultValue("1.0.0"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC)
|
||||
.defaultValue(Boolean.TRUE.toString()));
|
||||
cliOptions.add(new CliOption(CodegenConstants.EXCEPTION_ON_FAILURE, CodegenConstants.EXCEPTION_ON_FAILURE_DESC)
|
||||
.defaultValue(Boolean.FALSE.toString()));
|
||||
|
||||
exceptionPackages.put(DEFAULT, "Use stop() for raising exceptions.");
|
||||
exceptionPackages.put(RLANG, "Use rlang package for exceptions.");
|
||||
|
||||
CliOption exceptionPackage = new CliOption(EXCEPTION_PACKAGE, "Specify the exception handling package");
|
||||
exceptionPackage.setEnum(exceptionPackages);
|
||||
exceptionPackage.setDefault(DEFAULT);
|
||||
cliOptions.add(exceptionPackage);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -133,8 +154,27 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
setPackageVersion("1.0.0");
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.EXCEPTION_ON_FAILURE)) {
|
||||
boolean booleanValue = Boolean.valueOf(additionalProperties.get(CodegenConstants.EXCEPTION_ON_FAILURE).toString());
|
||||
setReturnExceptionOnFailure(booleanValue);
|
||||
} else {
|
||||
setReturnExceptionOnFailure(false);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(EXCEPTION_PACKAGE)) {
|
||||
String exceptionPackage = additionalProperties.get(EXCEPTION_PACKAGE).toString();
|
||||
setExceptionPackageToUse(exceptionPackage);
|
||||
} else {
|
||||
setExceptionPackageToUse(DEFAULT);
|
||||
}
|
||||
|
||||
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
|
||||
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
|
||||
additionalProperties.put(CodegenConstants.EXCEPTION_ON_FAILURE, returnExceptionOnFailure);
|
||||
|
||||
additionalProperties.put(USE_DEFAULT_EXCEPTION, this.useDefaultExceptionHandling);
|
||||
additionalProperties.put(USE_RLANG_EXCEPTION, this.useRlangExceptionHandling);
|
||||
|
||||
|
||||
additionalProperties.put("apiDocPath", apiDocPath);
|
||||
additionalProperties.put("modelDocPath", modelDocPath);
|
||||
@ -384,6 +424,19 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
this.packageVersion = packageVersion;
|
||||
}
|
||||
|
||||
public void setReturnExceptionOnFailure(boolean returnExceptionOnFailure) {
|
||||
this.returnExceptionOnFailure = returnExceptionOnFailure;
|
||||
}
|
||||
|
||||
public void setExceptionPackageToUse(String exceptionPackage) {
|
||||
if(DEFAULT.equals(exceptionPackage))
|
||||
this.useDefaultExceptionHandling = true;
|
||||
if(RLANG.equals(exceptionPackage)){
|
||||
supportingFiles.add(new SupportingFile("api_exception.mustache", File.separator + "R", "api_exception.R"));
|
||||
this.useRlangExceptionHandling = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeQuotationMark(String input) {
|
||||
// remove " to avoid code injection
|
||||
|
@ -52,6 +52,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
public static final String DELEGATE_PATTERN = "delegatePattern";
|
||||
public static final String SINGLE_CONTENT_TYPES = "singleContentTypes";
|
||||
public static final String VIRTUAL_SERVICE = "virtualService";
|
||||
public static final String SKIP_DEFAULT_INTERFACE = "skipDefaultInterface";
|
||||
|
||||
public static final String JAVA_8 = "java8";
|
||||
public static final String ASYNC = "async";
|
||||
@ -66,6 +67,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
public static final String API_FIRST = "apiFirst";
|
||||
public static final String HATEOAS = "hateoas";
|
||||
public static final String RETURN_SUCCESS_CODE = "returnSuccessCode";
|
||||
public static final String UNHANDLED_EXCEPTION_HANDLING = "unhandledException";
|
||||
|
||||
protected String title = "OpenAPI Spring";
|
||||
protected String configPackage = "org.openapitools.configuration";
|
||||
@ -78,6 +80,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
protected boolean async = false;
|
||||
protected boolean reactive = false;
|
||||
protected String responseWrapper = "";
|
||||
protected boolean skipDefaultInterface = false;
|
||||
protected boolean useTags = false;
|
||||
protected boolean useBeanValidation = true;
|
||||
protected boolean performBeanValidation = false;
|
||||
@ -88,6 +91,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
protected boolean virtualService = false;
|
||||
protected boolean hateoas = false;
|
||||
protected boolean returnSuccessCode = false;
|
||||
protected boolean unhandledException = false;
|
||||
|
||||
public SpringCodegen() {
|
||||
super();
|
||||
@ -117,6 +121,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
cliOptions.add(CliOption.newBoolean(DELEGATE_PATTERN, "Whether to generate the server files using the delegate pattern", delegatePattern));
|
||||
cliOptions.add(CliOption.newBoolean(SINGLE_CONTENT_TYPES, "Whether to select only one produces/consumes content-type by operation.", singleContentTypes));
|
||||
updateJava8CliOptions();
|
||||
cliOptions.add(CliOption.newBoolean(SKIP_DEFAULT_INTERFACE, "Whether to generate default implementations for java8 interfaces", skipDefaultInterface));
|
||||
cliOptions.add(CliOption.newBoolean(ASYNC, "use async Callable controllers", async));
|
||||
cliOptions.add(CliOption.newBoolean(REACTIVE, "wrap responses in Mono/Flux Reactor types (spring-boot only)", reactive));
|
||||
cliOptions.add(new CliOption(RESPONSE_WRAPPER, "wrap the responses in given type (Future,Callable,CompletableFuture,ListenableFuture,DeferredResult,HystrixCommand,RxObservable,RxSingle or fully qualified type)"));
|
||||
@ -130,6 +135,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
cliOptions.add(CliOption.newBoolean(USE_OPTIONAL,"Use Optional container for optional parameters", useOptional));
|
||||
cliOptions.add(CliOption.newBoolean(HATEOAS, "Use Spring HATEOAS library to allow adding HATEOAS links", hateoas));
|
||||
cliOptions.add(CliOption.newBoolean(RETURN_SUCCESS_CODE, "Generated server returns 2xx code", returnSuccessCode));
|
||||
cliOptions.add(CliOption.newBoolean(UNHANDLED_EXCEPTION_HANDLING, "Declare operation methods to throw a generic exception and allow unhandled exceptions (useful for Spring `@ControllerAdvice` directives).", unhandledException));
|
||||
|
||||
supportedLibraries.put(SPRING_BOOT, "Spring-boot Server application using the SpringFox integration.");
|
||||
supportedLibraries.put(SPRING_MVC_LIBRARY, "Spring-MVC Server application using the SpringFox integration.");
|
||||
@ -231,6 +237,10 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
this.setSingleContentTypes(Boolean.valueOf(additionalProperties.get(SINGLE_CONTENT_TYPES).toString()));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(SKIP_DEFAULT_INTERFACE)) {
|
||||
this.setSkipDefaultInterface(Boolean.valueOf(additionalProperties.get(SKIP_DEFAULT_INTERFACE).toString()));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(ASYNC)) {
|
||||
this.setAsync(Boolean.valueOf(additionalProperties.get(ASYNC).toString()));
|
||||
//fix for issue/1164
|
||||
@ -286,6 +296,12 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
this.setReturnSuccessCode(Boolean.valueOf(additionalProperties.get(RETURN_SUCCESS_CODE).toString()));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(UNHANDLED_EXCEPTION_HANDLING)) {
|
||||
this.setUnhandledException(Boolean.valueOf(additionalProperties.get(UNHANDLED_EXCEPTION_HANDLING).toString()));
|
||||
} else {
|
||||
additionalProperties.put(UNHANDLED_EXCEPTION_HANDLING, this.isUnhandledException());
|
||||
}
|
||||
|
||||
typeMapping.put("file", "Resource");
|
||||
importMapping.put("Resource", "org.springframework.core.io.Resource");
|
||||
|
||||
@ -384,6 +400,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
|
||||
if (this.java8) {
|
||||
additionalProperties.put("javaVersion", "1.8");
|
||||
additionalProperties.put("jdk8-default-interface", !this.skipDefaultInterface);
|
||||
if (!SPRING_CLOUD_LIBRARY.equals(library)) {
|
||||
additionalProperties.put("jdk8", true);
|
||||
}
|
||||
@ -405,6 +422,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
// Some well-known Spring or Spring-Cloud response wrappers
|
||||
if (isNotEmpty(this.responseWrapper)) {
|
||||
additionalProperties.put("jdk8", false);
|
||||
additionalProperties.put("jdk8-default-interface", false);
|
||||
switch (this.responseWrapper) {
|
||||
case "Future":
|
||||
case "Callable":
|
||||
@ -687,6 +705,10 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
return this.configPackage;
|
||||
}
|
||||
|
||||
public boolean isUnhandledException() {
|
||||
return unhandledException;
|
||||
}
|
||||
|
||||
public void setBasePackage(String basePackage) {
|
||||
this.basePackage = basePackage;
|
||||
}
|
||||
@ -703,6 +725,8 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
this.singleContentTypes = singleContentTypes;
|
||||
}
|
||||
|
||||
public void setSkipDefaultInterface(boolean skipDefaultInterface) { this.skipDefaultInterface = skipDefaultInterface; }
|
||||
|
||||
public void setJava8(boolean java8) { this.java8 = java8; }
|
||||
|
||||
public void setVirtualService(boolean virtualService) { this.virtualService = virtualService; }
|
||||
@ -737,6 +761,10 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
this.returnSuccessCode = returnSuccessCode;
|
||||
}
|
||||
|
||||
public void setUnhandledException(boolean unhandledException) {
|
||||
this.unhandledException = unhandledException;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
|
||||
super.postProcessModelProperty(model, property);
|
||||
|
@ -35,7 +35,6 @@ public class TypeScriptJqueryClientCodegen extends AbstractTypeScriptClientCodeg
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TypeScriptJqueryClientCodegen.class);
|
||||
|
||||
public static final String NPM_REPOSITORY = "npmRepository";
|
||||
public static final String SNAPSHOT = "snapshot";
|
||||
public static final String JQUERY_ALREADY_IMPORTED = "jqueryAlreadyImported";
|
||||
|
||||
protected String npmRepository = null;
|
||||
|
@ -173,23 +173,12 @@ public class ModelUtils {
|
||||
if (allOperations != null) {
|
||||
for (Operation operation : allOperations) {
|
||||
//Params:
|
||||
if (operation.getParameters() != null) {
|
||||
for (Parameter p : operation.getParameters()) {
|
||||
Parameter parameter = getReferencedParameter(openAPI, p);
|
||||
if (parameter.getSchema() != null) {
|
||||
visitSchema(openAPI, parameter.getSchema(), null, visitedSchemas, visitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
visitParameters(openAPI, operation.getParameters(), visitor, visitedSchemas);
|
||||
|
||||
//RequestBody:
|
||||
RequestBody requestBody = getReferencedRequestBody(openAPI, operation.getRequestBody());
|
||||
if (requestBody != null && requestBody.getContent() != null) {
|
||||
for (Entry<String, MediaType> e : requestBody.getContent().entrySet()) {
|
||||
if (e.getValue().getSchema() != null) {
|
||||
visitSchema(openAPI, e.getValue().getSchema(), e.getKey(), visitedSchemas, visitor);
|
||||
}
|
||||
}
|
||||
if (requestBody != null) {
|
||||
visitContent(openAPI, requestBody.getContent(), visitor, visitedSchemas);
|
||||
}
|
||||
|
||||
//Responses:
|
||||
@ -197,19 +186,14 @@ public class ModelUtils {
|
||||
for (ApiResponse r : operation.getResponses().values()) {
|
||||
ApiResponse apiResponse = getReferencedApiResponse(openAPI, r);
|
||||
if (apiResponse != null) {
|
||||
if (apiResponse.getContent() != null) {
|
||||
for (Entry<String, MediaType> e : apiResponse.getContent().entrySet()) {
|
||||
if (e.getValue().getSchema() != null) {
|
||||
visitSchema(openAPI, e.getValue().getSchema(), e.getKey(), visitedSchemas, visitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
visitContent(openAPI, apiResponse.getContent(), visitor, visitedSchemas);
|
||||
if (apiResponse.getHeaders() != null) {
|
||||
for (Entry<String, Header> e : apiResponse.getHeaders().entrySet()) {
|
||||
Header header = getReferencedHeader(openAPI, e.getValue());
|
||||
if (header.getSchema() != null) {
|
||||
visitSchema(openAPI, header.getSchema(), e.getKey(), visitedSchemas, visitor);
|
||||
}
|
||||
visitContent(openAPI, header.getContent(), visitor, visitedSchemas);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -229,6 +213,31 @@ public class ModelUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
//Params:
|
||||
visitParameters(openAPI, pathItem.getParameters(), visitor, visitedSchemas);
|
||||
}
|
||||
|
||||
private static void visitParameters(OpenAPI openAPI, List<Parameter> parameters, OpenAPISchemaVisitor visitor,
|
||||
List<String> visitedSchemas) {
|
||||
if (parameters != null) {
|
||||
for (Parameter p : parameters) {
|
||||
Parameter parameter = getReferencedParameter(openAPI, p);
|
||||
if (parameter.getSchema() != null) {
|
||||
visitSchema(openAPI, parameter.getSchema(), null, visitedSchemas, visitor);
|
||||
}
|
||||
visitContent(openAPI, parameter.getContent(), visitor, visitedSchemas);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void visitContent(OpenAPI openAPI, Content content, OpenAPISchemaVisitor visitor, List<String> visitedSchemas) {
|
||||
if (content != null) {
|
||||
for (Entry<String, MediaType> e : content.entrySet()) {
|
||||
if (e.getValue().getSchema() != null) {
|
||||
visitSchema(openAPI, e.getValue().getSchema(), e.getKey(), visitedSchemas, visitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void visitSchema(OpenAPI openAPI, Schema schema, String mimeType, List<String> visitedSchemas, OpenAPISchemaVisitor visitor) {
|
||||
|
@ -161,3 +161,7 @@ dependencies {
|
||||
{{/java8}}
|
||||
testCompile "junit:junit:$junit_version"
|
||||
}
|
||||
|
||||
javadoc {
|
||||
options.tags = [ "http.response.details:a:Http Response Details" ]
|
||||
}
|
||||
|
@ -170,17 +170,17 @@
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<tags>
|
||||
<tag>
|
||||
<name>http.response.details</name>
|
||||
<placement>a</placement>
|
||||
<head>Http Response Details:</head>
|
||||
</tag>
|
||||
</tags>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<tags>
|
||||
<tag>
|
||||
<name>http.response.details</name>
|
||||
<placement>a</placement>
|
||||
<head>Http Response Details:</head>
|
||||
</tag>
|
||||
</tags>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
@ -143,3 +143,7 @@ dependencies {
|
||||
{{/threetenbp}}
|
||||
testCompile 'junit:junit:4.12'
|
||||
}
|
||||
|
||||
javadoc {
|
||||
options.tags = [ "http.response.details:a:Http Response Details" ]
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ lazy val root = (project in file(".")).
|
||||
"org.threeten" % "threetenbp" % "1.3.5" % "compile",
|
||||
{{/threetenbp}}
|
||||
"io.gsonfire" % "gson-fire" % "1.8.3" % "compile",
|
||||
"javax.annotation" % "jsr250-api" % "1.0" % "compile",
|
||||
"junit" % "junit" % "4.12" % "test",
|
||||
"com.novocode" % "junit-interface" % "0.10" % "test"
|
||||
)
|
||||
|
@ -149,17 +149,17 @@
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<tags>
|
||||
<tag>
|
||||
<name>http.response.details</name>
|
||||
<placement>a</placement>
|
||||
<head>Http Response Details:</head>
|
||||
</tag>
|
||||
</tags>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<tags>
|
||||
<tag>
|
||||
<name>http.response.details</name>
|
||||
<placement>a</placement>
|
||||
<head>Http Response Details:</head>
|
||||
</tag>
|
||||
</tags>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@ -284,6 +284,11 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
{{/parcelableModel}}
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>jsr250-api</artifactId>
|
||||
<version>${javax-annotation-version}</version>
|
||||
</dependency>
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
@ -297,7 +302,7 @@
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<gson-fire-version>1.8.3</gson-fire-version>
|
||||
<swagger-core-version>1.5.21</swagger-core-version>
|
||||
<swagger-core-version>1.5.22</swagger-core-version>
|
||||
<okhttp-version>3.14.2</okhttp-version>
|
||||
<gson-version>2.8.5</gson-version>
|
||||
<commons-lang3-version>3.9</commons-lang3-version>
|
||||
@ -308,6 +313,7 @@
|
||||
<threetenbp-version>1.3.8</threetenbp-version>
|
||||
{{/threetenbp}}
|
||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||
<javax-annotation-version>1.0</javax-annotation-version>
|
||||
<junit-version>4.12</junit-version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
@ -96,7 +96,7 @@ if(hasProperty('target') && target == 'android') {
|
||||
|
||||
ext {
|
||||
swagger_annotations_version = "1.5.21"
|
||||
rest_assured_version = "3.3.0"
|
||||
rest_assured_version = "4.0.0"
|
||||
junit_version = "4.12"
|
||||
gson_version = "2.8.5"
|
||||
gson_fire_version = "1.8.3"
|
||||
|
@ -10,7 +10,7 @@ lazy val root = (project in file(".")).
|
||||
resolvers += Resolver.mavenLocal,
|
||||
libraryDependencies ++= Seq(
|
||||
"io.swagger" % "swagger-annotations" % "1.5.21",
|
||||
"io.rest-assured" % "scala-support" % "3.3.0",
|
||||
"io.rest-assured" % "scala-support" % "4.0.0",
|
||||
"com.google.code.gson" % "gson" % "2.8.5",
|
||||
"io.gsonfire" % "gson-fire" % "1.8.3" % "compile",
|
||||
{{#joda}}
|
||||
|
@ -251,7 +251,7 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<swagger-annotations-version>1.5.21</swagger-annotations-version>
|
||||
<rest-assured.version>3.3.0</rest-assured.version>
|
||||
<rest-assured.version>4.0.0</rest-assured.version>
|
||||
<gson-version>2.8.5</gson-version>
|
||||
<gson-fire-version>1.8.3</gson-fire-version>
|
||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||
|
@ -1,17 +1,22 @@
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
#
|
||||
# Ref: https://docs.travis-ci.com/user/languages/java/
|
||||
#
|
||||
language: java
|
||||
jdk:
|
||||
- oraclejdk8
|
||||
- oraclejdk7
|
||||
- openjdk12
|
||||
- openjdk11
|
||||
- openjdk10
|
||||
- openjdk9
|
||||
- openjdk8
|
||||
before_install:
|
||||
# ensure gradlew has proper permission
|
||||
- chmod a+x ./gradlew
|
||||
script:
|
||||
# test using maven
|
||||
- mvn test
|
||||
# uncomment below to test using gradle
|
||||
# - gradle test
|
||||
# uncomment below to test using sbt
|
||||
#- mvn test
|
||||
# test using gradle
|
||||
- gradle test
|
||||
# test using sbt
|
||||
# - sbt test
|
||||
|
@ -66,7 +66,7 @@ import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture
|
||||
@VirtualService
|
||||
{{/virtualService}}
|
||||
public interface {{classname}} {
|
||||
{{#jdk8}}
|
||||
{{#jdk8-default-interface}}
|
||||
{{^isDelegate}}
|
||||
{{^reactive}}
|
||||
|
||||
@ -81,7 +81,7 @@ public interface {{classname}} {
|
||||
return new {{classname}}Delegate() {};
|
||||
}
|
||||
{{/isDelegate}}
|
||||
{{/jdk8}}
|
||||
{{/jdk8-default-interface}}
|
||||
{{#operation}}
|
||||
|
||||
{{#virtualService}}
|
||||
@ -109,13 +109,13 @@ public interface {{classname}} {
|
||||
produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}}
|
||||
consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}}
|
||||
method = RequestMethod.{{httpMethod}})
|
||||
{{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{#delegate-method}}_{{/delegate-method}}{{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{^hasMore}}{{#reactive}}, {{/reactive}}{{/hasMore}}{{/allParams}}{{#reactive}}ServerWebExchange exchange{{/reactive}}){{^jdk8}};{{/jdk8}}{{#jdk8}} {
|
||||
{{#jdk8-default-interface}}default {{/jdk8-default-interface}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{#delegate-method}}_{{/delegate-method}}{{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{^hasMore}}{{#reactive}}, {{/reactive}}{{/hasMore}}{{/allParams}}{{#reactive}}ServerWebExchange exchange{{/reactive}}){{^jdk8-default-interface}};{{/jdk8-default-interface}}{{#jdk8-default-interface}}{{#unhandledException}} throws Exception{{/unhandledException}} {
|
||||
{{#delegate-method}}
|
||||
return {{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}exchange{{/reactive}});
|
||||
}
|
||||
|
||||
// Override this method
|
||||
{{#jdk8}}default {{/jdk8}} {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{#isBodyParam}}{{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isListContainer}}Mono{{/isListContainer}}{{#isListContainer}}Flux{{/isListContainer}}<{{{baseType}}}>{{/reactive}}{{/isBodyParam}}{{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}ServerWebExchange exchange{{/reactive}}) {
|
||||
{{#jdk8-default-interface}}default {{/jdk8-default-interface}} {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{#isBodyParam}}{{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isListContainer}}Mono{{/isListContainer}}{{#isListContainer}}Flux{{/isListContainer}}<{{{baseType}}}>{{/reactive}}{{/isBodyParam}}{{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}ServerWebExchange exchange{{/reactive}}) {
|
||||
{{/delegate-method}}
|
||||
{{^isDelegate}}
|
||||
{{>methodBody}}
|
||||
@ -123,8 +123,8 @@ public interface {{classname}} {
|
||||
{{#isDelegate}}
|
||||
return getDelegate().{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}exchange{{/reactive}});
|
||||
{{/isDelegate}}
|
||||
}{{/jdk8}}
|
||||
}{{/jdk8-default-interface}}
|
||||
|
||||
{{/operation}}
|
||||
}
|
||||
{{/operations}}
|
||||
{{/operations}}
|
||||
|
@ -39,22 +39,22 @@ import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
public interface {{classname}}Delegate {
|
||||
{{#jdk8}}
|
||||
{{#jdk8-default-interface}}
|
||||
|
||||
default Optional<NativeWebRequest> getRequest() {
|
||||
return Optional.empty();
|
||||
}
|
||||
{{/jdk8}}
|
||||
{{/jdk8-default-interface}}
|
||||
|
||||
{{#operation}}
|
||||
/**
|
||||
* @see {{classname}}#{{operationId}}
|
||||
*/
|
||||
{{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{#isBodyParam}}{{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isListContainer}}Mono{{/isListContainer}}{{#isListContainer}}Flux{{/isListContainer}}<{{{baseType}}}>{{/reactive}}{{/isBodyParam}}{{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}},
|
||||
{{#jdk8-default-interface}}default {{/jdk8-default-interface}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{#isBodyParam}}{{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isListContainer}}Mono{{/isListContainer}}{{#isListContainer}}Flux{{/isListContainer}}<{{{baseType}}}>{{/reactive}}{{/isBodyParam}}{{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}},
|
||||
{{/hasMore}}{{/allParams}}{{#reactive}}{{#hasParams}},
|
||||
{{/hasParams}}ServerWebExchange exchange{{/reactive}}){{^jdk8}};{{/jdk8}}{{#jdk8}} {
|
||||
{{/hasParams}}ServerWebExchange exchange{{/reactive}}){{^jdk8-default-interface}};{{/jdk8-default-interface}}{{#jdk8-default-interface}} {
|
||||
{{>methodBody}}
|
||||
}{{/jdk8}}
|
||||
}{{/jdk8-default-interface}}
|
||||
|
||||
{{/operation}}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@
|
||||
"@babel/plugin-transform-flow-strip-types": "^7.0.0",
|
||||
"@babel/preset-flow": "^7.0.0",
|
||||
"babel-preset-react-app": "^7.0.0",
|
||||
"flow-copy-source": "^1.3.0",
|
||||
"flow-copy-source": "^2.0.0",
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ org.openapitools.codegen.languages.ErlangProperCodegen
|
||||
org.openapitools.codegen.languages.ErlangServerCodegen
|
||||
org.openapitools.codegen.languages.FlashClientCodegen
|
||||
org.openapitools.codegen.languages.GoClientCodegen
|
||||
org.openapitools.codegen.languages.GoClientExperimentalCodegen
|
||||
org.openapitools.codegen.languages.GoServerCodegen
|
||||
org.openapitools.codegen.languages.GoGinServerCodegen
|
||||
org.openapitools.codegen.languages.GraphQLSchemaCodegen
|
||||
@ -73,6 +74,7 @@ org.openapitools.codegen.languages.PhpSymfonyServerCodegen
|
||||
org.openapitools.codegen.languages.PhpZendExpressivePathHandlerServerCodegen
|
||||
org.openapitools.codegen.languages.PowerShellClientCodegen
|
||||
org.openapitools.codegen.languages.PythonClientCodegen
|
||||
org.openapitools.codegen.languages.PythonClientExperimentalCodegen
|
||||
org.openapitools.codegen.languages.PythonFlaskConnexionServerCodegen
|
||||
org.openapitools.codegen.languages.PythonAiohttpConnexionServerCodegen
|
||||
org.openapitools.codegen.languages.PythonBluePlanetServerCodegen
|
||||
|
@ -21,7 +21,7 @@ import 'package:jaguar_mimetype/jaguar_mimetype.dart';
|
||||
final _jsonJaguarRepo = JsonRepo()
|
||||
{{#models}}{{#model}}..add({{classname}}Serializer())
|
||||
{{/model}}{{/models}};
|
||||
final Map<String, CodecRepo> _converters = {
|
||||
final Map<String, CodecRepo> converters = {
|
||||
MimeTypes.json: _jsonJaguarRepo,
|
||||
};
|
||||
{{/jsonFormat}}
|
||||
@ -33,7 +33,7 @@ final _protoJaguarRepo = ProtoCodecRepo()
|
||||
final _jsonJaguarRepo = ProtoCodecRepo(isJsonFormatEnabled: true)
|
||||
{{#models}}{{#model}}..add((data) => {{classname}}.fromBuffer(List<int>.from(data)))
|
||||
{{/model}}{{/models}};
|
||||
final Map<String, CodecRepo> _converters = {
|
||||
final Map<String, CodecRepo> converters = {
|
||||
MimeTypes.json: _jsonJaguarRepo,
|
||||
MimeTypes.binary: _protoJaguarRepo,
|
||||
};
|
||||
@ -91,7 +91,7 @@ class JaguarApiGen {
|
||||
base = _baseRoute;
|
||||
}
|
||||
if(converters == null) {
|
||||
converters = _converters;
|
||||
converters = this.converters;
|
||||
}
|
||||
return {{classname}}(base: base, converters: converters, timeout: timeout);
|
||||
}
|
||||
|
@ -0,0 +1,8 @@
|
||||
language: go
|
||||
|
||||
install:
|
||||
- go get -d -v .
|
||||
|
||||
script:
|
||||
- go build -v ./
|
||||
|
119
modules/openapi-generator/src/main/resources/go-experimental/README.mustache
vendored
Normal file
119
modules/openapi-generator/src/main/resources/go-experimental/README.mustache
vendored
Normal file
@ -0,0 +1,119 @@
|
||||
# Go API client for {{packageName}}
|
||||
|
||||
{{#appDescription}}
|
||||
{{{appDescription}}}
|
||||
{{/appDescription}}
|
||||
|
||||
## Overview
|
||||
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client.
|
||||
|
||||
- API version: {{appVersion}}
|
||||
- Package version: {{packageVersion}}
|
||||
{{^hideGenerationTimestamp}}
|
||||
- Build date: {{generatedDate}}
|
||||
{{/hideGenerationTimestamp}}
|
||||
- Build package: {{generatorClass}}
|
||||
{{#infoUrl}}
|
||||
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
||||
{{/infoUrl}}
|
||||
|
||||
## Installation
|
||||
|
||||
Install the following dependencies:
|
||||
|
||||
```shell
|
||||
go get github.com/stretchr/testify/assert
|
||||
go get golang.org/x/oauth2
|
||||
go get golang.org/x/net/context
|
||||
go get github.com/antihax/optional
|
||||
```
|
||||
|
||||
Put the package under your project folder and add the following in import:
|
||||
|
||||
```golang
|
||||
import "./{{packageName}}"
|
||||
```
|
||||
|
||||
## Documentation for API Endpoints
|
||||
|
||||
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}}
|
||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
|
||||
## Documentation For Models
|
||||
|
||||
{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
|
||||
{{/model}}{{/models}}
|
||||
|
||||
## Documentation For Authorization
|
||||
|
||||
{{^authMethods}} Endpoints do not require authorization.
|
||||
{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}}
|
||||
{{#authMethods}}
|
||||
|
||||
## {{{name}}}
|
||||
|
||||
{{#isApiKey}}- **Type**: API key
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{
|
||||
Key: "APIKEY",
|
||||
Prefix: "Bearer", // Omit if not necessary.
|
||||
})
|
||||
r, err := client.Service.Operation(auth, args)
|
||||
```
|
||||
|
||||
{{/isApiKey}}
|
||||
{{#isBasic}}- **Type**: HTTP basic authentication
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{
|
||||
UserName: "username",
|
||||
Password: "password",
|
||||
})
|
||||
r, err := client.Service.Operation(auth, args)
|
||||
```
|
||||
|
||||
{{/isBasic}}
|
||||
{{#isOAuth}}
|
||||
|
||||
- **Type**: OAuth
|
||||
- **Flow**: {{{flow}}}
|
||||
- **Authorization URL**: {{{authorizationUrl}}}
|
||||
- **Scopes**: {{^scopes}}N/A{{/scopes}}
|
||||
{{#scopes}} - **{{{scope}}}**: {{{description}}}
|
||||
{{/scopes}}
|
||||
|
||||
Example
|
||||
|
||||
```golang
|
||||
auth := context.WithValue(context.Background(), sw.ContextAccessToken, "ACCESSTOKENSTRING")
|
||||
r, err := client.Service.Operation(auth, args)
|
||||
```
|
||||
|
||||
Or via OAuth2 module to automatically refresh tokens and perform user authentication.
|
||||
|
||||
```golang
|
||||
import "golang.org/x/oauth2"
|
||||
|
||||
/* Perform OAuth2 round trip request and obtain a token */
|
||||
|
||||
tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
|
||||
auth := context.WithValue(oauth2.NoContext, sw.ContextOAuth2, tokenSource)
|
||||
r, err := client.Service.Operation(auth, args)
|
||||
```
|
||||
|
||||
{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
|
||||
## Author
|
||||
|
||||
{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}}
|
||||
{{/hasMore}}{{/apis}}{{/apiInfo}}
|
322
modules/openapi-generator/src/main/resources/go-experimental/api.mustache
vendored
Normal file
322
modules/openapi-generator/src/main/resources/go-experimental/api.mustache
vendored
Normal file
@ -0,0 +1,322 @@
|
||||
{{>partial_header}}
|
||||
package {{packageName}}
|
||||
|
||||
{{#operations}}
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
{{#imports}} "{{import}}"
|
||||
{{/imports}}
|
||||
)
|
||||
|
||||
// Linger please
|
||||
var (
|
||||
_ context.Context
|
||||
)
|
||||
|
||||
type {{classname}}Service service
|
||||
{{#operation}}
|
||||
|
||||
/*
|
||||
{{{classname}}}Service{{#summary}} {{{.}}}{{/summary}}
|
||||
{{#notes}}
|
||||
{{notes}}
|
||||
{{/notes}}
|
||||
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||
{{#allParams}}
|
||||
{{#required}}
|
||||
* @param {{paramName}}{{#description}} {{{.}}}{{/description}}
|
||||
{{/required}}
|
||||
{{/allParams}}
|
||||
{{#hasOptionalParams}}
|
||||
* @param optional nil or *{{{nickname}}}Opts - Optional Parameters:
|
||||
{{#allParams}}
|
||||
{{^required}}
|
||||
* @param "{{vendorExtensions.x-exportParamName}}" ({{#isPrimitiveType}}{{^isBinary}}optional.{{vendorExtensions.x-optionalDataType}}{{/isBinary}}{{#isBinary}}optional.Interface of {{dataType}}{{/isBinary}}{{/isPrimitiveType}}{{^isPrimitiveType}}optional.Interface of {{dataType}}{{/isPrimitiveType}}) - {{#description}} {{{.}}}{{/description}}
|
||||
{{/required}}
|
||||
{{/allParams}}
|
||||
{{/hasOptionalParams}}
|
||||
{{#returnType}}
|
||||
@return {{{returnType}}}
|
||||
{{/returnType}}
|
||||
*/
|
||||
{{#hasOptionalParams}}
|
||||
|
||||
type {{{nickname}}}Opts struct {
|
||||
{{#allParams}}
|
||||
{{^required}}
|
||||
{{#isPrimitiveType}}
|
||||
{{^isBinary}}
|
||||
{{vendorExtensions.x-exportParamName}} optional.{{vendorExtensions.x-optionalDataType}}
|
||||
{{/isBinary}}
|
||||
{{#isBinary}}
|
||||
{{vendorExtensions.x-exportParamName}} optional.Interface
|
||||
{{/isBinary}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
{{vendorExtensions.x-exportParamName}} optional.Interface
|
||||
{{/isPrimitiveType}}
|
||||
{{/required}}
|
||||
{{/allParams}}
|
||||
}
|
||||
|
||||
{{/hasOptionalParams}}
|
||||
func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}}, {{/hasParams}}{{#allParams}}{{#required}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}localVarOptionals *{{{nickname}}}Opts{{/hasOptionalParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}*http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = http.Method{{httpMethod}}
|
||||
localVarPostBody interface{}
|
||||
localVarFormFileName string
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
{{#returnType}}
|
||||
localVarReturnValue {{{returnType}}}
|
||||
{{/returnType}}
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "{{{path}}}"{{#pathParams}}
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"{{baseName}}"+"}", fmt.Sprintf("%v", {{paramName}}), -1){{/pathParams}}
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
{{#allParams}}
|
||||
{{#required}}
|
||||
{{#minItems}}
|
||||
if len({{paramName}}) < {{minItems}} {
|
||||
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must have at least {{minItems}} elements")
|
||||
}
|
||||
{{/minItems}}
|
||||
{{#maxItems}}
|
||||
if len({{paramName}}) > {{maxItems}} {
|
||||
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must have less than {{maxItems}} elements")
|
||||
}
|
||||
{{/maxItems}}
|
||||
{{#minLength}}
|
||||
if strlen({{paramName}}) < {{minLength}} {
|
||||
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must have at least {{minLength}} elements")
|
||||
}
|
||||
{{/minLength}}
|
||||
{{#maxLength}}
|
||||
if strlen({{paramName}}) > {{maxLength}} {
|
||||
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must have less than {{maxLength}} elements")
|
||||
}
|
||||
{{/maxLength}}
|
||||
{{#minimum}}
|
||||
{{#isString}}
|
||||
{{paramName}}Txt, err := atoi({{paramName}})
|
||||
if {{paramName}}Txt < {{minimum}} {
|
||||
{{/isString}}
|
||||
{{^isString}}
|
||||
if {{paramName}} < {{minimum}} {
|
||||
{{/isString}}
|
||||
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must be greater than {{minimum}}")
|
||||
}
|
||||
{{/minimum}}
|
||||
{{#maximum}}
|
||||
{{#isString}}
|
||||
{{paramName}}Txt, err := atoi({{paramName}})
|
||||
if {{paramName}}Txt > {{maximum}} {
|
||||
{{/isString}}
|
||||
{{^isString}}
|
||||
if {{paramName}} > {{maximum}} {
|
||||
{{/isString}}
|
||||
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must be less than {{maximum}}")
|
||||
}
|
||||
{{/maximum}}
|
||||
{{/required}}
|
||||
{{/allParams}}
|
||||
|
||||
{{#hasQueryParams}}
|
||||
{{#queryParams}}
|
||||
{{#required}}
|
||||
localVarQueryParams.Add("{{baseName}}", parameterToString({{paramName}}, "{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}"))
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if localVarOptionals != nil && localVarOptionals.{{vendorExtensions.x-exportParamName}}.IsSet() {
|
||||
localVarQueryParams.Add("{{baseName}}", parameterToString(localVarOptionals.{{vendorExtensions.x-exportParamName}}.Value(), "{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}"))
|
||||
}
|
||||
{{/required}}
|
||||
{{/queryParams}}
|
||||
{{/hasQueryParams}}
|
||||
// to determine the Content-Type header
|
||||
{{=<% %>=}}
|
||||
localVarHttpContentTypes := []string{<%#consumes%>"<%&mediaType%>"<%^-last%>, <%/-last%><%/consumes%>}
|
||||
<%={{ }}=%>
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
{{=<% %>=}}
|
||||
localVarHttpHeaderAccepts := []string{<%#produces%>"<%&mediaType%>"<%^-last%>, <%/-last%><%/produces%>}
|
||||
<%={{ }}=%>
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
{{#hasHeaderParams}}
|
||||
{{#headerParams}}
|
||||
{{#required}}
|
||||
localVarHeaderParams["{{baseName}}"] = parameterToString({{paramName}}, "{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}")
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if localVarOptionals != nil && localVarOptionals.{{vendorExtensions.x-exportParamName}}.IsSet() {
|
||||
localVarHeaderParams["{{baseName}}"] = parameterToString(localVarOptionals.{{vendorExtensions.x-exportParamName}}.Value(), "{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}")
|
||||
}
|
||||
{{/required}}
|
||||
{{/headerParams}}
|
||||
{{/hasHeaderParams}}
|
||||
{{#hasFormParams}}
|
||||
{{#formParams}}
|
||||
{{#isFile}}
|
||||
localVarFormFileName = "{{baseName}}"
|
||||
{{#required}}
|
||||
localVarFile := {{paramName}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
var localVarFile {{dataType}}
|
||||
if localVarOptionals != nil && localVarOptionals.{{vendorExtensions.x-exportParamName}}.IsSet() {
|
||||
localVarFileOk := false
|
||||
localVarFile, localVarFileOk = localVarOptionals.{{vendorExtensions.x-exportParamName}}.Value().({{dataType}})
|
||||
if !localVarFileOk {
|
||||
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} should be {{dataType}}")
|
||||
}
|
||||
}
|
||||
{{/required}}
|
||||
if localVarFile != nil {
|
||||
fbs, _ := ioutil.ReadAll(localVarFile)
|
||||
localVarFileBytes = fbs
|
||||
localVarFileName = localVarFile.Name()
|
||||
localVarFile.Close()
|
||||
}
|
||||
{{/isFile}}
|
||||
{{^isFile}}
|
||||
{{#required}}
|
||||
localVarFormParams.Add("{{baseName}}", parameterToString({{paramName}}, "{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}"))
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
{{#isModel}}
|
||||
if localVarOptionals != nil && localVarOptionals.{{vendorExtensions.x-exportParamName}}.IsSet() {
|
||||
paramJson, err := parameterToJson(localVarOptionals.{{vendorExtensions.x-exportParamName}}.Value())
|
||||
if err != nil {
|
||||
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, err
|
||||
}
|
||||
localVarFormParams.Add("{{baseName}}", paramJson)
|
||||
}
|
||||
{{/isModel}}
|
||||
{{^isModel}}
|
||||
if localVarOptionals != nil && localVarOptionals.{{vendorExtensions.x-exportParamName}}.IsSet() {
|
||||
localVarFormParams.Add("{{baseName}}", parameterToString(localVarOptionals.{{vendorExtensions.x-exportParamName}}.Value(), "{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}"))
|
||||
}
|
||||
{{/isModel}}
|
||||
{{/required}}
|
||||
{{/isFile}}
|
||||
{{/formParams}}
|
||||
{{/hasFormParams}}
|
||||
{{#hasBodyParam}}
|
||||
{{#bodyParams}}
|
||||
// body params
|
||||
{{#required}}
|
||||
localVarPostBody = &{{paramName}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if localVarOptionals != nil && localVarOptionals.{{vendorExtensions.x-exportParamName}}.IsSet() {
|
||||
{{#isPrimitiveType}}
|
||||
localVarPostBody = localVarOptionals.{{vendorExtensions.x-exportParamName}}.Value()
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
localVarOptional{{vendorExtensions.x-exportParamName}}, localVarOptional{{vendorExtensions.x-exportParamName}}ok := localVarOptionals.{{vendorExtensions.x-exportParamName}}.Value().({{{dataType}}})
|
||||
if !localVarOptional{{vendorExtensions.x-exportParamName}}ok {
|
||||
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} should be {{dataType}}")
|
||||
}
|
||||
localVarPostBody = &localVarOptional{{vendorExtensions.x-exportParamName}}
|
||||
{{/isPrimitiveType}}
|
||||
}
|
||||
|
||||
{{/required}}
|
||||
{{/bodyParams}}
|
||||
{{/hasBodyParam}}
|
||||
{{#authMethods}}
|
||||
{{#isApiKey}}
|
||||
{{^isKeyInCookie}}
|
||||
if ctx != nil {
|
||||
// API Key Authentication
|
||||
if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
|
||||
var key string
|
||||
if auth.Prefix != "" {
|
||||
key = auth.Prefix + " " + auth.Key
|
||||
} else {
|
||||
key = auth.Key
|
||||
}
|
||||
{{#isKeyInHeader}}
|
||||
localVarHeaderParams["{{keyParamName}}"] = key
|
||||
{{/isKeyInHeader}}
|
||||
{{#isKeyInQuery}}
|
||||
localVarQueryParams.Add("{{keyParamName}}", key)
|
||||
{{/isKeyInQuery}}
|
||||
}
|
||||
}
|
||||
{{/isKeyInCookie}}
|
||||
{{/isApiKey}}
|
||||
{{/authMethods}}
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, err
|
||||
}
|
||||
|
||||
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
localVarHttpResponse.Body.Close()
|
||||
if err != nil {
|
||||
return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, err
|
||||
}
|
||||
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
newErr := GenericOpenAPIError{
|
||||
body: localVarBody,
|
||||
error: localVarHttpResponse.Status,
|
||||
}
|
||||
{{#responses}}
|
||||
{{#dataType}}
|
||||
if localVarHttpResponse.StatusCode == {{{code}}} {
|
||||
var v {{{dataType}}}
|
||||
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
newErr.error = err.Error()
|
||||
return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, newErr
|
||||
}
|
||||
newErr.model = v
|
||||
return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHttpResponse, newErr
|
||||
}
|
||||
{{/dataType}}
|
||||
{{/responses}}
|
||||
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}}
|
||||
{{/operations}}
|
58
modules/openapi-generator/src/main/resources/go-experimental/api_doc.mustache
vendored
Normal file
58
modules/openapi-generator/src/main/resources/go-experimental/api_doc.mustache
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
# {{invokerPackage}}\{{classname}}{{#description}}
|
||||
|
||||
{{description}}{{/description}}
|
||||
|
||||
All URIs are relative to *{{basePath}}*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
|
||||
{{/operation}}{{/operations}}
|
||||
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
|
||||
## {{{operationId}}}
|
||||
|
||||
> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}(ctx, {{#allParams}}{{#required}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}optional{{/hasOptionalParams}})
|
||||
{{{summary}}}{{#notes}}
|
||||
|
||||
{{{notes}}}{{/notes}}
|
||||
|
||||
### Required Parameters
|
||||
|
||||
{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.{{/-last}}{{/allParams}}{{#allParams}}{{#required}}
|
||||
**{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}{{/required}}{{/allParams}}{{#hasOptionalParams}}
|
||||
**optional** | ***{{{nickname}}}Opts** | optional parameters | nil if no parameters
|
||||
|
||||
### Optional Parameters
|
||||
|
||||
Optional parameters are passed through a pointer to a {{{nickname}}}Opts struct
|
||||
{{#allParams}}{{#-last}}
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}{{#allParams}}
|
||||
{{^required}} **{{paramName}}** | {{#isFile}}**optional.Interface of {{dataType}}**{{/isFile}}{{#isPrimitiveType}}**optional.{{vendorExtensions.x-optionalDataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**optional.Interface of {{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}{{/required}}{{/allParams}}{{/hasOptionalParams}}
|
||||
|
||||
### Return type
|
||||
|
||||
{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}} (empty response body){{/returnType}}
|
||||
|
||||
### Authorization
|
||||
|
||||
{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}}
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
|
||||
- **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||
[[Back to Model list]](../README.md#documentation-for-models)
|
||||
[[Back to README]](../README.md)
|
||||
|
||||
{{/operation}}
|
||||
{{/operations}}
|
503
modules/openapi-generator/src/main/resources/go-experimental/client.mustache
vendored
Normal file
503
modules/openapi-generator/src/main/resources/go-experimental/client.mustache
vendored
Normal file
@ -0,0 +1,503 @@
|
||||
{{>partial_header}}
|
||||
package {{packageName}}
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
var (
|
||||
jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:vnd\.[^;]+\+)?json)`)
|
||||
xmlCheck = regexp.MustCompile(`(?i:(?:application|text)/xml)`)
|
||||
)
|
||||
|
||||
// APIClient manages communication with the {{appName}} API v{{version}}
|
||||
// In most cases there should be only one, shared, APIClient.
|
||||
type APIClient struct {
|
||||
cfg *Configuration
|
||||
common service // Reuse a single struct instead of allocating one for each service on the heap.
|
||||
|
||||
// API Services
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
|
||||
{{classname}} *{{classname}}Service
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *APIClient
|
||||
}
|
||||
|
||||
// NewAPIClient creates a new API client. Requires a userAgent string describing your application.
|
||||
// optionally a custom http.Client to allow for advanced features such as caching.
|
||||
func NewAPIClient(cfg *Configuration) *APIClient {
|
||||
if cfg.HTTPClient == nil {
|
||||
cfg.HTTPClient = http.DefaultClient
|
||||
}
|
||||
|
||||
c := &APIClient{}
|
||||
c.cfg = cfg
|
||||
c.common.client = c
|
||||
|
||||
{{#apiInfo}}
|
||||
// API Services
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
c.{{classname}} = (*{{classname}}Service)(&c.common)
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func atoi(in string) (int, error) {
|
||||
return strconv.Atoi(in)
|
||||
}
|
||||
|
||||
// selectHeaderContentType select a content type from the available list.
|
||||
func selectHeaderContentType(contentTypes []string) string {
|
||||
if len(contentTypes) == 0 {
|
||||
return ""
|
||||
}
|
||||
if contains(contentTypes, "application/json") {
|
||||
return "application/json"
|
||||
}
|
||||
return contentTypes[0] // use the first content type specified in 'consumes'
|
||||
}
|
||||
|
||||
// selectHeaderAccept join all accept types and return
|
||||
func selectHeaderAccept(accepts []string) string {
|
||||
if len(accepts) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
if contains(accepts, "application/json") {
|
||||
return "application/json"
|
||||
}
|
||||
|
||||
return strings.Join(accepts, ",")
|
||||
}
|
||||
|
||||
// contains is a case insenstive match, finding needle in a haystack
|
||||
func contains(haystack []string, needle string) bool {
|
||||
for _, a := range haystack {
|
||||
if strings.ToLower(a) == strings.ToLower(needle) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Verify optional parameters are of the correct type.
|
||||
func typeCheckParameter(obj interface{}, expected string, name string) error {
|
||||
// Make sure there is an object.
|
||||
if obj == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Check the type is as expected.
|
||||
if reflect.TypeOf(obj).String() != expected {
|
||||
return fmt.Errorf("Expected %s to be of type %s but received %s.", name, expected, reflect.TypeOf(obj).String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// parameterToString convert interface{} parameters to string, using a delimiter if format is provided.
|
||||
func parameterToString(obj interface{}, collectionFormat string) string {
|
||||
var delimiter string
|
||||
|
||||
switch collectionFormat {
|
||||
case "pipes":
|
||||
delimiter = "|"
|
||||
case "ssv":
|
||||
delimiter = " "
|
||||
case "tsv":
|
||||
delimiter = "\t"
|
||||
case "csv":
|
||||
delimiter = ","
|
||||
}
|
||||
|
||||
if reflect.TypeOf(obj).Kind() == reflect.Slice {
|
||||
return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]")
|
||||
} else if t, ok := obj.(time.Time); ok {
|
||||
return t.Format(time.RFC3339)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%v", obj)
|
||||
}
|
||||
|
||||
// helper for converting interface{} parameters to json strings
|
||||
func parameterToJson(obj interface{}) (string, error) {
|
||||
jsonBuf, err := json.Marshal(obj)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(jsonBuf), err
|
||||
}
|
||||
|
||||
|
||||
// callAPI do the request.
|
||||
func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) {
|
||||
return c.cfg.HTTPClient.Do(request)
|
||||
}
|
||||
|
||||
// Change base path to allow switching to mocks
|
||||
func (c *APIClient) ChangeBasePath(path string) {
|
||||
c.cfg.BasePath = path
|
||||
}
|
||||
|
||||
// prepareRequest build the request
|
||||
func (c *APIClient) prepareRequest(
|
||||
ctx context.Context,
|
||||
path string, method string,
|
||||
postBody interface{},
|
||||
headerParams map[string]string,
|
||||
queryParams url.Values,
|
||||
formParams url.Values,
|
||||
formFileName string,
|
||||
fileName string,
|
||||
fileBytes []byte) (localVarRequest *http.Request, err error) {
|
||||
|
||||
var body *bytes.Buffer
|
||||
|
||||
// Detect postBody type and post.
|
||||
if postBody != nil {
|
||||
contentType := headerParams["Content-Type"]
|
||||
if contentType == "" {
|
||||
contentType = detectContentType(postBody)
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
body, err = setBody(postBody, contentType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// add form parameters and file if available.
|
||||
if strings.HasPrefix(headerParams["Content-Type"], "multipart/form-data") && len(formParams) > 0 || (len(fileBytes) > 0 && fileName != "") {
|
||||
if body != nil {
|
||||
return nil, errors.New("Cannot specify postBody and multipart form at the same time.")
|
||||
}
|
||||
body = &bytes.Buffer{}
|
||||
w := multipart.NewWriter(body)
|
||||
|
||||
for k, v := range formParams {
|
||||
for _, iv := range v {
|
||||
if strings.HasPrefix(k, "@") { // file
|
||||
err = addFile(w, k[1:], iv)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else { // form value
|
||||
w.WriteField(k, iv)
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(fileBytes) > 0 && fileName != "" {
|
||||
w.Boundary()
|
||||
//_, fileNm := filepath.Split(fileName)
|
||||
part, err := w.CreateFormFile(formFileName, filepath.Base(fileName))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = part.Write(fileBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// Set the Boundary in the Content-Type
|
||||
headerParams["Content-Type"] = w.FormDataContentType()
|
||||
|
||||
// Set Content-Length
|
||||
headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len())
|
||||
w.Close()
|
||||
}
|
||||
|
||||
if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 {
|
||||
if body != nil {
|
||||
return nil, errors.New("Cannot specify postBody and x-www-form-urlencoded form at the same time.")
|
||||
}
|
||||
body = &bytes.Buffer{}
|
||||
body.WriteString(formParams.Encode())
|
||||
// Set Content-Length
|
||||
headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len())
|
||||
}
|
||||
|
||||
// Setup path and query parameters
|
||||
url, err := url.Parse(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Override request host, if applicable
|
||||
if c.cfg.Host != "" {
|
||||
url.Host = c.cfg.Host
|
||||
}
|
||||
|
||||
// Override request scheme, if applicable
|
||||
if c.cfg.Scheme != "" {
|
||||
url.Scheme = c.cfg.Scheme
|
||||
}
|
||||
|
||||
// Adding Query Param
|
||||
query := url.Query()
|
||||
for k, v := range queryParams {
|
||||
for _, iv := range v {
|
||||
query.Add(k, iv)
|
||||
}
|
||||
}
|
||||
|
||||
// Encode the parameters.
|
||||
url.RawQuery = query.Encode()
|
||||
|
||||
// Generate a new request
|
||||
if body != nil {
|
||||
localVarRequest, err = http.NewRequest(method, url.String(), body)
|
||||
} else {
|
||||
localVarRequest, err = http.NewRequest(method, url.String(), nil)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// add header parameters, if any
|
||||
if len(headerParams) > 0 {
|
||||
headers := http.Header{}
|
||||
for h, v := range headerParams {
|
||||
headers.Set(h, v)
|
||||
}
|
||||
localVarRequest.Header = headers
|
||||
}
|
||||
|
||||
// Add the user agent to the request.
|
||||
localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent)
|
||||
|
||||
if ctx != nil {
|
||||
// add context to the request
|
||||
localVarRequest = localVarRequest.WithContext(ctx)
|
||||
|
||||
// Walk through any authentication.
|
||||
|
||||
// OAuth2 authentication
|
||||
if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok {
|
||||
// We were able to grab an oauth2 token from the context
|
||||
var latestToken *oauth2.Token
|
||||
if latestToken, err = tok.Token(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
latestToken.SetAuthHeader(localVarRequest)
|
||||
}
|
||||
|
||||
// Basic HTTP Authentication
|
||||
if auth, ok := ctx.Value(ContextBasicAuth).(BasicAuth); ok {
|
||||
localVarRequest.SetBasicAuth(auth.UserName, auth.Password)
|
||||
}
|
||||
|
||||
// AccessToken Authentication
|
||||
if auth, ok := ctx.Value(ContextAccessToken).(string); ok {
|
||||
localVarRequest.Header.Add("Authorization", "Bearer "+auth)
|
||||
}
|
||||
}
|
||||
|
||||
for header, value := range c.cfg.DefaultHeader {
|
||||
localVarRequest.Header.Add(header, value)
|
||||
}
|
||||
|
||||
return localVarRequest, nil
|
||||
}
|
||||
|
||||
func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) {
|
||||
if s, ok := v.(*string); ok {
|
||||
*s = string(b)
|
||||
return nil
|
||||
}
|
||||
if xmlCheck.MatchString(contentType) {
|
||||
if err = xml.Unmarshal(b, v); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if jsonCheck.MatchString(contentType) {
|
||||
if err = json.Unmarshal(b, v); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return errors.New("undefined response type")
|
||||
}
|
||||
|
||||
// Add a file to the multipart request
|
||||
func addFile(w *multipart.Writer, fieldName, path string) error {
|
||||
file, err := os.Open(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
part, err := w.CreateFormFile(fieldName, filepath.Base(path))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = io.Copy(part, file)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// Prevent trying to import "fmt"
|
||||
func reportError(format string, a ...interface{}) error {
|
||||
return fmt.Errorf(format, a...)
|
||||
}
|
||||
|
||||
// Set request body from an interface{}
|
||||
func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) {
|
||||
if bodyBuf == nil {
|
||||
bodyBuf = &bytes.Buffer{}
|
||||
}
|
||||
|
||||
if reader, ok := body.(io.Reader); ok {
|
||||
_, err = bodyBuf.ReadFrom(reader)
|
||||
} else if b, ok := body.([]byte); ok {
|
||||
_, err = bodyBuf.Write(b)
|
||||
} else if s, ok := body.(string); ok {
|
||||
_, err = bodyBuf.WriteString(s)
|
||||
} else if s, ok := body.(*string); ok {
|
||||
_, err = bodyBuf.WriteString(*s)
|
||||
} else if jsonCheck.MatchString(contentType) {
|
||||
err = json.NewEncoder(bodyBuf).Encode(body)
|
||||
} else if xmlCheck.MatchString(contentType) {
|
||||
err = xml.NewEncoder(bodyBuf).Encode(body)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if bodyBuf.Len() == 0 {
|
||||
err = fmt.Errorf("Invalid body type %s\n", contentType)
|
||||
return nil, err
|
||||
}
|
||||
return bodyBuf, nil
|
||||
}
|
||||
|
||||
// detectContentType method is used to figure out `Request.Body` content type for request header
|
||||
func detectContentType(body interface{}) string {
|
||||
contentType := "text/plain; charset=utf-8"
|
||||
kind := reflect.TypeOf(body).Kind()
|
||||
|
||||
switch kind {
|
||||
case reflect.Struct, reflect.Map, reflect.Ptr:
|
||||
contentType = "application/json; charset=utf-8"
|
||||
case reflect.String:
|
||||
contentType = "text/plain; charset=utf-8"
|
||||
default:
|
||||
if b, ok := body.([]byte); ok {
|
||||
contentType = http.DetectContentType(b)
|
||||
} else if kind == reflect.Slice {
|
||||
contentType = "application/json; charset=utf-8"
|
||||
}
|
||||
}
|
||||
|
||||
return contentType
|
||||
}
|
||||
|
||||
// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go
|
||||
type cacheControl map[string]string
|
||||
|
||||
func parseCacheControl(headers http.Header) cacheControl {
|
||||
cc := cacheControl{}
|
||||
ccHeader := headers.Get("Cache-Control")
|
||||
for _, part := range strings.Split(ccHeader, ",") {
|
||||
part = strings.Trim(part, " ")
|
||||
if part == "" {
|
||||
continue
|
||||
}
|
||||
if strings.ContainsRune(part, '=') {
|
||||
keyval := strings.Split(part, "=")
|
||||
cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",")
|
||||
} else {
|
||||
cc[part] = ""
|
||||
}
|
||||
}
|
||||
return cc
|
||||
}
|
||||
|
||||
// CacheExpires helper function to determine remaining time before repeating a request.
|
||||
func CacheExpires(r *http.Response) time.Time {
|
||||
// Figure out when the cache expires.
|
||||
var expires time.Time
|
||||
now, err := time.Parse(time.RFC1123, r.Header.Get("date"))
|
||||
if err != nil {
|
||||
return time.Now()
|
||||
}
|
||||
respCacheControl := parseCacheControl(r.Header)
|
||||
|
||||
if maxAge, ok := respCacheControl["max-age"]; ok {
|
||||
lifetime, err := time.ParseDuration(maxAge + "s")
|
||||
if err != nil {
|
||||
expires = now
|
||||
} else {
|
||||
expires = now.Add(lifetime)
|
||||
}
|
||||
} else {
|
||||
expiresHeader := r.Header.Get("Expires")
|
||||
if expiresHeader != "" {
|
||||
expires, err = time.Parse(time.RFC1123, expiresHeader)
|
||||
if err != nil {
|
||||
expires = now
|
||||
}
|
||||
}
|
||||
}
|
||||
return expires
|
||||
}
|
||||
|
||||
func strlen(s string) int {
|
||||
return utf8.RuneCountInString(s)
|
||||
}
|
||||
|
||||
// GenericOpenAPIError Provides access to the body, error and model on returned errors.
|
||||
type GenericOpenAPIError struct {
|
||||
body []byte
|
||||
error string
|
||||
model interface{}
|
||||
}
|
||||
|
||||
// Error returns non-empty string if there was an error.
|
||||
func (e GenericOpenAPIError) Error() string {
|
||||
return e.error
|
||||
}
|
||||
|
||||
// Body returns the raw bytes of the response
|
||||
func (e GenericOpenAPIError) Body() []byte {
|
||||
return e.body
|
||||
}
|
||||
|
||||
// Model returns the unpacked model of the error
|
||||
func (e GenericOpenAPIError) Model() interface{} {
|
||||
return e.model
|
||||
}
|
64
modules/openapi-generator/src/main/resources/go-experimental/configuration.mustache
vendored
Normal file
64
modules/openapi-generator/src/main/resources/go-experimental/configuration.mustache
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
{{>partial_header}}
|
||||
package {{packageName}}
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// contextKeys are used to identify the type of value in the context.
|
||||
// Since these are string, it is possible to get a short description of the
|
||||
// context key for logging and debugging using key.String().
|
||||
|
||||
type contextKey string
|
||||
|
||||
func (c contextKey) String() string {
|
||||
return "auth " + string(c)
|
||||
}
|
||||
|
||||
var (
|
||||
// ContextOAuth2 takes an oauth2.TokenSource as authentication for the request.
|
||||
ContextOAuth2 = contextKey("token")
|
||||
|
||||
// ContextBasicAuth takes BasicAuth as authentication for the request.
|
||||
ContextBasicAuth = contextKey("basic")
|
||||
|
||||
// ContextAccessToken takes a string oauth2 access token as authentication for the request.
|
||||
ContextAccessToken = contextKey("accesstoken")
|
||||
|
||||
// ContextAPIKey takes an APIKey as authentication for the request
|
||||
ContextAPIKey = contextKey("apikey")
|
||||
)
|
||||
|
||||
// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
|
||||
type BasicAuth struct {
|
||||
UserName string `json:"userName,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
}
|
||||
|
||||
// APIKey provides API key based authentication to a request passed via context using ContextAPIKey
|
||||
type APIKey struct {
|
||||
Key string
|
||||
Prefix string
|
||||
}
|
||||
|
||||
type Configuration struct {
|
||||
BasePath string `json:"basePath,omitempty"`
|
||||
Host string `json:"host,omitempty"`
|
||||
Scheme string `json:"scheme,omitempty"`
|
||||
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
|
||||
UserAgent string `json:"userAgent,omitempty"`
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
func NewConfiguration() *Configuration {
|
||||
cfg := &Configuration{
|
||||
BasePath: "{{{basePath}}}",
|
||||
DefaultHeader: make(map[string]string),
|
||||
UserAgent: "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/go{{/httpUserAgent}}",
|
||||
}
|
||||
return cfg
|
||||
}
|
||||
|
||||
func (c *Configuration) AddDefaultHeader(key string, value string) {
|
||||
c.DefaultHeader[key] = value
|
||||
}
|
52
modules/openapi-generator/src/main/resources/go-experimental/git_push.sh.mustache
vendored
Executable file
52
modules/openapi-generator/src/main/resources/go-experimental/git_push.sh.mustache
vendored
Executable file
@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="{{{gitUserId}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||
fi
|
||||
|
||||
if [ "$git_repo_id" = "" ]; then
|
||||
git_repo_id="{{{gitRepoId}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||
fi
|
||||
|
||||
if [ "$release_note" = "" ]; then
|
||||
release_note="{{{releaseNote}}}"
|
||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||
fi
|
||||
|
||||
# Initialize the local directory as a Git repository
|
||||
git init
|
||||
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
git_remote=`git remote`
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
|
24
modules/openapi-generator/src/main/resources/go-experimental/gitignore.mustache
vendored
Normal file
24
modules/openapi-generator/src/main/resources/go-experimental/gitignore.mustache
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
|
||||
# Folders
|
||||
_obj
|
||||
_test
|
||||
|
||||
# Architecture specific extensions/prefixes
|
||||
*.[568vq]
|
||||
[568vq].out
|
||||
|
||||
*.cgo1.go
|
||||
*.cgo2.c
|
||||
_cgo_defun.c
|
||||
_cgo_gotypes.go
|
||||
_cgo_export.*
|
||||
|
||||
_testmain.go
|
||||
|
||||
*.exe
|
||||
*.test
|
||||
*.prof
|
6
modules/openapi-generator/src/main/resources/go-experimental/go.mod.mustache
vendored
Normal file
6
modules/openapi-generator/src/main/resources/go-experimental/go.mod.mustache
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
module github.com/{{gitUserId}}/{{gitRepoId}}{{#isGoSubmodule}}/{{packageName}}{{/isGoSubmodule}}
|
||||
|
||||
require (
|
||||
github.com/antihax/optional v0.0.0-20180406194304-ca021399b1a6
|
||||
golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a
|
||||
)
|
@ -0,0 +1,11 @@
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/antihax/optional v0.0.0-20180406194304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a h1:tImsplftrFpALCYumobsd0K86vlAs/eXGFms2txfJfA=
|
||||
golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
43
modules/openapi-generator/src/main/resources/go-experimental/model.mustache
vendored
Normal file
43
modules/openapi-generator/src/main/resources/go-experimental/model.mustache
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
{{>partial_header}}
|
||||
package {{packageName}}
|
||||
{{#models}}
|
||||
{{#imports}}
|
||||
{{#-first}}
|
||||
import (
|
||||
{{/-first}}
|
||||
"{{import}}"
|
||||
{{#-last}}
|
||||
)
|
||||
{{/-last}}
|
||||
{{/imports}}
|
||||
{{#model}}
|
||||
{{#isEnum}}
|
||||
{{#description}}
|
||||
// {{{classname}}} : {{{description}}}
|
||||
{{/description}}
|
||||
type {{{classname}}} {{^format}}{{dataType}}{{/format}}{{#format}}{{{format}}}{{/format}}
|
||||
|
||||
// List of {{{name}}}
|
||||
const (
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
{{^-first}}
|
||||
{{/-first}}
|
||||
{{name}} {{{classname}}} = "{{{value}}}"
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
){{/isEnum}}{{^isEnum}}{{#description}}
|
||||
// {{{description}}}{{/description}}
|
||||
type {{classname}} struct {
|
||||
{{#vars}}
|
||||
{{^-first}}
|
||||
{{/-first}}
|
||||
{{#description}}
|
||||
// {{{description}}}
|
||||
{{/description}}
|
||||
{{name}} {{#isNullable}}*{{/isNullable}}{{{dataType}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"{{#withXml}} xml:"{{baseName}}{{#isXmlAttribute}},attr{{/isXmlAttribute}}"{{/withXml}}{{#vendorExtensions.x-go-custom-tag}} {{{.}}}{{/vendorExtensions.x-go-custom-tag}}`
|
||||
{{/vars}}
|
||||
}
|
||||
{{/isEnum}}
|
||||
{{/model}}
|
||||
{{/models}}
|
12
modules/openapi-generator/src/main/resources/go-experimental/model_doc.mustache
vendored
Normal file
12
modules/openapi-generator/src/main/resources/go-experimental/model_doc.mustache
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
{{#models}}{{#model}}# {{classname}}
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#vars}}**{{name}}** | {{#isNullable}}Pointer to {{/isNullable}}{{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{{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)
|
||||
|
||||
{{/model}}{{/models}}
|
1
modules/openapi-generator/src/main/resources/go-experimental/openapi.mustache
vendored
Normal file
1
modules/openapi-generator/src/main/resources/go-experimental/openapi.mustache
vendored
Normal file
@ -0,0 +1 @@
|
||||
{{{openapi-yaml}}}
|
23
modules/openapi-generator/src/main/resources/go-experimental/partial_header.mustache
vendored
Normal file
23
modules/openapi-generator/src/main/resources/go-experimental/partial_header.mustache
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
{{#appName}}
|
||||
* {{{appName}}}
|
||||
*
|
||||
{{/appName}}
|
||||
{{#appDescription}}
|
||||
* {{{appDescription}}}
|
||||
*
|
||||
{{/appDescription}}
|
||||
{{#version}}
|
||||
* API version: {{{version}}}
|
||||
{{/version}}
|
||||
{{#infoEmail}}
|
||||
* Contact: {{{infoEmail}}}
|
||||
{{/infoEmail}}
|
||||
{{^withGoCodegenComment}}
|
||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||
{{/withGoCodegenComment}}
|
||||
*/
|
||||
{{#withGoCodegenComment}}
|
||||
|
||||
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
||||
{{/withGoCodegenComment}}
|
35
modules/openapi-generator/src/main/resources/go-experimental/response.mustache
vendored
Normal file
35
modules/openapi-generator/src/main/resources/go-experimental/response.mustache
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
{{>partial_header}}
|
||||
package {{packageName}}
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type APIResponse struct {
|
||||
*http.Response `json:"-"`
|
||||
Message string `json:"message,omitempty"`
|
||||
// Operation is the name of the OpenAPI operation.
|
||||
Operation string `json:"operation,omitempty"`
|
||||
// RequestURL is the request URL. This value is always available, even if the
|
||||
// embedded *http.Response is nil.
|
||||
RequestURL string `json:"url,omitempty"`
|
||||
// Method is the HTTP method used for the request. This value is always
|
||||
// available, even if the embedded *http.Response is nil.
|
||||
Method string `json:"method,omitempty"`
|
||||
// Payload holds the contents of the response body (which may be nil or empty).
|
||||
// This is provided here as the raw response.Body() reader will have already
|
||||
// been drained.
|
||||
Payload []byte `json:"-"`
|
||||
}
|
||||
|
||||
func NewAPIResponse(r *http.Response) *APIResponse {
|
||||
|
||||
response := &APIResponse{Response: r}
|
||||
return response
|
||||
}
|
||||
|
||||
func NewAPIResponseWithError(errorMessage string) *APIResponse {
|
||||
|
||||
response := &APIResponse{Message: errorMessage}
|
||||
return response
|
||||
}
|
@ -87,7 +87,7 @@ public class AppConfig extends WebMvcConfigurerAdapter {
|
||||
* .exposedHeaders("header1", "header2")
|
||||
* .allowCredentials(false).maxAge(3600);
|
||||
*
|
||||
* @return
|
||||
* @return a new WebMvcConfigurer instance
|
||||
*/
|
||||
@Bean
|
||||
public WebMvcConfigurer corsConfigurer() {
|
||||
|
@ -18,7 +18,7 @@ import org.springframework.security.oauth2.provider.request.DefaultOAuth2Request
|
||||
import org.springframework.security.oauth2.provider.token.TokenStore;
|
||||
import org.springframework.security.oauth2.provider.token.store.InMemoryTokenStore;
|
||||
/**
|
||||
* Provides a convenient base class for creating a {@link WebSecurityConfigurer}
|
||||
* Provides a convenient base class for creating a WebSecurityConfigurer
|
||||
* instance. The implementation allows customization by overriding methods.
|
||||
*
|
||||
* @see EnableWebSecurity
|
||||
|
@ -10,7 +10,7 @@ import org.springframework.http.HttpMethod;
|
||||
/**
|
||||
* Configurer class for <code>@EnableResourceServer</code> classes. This class adjust the access
|
||||
* rules and paths that are protected by OAuth2 security. If more than one configures the same property, then the last
|
||||
* one wins. The configurers are sorted by {@link Order} before being applied.
|
||||
* one wins. The configurers are sorted by Order before being applied.
|
||||
*
|
||||
* @author pkmst
|
||||
*
|
||||
|
@ -23,6 +23,7 @@
|
||||
</whitelist>
|
||||
</filter>
|
||||
<php>
|
||||
<ini name="error_reporting" value="E_ALL" />
|
||||
<env name="APP_ENV" value="testing"/>
|
||||
<env name="BCRYPT_ROUNDS" value="4"/>
|
||||
<env name="CACHE_DRIVER" value="array"/>
|
||||
|
@ -20,6 +20,7 @@
|
||||
</whitelist>
|
||||
</filter>
|
||||
<php>
|
||||
<ini name="error_reporting" value="E_ALL" />
|
||||
<env name="APP_ENV" value="testing"/>
|
||||
<env name="CACHE_DRIVER" value="array"/>
|
||||
<env name="QUEUE_DRIVER" value="sync"/>
|
||||
|
@ -24,4 +24,7 @@
|
||||
<directory suffix=".php">{{modelSrcPath}}</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
<php>
|
||||
<ini name="error_reporting" value="E_ALL" />
|
||||
</php>
|
||||
</phpunit>
|
||||
|
@ -11,15 +11,14 @@
|
||||
<directory>{{modelTestPath}}</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<php>
|
||||
<server name="KERNEL_DIR" value="Tests/" />
|
||||
</php>
|
||||
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">{{apiSrcPath}}</directory>
|
||||
<directory suffix=".php">{{modelSrcPath}}</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<php>
|
||||
<ini name="error_reporting" value="E_ALL" />
|
||||
<server name="KERNEL_DIR" value="Tests/" />
|
||||
</php>
|
||||
</phpunit>
|
||||
|
@ -11,11 +11,13 @@
|
||||
<directory>{{modelTestPath}}</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">{{apiSrcPath}}</directory>
|
||||
<directory suffix=".php">{{modelSrcPath}}</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<php>
|
||||
<ini name="error_reporting" value="E_ALL" />
|
||||
</php>
|
||||
</phpunit>
|
||||
|
@ -1,6 +1,9 @@
|
||||
#' ApiResponse Class
|
||||
#'
|
||||
#' ApiResponse Class
|
||||
#' @docType class
|
||||
#' @title ApiResponse
|
||||
#' @description ApiResponse Class
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field content The deserialized response body.
|
||||
#' @field response The raw response from the endpoint.
|
||||
#' @export
|
||||
ApiResponse <- R6::R6Class(
|
||||
'ApiResponse',
|
||||
|
@ -1,23 +1,150 @@
|
||||
{{>partial_header}}
|
||||
{{#operations}}
|
||||
#' @docType class
|
||||
#' @title {{baseName}} operations
|
||||
#' @description {{importPath}}
|
||||
#'
|
||||
#' @field path Stores url path of the request.
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field apiClient Handles the client-server communication.
|
||||
#'
|
||||
#' @importFrom R6 R6Class
|
||||
#'
|
||||
#' @section Methods:
|
||||
{{! Adding the below changes for generating documentation for the api methods. }}
|
||||
#' \describe{
|
||||
{{#operation}}
|
||||
#' \strong{ {{operationId}} } \emph{ {{summary}} }
|
||||
#' {{notes}}
|
||||
#'
|
||||
#' {{operationId}} {{summary}}
|
||||
#' \itemize{
|
||||
{{#allParams}}
|
||||
{{#isEnum}}
|
||||
#' \item \emph{ @param } {{paramName}} Enum < {{#allowableValues}}{{values}}{{/allowableValues}} >
|
||||
{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
{{#isContainer}}
|
||||
{{#isListContainer}}
|
||||
{{#items}}
|
||||
{{#isPrimitiveType}}
|
||||
#' \item \emph{ @param } {{paramName}} list( {{dataType}} )
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
#' \item \emph{ @param } {{paramName}} list( \link[{{packageName}}:{{baseType}}]{ {{dataType}} } )
|
||||
{{/isPrimitiveType}}
|
||||
{{/items}}
|
||||
{{/isListContainer}}
|
||||
{{#isMapContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
#' \item \emph{ @param } {{paramName}} named list( {{dataType}} )
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
#' \item \emph{ @param } {{paramName}} named list( \link[{{packageName}}:{{baseType}}]{ {{dataType}} } )
|
||||
{{/isPrimitiveType}}
|
||||
{{/isMapContainer}}
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
{{#isPrimitiveType}}
|
||||
#' \item \emph{ @param } {{paramName}} {{dataType}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
#' \item \emph{ @param } {{paramName}} \link[{{packageName}}:{{baseType}}]{ {{dataType}} }
|
||||
{{/isPrimitiveType}}
|
||||
{{/isContainer}}
|
||||
{{/isEnum}}
|
||||
{{/allParams}}
|
||||
{{#returnType}}
|
||||
{{^returnTypeIsPrimitive}}
|
||||
#' \item \emph{ @returnType } \link[{{packageName}}:{{returnBaseType}}]{ {{#returnContainer}}{{#isListContainer}}list({{returnBaseType}}){{/isListContainer}}{{#isMapContainer}}named list({{returnBaseType}}){{/isMapContainer}}{{/returnContainer}}{{^returnContainer}}{{returnType}}{{/returnContainer}} } \cr
|
||||
{{/returnTypeIsPrimitive}}
|
||||
{{/returnType}}
|
||||
#'
|
||||
{{#useRlangExceptionHandling}}
|
||||
#' \item On encountering errors, an error of subclass ApiException will be thrown.
|
||||
{{/useRlangExceptionHandling}}
|
||||
#'
|
||||
{{#responses}}
|
||||
#' \item status code : {{code}} | {{message}}
|
||||
#'
|
||||
#'{{#dataType}} \item return type : {{dataType}} {{/dataType}}
|
||||
#' \item response headers :
|
||||
#'
|
||||
#' \tabular{ll}{
|
||||
{{#headers}}
|
||||
#' {{name}} \tab {{description}} \cr
|
||||
{{/headers}}
|
||||
#' }
|
||||
{{/responses}}
|
||||
#' }
|
||||
#'
|
||||
{{/operation}}
|
||||
#' }
|
||||
#'
|
||||
#'
|
||||
#' @examples
|
||||
#' \donttest{
|
||||
{{#operation}}
|
||||
#' #################### {{operationId}} ####################
|
||||
#'
|
||||
#' library({{{packageName}}})
|
||||
{{#allParams}}
|
||||
#' var.{{{paramName}}} <- {{{example}}} # {{{dataType}}} | {{{description}}}
|
||||
{{/allParams}}
|
||||
#'
|
||||
{{#summary}}
|
||||
#' #{{{.}}}
|
||||
{{/summary}}
|
||||
#' api.instance <- {{{classname}}}$new()
|
||||
{{#hasAuthMethods}}
|
||||
{{#authMethods}}
|
||||
#'
|
||||
{{#isBasic}}
|
||||
#' #Configure HTTP basic authorization: {{{name}}}
|
||||
#' # provide your username in the user-serial format
|
||||
#' api.instance$apiClient$username <- '<user-serial>';
|
||||
#' # provide your api key generated using the developer portal
|
||||
#' api.instance$apiClient$password <- '<api_key>';
|
||||
{{/isBasic}}
|
||||
{{#isApiKey}}
|
||||
#' #Configure API key authorization: {{{name}}}
|
||||
#' api.instance$apiClient$apiKeys['{{{keyParamName}}}'] <- 'TODO_YOUR_API_KEY';
|
||||
{{/isApiKey}}
|
||||
{{#isOAuth}}
|
||||
#' # Configure OAuth2 access token for authorization: {{{name}}}
|
||||
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
{{/hasAuthMethods}}
|
||||
#'
|
||||
{{#returnExceptionOnFailure}}
|
||||
{{#useRlangExceptionHandling}}
|
||||
#'result <- tryCatch(
|
||||
#' api.instance${{{operationId}}}({{#requiredParams}}var.{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-first}}{{#requiredParams.0}}, {{/requiredParams.0}}{{/-first}}{{{paramName}}}=var.{{{paramName}}}{{^-last}}, {{/-last}}{{/optionalParams}}),
|
||||
#' ApiException = function(ex) ex
|
||||
#' )
|
||||
#' # In case of error, print the error object
|
||||
#' if(!is.null(result$ApiException)) {
|
||||
#' cat(result$ApiException$toString())
|
||||
#' } else {
|
||||
{{#returnType}}
|
||||
#' # deserialized response object
|
||||
#' response.object <- result$content
|
||||
{{/returnType}}
|
||||
#' # response headers
|
||||
#' response.headers <- result$response$headers
|
||||
#' # response status code
|
||||
#' response.status.code <- result$response$status_code
|
||||
#' }
|
||||
{{/useRlangExceptionHandling}}
|
||||
{{/returnExceptionOnFailure}}
|
||||
{{^useRlangExceptionHandling}}
|
||||
#' result <- api.instance${{{operationId}}}({{#requiredParams}}var.{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-first}}{{#requiredParams.0}}, {{/requiredParams.0}}{{/-first}}{{{paramName}}}=var.{{{paramName}}}{{^-last}}, {{/-last}}{{/optionalParams}})
|
||||
{{/useRlangExceptionHandling}}
|
||||
#'
|
||||
#'
|
||||
{{/operation}}
|
||||
#' }
|
||||
#' @importFrom R6 R6Class
|
||||
#' @importFrom caTools base64encode
|
||||
{{#useRlangExceptionHandling}}
|
||||
#' @importFrom rlang abort
|
||||
{{/useRlangExceptionHandling}}
|
||||
#' @export
|
||||
{{classname}} <- R6::R6Class(
|
||||
'{{classname}}',
|
||||
@ -51,7 +178,12 @@
|
||||
|
||||
{{#requiredParams}}
|
||||
if (missing(`{{paramName}}`)) {
|
||||
{{#useDefaultExceptionHandling}}
|
||||
stop("Missing required parameter `{{{paramName}}}`.")
|
||||
{{/useDefaultExceptionHandling}}
|
||||
{{#useRlangExceptionHandling}}
|
||||
rlang::abort(message = "Missing required parameter `{{{paramName}}}`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `{{{paramName}}}`."))
|
||||
{{/useRlangExceptionHandling}}
|
||||
}
|
||||
|
||||
{{/requiredParams}}
|
||||
@ -141,7 +273,17 @@
|
||||
ApiResponse$new(content,resp)
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
deserializedRespObj <- self$apiClient$deserialize(resp, "{{returnType}}", "package:{{packageName}}")
|
||||
deserializedRespObj <- tryCatch(
|
||||
self$apiClient$deserialize(resp, "{{returnType}}", "package:{{packageName}}"),
|
||||
error = function(e){
|
||||
{{#useDefaultExceptionHandling}}
|
||||
stop("Failed to deserialize response")
|
||||
{{/useDefaultExceptionHandling}}
|
||||
{{#useRlangExceptionHandling}}
|
||||
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||
{{/useRlangExceptionHandling}}
|
||||
}
|
||||
)
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
{{/isPrimitiveType}}
|
||||
{{/returnType}}
|
||||
@ -150,9 +292,37 @@
|
||||
ApiResponse$new(NULL, resp)
|
||||
{{/returnType}}
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
{{#returnExceptionOnFailure}}
|
||||
errorMsg <- toString(content(resp))
|
||||
if(errorMsg == ""){
|
||||
errorMsg <- "Api client exception encountered."
|
||||
}
|
||||
{{#useDefaultExceptionHandling}}
|
||||
stop(errorMsg)
|
||||
{{/useDefaultExceptionHandling}}
|
||||
{{#useRlangExceptionHandling}}
|
||||
rlang::abort(message = errorMsg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||
{{/useRlangExceptionHandling}}
|
||||
{{/returnExceptionOnFailure}}
|
||||
{{^returnExceptionOnFailure}}
|
||||
ApiResponse$new("API client error", resp)
|
||||
{{/returnExceptionOnFailure}}
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
{{#returnExceptionOnFailure}}
|
||||
errorMsg <- toString(content(resp))
|
||||
if(errorMsg == ""){
|
||||
errorMsg <- "Api server exception encountered."
|
||||
}
|
||||
{{#useDefaultExceptionHandling}}
|
||||
stop(errorMsg)
|
||||
{{/useDefaultExceptionHandling}}
|
||||
{{#useRlangExceptionHandling}}
|
||||
rlang::abort(message = errorMsg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||
{{/useRlangExceptionHandling}}
|
||||
{{/returnExceptionOnFailure}}
|
||||
{{^returnExceptionOnFailure}}
|
||||
ApiResponse$new("API server error", resp)
|
||||
{{/returnExceptionOnFailure}}
|
||||
}
|
||||
}{{#hasMore}},{{/hasMore}}
|
||||
{{/operation}}
|
||||
|
@ -12,14 +12,22 @@
|
||||
#' Ref: https://openapi-generator.tech
|
||||
#' Do not edit the class manually.
|
||||
#'
|
||||
#' @field basePath
|
||||
#' @field userAgent
|
||||
#' @docType class
|
||||
#' @title ApiClient
|
||||
#' @description ApiClient Class
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field basePath Base url
|
||||
#' @field userAgent Default user agent
|
||||
#' @field defaultHeaders
|
||||
#' @field username
|
||||
#' @field password
|
||||
#' @field username Username for HTTP basic authentication
|
||||
#' @field password Password for HTTP basic authentication
|
||||
#' @field apiKeys
|
||||
#' @field accessToken
|
||||
#' @importFrom httr
|
||||
#' @field timeout Default timeout in seconds
|
||||
#' @importFrom httr add_headers accept timeout content
|
||||
{{#useRlangExceptionHandling}}
|
||||
#' @importFrom rlang abort
|
||||
{{/useRlangExceptionHandling}}
|
||||
#' @export
|
||||
ApiClient <- R6::R6Class(
|
||||
'ApiClient',
|
||||
@ -98,26 +106,42 @@ ApiClient <- R6::R6Class(
|
||||
} else if (method == "DELETE") {
|
||||
httr::DELETE(url, query = queryParams, headers, httpTimeout, httpTimeout, httr::user_agent(self$`userAgent`), ...)
|
||||
} else {
|
||||
stop("http method must be `GET`, `HEAD`, `OPTIONS`, `POST`, `PATCH`, `PUT` or `DELETE`.")
|
||||
errMsg <- "Http method must be `GET`, `HEAD`, `OPTIONS`, `POST`, `PATCH`, `PUT` or `DELETE`."
|
||||
{{#useDefaultExceptionHandling}}
|
||||
stop(errMsg)
|
||||
{{/useDefaultExceptionHandling}}
|
||||
{{#useRlangExceptionHandling}}
|
||||
rlang::abort(message = errMsg, .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = errMsg))
|
||||
{{/useRlangExceptionHandling}}
|
||||
}
|
||||
},
|
||||
|
||||
# Deserialize the content of api response to the given type.
|
||||
deserialize = function(resp, returnType, pkgEnv) {
|
||||
respObj <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
self$deserializeObj(respObj, returnType, pkgEnv)
|
||||
},
|
||||
|
||||
|
||||
# Deserialize the response from jsonlite object based on the given type
|
||||
# by handling complex and nested types by iterating recursively
|
||||
# Example returnTypes will be like "array[integer]", "map(Pet)", "array[map(Tag)]", etc.,
|
||||
|
||||
deserializeObj = function(obj, returnType, pkgEnv) {
|
||||
returnObj <- NULL
|
||||
primitiveTypes <- c("character", "numeric", "integer", "logical", "complex")
|
||||
|
||||
# To handle the "map" type
|
||||
if (startsWith(returnType, "map(")) {
|
||||
innerReturnType <- regmatches(returnType, regexec(pattern = "map\\((.*)\\)", returnType))[[1]][2]
|
||||
returnObj <- lapply(names(obj), function(name) {
|
||||
self$deserializeObj(obj[[name]], innerReturnType, pkgEnv)
|
||||
})
|
||||
names(returnObj) <- names(obj)
|
||||
} else if (startsWith(returnType, "array[")) {
|
||||
}
|
||||
|
||||
# To handle the "array" type
|
||||
else if (startsWith(returnType, "array[")) {
|
||||
innerReturnType <- regmatches(returnType, regexec(pattern = "array\\[(.*)\\]", returnType))[[1]][2]
|
||||
if (c(innerReturnType) %in% primitiveTypes) {
|
||||
returnObj <- vector("list", length = length(obj))
|
||||
@ -134,11 +158,17 @@ ApiClient <- R6::R6Class(
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (exists(returnType, pkgEnv) && !(c(returnType) %in% primitiveTypes)) {
|
||||
}
|
||||
|
||||
# To handle model objects which are not array or map containers. Ex:"Pet"
|
||||
else if (exists(returnType, pkgEnv) && !(c(returnType) %in% primitiveTypes)) {
|
||||
returnType <- get(returnType, envir = as.environment(pkgEnv))
|
||||
returnObj <- returnType$new()
|
||||
returnObj$fromJSON(jsonlite::toJSON(obj, digits = NA))
|
||||
} else {
|
||||
}
|
||||
|
||||
# To handle primitive type
|
||||
else {
|
||||
returnObj <- obj
|
||||
}
|
||||
returnObj
|
||||
|
55
modules/openapi-generator/src/main/resources/r/api_exception.mustache
vendored
Normal file
55
modules/openapi-generator/src/main/resources/r/api_exception.mustache
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
{{! ApiException class for returning the ApiException object on encountering errors}}
|
||||
#' @docType class
|
||||
#' @title ApiException
|
||||
#' @description ApiException Class
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field status Status of the ApiException
|
||||
#' @field reason Reason of the ApiException
|
||||
#' @field body Body of the http response
|
||||
#' @field headers Headers of the http response
|
||||
#' @export
|
||||
ApiException <- R6::R6Class(
|
||||
"ApiException",
|
||||
public = list(
|
||||
status = NULL,
|
||||
reason = NULL,
|
||||
body = NULL,
|
||||
headers = NULL,
|
||||
|
||||
initialize = function(status = NULL, reason = NULL, http_response = NULL) {
|
||||
if (!is.null(http_response)) {
|
||||
self$status <- http_response$status_code
|
||||
errorMsg <- toString(content(http_response))
|
||||
if(errorMsg == ""){
|
||||
errorMsg <- "Api exception encountered."
|
||||
}
|
||||
self$body <- errorMsg
|
||||
self$headers <- http_response$headers
|
||||
self$reason <- httr::http_status(http_response)$reason
|
||||
} else {
|
||||
self$status <- status
|
||||
self$reason <- reason
|
||||
self$body <- NULL
|
||||
self$headers <- NULL
|
||||
}
|
||||
},
|
||||
|
||||
# returns the string format of ApiException
|
||||
toString = function() {
|
||||
errorMsg <- ""
|
||||
errorMsg <- paste("status : ", self$status, "\n", sep = "")
|
||||
errorMsg <- paste(errorMsg, "Reason : ", self$reason, "\n", sep = "")
|
||||
if (!is.null(self$headers)) {
|
||||
errorMsg <- paste(errorMsg, "Headers : ", "\n", sep = "")
|
||||
for (name in names(self$headers)) {
|
||||
errorMsg <- paste(errorMsg, name, " : ", self$headers[[name]], "\n", sep = " ")
|
||||
}
|
||||
}
|
||||
if (!is.null(self$body)) {
|
||||
errorMsg <- paste(errorMsg, "Body : ", "\n", sep = "")
|
||||
errorMsg <- paste(errorMsg, self$body,"\n")
|
||||
}
|
||||
errorMsg
|
||||
}
|
||||
)
|
||||
)
|
@ -8,5 +8,5 @@ Encoding: UTF-8
|
||||
License: Unlicense
|
||||
LazyData: true
|
||||
Suggests: testthat
|
||||
Imports: jsonlite, httr, R6, caTools
|
||||
Imports: jsonlite, httr, R6, caTools{{#useRlangExceptionHandling}}, rlang{{/useRlangExceptionHandling}}
|
||||
RoxygenNote: 6.0.1.9000
|
||||
|
@ -1,11 +1,13 @@
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
{{>partial_header}}
|
||||
|
||||
#' {{classname}} Class
|
||||
#'
|
||||
#' @docType class
|
||||
#' @title {{classname}}
|
||||
#' @description {{classname}} Class
|
||||
#' @format An \code{R6Class} generator object
|
||||
{{#vars}}
|
||||
#' @field {{baseName}} {{title}}
|
||||
#' @field {{baseName}} {{title}} {{^isPrimitiveType}} \link[{{packageName}}:{{complexType}}]{ {{/isPrimitiveType}} {{#isContainer}} {{#isListContainer}}list({{#items}}{{dataType}}{{/items}}){{/isListContainer}}{{#isMapContainer}}named list({{#items}}{{dataType}}{{/items}}){{/isMapContainer}} {{/isContainer}}{{^isContainer}}{{dataType}}{{/isContainer}} {{^isPrimitiveType}} } {{/isPrimitiveType}} {{^required}}[optional]{{/required}}
|
||||
#'
|
||||
{{/vars}}
|
||||
#'
|
||||
#' @importFrom R6 R6Class
|
||||
|
@ -31,7 +31,7 @@ export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{
|
||||
export function {{classname}}FromJSON(json: any): {{classname}} {
|
||||
{{#hasVars}}
|
||||
return {
|
||||
{{#allVars}}
|
||||
{{#vars}}
|
||||
{{#isPrimitiveType}}
|
||||
{{#isDate}}
|
||||
'{{name}}': {{^required}}!exists(json, '{{baseName}}') ? undefined : {{/required}}new Date(json['{{baseName}}']),
|
||||
@ -63,7 +63,7 @@ export function {{classname}}FromJSON(json: any): {{classname}} {
|
||||
{{/isMapContainer}}
|
||||
{{/isListContainer}}
|
||||
{{/isPrimitiveType}}
|
||||
{{/allVars}}
|
||||
{{/vars}}
|
||||
};
|
||||
{{/hasVars}}
|
||||
{{^hasVars}}
|
||||
@ -77,7 +77,7 @@ export function {{classname}}ToJSON(value?: {{classname}}): any {
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
{{#allVars}}
|
||||
{{#vars}}
|
||||
{{^isReadOnly}}
|
||||
{{#isPrimitiveType}}
|
||||
'{{baseName}}': {{#isDate}}{{^required}}value.{{name}} === undefined ? undefined : {{/required}}value.{{name}}.toISOString().substr(0,10){{/isDate}}{{#isDateTime}}{{^required}}value.{{name}} === undefined ? undefined : {{/required}}value.{{name}}.toISOString(){{/isDateTime}}{{^isDate}}{{^isDateTime}}value.{{name}}{{/isDateTime}}{{/isDate}},
|
||||
@ -101,7 +101,7 @@ export function {{classname}}ToJSON(value?: {{classname}}): any {
|
||||
{{/isListContainer}}
|
||||
{{/isPrimitiveType}}
|
||||
{{/isReadOnly}}
|
||||
{{/allVars}}
|
||||
{{/vars}}
|
||||
};
|
||||
{{/hasVars}}
|
||||
{{^hasVars}}
|
||||
|
@ -107,7 +107,7 @@ export class BaseAPI {
|
||||
return of(params).pipe(
|
||||
map((args) => {
|
||||
if (preMiddlewares) {
|
||||
preMiddlewares.forEach((mw) => (args = mw.pre({ ...args })));
|
||||
preMiddlewares.forEach((mw) => (args = mw.pre!({ ...args })));
|
||||
}
|
||||
return args;
|
||||
}),
|
||||
@ -115,7 +115,7 @@ export class BaseAPI {
|
||||
ajax({ url: args.url, ...args.options }).pipe(
|
||||
map((response) => {
|
||||
if (postMiddlewares) {
|
||||
postMiddlewares.forEach((mw) => (response = mw.post({ ...params, response })));
|
||||
postMiddlewares.forEach((mw) => (response = mw.post!({ ...params, response })));
|
||||
}
|
||||
return response;
|
||||
})
|
||||
|
@ -189,6 +189,7 @@ public class DefaultCodegenTest {
|
||||
|
||||
@Test
|
||||
public void testArraySchemaIsNotIncluedInAliases() throws Exception {
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
Map<String, Schema> schemas = new HashMap<String, Schema>() {
|
||||
{
|
||||
put("ArraySchemaTest", new ArraySchema());
|
||||
@ -196,7 +197,7 @@ public class DefaultCodegenTest {
|
||||
|
||||
};
|
||||
|
||||
Map<String, String> aliases = DefaultCodegen.getAllAliases(schemas);
|
||||
Map<String, String> aliases = codegen.getAllAliases(schemas);
|
||||
|
||||
Assert.assertEquals(aliases.size(), 0);
|
||||
}
|
||||
@ -582,7 +583,7 @@ public class DefaultCodegenTest {
|
||||
test.setPropertyName("DollarUnderscoretype");
|
||||
test.setMapping(new HashMap<>());
|
||||
test.getMapping().put("a", "#/components/schemas/Adult");
|
||||
test.getMapping().put("c", "#/components/schemas/Child");
|
||||
test.getMapping().put("c", "Child");
|
||||
test.getMappedModels().add(new CodegenDiscriminator.MappedModel("a", "Adult"));
|
||||
test.getMappedModels().add(new CodegenDiscriminator.MappedModel("c", "Child"));
|
||||
Assert.assertEquals(discriminator, test);
|
||||
|
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright 2019 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
|
||||
*
|
||||
* http://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.elm;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static java.util.Collections.emptyList;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.openapitools.codegen.ClientOptInput;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.MockDefaultGenerator;
|
||||
import org.openapitools.codegen.languages.ElmClientCodegen;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import io.swagger.parser.OpenAPIParser;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.parser.core.models.ParseOptions;
|
||||
|
||||
public class ElmClientCodegenTest {
|
||||
|
||||
@Test
|
||||
public void testPostProcessRootEndpoint() {
|
||||
// given
|
||||
final ElmClientCodegen codegen = new ElmClientCodegen();
|
||||
|
||||
CodegenOperation rootOp = new CodegenOperation() {{ path = "/"; }};
|
||||
List<CodegenOperation> ops = newArrayList(rootOp);
|
||||
|
||||
Map<String, Object> operations = new HashMap<>();
|
||||
operations.put("operations", ImmutableMap
|
||||
.<String, Object>builder()
|
||||
.put("operation", ops)
|
||||
.build());
|
||||
|
||||
// when
|
||||
Map<String, Object> result = codegen.postProcessOperationsWithModels(operations, emptyList());
|
||||
|
||||
// then
|
||||
assertEquals(result.size(), 2);
|
||||
assertTrue(result.containsKey("operations"));
|
||||
assertTrue(result.containsKey("elmImports"));
|
||||
|
||||
assertEquals(rootOp.path, "\"\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenerateRootEndpoint() throws IOException {
|
||||
// given
|
||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||
output.deleteOnExit();
|
||||
String outputPath = output.getAbsolutePath().replace('\\', '/');
|
||||
|
||||
final ElmClientCodegen codegen = new ElmClientCodegen();
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
|
||||
OpenAPI openAPI = new OpenAPIParser()
|
||||
.readLocation("src/test/resources/3_0/rootOperation.yaml", null, new ParseOptions())
|
||||
.getOpenAPI();
|
||||
|
||||
ClientOptInput input = new ClientOptInput();
|
||||
input.setOpenAPI(openAPI);
|
||||
input.setConfig(codegen);
|
||||
|
||||
// when
|
||||
MockDefaultGenerator generator = new MockDefaultGenerator();
|
||||
generator.opts(input).generate();
|
||||
|
||||
// then
|
||||
assertFileContains(generator, outputPath + "/src/Request/Default.elm", "rootGet", "[\"\"]");
|
||||
}
|
||||
|
||||
private static void assertFileContains(MockDefaultGenerator generator, String file, String... expected) {
|
||||
String content = generator.getFiles().get(file);
|
||||
assertNotNull(content, "The file \"" + file + "\" was not generated");
|
||||
for (String line : expected) {
|
||||
assertTrue(content.contains(line), "The file \"" + file + "\" does not contain \"" + line + "\"");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright 2019 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
|
||||
*
|
||||
* http://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.haskellservant;
|
||||
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.openapitools.codegen.ClientOptInput;
|
||||
import org.openapitools.codegen.MockDefaultGenerator;
|
||||
import org.openapitools.codegen.languages.HaskellServantCodegen;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import io.swagger.parser.OpenAPIParser;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.parser.core.models.ParseOptions;
|
||||
|
||||
public class HaskellServantCodegenTest {
|
||||
|
||||
@Test
|
||||
public void testGenerateRootEndpoint() throws IOException {
|
||||
// given
|
||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||
output.deleteOnExit();
|
||||
String outputPath = output.getAbsolutePath().replace('\\', '/');
|
||||
|
||||
final HaskellServantCodegen codegen = new HaskellServantCodegen();
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
|
||||
OpenAPI openAPI = new OpenAPIParser()
|
||||
.readLocation("src/test/resources/3_0/rootOperation.yaml", null, new ParseOptions())
|
||||
.getOpenAPI();
|
||||
|
||||
ClientOptInput input = new ClientOptInput();
|
||||
input.setOpenAPI(openAPI);
|
||||
input.setConfig(codegen);
|
||||
|
||||
// when
|
||||
MockDefaultGenerator generator = new MockDefaultGenerator();
|
||||
generator.opts(input).generate();
|
||||
|
||||
// then
|
||||
assertFileNotContains(generator, outputPath + "/lib/RootOperation/API.hs", "\"\" :>");
|
||||
}
|
||||
|
||||
private static void assertFileNotContains(MockDefaultGenerator generator, String file, String... expected) {
|
||||
String content = generator.getFiles().get(file);
|
||||
assertNotNull(content, "The file \"" + file + "\" was not generated");
|
||||
for (String line : expected) {
|
||||
assertFalse(content.contains(line), "The file \"" + file + "\" contains \"" + line + "\"");
|
||||
}
|
||||
}
|
||||
}
|
@ -66,6 +66,7 @@ public class SpringCodegenTest {
|
||||
Assert.assertEquals(codegen.getConfigPackage(), "org.openapitools.configuration");
|
||||
Assert.assertEquals(codegen.additionalProperties().get(SpringCodegen.CONFIG_PACKAGE), "org.openapitools.configuration");
|
||||
Assert.assertEquals(codegen.additionalProperties().get(SpringCodegen.SERVER_PORT), "8082");
|
||||
Assert.assertEquals(codegen.additionalProperties().get(SpringCodegen.UNHANDLED_EXCEPTION_HANDLING), false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -77,6 +78,7 @@ public class SpringCodegenTest {
|
||||
codegen.setInvokerPackage("xx.yyyyyyyy.invoker");
|
||||
codegen.setBasePackage("xx.yyyyyyyy.base");
|
||||
codegen.setConfigPackage("xx.yyyyyyyy.config");
|
||||
codegen.setUnhandledException(true);
|
||||
codegen.processOpts();
|
||||
|
||||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE);
|
||||
@ -91,6 +93,8 @@ public class SpringCodegenTest {
|
||||
Assert.assertEquals(codegen.additionalProperties().get(SpringCodegen.BASE_PACKAGE), "xx.yyyyyyyy.base");
|
||||
Assert.assertEquals(codegen.getConfigPackage(), "xx.yyyyyyyy.config");
|
||||
Assert.assertEquals(codegen.additionalProperties().get(SpringCodegen.CONFIG_PACKAGE), "xx.yyyyyyyy.config");
|
||||
Assert.assertEquals(codegen.isUnhandledException(), true);
|
||||
Assert.assertEquals(codegen.additionalProperties().get(SpringCodegen.UNHANDLED_EXCEPTION_HANDLING), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -37,7 +37,7 @@ public class ModelUtilsTest {
|
||||
public void testGetAllUsedSchemas() {
|
||||
final OpenAPI openAPI = TestUtils.parseSpec("src/test/resources/3_0/unusedSchemas.yaml");
|
||||
List<String> allUsedSchemas = ModelUtils.getAllUsedSchemas(openAPI);
|
||||
Assert.assertEquals(allUsedSchemas.size(), 34);
|
||||
Assert.assertEquals(allUsedSchemas.size(), 38);
|
||||
|
||||
Assert.assertTrue(allUsedSchemas.contains("SomeObjShared"), "contains 'SomeObjShared'");
|
||||
Assert.assertTrue(allUsedSchemas.contains("SomeObj1"), "contains 'UnusedObj1'");
|
||||
@ -73,6 +73,10 @@ public class ModelUtilsTest {
|
||||
Assert.assertTrue(allUsedSchemas.contains("SOutput22"), "contains 'SInput22'");
|
||||
Assert.assertTrue(allUsedSchemas.contains("SomeHeader23"), "contains 'SomeHeader23'");
|
||||
Assert.assertTrue(allUsedSchemas.contains("SomeHeader24"), "contains 'SomeHeader24'");
|
||||
Assert.assertTrue(allUsedSchemas.contains("SomeObj25"), "contains 'SomeObj25'");
|
||||
Assert.assertTrue(allUsedSchemas.contains("SomeObj26"), "contains 'SomeObj26'");
|
||||
Assert.assertTrue(allUsedSchemas.contains("Param27"), "contains 'Param27'");
|
||||
Assert.assertTrue(allUsedSchemas.contains("Param28"), "contains 'Param28'");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -32,7 +32,7 @@ components:
|
||||
propertyName: $_type
|
||||
mapping:
|
||||
a: '#/components/schemas/Adult'
|
||||
c: '#/components/schemas/Child'
|
||||
c: Child
|
||||
properties:
|
||||
$_type:
|
||||
type: string
|
||||
|
@ -0,0 +1,13 @@
|
||||
openapi: 3.0.0
|
||||
|
||||
info:
|
||||
title: Root Operation
|
||||
version: 1.0.0
|
||||
|
||||
paths:
|
||||
/:
|
||||
get:
|
||||
summary: Simple root endpoint
|
||||
responses:
|
||||
204:
|
||||
description: No response body
|
@ -301,6 +301,57 @@ paths:
|
||||
headers:
|
||||
x-app-info:
|
||||
$ref: "#/components/headers/sharedHeader24"
|
||||
/some/p25:
|
||||
post:
|
||||
operationId: op25
|
||||
parameters:
|
||||
- name: q
|
||||
in: query
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/SomeObj25"
|
||||
responses:
|
||||
'200':
|
||||
description: OK
|
||||
/some/p26:
|
||||
post:
|
||||
operationId: op26
|
||||
responses:
|
||||
'200':
|
||||
description: OK
|
||||
headers:
|
||||
x-something:
|
||||
description: basic app info
|
||||
style: simple
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/SomeObj26"
|
||||
/some/p27/{q}:
|
||||
parameters:
|
||||
- name: q
|
||||
in: path
|
||||
schema:
|
||||
$ref: "#/components/schemas/Param27"
|
||||
post:
|
||||
operationId: op27
|
||||
responses:
|
||||
'200':
|
||||
description: OK
|
||||
/some/p28/{q}:
|
||||
parameters:
|
||||
- name: q
|
||||
in: path
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Param28"
|
||||
post:
|
||||
operationId: op27
|
||||
responses:
|
||||
'200':
|
||||
description: OK
|
||||
components:
|
||||
schemas:
|
||||
UnusedObj1:
|
||||
@ -564,6 +615,32 @@ components:
|
||||
SomeHeader24:
|
||||
type: integer
|
||||
format: int64
|
||||
SomeObj25:
|
||||
type: object
|
||||
properties:
|
||||
p1:
|
||||
type: string
|
||||
p2:
|
||||
type: string
|
||||
SomeObj26:
|
||||
type: object
|
||||
properties:
|
||||
q1:
|
||||
type: string
|
||||
q2:
|
||||
type: string
|
||||
Param27:
|
||||
type: string
|
||||
enum:
|
||||
- alpha
|
||||
- beta
|
||||
Param28:
|
||||
type: object
|
||||
properties:
|
||||
r1:
|
||||
type: string
|
||||
r2:
|
||||
type: string
|
||||
SomeObjShared:
|
||||
type: object
|
||||
properties:
|
||||
|
10
pom.xml
10
pom.xml
@ -1041,6 +1041,7 @@
|
||||
<module>samples/client/petstore/javascript-promise-es6</module>
|
||||
<module>samples/client/petstore/javascript-flowtyped</module>
|
||||
<module>samples/client/petstore/python</module>
|
||||
<module>samples/client/petstore/python-experimental</module>
|
||||
<module>samples/client/petstore/python-asyncio</module>
|
||||
<module>samples/client/petstore/python-tornado</module>
|
||||
<module>samples/openapi3/client/petstore/python</module>
|
||||
@ -1063,8 +1064,8 @@
|
||||
<!--<module>samples/client/petstore/bash</module>-->
|
||||
<module>samples/server/petstore/rust-server</module>
|
||||
<module>samples/server/petstore/python-aiohttp</module>
|
||||
<module>samples/server/petstore/python-flask</module>
|
||||
<module>samples/server/petstore/python-flask-python2</module>
|
||||
<!--<module>samples/server/petstore/python-flask</module>
|
||||
<module>samples/server/petstore/python-flask-python2</module>-->
|
||||
</modules>
|
||||
</profile>
|
||||
<!-- test with JDK8 in CircleCI -->
|
||||
@ -1080,6 +1081,7 @@
|
||||
<!-- clients -->
|
||||
<!-- test non-java projects -->
|
||||
<module>samples/client/petstore/go</module>
|
||||
<module>samples/client/petstore/go-experimental</module>
|
||||
<!-- test java-related projects -->
|
||||
<!--<module>samples/client/petstore/scala-akka</module>-->
|
||||
<module>samples/client/petstore/scala-httpclient</module>
|
||||
@ -1254,9 +1256,9 @@
|
||||
<modules>
|
||||
<!-- clients -->
|
||||
<module>samples/client/petstore/R</module>
|
||||
<module>samples/client/petstore/haskell-http-client</module>
|
||||
<!--<module>samples/client/petstore/haskell-http-client</module>-->
|
||||
<!-- servers -->
|
||||
<module>samples/server/petstore/haskell-servant</module>
|
||||
<!--<module>samples/server/petstore/haskell-servant</module>-->
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user