forked from loafle/openapi-generator-original
Compare commits
53 Commits
enable-has
...
csharp-nus
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd111791bb | ||
|
|
e4c858cd25 | ||
|
|
6f0bef61ba | ||
|
|
5bbcf30c9c | ||
|
|
930c622d11 | ||
|
|
f1989cc70f | ||
|
|
d78e91517e | ||
|
|
2a17625e1f | ||
|
|
03a0dc7713 | ||
|
|
5abf8b8378 | ||
|
|
4811785c43 | ||
|
|
57ee092abd | ||
|
|
159936d85a | ||
|
|
227fb50b2b | ||
|
|
5ad2c8315e | ||
|
|
5a68bcf532 | ||
|
|
742b8bd650 | ||
|
|
4a7c4ac81d | ||
|
|
201ac77d0c | ||
|
|
be02a33c72 | ||
|
|
f752f29af2 | ||
|
|
f5775f483a | ||
|
|
51c45eb28b | ||
|
|
c1b8c294aa | ||
|
|
aa698633b3 | ||
|
|
9f1d012d14 | ||
|
|
c1b53df345 | ||
|
|
cbcb7ff848 | ||
|
|
66cd0f6511 | ||
|
|
0cb4c43c42 | ||
|
|
b8e87bb6fc | ||
|
|
ba8a50137a | ||
|
|
ca3fa4b9cb | ||
|
|
34f0d02f38 | ||
|
|
7a846a193a | ||
|
|
6a08ec59c0 | ||
|
|
1be98b4920 | ||
|
|
1ffe2a780a | ||
|
|
a9576a1e2b | ||
|
|
93159de77d | ||
|
|
761364eec9 | ||
|
|
43471bacbc | ||
|
|
647d253ac8 | ||
|
|
800d9453a4 | ||
|
|
44726ef471 | ||
|
|
828bdebdac | ||
|
|
5b22d08d41 | ||
|
|
62e5950799 | ||
|
|
d143f8db5c | ||
|
|
a7ccc4addd | ||
|
|
f49ab2a7ed | ||
|
|
b838e1885f | ||
|
|
0f3edb13f5 |
8
.github/ISSUE_TEMPLATE/bug_report.md
vendored
8
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -45,9 +45,13 @@ please create a Gist (https://gist.github.com) or upload it somewhere else and
|
|||||||
link it here.
|
link it here.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
##### Command line used for generation
|
##### Generation Details
|
||||||
|
|
||||||
<!-- including the language, libraries and various options -->
|
<!--
|
||||||
|
Prefer CLI steps, including the language, libraries and various options.
|
||||||
|
Providing config-based settings allows for simpler testing across CLI and plugins.
|
||||||
|
For examples, see https://github.com/OpenAPITools/openapi-generator/tree/master/bin/configs
|
||||||
|
-->
|
||||||
|
|
||||||
##### Steps to reproduce
|
##### Steps to reproduce
|
||||||
|
|
||||||
|
|||||||
3
.github/PULL_REQUEST_TEMPLATE.md
vendored
3
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
<!-- Please check the completed items below -->
|
<!-- Please check the completed items below -->
|
||||||
### PR checklist
|
### PR checklist
|
||||||
|
|
||||||
- [ ] Read the [contribution guidelines](https://github.com/openapitools/openapi-generator/blob/master/CONTRIBUTING.md).
|
- [ ] Read the [contribution guidelines](https://github.com/openapitools/openapi-generator/blob/master/CONTRIBUTING.md).
|
||||||
|
- [ ] Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
|
||||||
- [ ] If contributing template-only or documentation-only changes which will change sample output, [build the project](https://github.com/OpenAPITools/openapi-generator#14---build-projects) beforehand.
|
- [ ] If contributing template-only or documentation-only changes which will change sample output, [build the project](https://github.com/OpenAPITools/openapi-generator#14---build-projects) beforehand.
|
||||||
- [ ] Run the shell script `./bin/generate-samples.sh`to update all Petstore samples related to your fix. This is important, as CI jobs will verify _all_ generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example `./bin/generate-samples.sh bin/configs/java*`. For Windows users, please run the script in [Git BASH](https://gitforwindows.org/).
|
- [ ] Run the shell script `./bin/generate-samples.sh`to update all Petstore samples related to your fix. This is important, as CI jobs will verify _all_ generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example `./bin/generate-samples.sh bin/configs/java*`. For Windows users, please run the script in [Git BASH](https://gitforwindows.org/).
|
||||||
- [ ] File the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master`
|
- [ ] File the PR against the [correct branch](https://github.com/OpenAPITools/openapi-generator/wiki/Git-Branches): `master`
|
||||||
|
|||||||
80
.github/workflows/check-supported-versions.yaml
vendored
Normal file
80
.github/workflows/check-supported-versions.yaml
vendored
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
name: Check Supported Java Versions
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build on JDK ${{ matrix.java }} and ${{ matrix.os }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
java: [8, 11]
|
||||||
|
os: [ubuntu-latest]
|
||||||
|
include:
|
||||||
|
- java: 8
|
||||||
|
os: windows-latest
|
||||||
|
- java: 13
|
||||||
|
os: ubuntu-latest
|
||||||
|
# Need to update to Gradle version with v13 support in modules/openapi-generator-gradle-plugin/pom.xml
|
||||||
|
flags: -am -pl modules/openapi-generator-cli
|
||||||
|
steps:
|
||||||
|
- name: Check out code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up JDK ${{ matrix.java }}
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: ${{ matrix.java }}
|
||||||
|
|
||||||
|
- uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: ~/.m2/repository
|
||||||
|
key: ${{ runner.os }}-maven-${{ hashFiles('pom.xml', 'modules/**/pom.xml') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-maven-
|
||||||
|
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.gradle/caches
|
||||||
|
~/.gradle/wrapper
|
||||||
|
key: ${{ runner.os }}-gradle-${{ hashFiles('modules/openapi-generator-gradle-plugin/pom.xml') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-gradle-
|
||||||
|
|
||||||
|
- name: Build with Maven
|
||||||
|
shell: bash
|
||||||
|
run: mvn -nsu -B --quiet -Djacoco.skip=true -Dorg.slf4j.simpleLogger.defaultLogLevel=error --no-transfer-progress clean install --file pom.xml ${{ matrix.flags }}
|
||||||
|
|
||||||
|
- name: Test gradle
|
||||||
|
shell: bash
|
||||||
|
run: gradle -b modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle buildGoSdk --stacktrace
|
||||||
|
|
||||||
|
- name: Upload Maven build artifact
|
||||||
|
uses: actions/upload-artifact@v1
|
||||||
|
if: matrix.java == '8'
|
||||||
|
with:
|
||||||
|
name: artifact
|
||||||
|
path: modules/openapi-generator-cli/target/openapi-generator-cli.jar
|
||||||
|
|
||||||
|
verify:
|
||||||
|
name: Verifies integrity of the commit on ${{ matrix.os }}
|
||||||
|
needs: build
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest]
|
||||||
|
steps:
|
||||||
|
- name: Check out code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Download build artifact
|
||||||
|
uses: actions/download-artifact@v1
|
||||||
|
with:
|
||||||
|
name: artifact
|
||||||
|
- name: Run Ensures Script
|
||||||
|
run: |
|
||||||
|
mkdir -p modules/openapi-generator-cli/target/
|
||||||
|
mv artifact/openapi-generator-cli.jar modules/openapi-generator-cli/target/
|
||||||
|
./bin/utils/ensure-up-to-date
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -173,6 +173,9 @@ samples/client/petstore/python-asyncio/.venv/
|
|||||||
samples/client/petstore/python-asyncio/.pytest_cache/
|
samples/client/petstore/python-asyncio/.pytest_cache/
|
||||||
samples/client/petstore/python-tornado/.venv/
|
samples/client/petstore/python-tornado/.venv/
|
||||||
|
|
||||||
|
# PHP
|
||||||
|
samples/server/petstore/php-lumen/lib/composer.lock
|
||||||
|
|
||||||
# ts
|
# ts
|
||||||
samples/client/petstore/typescript-angular2/npm/npm-debug.log
|
samples/client/petstore/typescript-angular2/npm/npm-debug.log
|
||||||
samples/client/petstore/typescript-node/npm/npm-debug.log
|
samples/client/petstore/typescript-node/npm/npm-debug.log
|
||||||
|
|||||||
27
.travis.yml
27
.travis.yml
@@ -77,11 +77,13 @@ before_install:
|
|||||||
- docker pull swaggerapi/petstore
|
- docker pull swaggerapi/petstore
|
||||||
- docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore
|
- docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore
|
||||||
- docker ps -a
|
- docker ps -a
|
||||||
|
# -- skip bash test to shorten build time
|
||||||
# Add bats test framework and cURL for Bash script integration tests
|
# Add bats test framework and cURL for Bash script integration tests
|
||||||
- sudo add-apt-repository ppa:duggan/bats --yes
|
#- sudo add-apt-repository ppa:duggan/bats --yes
|
||||||
- sudo apt-get update -qq
|
#- sudo apt-get update -qq
|
||||||
- sudo apt-get install -qq bats
|
#- sudo apt-get install -qq bats
|
||||||
- sudo apt-get install -qq curl
|
#- sudo apt-get install -qq curl
|
||||||
|
# -- skip bash test end
|
||||||
# install dart
|
# install dart
|
||||||
#- sudo apt-get update
|
#- sudo apt-get update
|
||||||
#- sudo apt-get install apt-transport-https
|
#- sudo apt-get install apt-transport-https
|
||||||
@@ -93,9 +95,6 @@ before_install:
|
|||||||
- phpenv versions
|
- phpenv versions
|
||||||
- phpenv global 7.2.15
|
- phpenv global 7.2.15
|
||||||
- php -v
|
- php -v
|
||||||
# install perl module
|
|
||||||
#- cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
|
|
||||||
#- cpanm Test::Exception Test::More Log::Any LWP::UserAgent JSON URI:Query Module::Runtime DateTime Module::Find Moose::Role
|
|
||||||
# comment out below as installation failed in travis
|
# comment out below as installation failed in travis
|
||||||
# Add rebar3 build tool and recent Erlang/OTP for Erlang petstore server tests.
|
# Add rebar3 build tool and recent Erlang/OTP for Erlang petstore server tests.
|
||||||
# - Travis CI does not support rebar3 [yet](https://github.com/travis-ci/travis-ci/issues/6506#issuecomment-275189490).
|
# - Travis CI does not support rebar3 [yet](https://github.com/travis-ci/travis-ci/issues/6506#issuecomment-275189490).
|
||||||
@@ -107,9 +106,11 @@ before_install:
|
|||||||
# install Qt5
|
# install Qt5
|
||||||
- sudo apt install -y --no-install-recommends qt5-default
|
- sudo apt install -y --no-install-recommends qt5-default
|
||||||
- cmake --version
|
- cmake --version
|
||||||
|
# -- skip perl test to shorten build time
|
||||||
# perl dep
|
# perl dep
|
||||||
- cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
|
#- cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
|
||||||
- cpanm --quiet --no-interactive Test::Exception Test::More Log::Any LWP::UserAgent URI::Query Module::Runtime DateTime Module::Find Moose::Role JSON || echo "Igorned failure from cpanm"
|
#- cpanm --quiet --no-interactive Test::Exception Test::More Log::Any LWP::UserAgent URI::Query Module::Runtime DateTime Module::Find Moose::Role JSON || echo "Igorned failure from cpanm"
|
||||||
|
# -- skip perl test end
|
||||||
# show host table to confirm petstore.swagger.io is mapped to localhost
|
# show host table to confirm petstore.swagger.io is mapped to localhost
|
||||||
- cat /etc/hosts
|
- cat /etc/hosts
|
||||||
# show java version
|
# show java version
|
||||||
@@ -149,14 +150,6 @@ script:
|
|||||||
# WARN: Travis will timeout after 10 minutes of no stdout/stderr activity, which is problematic with mvn --quiet.
|
# WARN: Travis will timeout after 10 minutes of no stdout/stderr activity, which is problematic with mvn --quiet.
|
||||||
- mvn --no-snapshot-updates --quiet --batch-mode --show-version clean install -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
- mvn --no-snapshot-updates --quiet --batch-mode --show-version clean install -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
||||||
- mvn --no-snapshot-updates --quiet --batch-mode --show-version verify -Psamples -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
- mvn --no-snapshot-updates --quiet --batch-mode --show-version verify -Psamples -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
||||||
# test maven plugin
|
|
||||||
- mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/java-client.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
|
||||||
- mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/multi-module/pom.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
|
||||||
- mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/kotlin.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
|
||||||
- mvn --no-snapshot-updates --quiet clean compile -f modules/openapi-generator-maven-plugin/examples/spring.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
|
||||||
# test gradle plugin
|
|
||||||
- (cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew buildGoSdk)
|
|
||||||
- (cd modules/openapi-generator-gradle-plugin/samples/local-spec && ./gradlew openApiGenerate)
|
|
||||||
after_success:
|
after_success:
|
||||||
# push to maven repo
|
# push to maven repo
|
||||||
- if [ $SONATYPE_USERNAME ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
- if [ $SONATYPE_USERNAME ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
- If you're not using the latest master to generate API clients or server stubs, please give it another try by pulling the latest master as the issue may have already been addressed. Ref: [Getting Started](https://github.com/openapitools/openapi-generator#getting-started)
|
- If you're not using the latest master to generate API clients or server stubs, please give it another try by pulling the latest master as the issue may have already been addressed. Ref: [Getting Started](https://github.com/openapitools/openapi-generator#getting-started)
|
||||||
- Search the [open issue](https://github.com/openapitools/openapi-generator/issues) and [closed issue](https://github.com/openapitools/openapi-generator/issues?q=is%3Aissue+is%3Aclosed) to ensure no one else has reported something similar before.
|
- Search the [open issue](https://github.com/openapitools/openapi-generator/issues) and [closed issue](https://github.com/openapitools/openapi-generator/issues?q=is%3Aissue+is%3Aclosed) to ensure no one else has reported something similar before.
|
||||||
- File an [issue ticket](https://github.com/openapitools/openapi-generator/issues/new) by providing all the required information.
|
- File an [issue ticket](https://github.com/openapitools/openapi-generator/issues/new) by providing all the required information. Failure to provide enough detail may result in slow response from the community.
|
||||||
- Test with the latest master by building the JAR locally to see if the issue has already been addressed.
|
- Test with the latest master by building the JAR locally to see if the issue has already been addressed.
|
||||||
- You can also make a suggestion or ask a question by opening an "issue".
|
- You can also make a suggestion or ask a question by opening an "issue".
|
||||||
|
|
||||||
@@ -87,8 +87,7 @@ To add test cases (optional) covering the change in the code generator, please r
|
|||||||
To test the templates, please perform the following:
|
To test the templates, please perform the following:
|
||||||
|
|
||||||
- Update the Petstore sample by running the shell scripts under the `bin` folder. For example, run `./bin/generate-samples.sh .
|
- Update the Petstore sample by running the shell scripts under the `bin` folder. For example, run `./bin/generate-samples.sh .
|
||||||
/bin/configs/python*` to update the Python-related samples under [`samples`](https://github.com/openapitools/openapi-generator/t
|
/bin/configs/python*` to update the Python-related samples under [`samples`](https://github.com/openapitools/openapi-generator/tree/master/samples). For Windows, please install [GIT bash](https://gitforwindows.org/). (If you find that there are new files g
|
||||||
ree/master/samples). For Windows, please install [GIT bash](https://gitforwindows.org/). (If you find that there are new files g
|
|
||||||
enerated or unexpected changes as a result of the update, that's not unusual as the test cases are added to the OpenAPI spec fro
|
enerated or unexpected changes as a result of the update, that's not unusual as the test cases are added to the OpenAPI spec fro
|
||||||
m time to time. If you've questions or concerns, please open a ticket to start a discussion)
|
m time to time. If you've questions or concerns, please open a ticket to start a discussion)
|
||||||
- During development it can be helpful to quickly regenerate the samples without recompiling all of openapi-generator, e.g. when you have only updated the mustache templates. This can be done by passing the `-t` parameter: `-t modules/openapi-generator/src/main/resources/python`.
|
- During development it can be helpful to quickly regenerate the samples without recompiling all of openapi-generator, e.g. when you have only updated the mustache templates. This can be done by passing the `-t` parameter: `-t modules/openapi-generator/src/main/resources/python`.
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
||||||
[](https://cloud.drone.io/OpenAPITools/openapi-generator)
|
[](https://cloud.drone.io/OpenAPITools/openapi-generator)
|
||||||
[](https://app.bitrise.io/app/4a2b10a819d12b67)
|
[](https://app.bitrise.io/app/4a2b10a819d12b67)
|
||||||
|

|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -767,6 +768,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
|||||||
- 2020-07-20 - [Datadog API client libraries now available for Java and Go](https://www.datadoghq.com/blog/java-go-libraries/) by Jordan Obey at [Datadog Blog](https://www.datadoghq.com/blog)
|
- 2020-07-20 - [Datadog API client libraries now available for Java and Go](https://www.datadoghq.com/blog/java-go-libraries/) by Jordan Obey at [Datadog Blog](https://www.datadoghq.com/blog)
|
||||||
- 2020-07-23 - [Generate Client SDK for .NET Core using Open Api](https://dev.to/no0law1/generate-client-sdk-for-net-core-using-open-api-2dgh) by [Nuno Reis](https://dev.to/no0law1)
|
- 2020-07-23 - [Generate Client SDK for .NET Core using Open Api](https://dev.to/no0law1/generate-client-sdk-for-net-core-using-open-api-2dgh) by [Nuno Reis](https://dev.to/no0law1)
|
||||||
- 2020-07-26 - [Dartのhttp_interceptorライブラリを使うと配列のクエリパラメータが消えてしまう件の応急処置](https://qiita.com/gyamoto/items/eeeff81b6770487319ed) by [@gyamoto](https://qiita.com/gyamoto)
|
- 2020-07-26 - [Dartのhttp_interceptorライブラリを使うと配列のクエリパラメータが消えてしまう件の応急処置](https://qiita.com/gyamoto/items/eeeff81b6770487319ed) by [@gyamoto](https://qiita.com/gyamoto)
|
||||||
|
- 2020-08-03 - [Criando Bibliotecas para APIs RESTful com OpenAPI, Swagger Editor e OpenAPI Generator](https://medium.com/@everisBrasil/criando-bibliotecas-para-apis-restful-com-openapi-swagger-editor-e-openapi-generator-75349a6420fd) by [everis Brasil (an NTT DATA Company)](https://medium.com/@everisBrasil)
|
||||||
|
|
||||||
## [6 - About Us](#table-of-contents)
|
## [6 - About Us](#table-of-contents)
|
||||||
|
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ install:
|
|||||||
# install gradle
|
# install gradle
|
||||||
- ps: |
|
- ps: |
|
||||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||||
if (!(Test-Path -Path "C:\gradle" )) {
|
if (!(Test-Path -Path "C:\gradle\gradle-5.6.4" )) {
|
||||||
(new-object System.Net.WebClient).DownloadFile(
|
(new-object System.Net.WebClient).DownloadFile(
|
||||||
'https://services.gradle.org/distributions/gradle-5.3.1-bin.zip',
|
'https://services.gradle.org/distributions/gradle-5.6.4-bin.zip',
|
||||||
'C:\gradle-bin.zip'
|
'C:\gradle-bin.zip'
|
||||||
)
|
)
|
||||||
[System.IO.Compression.ZipFile]::ExtractToDirectory("C:\gradle-bin.zip", "C:\gradle")
|
[System.IO.Compression.ZipFile]::ExtractToDirectory("C:\gradle-bin.zip", "C:\gradle")
|
||||||
}
|
}
|
||||||
- cmd: SET PATH=C:\maven\apache-maven-3.2.5\bin;C:\gradle\gradle-5.3.1\bin;%JAVA_HOME%\bin;%PATH%
|
- cmd: SET PATH=C:\maven\apache-maven-3.2.5\bin;C:\gradle\gradle-5.6.4\bin;%JAVA_HOME%\bin;%PATH%
|
||||||
- cmd: SET MAVEN_OPTS=-Xmx4g
|
- cmd: SET MAVEN_OPTS=-Xmx4g
|
||||||
- cmd: SET JAVA_OPTS=-Xmx4g
|
- cmd: SET JAVA_OPTS=-Xmx4g
|
||||||
- cmd: SET M2_HOME=C:\maven\apache-maven-3.2.5
|
- cmd: SET M2_HOME=C:\maven\apache-maven-3.2.5
|
||||||
|
|||||||
@@ -5,4 +5,5 @@ templateDir: modules/openapi-generator/src/main/resources/csharp-netcore
|
|||||||
additionalProperties:
|
additionalProperties:
|
||||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
||||||
targetFramework: netcoreapp2.0
|
targetFramework: netcoreapp2.0
|
||||||
useCompareNetObjects: "true"
|
useCompareNetObjects: true
|
||||||
|
license: BSD-2-Clause OR MIT
|
||||||
|
|||||||
8
bin/configs/kotlin-jvm-retrofit2-rx3.yaml
Normal file
8
bin/configs/kotlin-jvm-retrofit2-rx3.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
generatorName: kotlin
|
||||||
|
outputDir: samples/client/petstore/kotlin-retrofit2-rx3
|
||||||
|
library: jvm-retrofit2
|
||||||
|
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||||
|
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
|
||||||
|
additionalProperties:
|
||||||
|
artifactId: kotlin-petstore-retrofit2-rx3
|
||||||
|
useRxJava3: "true"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
generatorName: php-lumen
|
generatorName: php-lumen
|
||||||
outputDir: samples/server/petstore/php-lumen
|
outputDir: samples/server/petstore/php-lumen
|
||||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||||
templateDir: modules/openapi-generator/src/main/resources/php-lumen
|
templateDir: modules/openapi-generator/src/main/resources/php-lumen
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ sidebar_label: Guidelines
|
|||||||
|
|
||||||
- If you're not using the latest master to generate API clients or server stubs, please give it another try by pulling the latest master as the issue may have already been addressed. Ref: [Getting Started](https://github.com/openapitools/openapi-generator#getting-started)
|
- If you're not using the latest master to generate API clients or server stubs, please give it another try by pulling the latest master as the issue may have already been addressed. Ref: [Getting Started](https://github.com/openapitools/openapi-generator#getting-started)
|
||||||
- Search the [open issue](https://github.com/openapitools/openapi-generator/issues) and [closed issue](https://github.com/openapitools/openapi-generator/issues?q=is%3Aissue+is%3Aclosed) to ensure no one else has reported something similar before.
|
- Search the [open issue](https://github.com/openapitools/openapi-generator/issues) and [closed issue](https://github.com/openapitools/openapi-generator/issues?q=is%3Aissue+is%3Aclosed) to ensure no one else has reported something similar before.
|
||||||
- File an [issue ticket](https://github.com/openapitools/openapi-generator/issues/new) by providing all the required information.
|
- File an [issue ticket](https://github.com/openapitools/openapi-generator/issues/new) by providing all the required information. Failure to provide enough detail may result in slow response from the community.
|
||||||
- Test with the latest master by building the JAR locally to see if the issue has already been addressed.
|
- Test with the latest master by building the JAR locally to see if the issue has already been addressed.
|
||||||
- You can also make a suggestion or ask a question by opening an "issue".
|
- You can also make a suggestion or ask a question by opening an "issue".
|
||||||
|
|
||||||
@@ -91,8 +91,7 @@ To add test cases (optional) covering the change in the code generator, please r
|
|||||||
To test the templates, please perform the following:
|
To test the templates, please perform the following:
|
||||||
|
|
||||||
- Update the Petstore sample by running the shell scripts under the `bin` folder. For example, run `./bin/generate-samples.sh .
|
- Update the Petstore sample by running the shell scripts under the `bin` folder. For example, run `./bin/generate-samples.sh .
|
||||||
/bin/configs/python*` to update the Python-related samples under [`samples`](https://github.com/openapitools/openapi-generator/t
|
/bin/configs/python*` to update the Python-related samples under [`samples`](https://github.com/openapitools/openapi-generator/tree/master/samples). For Windows, please install [GIT bash](https://gitforwindows.org/). (If you find that there are new files g
|
||||||
ree/master/samples). For Windows, please install [GIT bash](https://gitforwindows.org/). (If you find that there are new files g
|
|
||||||
enerated or unexpected changes as a result of the update, that's not unusual as the test cases are added to the OpenAPI spec fro
|
enerated or unexpected changes as a result of the update, that's not unusual as the test cases are added to the OpenAPI spec fro
|
||||||
m time to time. If you've questions or concerns, please open a ticket to start a discussion)
|
m time to time. If you've questions or concerns, please open a ticket to start a discussion)
|
||||||
- During development it can be helpful to quickly regenerate the samples without recompiling all of openapi-generator, e.g. when you have only updated the mustache templates. This can be done by passing the `-t` parameter: `-t modules/openapi-generator/src/main/resources/python`.
|
- During development it can be helpful to quickly regenerate the samples without recompiling all of openapi-generator, e.g. when you have only updated the mustache templates. This can be done by passing the `-t` parameter: `-t modules/openapi-generator/src/main/resources/python`.
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ sidebar_label: aspnetcore
|
|||||||
|modelClassModifier|Model Class Modifier can be nothing or partial| |partial|
|
|modelClassModifier|Model Class Modifier can be nothing or partial| |partial|
|
||||||
|newtonsoftVersion|Version for Microsoft.AspNetCore.Mvc.NewtonsoftJson for ASP.NET Core 3.0+| |3.0.0|
|
|newtonsoftVersion|Version for Microsoft.AspNetCore.Mvc.NewtonsoftJson for ASP.NET Core 3.0+| |3.0.0|
|
||||||
|operationIsAsync|Set methods to async or sync (default).| |false|
|
|operationIsAsync|Set methods to async or sync (default).| |false|
|
||||||
|operationModifier|Operation Modifier can be virtual, abstract or partial| |virtual|
|
|operationModifier|Operation Modifier can be virtual or abstract| |virtual|
|
||||||
|operationResultTask|Set methods result to Task<>.| |false|
|
|operationResultTask|Set methods result to Task<>.| |false|
|
||||||
|packageAuthors|Specifies Authors property in the .NET Core project file.| |OpenAPI|
|
|packageAuthors|Specifies Authors property in the .NET Core project file.| |OpenAPI|
|
||||||
|packageCopyright|Specifies an AssemblyCopyright for the .NET Framework global assembly attributes stored in the AssemblyInfo file.| |No Copyright|
|
|packageCopyright|Specifies an AssemblyCopyright for the .NET Framework global assembly attributes stored in the AssemblyInfo file.| |No Copyright|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ sidebar_label: go-server
|
|||||||
|
|
||||||
| Option | Description | Values | Default |
|
| Option | Description | Values | Default |
|
||||||
| ------ | ----------- | ------ | ------- |
|
| ------ | ----------- | ------ | ------- |
|
||||||
|
|enumClassPrefix|Prefix enum with class name| |false|
|
||||||
|featureCORS|Enable Cross-Origin Resource Sharing middleware| |false|
|
|featureCORS|Enable Cross-Origin Resource Sharing middleware| |false|
|
||||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||||
|packageName|Go package name (convention: lowercase).| |openapi|
|
|packageName|Go package name (convention: lowercase).| |openapi|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ sidebar_label: kotlin
|
|||||||
|useCoroutines|Whether to use the Coroutines adapter with the retrofit2 library.| |false|
|
|useCoroutines|Whether to use the Coroutines adapter with the retrofit2 library.| |false|
|
||||||
|useRxJava|Whether to use the RxJava adapter with the retrofit2 library.| |false|
|
|useRxJava|Whether to use the RxJava adapter with the retrofit2 library.| |false|
|
||||||
|useRxJava2|Whether to use the RxJava2 adapter with the retrofit2 library.| |false|
|
|useRxJava2|Whether to use the RxJava2 adapter with the retrofit2 library.| |false|
|
||||||
|
|useRxJava3|Whether to use the RxJava3 adapter with the retrofit2 library.| |false|
|
||||||
|
|
||||||
## IMPORT MAPPING
|
## IMPORT MAPPING
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,35 @@ task validateBadSpec(type: org.openapitools.generator.gradle.plugin.tasks.Valida
|
|||||||
task validateSpecs(dependsOn: ['validateGoodSpec', 'validateBadSpec'])
|
task validateSpecs(dependsOn: ['validateGoodSpec', 'validateBadSpec'])
|
||||||
----
|
----
|
||||||
|
|
||||||
|
[NOTE]
|
||||||
|
====
|
||||||
|
The tasks support Gradle Up-To-Date checking and Gradle Cache. Enable caching globally by setting `org.gradle.caching=true` in the `gradle.settings`
|
||||||
|
file or by passing the command line property `--build-cache` when executing on the command line.
|
||||||
|
|
||||||
|
Disable up-to-date checks and caching by setting the following property when using the extension:
|
||||||
|
|
||||||
|
.Disable caching for extension
|
||||||
|
[source,groovy]
|
||||||
|
----
|
||||||
|
tasks.withType(org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
|
||||||
|
outputs.upToDateWhen { false }
|
||||||
|
outputs.cacheIf { false }
|
||||||
|
}
|
||||||
|
----
|
||||||
|
Disable up-to-date checks and caching for a custom task:
|
||||||
|
|
||||||
|
.Disable caching for custom task
|
||||||
|
[source,groovy]
|
||||||
|
----
|
||||||
|
task validateGoodSpec(type: org.openapitools.generator.gradle.plugin.tasks.ValidateTask){
|
||||||
|
outputs.upToDateWhen { false }
|
||||||
|
outputs.cacheIf { false }
|
||||||
|
|
||||||
|
inputSpec = "$rootDir/petstore-v3.0.yaml".toString()
|
||||||
|
}
|
||||||
|
----
|
||||||
|
====
|
||||||
|
|
||||||
== Plugin Setup
|
== Plugin Setup
|
||||||
|
|
||||||
//# RELEASE_VERSION
|
//# RELEASE_VERSION
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#Thu Jan 30 22:14:34 EST 2020
|
#Thu Jan 30 22:14:34 EST 2020
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
# Local Spec Sample
|
# Local Spec Sample
|
||||||
|
|
||||||
This example assumes you have Gradle 4.7+ installed. No gradle wrapper is provided in samples.
|
This example assumes you have Gradle 5.6.4+ installed. No gradle wrapper is provided in samples.
|
||||||
|
|
||||||
First, publish the openapi-generator-gradle-plugin locally via `./gradlew assemble install` in the module directory.
|
First, publish the openapi-generator-gradle-plugin locally via `./gradlew assemble publishToMavenLocal` in the module directory.
|
||||||
|
|
||||||
Then, run the following tasks in this example directory.
|
Then, run the following tasks in this example directory.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gradle openApiGenerate
|
gradle openApiGenerate # expected outcome: BUILD SCCESSFUL
|
||||||
gradle openApiMeta
|
gradle openApiMeta # expected outcome: BUILD SCCESSFUL
|
||||||
gradle openApiValidate
|
gradle openApiValidate # expected outcome: BUILD FAILED
|
||||||
gradle buildGoSdk
|
gradle buildGoSdk # expected outcome: BUILD SCCESSFUL
|
||||||
gradle buildDotnetSdk
|
gradle buildDotnetSdk # expected outcome: BUILD SCCESSFUL
|
||||||
gradle generateGoWithInvalidSpec
|
gradle generateGoWithInvalidSpec # expected outcome: BUILD FAILED
|
||||||
```
|
```
|
||||||
|
|
||||||
The samples can be tested against other versions of the plugin using the `openApiGeneratorVersion` property. For example:
|
The samples can be tested against other versions of the plugin using the `openApiGeneratorVersion` property. For example:
|
||||||
|
|||||||
@@ -55,9 +55,9 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
|
|||||||
)
|
)
|
||||||
|
|
||||||
val generators = extensions.create(
|
val generators = extensions.create(
|
||||||
"openApiGenerators",
|
"openApiGenerators",
|
||||||
OpenApiGeneratorGeneratorsExtension::class.java,
|
OpenApiGeneratorGeneratorsExtension::class.java,
|
||||||
project
|
project
|
||||||
)
|
)
|
||||||
|
|
||||||
generate.outputDir.set("$buildDir/generate-resources/main")
|
generate.outputDir.set("$buildDir/generate-resources/main")
|
||||||
|
|||||||
@@ -317,7 +317,7 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
fun applyDefaults(){
|
fun applyDefaults() {
|
||||||
releaseNote.set("Minor update")
|
releaseNote.set("Minor update")
|
||||||
modelNamePrefix.set("")
|
modelNamePrefix.set("")
|
||||||
modelNameSuffix.set("")
|
modelNameSuffix.set("")
|
||||||
|
|||||||
@@ -19,7 +19,14 @@ package org.openapitools.generator.gradle.plugin.tasks
|
|||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
import org.gradle.api.GradleException
|
import org.gradle.api.GradleException
|
||||||
import org.gradle.api.provider.Property
|
import org.gradle.api.provider.Property
|
||||||
|
import org.gradle.api.tasks.CacheableTask
|
||||||
|
import org.gradle.api.tasks.Input
|
||||||
|
import org.gradle.api.tasks.InputFile
|
||||||
import org.gradle.api.tasks.Internal
|
import org.gradle.api.tasks.Internal
|
||||||
|
import org.gradle.api.tasks.Optional
|
||||||
|
import org.gradle.api.tasks.OutputDirectory
|
||||||
|
import org.gradle.api.tasks.PathSensitive
|
||||||
|
import org.gradle.api.tasks.PathSensitivity
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.tasks.TaskAction
|
||||||
import org.gradle.api.tasks.options.Option
|
import org.gradle.api.tasks.options.Option
|
||||||
import org.gradle.internal.logging.text.StyledTextOutput
|
import org.gradle.internal.logging.text.StyledTextOutput
|
||||||
@@ -32,7 +39,6 @@ import org.openapitools.codegen.DefaultGenerator
|
|||||||
import org.openapitools.codegen.config.CodegenConfigurator
|
import org.openapitools.codegen.config.CodegenConfigurator
|
||||||
import org.openapitools.codegen.config.GlobalSettings
|
import org.openapitools.codegen.config.GlobalSettings
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A task which generates the desired code.
|
* A task which generates the desired code.
|
||||||
*
|
*
|
||||||
@@ -43,63 +49,73 @@ import org.openapitools.codegen.config.GlobalSettings
|
|||||||
* @author Jim Schubert
|
* @author Jim Schubert
|
||||||
*/
|
*/
|
||||||
@Suppress("UnstableApiUsage")
|
@Suppress("UnstableApiUsage")
|
||||||
|
@CacheableTask
|
||||||
open class GenerateTask : DefaultTask() {
|
open class GenerateTask : DefaultTask() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The verbosity of generation
|
* The verbosity of generation
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val verbose = project.objects.property<Boolean>()
|
val verbose = project.objects.property<Boolean>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not an input specification should be validated upon generation.
|
* Whether or not an input specification should be validated upon generation.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val validateSpec = project.objects.property<Boolean>()
|
val validateSpec = project.objects.property<Boolean>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the generator which will handle codegen. (see "openApiGenerators" task)
|
* The name of the generator which will handle codegen. (see "openApiGenerators" task)
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val generatorName = project.objects.property<String>()
|
val generatorName = project.objects.property<String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The output target directory into which code will be generated.
|
* The output target directory into which code will be generated.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@get:OutputDirectory
|
||||||
val outputDir = project.objects.property<String>()
|
val outputDir = project.objects.property<String>()
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
@get:Internal
|
@get:Internal
|
||||||
@set:Option(option = "input", description = "The input specification.")
|
@set:Option(option = "input", description = "The input specification.")
|
||||||
|
@Input
|
||||||
var input: String? = null
|
var input: String? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
inputSpec.set(value)
|
inputSpec.set(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Open API 2.0/3.x specification location.
|
* The Open API 2.0/3.x specification location.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@get:InputFile
|
||||||
|
@PathSensitive(PathSensitivity.RELATIVE)
|
||||||
val inputSpec = project.objects.property<String>()
|
val inputSpec = project.objects.property<String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The template directory holding a custom template.
|
* The template directory holding a custom template.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val templateDir = project.objects.property<String?>()
|
val templateDir = project.objects.property<String?>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds authorization headers when fetching the OpenAPI definitions remotely.
|
* Adds authorization headers when fetching the OpenAPI definitions remotely.
|
||||||
* Pass in a URL-encoded string of name:header with a comma separating multiple values
|
* Pass in a URL-encoded string of name:header with a comma separating multiple values
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val auth = project.objects.property<String>()
|
val auth = project.objects.property<String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets specified global properties.
|
* Sets specified global properties.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val globalProperties = project.objects.mapProperty<String, String>()
|
val globalProperties = project.objects.mapProperty<String, String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,159 +123,185 @@ open class GenerateTask : DefaultTask() {
|
|||||||
* File content should be in a json format { "optionKey":"optionValue", "optionKey1":"optionValue1"...}
|
* File content should be in a json format { "optionKey":"optionValue", "optionKey1":"optionValue1"...}
|
||||||
* Supported options can be different for each language. Run config-help -g {generator name} command for language specific config options.
|
* Supported options can be different for each language. Run config-help -g {generator name} command for language specific config options.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val configFile = project.objects.property<String>()
|
val configFile = project.objects.property<String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies if the existing files should be overwritten during the generation.
|
* Specifies if the existing files should be overwritten during the generation.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val skipOverwrite = project.objects.property<Boolean?>()
|
val skipOverwrite = project.objects.property<Boolean?>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Package for generated classes (where supported)
|
* Package for generated classes (where supported)
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val packageName = project.objects.property<String>()
|
val packageName = project.objects.property<String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Package for generated api classes
|
* Package for generated api classes
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val apiPackage = project.objects.property<String>()
|
val apiPackage = project.objects.property<String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Package for generated models
|
* Package for generated models
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val modelPackage = project.objects.property<String>()
|
val modelPackage = project.objects.property<String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prefix that will be prepended to all model names. Default is the empty string.
|
* Prefix that will be prepended to all model names. Default is the empty string.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val modelNamePrefix = project.objects.property<String>()
|
val modelNamePrefix = project.objects.property<String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Suffix that will be appended to all model names. Default is the empty string.
|
* Suffix that will be appended to all model names. Default is the empty string.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val modelNameSuffix = project.objects.property<String>()
|
val modelNameSuffix = project.objects.property<String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets instantiation type mappings.
|
* Sets instantiation type mappings.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val instantiationTypes = project.objects.mapProperty<String, String>()
|
val instantiationTypes = project.objects.mapProperty<String, String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets mappings between OpenAPI spec types and generated code types.
|
* Sets mappings between OpenAPI spec types and generated code types.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val typeMappings = project.objects.mapProperty<String, String>()
|
val typeMappings = project.objects.mapProperty<String, String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets additional properties that can be referenced by the mustache templates in the format of name=value,name=value.
|
* Sets additional properties that can be referenced by the mustache templates in the format of name=value,name=value.
|
||||||
* You can also have multiple occurrences of this option.
|
* You can also have multiple occurrences of this option.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val additionalProperties = project.objects.mapProperty<String, String>()
|
val additionalProperties = project.objects.mapProperty<String, String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets server variable for server URL template substitution, in the format of name=value,name=value.
|
* Sets server variable for server URL template substitution, in the format of name=value,name=value.
|
||||||
* You can also have multiple occurrences of this option.
|
* You can also have multiple occurrences of this option.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val serverVariables = project.objects.mapProperty<String, String>()
|
val serverVariables = project.objects.mapProperty<String, String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies additional language specific primitive types in the format of type1,type2,type3,type3. For example: String,boolean,Boolean,Double.
|
* Specifies additional language specific primitive types in the format of type1,type2,type3,type3. For example: String,boolean,Boolean,Double.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val languageSpecificPrimitives = project.objects.listProperty<String>()
|
val languageSpecificPrimitives = project.objects.listProperty<String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies mappings between a given class and the import that should be used for that class.
|
* Specifies mappings between a given class and the import that should be used for that class.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val importMappings = project.objects.mapProperty<String, String>()
|
val importMappings = project.objects.mapProperty<String, String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Root package for generated code.
|
* Root package for generated code.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val invokerPackage = project.objects.property<String>()
|
val invokerPackage = project.objects.property<String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GroupId in generated pom.xml/build.gradle or other build script. Language-specific conversions occur in non-jvm generators.
|
* GroupId in generated pom.xml/build.gradle or other build script. Language-specific conversions occur in non-jvm generators.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val groupId = project.objects.property<String>()
|
val groupId = project.objects.property<String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ArtifactId in generated pom.xml/build.gradle or other build script. Language-specific conversions occur in non-jvm generators.
|
* ArtifactId in generated pom.xml/build.gradle or other build script. Language-specific conversions occur in non-jvm generators.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val id = project.objects.property<String>()
|
val id = project.objects.property<String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Artifact version in generated pom.xml/build.gradle or other build script. Language-specific conversions occur in non-jvm generators.
|
* Artifact version in generated pom.xml/build.gradle or other build script. Language-specific conversions occur in non-jvm generators.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val version = project.objects.property<String>()
|
val version = project.objects.property<String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reference the library template (sub-template) of a generator.
|
* Reference the library template (sub-template) of a generator.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val library = project.objects.property<String?>()
|
val library = project.objects.property<String?>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Git host, e.g. gitlab.com.
|
* Git host, e.g. gitlab.com.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val gitHost = project.objects.property<String?>()
|
val gitHost = project.objects.property<String?>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Git user ID, e.g. openapitools.
|
* Git user ID, e.g. openapitools.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val gitUserId = project.objects.property<String?>()
|
val gitUserId = project.objects.property<String?>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Git repo ID, e.g. openapi-generator.
|
* Git repo ID, e.g. openapi-generator.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val gitRepoId = project.objects.property<String?>()
|
val gitRepoId = project.objects.property<String?>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Release note, default to 'Minor update'.
|
* Release note, default to 'Minor update'.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val releaseNote = project.objects.property<String?>()
|
val releaseNote = project.objects.property<String?>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HTTP user agent, e.g. codegen_csharp_api_client, default to 'OpenAPI-Generator/{packageVersion}/{language}'
|
* HTTP user agent, e.g. codegen_csharp_api_client, default to 'OpenAPI-Generator/{packageVersion}/{language}'
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val httpUserAgent = project.objects.property<String?>()
|
val httpUserAgent = project.objects.property<String?>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies how a reserved name should be escaped to.
|
* Specifies how a reserved name should be escaped to.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val reservedWordsMappings = project.objects.mapProperty<String, String>()
|
val reservedWordsMappings = project.objects.mapProperty<String, String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies an override location for the .openapi-generator-ignore file. Most useful on initial generation.
|
* Specifies an override location for the .openapi-generator-ignore file. Most useful on initial generation.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val ignoreFileOverride = project.objects.property<String?>()
|
val ignoreFileOverride = project.objects.property<String?>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove prefix of operationId, e.g. config_getId => getId
|
* Remove prefix of operationId, e.g. config_getId => getId
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val removeOperationIdPrefix = project.objects.property<Boolean?>()
|
val removeOperationIdPrefix = project.objects.property<Boolean?>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -271,7 +313,8 @@ open class GenerateTask : DefaultTask() {
|
|||||||
* in others being disabled. That is, OpenAPI Generator considers any one of these to define a subset of generation.
|
* in others being disabled. That is, OpenAPI Generator considers any one of these to define a subset of generation.
|
||||||
* For more control over generation of individual files, configure an ignore file and refer to it via [ignoreFileOverride].
|
* For more control over generation of individual files, configure an ignore file and refer to it via [ignoreFileOverride].
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val apiFilesConstrainedTo = project.objects.listProperty<String>()
|
val apiFilesConstrainedTo = project.objects.listProperty<String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -281,7 +324,8 @@ open class GenerateTask : DefaultTask() {
|
|||||||
* in others being disabled. That is, OpenAPI Generator considers any one of these to define a subset of generation.
|
* in others being disabled. That is, OpenAPI Generator considers any one of these to define a subset of generation.
|
||||||
* For more control over generation of individual files, configure an ignore file and refer to it via [ignoreFileOverride].
|
* For more control over generation of individual files, configure an ignore file and refer to it via [ignoreFileOverride].
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val modelFilesConstrainedTo = project.objects.listProperty<String>()
|
val modelFilesConstrainedTo = project.objects.listProperty<String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -294,7 +338,8 @@ open class GenerateTask : DefaultTask() {
|
|||||||
* in others being disabled. That is, OpenAPI Generator considers any one of these to define a subset of generation.
|
* in others being disabled. That is, OpenAPI Generator considers any one of these to define a subset of generation.
|
||||||
* For more control over generation of individual files, configure an ignore file and refer to it via [ignoreFileOverride].
|
* For more control over generation of individual files, configure an ignore file and refer to it via [ignoreFileOverride].
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val supportingFilesConstrainedTo = project.objects.listProperty<String>()
|
val supportingFilesConstrainedTo = project.objects.listProperty<String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -305,7 +350,8 @@ open class GenerateTask : DefaultTask() {
|
|||||||
* For more control over generation of individual files, configure an ignore file and
|
* For more control over generation of individual files, configure an ignore file and
|
||||||
* refer to it via [ignoreFileOverride].
|
* refer to it via [ignoreFileOverride].
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val generateModelTests = project.objects.property<Boolean>()
|
val generateModelTests = project.objects.property<Boolean>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -316,7 +362,8 @@ open class GenerateTask : DefaultTask() {
|
|||||||
* For more control over generation of individual files, configure an ignore file and
|
* For more control over generation of individual files, configure an ignore file and
|
||||||
* refer to it via [ignoreFileOverride].
|
* refer to it via [ignoreFileOverride].
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val generateModelDocumentation = project.objects.property<Boolean>()
|
val generateModelDocumentation = project.objects.property<Boolean>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -327,7 +374,8 @@ open class GenerateTask : DefaultTask() {
|
|||||||
* For more control over generation of individual files, configure an ignore file and
|
* For more control over generation of individual files, configure an ignore file and
|
||||||
* refer to it via [ignoreFileOverride].
|
* refer to it via [ignoreFileOverride].
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val generateApiTests = project.objects.property<Boolean>()
|
val generateApiTests = project.objects.property<Boolean>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -338,21 +386,23 @@ open class GenerateTask : DefaultTask() {
|
|||||||
* For more control over generation of individual files, configure an ignore file and
|
* For more control over generation of individual files, configure an ignore file and
|
||||||
* refer to it via [ignoreFileOverride].
|
* refer to it via [ignoreFileOverride].
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val generateApiDocumentation = project.objects.property<Boolean>()
|
val generateApiDocumentation = project.objects.property<Boolean>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A special-case setting which configures some generators with XML support. In some cases,
|
* A special-case setting which configures some generators with XML support. In some cases,
|
||||||
* this forces json OR xml, so the default here is false.
|
* this forces json OR xml, so the default here is false.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val withXml = project.objects.property<Boolean>()
|
val withXml = project.objects.property<Boolean>()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To write all log messages (not just errors) to STDOUT
|
* To write all log messages (not just errors) to STDOUT
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val logToStderr = project.objects.property<Boolean>()
|
val logToStderr = project.objects.property<Boolean>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -361,13 +411,15 @@ open class GenerateTask : DefaultTask() {
|
|||||||
* LANG_POST_PROCESS_FILE (e.g. GO_POST_PROCESS_FILE, SCALA_POST_PROCESS_FILE). Please open an issue if your target
|
* LANG_POST_PROCESS_FILE (e.g. GO_POST_PROCESS_FILE, SCALA_POST_PROCESS_FILE). Please open an issue if your target
|
||||||
* generator does not support this functionality.
|
* generator does not support this functionality.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val enablePostProcessFile = project.objects.property<Boolean>()
|
val enablePostProcessFile = project.objects.property<Boolean>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To skip spec validation. When true, we will skip the default behavior of validating a spec before generation.
|
* To skip spec validation. When true, we will skip the default behavior of validating a spec before generation.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val skipValidateSpec = project.objects.property<Boolean>()
|
val skipValidateSpec = project.objects.property<Boolean>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -375,19 +427,22 @@ open class GenerateTask : DefaultTask() {
|
|||||||
* definitions generated as top-level Array-of-items, List-of-items, Map-of-items definitions.
|
* definitions generated as top-level Array-of-items, List-of-items, Map-of-items definitions.
|
||||||
* When true, A model representation either containing or extending the array,list,map (depending on specific generator implementation) will be generated.
|
* When true, A model representation either containing or extending the array,list,map (depending on specific generator implementation) will be generated.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val generateAliasAsModel = project.objects.property<Boolean>()
|
val generateAliasAsModel = project.objects.property<Boolean>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A dynamic map of options specific to a generator.
|
* A dynamic map of options specific to a generator.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val configOptions = project.objects.mapProperty<String, String>()
|
val configOptions = project.objects.mapProperty<String, String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Templating engine: "mustache" (default) or "handlebars" (beta)
|
* Templating engine: "mustache" (default) or "handlebars" (beta)
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
val engine = project.objects.property<String?>()
|
val engine = project.objects.property<String?>()
|
||||||
|
|
||||||
private fun <T : Any?> Property<T>.ifNotEmpty(block: Property<T>.(T) -> Unit) {
|
private fun <T : Any?> Property<T>.ifNotEmpty(block: Property<T>.(T) -> Unit) {
|
||||||
|
|||||||
@@ -19,15 +19,18 @@ package org.openapitools.generator.gradle.plugin.tasks
|
|||||||
import com.samskivert.mustache.Mustache
|
import com.samskivert.mustache.Mustache
|
||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
import org.gradle.api.GradleException
|
import org.gradle.api.GradleException
|
||||||
import org.gradle.api.tasks.Internal
|
import org.gradle.api.tasks.CacheableTask
|
||||||
|
import org.gradle.api.tasks.Input
|
||||||
|
import org.gradle.api.tasks.OutputDirectory
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.tasks.TaskAction
|
||||||
import org.gradle.internal.logging.text.StyledTextOutput
|
import org.gradle.internal.logging.text.StyledTextOutput
|
||||||
import org.gradle.internal.logging.text.StyledTextOutputFactory
|
import org.gradle.internal.logging.text.StyledTextOutputFactory
|
||||||
import org.gradle.kotlin.dsl.property
|
import org.gradle.kotlin.dsl.property
|
||||||
import org.openapitools.codegen.*
|
import org.openapitools.codegen.CodegenConfig
|
||||||
import org.openapitools.codegen.api.TemplatePathLocator
|
import org.openapitools.codegen.CodegenConstants
|
||||||
|
import org.openapitools.codegen.SupportingFile
|
||||||
|
import org.openapitools.codegen.TemplateManager
|
||||||
import org.openapitools.codegen.templating.CommonTemplateContentLocator
|
import org.openapitools.codegen.templating.CommonTemplateContentLocator
|
||||||
import org.openapitools.codegen.templating.GeneratorTemplateContentLocator
|
|
||||||
import org.openapitools.codegen.templating.MustacheEngineAdapter
|
import org.openapitools.codegen.templating.MustacheEngineAdapter
|
||||||
import org.openapitools.codegen.templating.TemplateManagerOptions
|
import org.openapitools.codegen.templating.TemplateManagerOptions
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -39,15 +42,16 @@ import java.nio.charset.Charset
|
|||||||
*
|
*
|
||||||
* @author Jim Schubert
|
* @author Jim Schubert
|
||||||
*/
|
*/
|
||||||
|
@CacheableTask
|
||||||
open class MetaTask : DefaultTask() {
|
open class MetaTask : DefaultTask() {
|
||||||
|
|
||||||
@get:Internal
|
@get:Input
|
||||||
val generatorName = project.objects.property<String>()
|
val generatorName = project.objects.property<String>()
|
||||||
|
|
||||||
@get:Internal
|
@get:Input
|
||||||
val packageName = project.objects.property<String>()
|
val packageName = project.objects.property<String>()
|
||||||
|
|
||||||
@get:Internal
|
@get:OutputDirectory
|
||||||
val outputFolder = project.objects.property<String>()
|
val outputFolder = project.objects.property<String>()
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
@@ -92,9 +96,9 @@ open class MetaTask : DefaultTask() {
|
|||||||
val outputFile = File(destinationFolder, it.destinationFilename)
|
val outputFile = File(destinationFolder, it.destinationFilename)
|
||||||
|
|
||||||
val templateProcessor = TemplateManager(
|
val templateProcessor = TemplateManager(
|
||||||
TemplateManagerOptions(false, false),
|
TemplateManagerOptions(false, false),
|
||||||
MustacheEngineAdapter(),
|
MustacheEngineAdapter(),
|
||||||
arrayOf(CommonTemplateContentLocator("codegen"))
|
arrayOf(CommonTemplateContentLocator("codegen"))
|
||||||
)
|
)
|
||||||
|
|
||||||
val template = templateProcessor.getFullTemplateContents(it.templateFile)
|
val template = templateProcessor.getFullTemplateContents(it.templateFile)
|
||||||
|
|||||||
@@ -23,7 +23,12 @@ import io.swagger.v3.parser.core.models.ParseOptions
|
|||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
import org.gradle.api.GradleException
|
import org.gradle.api.GradleException
|
||||||
import org.gradle.api.logging.Logging
|
import org.gradle.api.logging.Logging
|
||||||
|
import org.gradle.api.tasks.Input
|
||||||
|
import org.gradle.api.tasks.InputFile
|
||||||
import org.gradle.api.tasks.Internal
|
import org.gradle.api.tasks.Internal
|
||||||
|
import org.gradle.api.tasks.Optional
|
||||||
|
import org.gradle.api.tasks.PathSensitive
|
||||||
|
import org.gradle.api.tasks.PathSensitivity
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.tasks.TaskAction
|
||||||
import org.gradle.api.tasks.options.Option
|
import org.gradle.api.tasks.options.Option
|
||||||
import org.gradle.internal.logging.text.StyledTextOutput
|
import org.gradle.internal.logging.text.StyledTextOutput
|
||||||
@@ -49,10 +54,12 @@ import org.openapitools.codegen.validations.oas.RuleConfiguration
|
|||||||
* @author Jim Schubert
|
* @author Jim Schubert
|
||||||
*/
|
*/
|
||||||
open class ValidateTask : DefaultTask() {
|
open class ValidateTask : DefaultTask() {
|
||||||
@get:Internal
|
@get:InputFile
|
||||||
|
@PathSensitive(PathSensitivity.RELATIVE)
|
||||||
var inputSpec = project.objects.property<String>()
|
var inputSpec = project.objects.property<String>()
|
||||||
|
|
||||||
@get:Internal
|
@Optional
|
||||||
|
@Input
|
||||||
var recommend = project.objects.property<Boolean?>()
|
var recommend = project.objects.property<Boolean?>()
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
@@ -75,12 +82,11 @@ open class ValidateTask : DefaultTask() {
|
|||||||
|
|
||||||
val options = ParseOptions()
|
val options = ParseOptions()
|
||||||
options.isResolve = true
|
options.isResolve = true
|
||||||
|
|
||||||
val result = OpenAPIParser().readLocation(spec, null, options)
|
val result = OpenAPIParser().readLocation(spec, null, options)
|
||||||
val messages = result.messages.toSet()
|
val messages = result.messages.toSet()
|
||||||
val out = services.get(StyledTextOutputFactory::class.java).create("openapi")
|
val out = services.get(StyledTextOutputFactory::class.java).create("openapi")
|
||||||
|
|
||||||
|
|
||||||
val ruleConfiguration = RuleConfiguration()
|
val ruleConfiguration = RuleConfiguration()
|
||||||
ruleConfiguration.isEnableRecommendations = recommendations
|
ruleConfiguration.isEnableRecommendations = recommendations
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import java.io.File
|
|||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
import kotlin.test.assertTrue
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
class GenerateTaskDslTest : TestBase() {
|
class GenerateTaskDslTest : TestBase() {
|
||||||
override var temp: File = createTempDir(javaClass.simpleName)
|
override var temp: File = createTempDir(javaClass.simpleName)
|
||||||
|
|
||||||
private val defaultBuildGradle = """
|
private val defaultBuildGradle = """
|
||||||
@@ -46,18 +46,18 @@ class GenerateTaskDslTest : TestBase() {
|
|||||||
assertTrue(result.output.contains("Successfully generated code to"), "User friendly generate notice is missing.")
|
assertTrue(result.output.contains("Successfully generated code to"), "User friendly generate notice is missing.")
|
||||||
|
|
||||||
listOf(
|
listOf(
|
||||||
"build/kotlin/.openapi-generator-ignore",
|
"build/kotlin/.openapi-generator-ignore",
|
||||||
"build/kotlin/docs/PetsApi.md",
|
"build/kotlin/docs/PetsApi.md",
|
||||||
"build/kotlin/docs/Error.md",
|
"build/kotlin/docs/Error.md",
|
||||||
"build/kotlin/docs/Pet.md",
|
"build/kotlin/docs/Pet.md",
|
||||||
"build/kotlin/README.md",
|
"build/kotlin/README.md",
|
||||||
"build/kotlin/build.gradle",
|
"build/kotlin/build.gradle",
|
||||||
"build/kotlin/.openapi-generator/VERSION",
|
"build/kotlin/.openapi-generator/VERSION",
|
||||||
"build/kotlin/settings.gradle",
|
"build/kotlin/settings.gradle",
|
||||||
"build/kotlin/src/main/kotlin/org/openapitools/example/model/Pet.kt",
|
"build/kotlin/src/main/kotlin/org/openapitools/example/model/Pet.kt",
|
||||||
"build/kotlin/src/main/kotlin/org/openapitools/example/model/Error.kt",
|
"build/kotlin/src/main/kotlin/org/openapitools/example/model/Error.kt",
|
||||||
"build/kotlin/src/main/kotlin/org/openapitools/example/api/PetsApi.kt",
|
"build/kotlin/src/main/kotlin/org/openapitools/example/api/PetsApi.kt",
|
||||||
"build/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt"
|
"build/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt"
|
||||||
).map {
|
).map {
|
||||||
val f = File(temp, it)
|
val f = File(temp, it)
|
||||||
assertTrue(f.exists() && f.isFile, "An expected file was not generated when invoking the generation.")
|
assertTrue(f.exists() && f.isFile, "An expected file was not generated when invoking the generation.")
|
||||||
@@ -67,6 +67,61 @@ class GenerateTaskDslTest : TestBase() {
|
|||||||
"Expected a successful run, but found ${result.task(":openApiGenerate")?.outcome}")
|
"Expected a successful run, but found ${result.task(":openApiGenerate")?.outcome}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `openApiGenerate should used up-to-date instead of regenerate`() {
|
||||||
|
// Arrange
|
||||||
|
val projectFiles = mapOf(
|
||||||
|
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0.yaml")
|
||||||
|
)
|
||||||
|
withProject(defaultBuildGradle, projectFiles)
|
||||||
|
|
||||||
|
// Act
|
||||||
|
val resultFirstRun = GradleRunner.create()
|
||||||
|
.withProjectDir(temp)
|
||||||
|
.withArguments("openApiGenerate")
|
||||||
|
.withPluginClasspath()
|
||||||
|
.build()
|
||||||
|
val resultSecondRun = GradleRunner.create()
|
||||||
|
.withProjectDir(temp)
|
||||||
|
.withArguments("openApiGenerate")
|
||||||
|
.withPluginClasspath()
|
||||||
|
.build()
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
assertTrue(resultFirstRun.output.contains("Task ':openApiGenerate' is not up-to-date"), "First run should not be up-to-date")
|
||||||
|
assertTrue(resultSecondRun.output.contains("Task :openApiGenerate UP-TO-DATE"), "Task of second run should be up-to-date")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `openApiGenerate should use cache instead of regenerate`() {
|
||||||
|
// Arrange
|
||||||
|
val projectFiles = mapOf(
|
||||||
|
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0.yaml")
|
||||||
|
)
|
||||||
|
withProject(defaultBuildGradle, projectFiles)
|
||||||
|
|
||||||
|
// Act
|
||||||
|
val resultFirstRun = GradleRunner.create()
|
||||||
|
.withProjectDir(temp)
|
||||||
|
.withArguments("openApiGenerate", "--build-cache")
|
||||||
|
.withPluginClasspath()
|
||||||
|
.build()
|
||||||
|
|
||||||
|
// delete the build directory from the last run
|
||||||
|
File(temp, "build/kotlin").deleteRecursively()
|
||||||
|
|
||||||
|
// re-run
|
||||||
|
val resultSecondRun = GradleRunner.create()
|
||||||
|
.withProjectDir(temp)
|
||||||
|
.withArguments("openApiGenerate", "--build-cache")
|
||||||
|
.withPluginClasspath()
|
||||||
|
.build()
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
assertTrue(resultFirstRun.output.contains("Task ':openApiGenerate' is not up-to-date"), "First run should not be up-to-date")
|
||||||
|
assertTrue(resultSecondRun.output.contains("Task :openApiGenerate FROM-CACHE"), "Task of second run should be from cache")
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `openApiValidate should fail on invalid spec`() {
|
fun `openApiValidate should fail on invalid spec`() {
|
||||||
// Arrange
|
// Arrange
|
||||||
@@ -128,10 +183,10 @@ class GenerateTaskDslTest : TestBase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `openapiGenerate should attempt to set handlebars when specified as engine`(){
|
fun `openapiGenerate should attempt to set handlebars when specified as engine`() {
|
||||||
// Arrange
|
// Arrange
|
||||||
val projectFiles = mapOf(
|
val projectFiles = mapOf(
|
||||||
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0.yaml")
|
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0.yaml")
|
||||||
)
|
)
|
||||||
|
|
||||||
withProject("""
|
withProject("""
|
||||||
@@ -151,16 +206,16 @@ class GenerateTaskDslTest : TestBase() {
|
|||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = GradleRunner.create()
|
val result = GradleRunner.create()
|
||||||
.withProjectDir(temp)
|
.withProjectDir(temp)
|
||||||
.withArguments("openApiGenerate", "--stacktrace")
|
.withArguments("openApiGenerate", "--stacktrace")
|
||||||
.withPluginClasspath()
|
.withPluginClasspath()
|
||||||
.buildAndFail()
|
.buildAndFail()
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// rather than write out full handlebars generator templates, we'll just test that the configurator has set handlebars as the engine.
|
// rather than write out full handlebars generator templates, we'll just test that the configurator has set handlebars as the engine.
|
||||||
assertTrue(result.output.contains("HandlebarsException"), "Stack should expose an exception for missing templates.")
|
assertTrue(result.output.contains("HandlebarsException"), "Stack should expose an exception for missing templates.")
|
||||||
assertTrue(result.output.contains("handlebars"), "Build should have attempted to use handlebars.")
|
assertTrue(result.output.contains("handlebars"), "Build should have attempted to use handlebars.")
|
||||||
assertEquals(TaskOutcome.FAILED, result.task(":openApiGenerate")?.outcome,
|
assertEquals(TaskOutcome.FAILED, result.task(":openApiGenerate")?.outcome,
|
||||||
"Expected a failed run, but found ${result.task(":openApiGenerate")?.outcome}")
|
"Expected a failed run, but found ${result.task(":openApiGenerate")?.outcome}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,8 +15,8 @@
|
|||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
<spring-boot-version>2.0.7.RELEASE</spring-boot-version>
|
<spring-boot-version>2.2.9.RELEASE</spring-boot-version>
|
||||||
<springfox-version>2.8.0</springfox-version>
|
<springfox-version>3.0.0</springfox-version>
|
||||||
<junit-version>4.13</junit-version>
|
<junit-version>4.13</junit-version>
|
||||||
<jackson-version>2.10.2</jackson-version>
|
<jackson-version>2.10.2</jackson-version>
|
||||||
</properties>
|
</properties>
|
||||||
@@ -105,13 +105,17 @@
|
|||||||
<version>${springfox-version}</version>
|
<version>${springfox-version}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>io.swagger</groupId>
|
||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>swagger-annotations</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>io.swagger</groupId>
|
||||||
<artifactId>swagger-models</artifactId>
|
<artifactId>swagger-models</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import org.springframework.boot.SpringApplication;
|
|||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.web.filter.ForwardedHeaderFilter;
|
||||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
@@ -60,4 +61,9 @@ public class OpenAPI2SpringBoot implements CommandLineRunner {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
ForwardedHeaderFilter forwardedHeaderFilter() {
|
||||||
|
return new ForwardedHeaderFilter();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||||||
@WebMvcTest(GenApiController.class)
|
@WebMvcTest(GenApiController.class)
|
||||||
public class GenApiControllerTest {
|
public class GenApiControllerTest {
|
||||||
|
|
||||||
private static final String OPENAPI_URL = "http://petstore.swagger.io/v2/swagger.json";
|
private static final String OPENAPI_URL = "https://raw.githubusercontent.com/OpenAPITools/openapi-generator/v4.3.1/modules/openapi-generator/src/test/resources/petstore.json";
|
||||||
private static final String UUID_REGEX = "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[89aAbB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}";
|
private static final String UUID_REGEX = "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[89aAbB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -43,7 +43,7 @@ public class GenApiControllerTest {
|
|||||||
public void getLanguages(String type, String expected) throws Exception {
|
public void getLanguages(String type, String expected) throws Exception {
|
||||||
mockMvc.perform(get("/api/gen/" + type))
|
mockMvc.perform(get("/api/gen/" + type))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||||
.andExpect(jsonPath("$.[*]").value(hasItem(expected)));
|
.andExpect(jsonPath("$.[*]").value(hasItem(expected)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ public class GenApiControllerTest {
|
|||||||
private void getOptions(String type, String name) throws Exception {
|
private void getOptions(String type, String name) throws Exception {
|
||||||
mockMvc.perform(get("/api/gen/" + type + "/" + name))
|
mockMvc.perform(get("/api/gen/" + type + "/" + name))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||||
.andExpect(jsonPath("$.sortParamsByRequiredFlag.opt").value("sortParamsByRequiredFlag"));
|
.andExpect(jsonPath("$.sortParamsByRequiredFlag.opt").value("sortParamsByRequiredFlag"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,10 +88,10 @@ public class GenApiControllerTest {
|
|||||||
|
|
||||||
private void generateAndDownload(String type, String name) throws Exception {
|
private void generateAndDownload(String type, String name) throws Exception {
|
||||||
String result = mockMvc.perform(post("http://test.com:1234/api/gen/" + type + "/" + name)
|
String result = mockMvc.perform(post("http://test.com:1234/api/gen/" + type + "/" + name)
|
||||||
.contentType(MediaType.APPLICATION_JSON_UTF8)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.content("{\"openAPIUrl\": \"" + OPENAPI_URL + "\"}"))
|
.content("{\"openAPIUrl\": \"" + OPENAPI_URL + "\"}"))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||||
.andExpect(jsonPath("$.code").value(matchesPattern(UUID_REGEX)))
|
.andExpect(jsonPath("$.code").value(matchesPattern(UUID_REGEX)))
|
||||||
.andExpect(jsonPath("$.link").value(matchesPattern("http\\:\\/\\/test.com\\:1234\\/api\\/gen\\/download\\/" + UUID_REGEX)))
|
.andExpect(jsonPath("$.link").value(matchesPattern("http\\:\\/\\/test.com\\:1234\\/api\\/gen\\/download\\/" + UUID_REGEX)))
|
||||||
.andReturn().getResponse().getContentAsString();
|
.andReturn().getResponse().getContentAsString();
|
||||||
@@ -107,13 +107,13 @@ public class GenApiControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void generateWIthForwardedHeaders() throws Exception {
|
public void generateWIthForwardedHeaders() throws Exception {
|
||||||
String result = mockMvc.perform(post("http://test.com:1234/api/gen/clients/java")
|
String result = mockMvc.perform(post("http://test.com:1234/api/gen/clients/java")
|
||||||
.contentType(MediaType.APPLICATION_JSON_UTF8)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("X-Forwarded-Proto", "https")
|
.header("X-Forwarded-Proto", "https")
|
||||||
.header("X-Forwarded-Host", "forwarded.com")
|
.header("X-Forwarded-Host", "forwarded.com")
|
||||||
.header("X-Forwarded-Port", "5678")
|
.header("X-Forwarded-Port", "5678")
|
||||||
.content("{\"openAPIUrl\": \"" + OPENAPI_URL + "\"}"))
|
.content("{\"openAPIUrl\": \"" + OPENAPI_URL + "\"}"))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||||
.andExpect(jsonPath("$.code").value(matchesPattern(UUID_REGEX)))
|
.andExpect(jsonPath("$.code").value(matchesPattern(UUID_REGEX)))
|
||||||
.andExpect(jsonPath("$.link").value(matchesPattern("https\\:\\/\\/forwarded.com\\:5678\\/api\\/gen\\/download\\/" + UUID_REGEX)))
|
.andExpect(jsonPath("$.link").value(matchesPattern("https\\:\\/\\/forwarded.com\\:5678\\/api\\/gen\\/download\\/" + UUID_REGEX)))
|
||||||
.andReturn().getResponse().getContentAsString();
|
.andReturn().getResponse().getContentAsString();
|
||||||
|
|||||||
@@ -5653,8 +5653,11 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
LOGGER.debug("debugging fromRequestBodyToFormParameters= " + body);
|
LOGGER.debug("debugging fromRequestBodyToFormParameters= " + body);
|
||||||
Schema schema = ModelUtils.getSchemaFromRequestBody(body);
|
Schema schema = ModelUtils.getSchemaFromRequestBody(body);
|
||||||
schema = ModelUtils.getReferencedSchema(this.openAPI, schema);
|
schema = ModelUtils.getReferencedSchema(this.openAPI, schema);
|
||||||
if (schema.getProperties() != null && !schema.getProperties().isEmpty()) {
|
List<String> allRequired = new ArrayList<String>();
|
||||||
Map<String, Schema> properties = schema.getProperties();
|
Map<String, Schema> properties = new LinkedHashMap<>();
|
||||||
|
addProperties(properties, allRequired, schema);
|
||||||
|
|
||||||
|
if (!properties.isEmpty()) {
|
||||||
for (Map.Entry<String, Schema> entry : properties.entrySet()) {
|
for (Map.Entry<String, Schema> entry : properties.entrySet()) {
|
||||||
CodegenParameter codegenParameter = CodegenModelFactory.newInstance(CodegenModelType.PARAMETER);
|
CodegenParameter codegenParameter = CodegenModelFactory.newInstance(CodegenModelType.PARAMETER);
|
||||||
// key => property name
|
// key => property name
|
||||||
|
|||||||
@@ -17,6 +17,10 @@
|
|||||||
|
|
||||||
package org.openapitools.codegen;
|
package org.openapitools.codegen;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
|
||||||
|
import com.fasterxml.jackson.databind.MapperFeature;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import io.swagger.v3.core.util.Json;
|
import io.swagger.v3.core.util.Json;
|
||||||
import io.swagger.v3.oas.models.*;
|
import io.swagger.v3.oas.models.*;
|
||||||
import io.swagger.v3.oas.models.callbacks.Callback;
|
import io.swagger.v3.oas.models.callbacks.Callback;
|
||||||
@@ -25,6 +29,7 @@ import io.swagger.v3.oas.models.parameters.Parameter;
|
|||||||
import io.swagger.v3.oas.models.parameters.RequestBody;
|
import io.swagger.v3.oas.models.parameters.RequestBody;
|
||||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||||
import io.swagger.v3.oas.models.responses.ApiResponses;
|
import io.swagger.v3.oas.models.responses.ApiResponses;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.openapitools.codegen.utils.ModelUtils;
|
import org.openapitools.codegen.utils.ModelUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -36,6 +41,17 @@ public class InlineModelResolver {
|
|||||||
private OpenAPI openapi;
|
private OpenAPI openapi;
|
||||||
private Map<String, Schema> addedModels = new HashMap<String, Schema>();
|
private Map<String, Schema> addedModels = new HashMap<String, Schema>();
|
||||||
private Map<String, String> generatedSignature = new HashMap<String, String>();
|
private Map<String, String> generatedSignature = new HashMap<String, String>();
|
||||||
|
|
||||||
|
// structure mapper sorts properties alphabetically on write to ensure models are
|
||||||
|
// serialized consistently for lookup of existing models
|
||||||
|
private static ObjectMapper structureMapper;
|
||||||
|
|
||||||
|
static {
|
||||||
|
structureMapper = Json.mapper().copy();
|
||||||
|
structureMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);
|
||||||
|
structureMapper.writer(new DefaultPrettyPrinter());
|
||||||
|
}
|
||||||
|
|
||||||
static Logger LOGGER = LoggerFactory.getLogger(InlineModelResolver.class);
|
static Logger LOGGER = LoggerFactory.getLogger(InlineModelResolver.class);
|
||||||
|
|
||||||
void flatten(OpenAPI openapi) {
|
void flatten(OpenAPI openapi) {
|
||||||
@@ -488,15 +504,25 @@ public class InlineModelResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String matchGenerated(Schema model) {
|
private String matchGenerated(Schema model) {
|
||||||
String json = Json.pretty(model);
|
try {
|
||||||
if (generatedSignature.containsKey(json)) {
|
String json = structureMapper.writeValueAsString(model);
|
||||||
return generatedSignature.get(json);
|
if (generatedSignature.containsKey(json)) {
|
||||||
|
return generatedSignature.get(json);
|
||||||
|
}
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addGenerated(String name, Schema model) {
|
private void addGenerated(String name, Schema model) {
|
||||||
generatedSignature.put(Json.pretty(model), name);
|
try {
|
||||||
|
String json = structureMapper.writeValueAsString(model);
|
||||||
|
generatedSignature.put(json, name);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,13 +646,45 @@ public class InlineModelResolver {
|
|||||||
}
|
}
|
||||||
XML xml = object.getXml();
|
XML xml = object.getXml();
|
||||||
Map<String, Schema> properties = object.getProperties();
|
Map<String, Schema> properties = object.getProperties();
|
||||||
|
|
||||||
|
// NOTE:
|
||||||
|
// No need to null check setters below. All defaults in the new'd Schema are null, so setting to null would just be a noop.
|
||||||
Schema model = new Schema();
|
Schema model = new Schema();
|
||||||
|
model.setType(object.getType());
|
||||||
|
|
||||||
|
// Even though the `format` keyword typically applies to primitive types only,
|
||||||
|
// the JSON schema specification states `format` can be used for any model type instance
|
||||||
|
// including object types.
|
||||||
|
model.setFormat(object.getFormat());
|
||||||
|
|
||||||
model.setDescription(description);
|
model.setDescription(description);
|
||||||
model.setExample(example);
|
model.setExample(example);
|
||||||
model.setName(object.getName());
|
model.setName(object.getName());
|
||||||
model.setXml(xml);
|
model.setXml(xml);
|
||||||
model.setRequired(object.getRequired());
|
model.setRequired(object.getRequired());
|
||||||
model.setNullable(object.getNullable());
|
model.setNullable(object.getNullable());
|
||||||
|
model.setDiscriminator(object.getDiscriminator());
|
||||||
|
model.setWriteOnly(object.getWriteOnly());
|
||||||
|
model.setUniqueItems(object.getUniqueItems());
|
||||||
|
model.setTitle(object.getTitle());
|
||||||
|
model.setReadOnly(object.getReadOnly());
|
||||||
|
model.setPattern(object.getPattern());
|
||||||
|
model.setNot(object.getNot());
|
||||||
|
model.setMinProperties(object.getMinProperties());
|
||||||
|
model.setMinLength(object.getMinLength());
|
||||||
|
model.setMinItems(object.getMinItems());
|
||||||
|
model.setMinimum(object.getMinimum());
|
||||||
|
model.setMaxProperties(object.getMaxProperties());
|
||||||
|
model.setMaxLength(object.getMaxLength());
|
||||||
|
model.setMaxItems(object.getMaxItems());
|
||||||
|
model.setMaximum(object.getMaximum());
|
||||||
|
model.setExternalDocs(object.getExternalDocs());
|
||||||
|
model.setExtensions(object.getExtensions());
|
||||||
|
model.setExclusiveMinimum(object.getExclusiveMinimum());
|
||||||
|
model.setExclusiveMaximum(object.getExclusiveMaximum());
|
||||||
|
model.setExample(object.getExample());
|
||||||
|
model.setDeprecated(object.getDeprecated());
|
||||||
|
|
||||||
if (properties != null) {
|
if (properties != null) {
|
||||||
flattenProperties(openAPI, properties, path);
|
flattenProperties(openAPI, properties, path);
|
||||||
model.setProperties(properties);
|
model.setProperties(properties);
|
||||||
|
|||||||
@@ -798,7 +798,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
|||||||
|
|
||||||
Schema<?> items = getSchemaItems((ArraySchema) schema);
|
Schema<?> items = getSchemaItems((ArraySchema) schema);
|
||||||
|
|
||||||
String typeDeclaration = getTypeDeclaration(items);
|
String typeDeclaration = getTypeDeclaration(ModelUtils.unaliasSchema(this.openAPI, items));
|
||||||
Object java8obj = additionalProperties.get("java8");
|
Object java8obj = additionalProperties.get("java8");
|
||||||
if (java8obj != null) {
|
if (java8obj != null) {
|
||||||
Boolean java8 = Boolean.valueOf(java8obj.toString());
|
Boolean java8 = Boolean.valueOf(java8obj.toString());
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
|||||||
protected CliOption swashbuckleVersion = new CliOption(SWASHBUCKLE_VERSION, "Swashbuckle version: 3.0.0, 4.0.0, 5.0.0");
|
protected CliOption swashbuckleVersion = new CliOption(SWASHBUCKLE_VERSION, "Swashbuckle version: 3.0.0, 4.0.0, 5.0.0");
|
||||||
protected CliOption aspnetCoreVersion = new CliOption(ASPNET_CORE_VERSION, "ASP.NET Core version: 3.1, 3.0, 2.2, 2.1, 2.0 (deprecated)");
|
protected CliOption aspnetCoreVersion = new CliOption(ASPNET_CORE_VERSION, "ASP.NET Core version: 3.1, 3.0, 2.2, 2.1, 2.0 (deprecated)");
|
||||||
private CliOption classModifier = new CliOption(CLASS_MODIFIER, "Class Modifier can be empty, abstract");
|
private CliOption classModifier = new CliOption(CLASS_MODIFIER, "Class Modifier can be empty, abstract");
|
||||||
private CliOption operationModifier = new CliOption(OPERATION_MODIFIER, "Operation Modifier can be virtual, abstract or partial");
|
private CliOption operationModifier = new CliOption(OPERATION_MODIFIER, "Operation Modifier can be virtual or abstract");
|
||||||
private CliOption modelClassModifier = new CliOption(MODEL_CLASS_MODIFIER, "Model Class Modifier can be nothing or partial");
|
private CliOption modelClassModifier = new CliOption(MODEL_CLASS_MODIFIER, "Model Class Modifier can be nothing or partial");
|
||||||
private boolean generateBody = true;
|
private boolean generateBody = true;
|
||||||
private CliOption buildTarget = new CliOption("buildTarget", "Target to build an application or library");
|
private CliOption buildTarget = new CliOption("buildTarget", "Target to build an application or library");
|
||||||
|
|||||||
@@ -476,7 +476,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
|
|||||||
+ "/pattern/modifiers convention. " + pattern + " is not valid.");
|
+ "/pattern/modifiers convention. " + pattern + " is not valid.");
|
||||||
}
|
}
|
||||||
|
|
||||||
String regex = pattern.substring(1, i).replace("'", "\'");
|
String regex = pattern.substring(1, i).replace("'", "\'").replace("\"", "\"\"");
|
||||||
List<String> modifiers = new ArrayList<String>();
|
List<String> modifiers = new ArrayList<String>();
|
||||||
|
|
||||||
// perl requires an explicit modifier to be culture specific and .NET is the reverse.
|
// perl requires an explicit modifier to be culture specific and .NET is the reverse.
|
||||||
|
|||||||
@@ -137,44 +137,32 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
|||||||
|
|
||||||
if (additionalProperties.containsKey(WITH_GO_CODEGEN_COMMENT)) {
|
if (additionalProperties.containsKey(WITH_GO_CODEGEN_COMMENT)) {
|
||||||
setWithGoCodegenComment(Boolean.parseBoolean(additionalProperties.get(WITH_GO_CODEGEN_COMMENT).toString()));
|
setWithGoCodegenComment(Boolean.parseBoolean(additionalProperties.get(WITH_GO_CODEGEN_COMMENT).toString()));
|
||||||
if (withGoCodegenComment) {
|
additionalProperties.put(WITH_GO_CODEGEN_COMMENT, withGoCodegenComment);
|
||||||
additionalProperties.put(WITH_GO_CODEGEN_COMMENT, "true");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey(WITH_AWSV4_SIGNATURE)) {
|
if (additionalProperties.containsKey(WITH_AWSV4_SIGNATURE)) {
|
||||||
setWithAWSV4Signature(Boolean.parseBoolean(additionalProperties.get(WITH_AWSV4_SIGNATURE).toString()));
|
setWithAWSV4Signature(Boolean.parseBoolean(additionalProperties.get(WITH_AWSV4_SIGNATURE).toString()));
|
||||||
if (withAWSV4Signature) {
|
additionalProperties.put(WITH_AWSV4_SIGNATURE, withAWSV4Signature);
|
||||||
additionalProperties.put(WITH_AWSV4_SIGNATURE, "true");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey(WITH_XML)) {
|
if (additionalProperties.containsKey(WITH_XML)) {
|
||||||
setWithXml(Boolean.parseBoolean(additionalProperties.get(WITH_XML).toString()));
|
setWithXml(Boolean.parseBoolean(additionalProperties.get(WITH_XML).toString()));
|
||||||
if (withXml) {
|
additionalProperties.put(WITH_XML, withXml);
|
||||||
additionalProperties.put(WITH_XML, "true");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.ENUM_CLASS_PREFIX)) {
|
if (additionalProperties.containsKey(CodegenConstants.ENUM_CLASS_PREFIX)) {
|
||||||
setEnumClassPrefix(Boolean.parseBoolean(additionalProperties.get(CodegenConstants.ENUM_CLASS_PREFIX).toString()));
|
setEnumClassPrefix(Boolean.parseBoolean(additionalProperties.get(CodegenConstants.ENUM_CLASS_PREFIX).toString()));
|
||||||
if (enumClassPrefix) {
|
additionalProperties.put(CodegenConstants.ENUM_CLASS_PREFIX, enumClassPrefix);
|
||||||
additionalProperties.put(CodegenConstants.ENUM_CLASS_PREFIX, "true");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey(CodegenConstants.IS_GO_SUBMODULE)) {
|
if (additionalProperties.containsKey(CodegenConstants.IS_GO_SUBMODULE)) {
|
||||||
setIsGoSubmodule(Boolean.parseBoolean(additionalProperties.get(CodegenConstants.IS_GO_SUBMODULE).toString()));
|
setIsGoSubmodule(Boolean.parseBoolean(additionalProperties.get(CodegenConstants.IS_GO_SUBMODULE).toString()));
|
||||||
if (isGoSubmodule) {
|
additionalProperties.put(CodegenConstants.IS_GO_SUBMODULE, isGoSubmodule);
|
||||||
additionalProperties.put(CodegenConstants.IS_GO_SUBMODULE, "true");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey(STRUCT_PREFIX)) {
|
if (additionalProperties.containsKey(STRUCT_PREFIX)) {
|
||||||
setStructPrefix(Boolean.parseBoolean(additionalProperties.get(STRUCT_PREFIX).toString()));
|
setStructPrefix(Boolean.parseBoolean(additionalProperties.get(STRUCT_PREFIX).toString()));
|
||||||
if (structPrefix) {
|
additionalProperties.put(STRUCT_PREFIX, structPrefix);
|
||||||
additionalProperties.put(STRUCT_PREFIX, "true");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,12 +17,7 @@
|
|||||||
|
|
||||||
package org.openapitools.codegen.languages;
|
package org.openapitools.codegen.languages;
|
||||||
|
|
||||||
import org.openapitools.codegen.CliOption;
|
import org.openapitools.codegen.*;
|
||||||
import org.openapitools.codegen.CodegenConstants;
|
|
||||||
import org.openapitools.codegen.CodegenOperation;
|
|
||||||
import org.openapitools.codegen.CodegenParameter;
|
|
||||||
import org.openapitools.codegen.CodegenType;
|
|
||||||
import org.openapitools.codegen.SupportingFile;
|
|
||||||
import org.openapitools.codegen.meta.features.*;
|
import org.openapitools.codegen.meta.features.*;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -83,6 +78,8 @@ public class GoServerCodegen extends AbstractGoCodegen {
|
|||||||
optFeatureCORS.defaultValue(corsFeatureEnabled.toString());
|
optFeatureCORS.defaultValue(corsFeatureEnabled.toString());
|
||||||
cliOptions.add(optFeatureCORS);
|
cliOptions.add(optFeatureCORS);
|
||||||
|
|
||||||
|
cliOptions.add(CliOption.newBoolean(CodegenConstants.ENUM_CLASS_PREFIX, CodegenConstants.ENUM_CLASS_PREFIX_DESC));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Models. You can write model files using the modelTemplateFiles map.
|
* Models. You can write model files using the modelTemplateFiles map.
|
||||||
* if you want to create one template for file, you can do so here.
|
* if you want to create one template for file, you can do so here.
|
||||||
@@ -104,7 +101,7 @@ public class GoServerCodegen extends AbstractGoCodegen {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Service templates. You can write services for each Api file with the apiTemplateFiles map.
|
* Service templates. You can write services for each Api file with the apiTemplateFiles map.
|
||||||
These services are skeletons built to implement the logic of your api using the
|
These services are skeletons built to implement the logic of your api using the
|
||||||
expected parameters and response.
|
expected parameters and response.
|
||||||
*/
|
*/
|
||||||
apiTemplateFiles.put(
|
apiTemplateFiles.put(
|
||||||
@@ -166,13 +163,11 @@ public class GoServerCodegen extends AbstractGoCodegen {
|
|||||||
|
|
||||||
if (additionalProperties.containsKey("serverPort") && additionalProperties.get("serverPort") instanceof Integer) {
|
if (additionalProperties.containsKey("serverPort") && additionalProperties.get("serverPort") instanceof Integer) {
|
||||||
this.setServerPort((int) additionalProperties.get("serverPort"));
|
this.setServerPort((int) additionalProperties.get("serverPort"));
|
||||||
} else if (additionalProperties.containsKey("serverPort") && additionalProperties.get("serverPort") instanceof String){
|
} else if (additionalProperties.containsKey("serverPort") && additionalProperties.get("serverPort") instanceof String) {
|
||||||
try {
|
try {
|
||||||
this.setServerPort(Integer.parseInt(additionalProperties.get("serverPort").toString()));
|
this.setServerPort(Integer.parseInt(additionalProperties.get("serverPort").toString()));
|
||||||
additionalProperties.put("serverPort", serverPort);
|
additionalProperties.put("serverPort", serverPort);
|
||||||
}
|
} catch (NumberFormatException e) {
|
||||||
catch (NumberFormatException e)
|
|
||||||
{
|
|
||||||
LOGGER.warn("serverPort is not a valid integer... defaulting to {}", serverPort);
|
LOGGER.warn("serverPort is not a valid integer... defaulting to {}", serverPort);
|
||||||
additionalProperties.put("serverPort", serverPort);
|
additionalProperties.put("serverPort", serverPort);
|
||||||
}
|
}
|
||||||
@@ -185,6 +180,13 @@ public class GoServerCodegen extends AbstractGoCodegen {
|
|||||||
additionalProperties.put("featureCORS", corsFeatureEnabled);
|
additionalProperties.put("featureCORS", corsFeatureEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(CodegenConstants.ENUM_CLASS_PREFIX)) {
|
||||||
|
setEnumClassPrefix(Boolean.parseBoolean(additionalProperties.get(CodegenConstants.ENUM_CLASS_PREFIX).toString()));
|
||||||
|
if (enumClassPrefix) {
|
||||||
|
additionalProperties.put(CodegenConstants.ENUM_CLASS_PREFIX, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
modelPackage = packageName;
|
modelPackage = packageName;
|
||||||
apiPackage = packageName;
|
apiPackage = packageName;
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
|||||||
|
|
||||||
public static final String USE_RX_JAVA = "useRxJava";
|
public static final String USE_RX_JAVA = "useRxJava";
|
||||||
public static final String USE_RX_JAVA2 = "useRxJava2";
|
public static final String USE_RX_JAVA2 = "useRxJava2";
|
||||||
|
public static final String USE_RX_JAVA3 = "useRxJava3";
|
||||||
public static final String USE_COROUTINES = "useCoroutines";
|
public static final String USE_COROUTINES = "useCoroutines";
|
||||||
public static final String DO_NOT_USE_RX_AND_COROUTINES = "doNotUseRxAndCoroutines";
|
public static final String DO_NOT_USE_RX_AND_COROUTINES = "doNotUseRxAndCoroutines";
|
||||||
|
|
||||||
@@ -65,6 +66,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
|||||||
protected String collectionType = CollectionType.LIST.value;
|
protected String collectionType = CollectionType.LIST.value;
|
||||||
protected boolean useRxJava = false;
|
protected boolean useRxJava = false;
|
||||||
protected boolean useRxJava2 = false;
|
protected boolean useRxJava2 = false;
|
||||||
|
protected boolean useRxJava3 = false;
|
||||||
protected boolean useCoroutines = false;
|
protected boolean useCoroutines = false;
|
||||||
// backwards compatibility for openapi configs that specify neither rx1 nor rx2
|
// backwards compatibility for openapi configs that specify neither rx1 nor rx2
|
||||||
// (mustache does not allow for boolean operators so we need this extra field)
|
// (mustache does not allow for boolean operators so we need this extra field)
|
||||||
@@ -198,6 +200,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
|||||||
|
|
||||||
cliOptions.add(CliOption.newBoolean(USE_RX_JAVA, "Whether to use the RxJava adapter with the retrofit2 library."));
|
cliOptions.add(CliOption.newBoolean(USE_RX_JAVA, "Whether to use the RxJava adapter with the retrofit2 library."));
|
||||||
cliOptions.add(CliOption.newBoolean(USE_RX_JAVA2, "Whether to use the RxJava2 adapter with the retrofit2 library."));
|
cliOptions.add(CliOption.newBoolean(USE_RX_JAVA2, "Whether to use the RxJava2 adapter with the retrofit2 library."));
|
||||||
|
cliOptions.add(CliOption.newBoolean(USE_RX_JAVA3, "Whether to use the RxJava3 adapter with the retrofit2 library."));
|
||||||
cliOptions.add(CliOption.newBoolean(USE_COROUTINES, "Whether to use the Coroutines adapter with the retrofit2 library."));
|
cliOptions.add(CliOption.newBoolean(USE_COROUTINES, "Whether to use the Coroutines adapter with the retrofit2 library."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,6 +219,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
|||||||
public void setUseRxJava(boolean useRxJava) {
|
public void setUseRxJava(boolean useRxJava) {
|
||||||
if (useRxJava) {
|
if (useRxJava) {
|
||||||
this.useRxJava2 = false;
|
this.useRxJava2 = false;
|
||||||
|
this.useRxJava3 = false;
|
||||||
this.doNotUseRxAndCoroutines = false;
|
this.doNotUseRxAndCoroutines = false;
|
||||||
this.useCoroutines = false;
|
this.useCoroutines = false;
|
||||||
}
|
}
|
||||||
@@ -225,16 +229,28 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
|||||||
public void setUseRxJava2(boolean useRxJava2) {
|
public void setUseRxJava2(boolean useRxJava2) {
|
||||||
if (useRxJava2) {
|
if (useRxJava2) {
|
||||||
this.useRxJava = false;
|
this.useRxJava = false;
|
||||||
|
this.useRxJava3 = false;
|
||||||
this.doNotUseRxAndCoroutines = false;
|
this.doNotUseRxAndCoroutines = false;
|
||||||
this.useCoroutines = false;
|
this.useCoroutines = false;
|
||||||
}
|
}
|
||||||
this.useRxJava2 = useRxJava2;
|
this.useRxJava2 = useRxJava2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUseRxJava3(boolean useRxJava3) {
|
||||||
|
if (useRxJava3) {
|
||||||
|
this.useRxJava = false;
|
||||||
|
this.useRxJava2 = false;
|
||||||
|
this.doNotUseRxAndCoroutines = false;
|
||||||
|
this.useCoroutines = false;
|
||||||
|
}
|
||||||
|
this.useRxJava3 = useRxJava3;
|
||||||
|
}
|
||||||
|
|
||||||
public void setDoNotUseRxAndCoroutines(boolean doNotUseRxAndCoroutines) {
|
public void setDoNotUseRxAndCoroutines(boolean doNotUseRxAndCoroutines) {
|
||||||
if (doNotUseRxAndCoroutines) {
|
if (doNotUseRxAndCoroutines) {
|
||||||
this.useRxJava = false;
|
this.useRxJava = false;
|
||||||
this.useRxJava2 = false;
|
this.useRxJava2 = false;
|
||||||
|
this.useRxJava3 = false;
|
||||||
this.useCoroutines = false;
|
this.useCoroutines = false;
|
||||||
}
|
}
|
||||||
this.doNotUseRxAndCoroutines = doNotUseRxAndCoroutines;
|
this.doNotUseRxAndCoroutines = doNotUseRxAndCoroutines;
|
||||||
@@ -244,6 +260,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
|||||||
if (useCoroutines) {
|
if (useCoroutines) {
|
||||||
this.useRxJava = false;
|
this.useRxJava = false;
|
||||||
this.useRxJava2 = false;
|
this.useRxJava2 = false;
|
||||||
|
this.useRxJava3 = false;
|
||||||
this.doNotUseRxAndCoroutines = false;
|
this.doNotUseRxAndCoroutines = false;
|
||||||
}
|
}
|
||||||
this.useCoroutines = useCoroutines;
|
this.useCoroutines = useCoroutines;
|
||||||
@@ -273,6 +290,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
|||||||
|
|
||||||
boolean hasRx = additionalProperties.containsKey(USE_RX_JAVA);
|
boolean hasRx = additionalProperties.containsKey(USE_RX_JAVA);
|
||||||
boolean hasRx2 = additionalProperties.containsKey(USE_RX_JAVA2);
|
boolean hasRx2 = additionalProperties.containsKey(USE_RX_JAVA2);
|
||||||
|
boolean hasRx3 = additionalProperties.containsKey(USE_RX_JAVA3);
|
||||||
boolean hasCoroutines = additionalProperties.containsKey(USE_COROUTINES);
|
boolean hasCoroutines = additionalProperties.containsKey(USE_COROUTINES);
|
||||||
int optionCount = 0;
|
int optionCount = 0;
|
||||||
if (hasRx) {
|
if (hasRx) {
|
||||||
@@ -281,6 +299,9 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
|||||||
if (hasRx2) {
|
if (hasRx2) {
|
||||||
optionCount++;
|
optionCount++;
|
||||||
}
|
}
|
||||||
|
if (hasRx3) {
|
||||||
|
optionCount++;
|
||||||
|
}
|
||||||
if (hasCoroutines) {
|
if (hasCoroutines) {
|
||||||
optionCount++;
|
optionCount++;
|
||||||
}
|
}
|
||||||
@@ -288,16 +309,18 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
|||||||
|
|
||||||
// RxJava & Coroutines
|
// RxJava & Coroutines
|
||||||
if (hasConflict) {
|
if (hasConflict) {
|
||||||
LOGGER.warn("You specified both RxJava versions 1 and 2 or Coroutines together, please choose one them.");
|
LOGGER.warn("You specified RxJava versions 1 and 2 and 3 or Coroutines together, please choose one of them.");
|
||||||
} else if (hasRx) {
|
} else if (hasRx) {
|
||||||
this.setUseRxJava(Boolean.valueOf(additionalProperties.get(USE_RX_JAVA).toString()));
|
this.setUseRxJava(Boolean.valueOf(additionalProperties.get(USE_RX_JAVA).toString()));
|
||||||
} else if (hasRx2) {
|
} else if (hasRx2) {
|
||||||
this.setUseRxJava2(Boolean.valueOf(additionalProperties.get(USE_RX_JAVA2).toString()));
|
this.setUseRxJava2(Boolean.valueOf(additionalProperties.get(USE_RX_JAVA2).toString()));
|
||||||
|
} else if (hasRx3) {
|
||||||
|
this.setUseRxJava3(Boolean.valueOf(additionalProperties.get(USE_RX_JAVA3).toString()));
|
||||||
} else if (hasCoroutines) {
|
} else if (hasCoroutines) {
|
||||||
this.setUseCoroutines(Boolean.valueOf(additionalProperties.get(USE_COROUTINES).toString()));
|
this.setUseCoroutines(Boolean.valueOf(additionalProperties.get(USE_COROUTINES).toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasRx && !hasRx2 && !hasCoroutines) {
|
if (!hasRx && !hasRx2 && !hasRx3 && !hasCoroutines) {
|
||||||
setDoNotUseRxAndCoroutines(true);
|
setDoNotUseRxAndCoroutines(true);
|
||||||
additionalProperties.put(DO_NOT_USE_RX_AND_COROUTINES, true);
|
additionalProperties.put(DO_NOT_USE_RX_AND_COROUTINES, true);
|
||||||
}
|
}
|
||||||
@@ -604,6 +627,13 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// import okhttp3.MultipartBody if any parameter is a file
|
||||||
|
for (CodegenParameter param : operation.allParams) {
|
||||||
|
if (Boolean.TRUE.equals(param.isFile)) {
|
||||||
|
operations.put("x-kotlin-multipart-import", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (usesRetrofit2Library() && StringUtils.isNotEmpty(operation.path) && operation.path.startsWith("/")) {
|
if (usesRetrofit2Library() && StringUtils.isNotEmpty(operation.path) && operation.path.startsWith("/")) {
|
||||||
operation.path = operation.path.substring(1);
|
operation.path = operation.path.substring(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,18 @@
|
|||||||
package org.openapitools.codegen.languages;
|
package org.openapitools.codegen.languages;
|
||||||
|
|
||||||
import org.openapitools.codegen.*;
|
import org.openapitools.codegen.CodegenConfig;
|
||||||
import io.swagger.models.properties.ArrayProperty;
|
import org.openapitools.codegen.CodegenType;
|
||||||
import io.swagger.models.properties.MapProperty;
|
import org.openapitools.codegen.DefaultCodegen;
|
||||||
import io.swagger.models.properties.Property;
|
import org.openapitools.codegen.SupportingFile;
|
||||||
import io.swagger.models.parameters.Parameter;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||||
import org.openapitools.codegen.meta.Stability;
|
import org.openapitools.codegen.meta.Stability;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import static org.openapitools.codegen.utils.StringUtils.escape;
|
||||||
|
|
||||||
public class MarkdownDocumentationCodegen extends DefaultCodegen implements CodegenConfig {
|
public class MarkdownDocumentationCodegen extends DefaultCodegen implements CodegenConfig {
|
||||||
public static final String PROJECT_NAME = "projectName";
|
public static final String PROJECT_NAME = "projectName";
|
||||||
|
|
||||||
@@ -49,4 +46,37 @@ public class MarkdownDocumentationCodegen extends DefaultCodegen implements Code
|
|||||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
// TODO: Fill this out.
|
// TODO: Fill this out.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initalizeSpecialCharacterMapping() {
|
||||||
|
// escape only those symbols that can mess up markdown
|
||||||
|
specialCharReplacements.put("\\", "\\\\");
|
||||||
|
specialCharReplacements.put("/", "\\/");
|
||||||
|
specialCharReplacements.put("`", "\\`");
|
||||||
|
specialCharReplacements.put("*", "\\*");
|
||||||
|
specialCharReplacements.put("_", "\\_");
|
||||||
|
specialCharReplacements.put("[", "\\[");
|
||||||
|
specialCharReplacements.put("]", "\\]");
|
||||||
|
|
||||||
|
// todo Current markdown api and model mustache templates display properties and parameters in tables. Pipe
|
||||||
|
// symbol in a table can be commonly escaped with a backslash (e.g. GFM supports this). However, in some cases
|
||||||
|
// it may be necessary to choose a different approach.
|
||||||
|
specialCharReplacements.put("|", "\\|");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Works identically to {@link DefaultCodegen#toParamName(String)} but doesn't camelize.
|
||||||
|
*
|
||||||
|
* @param name Codegen property object
|
||||||
|
* @return the sanitized parameter name
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toParamName(String name) {
|
||||||
|
if (reservedWords.contains(name)) {
|
||||||
|
return escapeReservedWord(name);
|
||||||
|
} else if (((CharSequence) name).chars().anyMatch(character -> specialCharReplacements.keySet().contains("" + ((char) character)))) {
|
||||||
|
return escape(name, specialCharReplacements, null, null);
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,6 +105,18 @@ public class PhpLumenServerCodegen extends AbstractPhpCodegen {
|
|||||||
* are available in models, apis, and supporting files
|
* are available in models, apis, and supporting files
|
||||||
*/
|
*/
|
||||||
additionalProperties.put("apiVersion", apiVersion);
|
additionalProperties.put("apiVersion", apiVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processOpts() {
|
||||||
|
super.processOpts();
|
||||||
|
|
||||||
|
// reset supporting files defined in AbstractPhpCodegen
|
||||||
|
supportingFiles.clear();
|
||||||
|
|
||||||
|
// AbstractPhpCodegen generates .gitignore in output folder
|
||||||
|
// current build needs .gitignore in a "lib" folder which is srcBasePath
|
||||||
|
supportingFiles.add(new SupportingFile("gitignore", srcBasePath, ".gitignore"));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Supporting Files. You can write single files for the generator with the
|
* Supporting Files. You can write single files for the generator with the
|
||||||
@@ -112,7 +124,11 @@ public class PhpLumenServerCodegen extends AbstractPhpCodegen {
|
|||||||
* it will be processed by the template engine. Otherwise, it will be copied
|
* it will be processed by the template engine. Otherwise, it will be copied
|
||||||
*/
|
*/
|
||||||
supportingFiles.add(new SupportingFile(".env.example", srcBasePath, ".env.example"));
|
supportingFiles.add(new SupportingFile(".env.example", srcBasePath, ".env.example"));
|
||||||
supportingFiles.add(new SupportingFile("storage_logs_.gitignore", srcBasePath + File.separator + "storage" + File.separator + "logs", ".gitignore"));
|
supportingFiles.add(new SupportingFile("storage_logs_gitignore", srcBasePath + File.separator + "storage" + File.separator + "logs", ".gitignore"));
|
||||||
|
supportingFiles.add(new SupportingFile("storage_logs_gitignore", srcBasePath + File.separator + "storage" + File.separator + "app", ".gitignore"));
|
||||||
|
supportingFiles.add(new SupportingFile("storage_logs_gitignore", srcBasePath + File.separator + "storage" + File.separator + "framework" + File.separator + "views", ".gitignore"));
|
||||||
|
supportingFiles.add(new SupportingFile("storage_framework_cache_gitignore", srcBasePath + File.separator + "storage" + File.separator + "framework" + File.separator + "cache", ".gitignore"));
|
||||||
|
supportingFiles.add(new SupportingFile("storage_logs_gitignore", srcBasePath + File.separator + "storage" + File.separator + "framework" + File.separator + "cache" + File.separator + "data", ".gitignore"));
|
||||||
supportingFiles.add(new SupportingFile("artisan", srcBasePath, "artisan"));
|
supportingFiles.add(new SupportingFile("artisan", srcBasePath, "artisan"));
|
||||||
supportingFiles.add(new SupportingFile("composer.mustache", srcBasePath, "composer.json"));
|
supportingFiles.add(new SupportingFile("composer.mustache", srcBasePath, "composer.json"));
|
||||||
supportingFiles.add(new SupportingFile("readme.md", srcBasePath, "readme.md"));
|
supportingFiles.add(new SupportingFile("readme.md", srcBasePath, "readme.md"));
|
||||||
@@ -142,6 +158,9 @@ public class PhpLumenServerCodegen extends AbstractPhpCodegen {
|
|||||||
supportingFiles.add(new SupportingFile("routes.mustache", srcBasePath + File.separator + "routes", "web.php"));
|
supportingFiles.add(new SupportingFile("routes.mustache", srcBasePath + File.separator + "routes", "web.php"));
|
||||||
supportingFiles.add(new SupportingFile("ExampleTest.php", srcBasePath + File.separator + "tests", "ExampleTest.php"));
|
supportingFiles.add(new SupportingFile("ExampleTest.php", srcBasePath + File.separator + "tests", "ExampleTest.php"));
|
||||||
supportingFiles.add(new SupportingFile("TestCase.php", srcBasePath + File.separator + "tests", "TestCase.php"));
|
supportingFiles.add(new SupportingFile("TestCase.php", srcBasePath + File.separator + "tests", "TestCase.php"));
|
||||||
|
supportingFiles.add(new SupportingFile("editorconfig", srcBasePath, ".editorconfig"));
|
||||||
|
supportingFiles.add(new SupportingFile("styleci", srcBasePath, ".styleci.yml"));
|
||||||
|
supportingFiles.add(new SupportingFile("phpunit.xml", srcBasePath, "phpunit.xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// override with any special post-processing
|
// override with any special post-processing
|
||||||
|
|||||||
@@ -148,6 +148,14 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
|||||||
return {{classname}}.schemas;
|
return {{classname}}.schemas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the instance that matches the anyOf child schema, check
|
||||||
|
* the instance parameter is valid against the anyOf child schemas:
|
||||||
|
* {{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}
|
||||||
|
*
|
||||||
|
* It could be an instance of the 'anyOf' schemas.
|
||||||
|
* The anyOf child schemas may themselves be a composed schema (allOf, anyOf, anyOf).
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setActualInstance(Object instance) {
|
public void setActualInstance(Object instance) {
|
||||||
{{#isNullable}}
|
{{#isNullable}}
|
||||||
@@ -166,4 +174,29 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
|||||||
{{/anyOf}}
|
{{/anyOf}}
|
||||||
throw new RuntimeException("Invalid instance type. Must be {{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}");
|
throw new RuntimeException("Invalid instance type. Must be {{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the actual instance, which can be the following:
|
||||||
|
* {{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}
|
||||||
|
*
|
||||||
|
* @return The actual instance ({{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}})
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Object getActualInstance() {
|
||||||
|
return super.getActualInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
{{#anyOf}}
|
||||||
|
/**
|
||||||
|
* Get the actual instance of `{{{.}}}`. If the actual instanct is not `{{{.}}}`,
|
||||||
|
* the ClassCastException will be thrown.
|
||||||
|
*
|
||||||
|
* @return The actual instance of `{{{.}}}`
|
||||||
|
* @throws ClassCastException if the instance is not `{{{.}}}`
|
||||||
|
*/
|
||||||
|
public {{{.}}} get{{{.}}}() throws ClassCastException {
|
||||||
|
return ({{{.}}})super.getActualInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/anyOf}}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,9 +137,9 @@ ext {
|
|||||||
{{#hasOAuthMethods}}
|
{{#hasOAuthMethods}}
|
||||||
scribejava_apis_version = "6.9.0"
|
scribejava_apis_version = "6.9.0"
|
||||||
{{/hasOAuthMethods}}
|
{{/hasOAuthMethods}}
|
||||||
{{#hasHttpBasicMethods}}
|
{{#hasHttpSignatureMethods}}
|
||||||
tomitribe_http_signatures_version = "1.3"
|
tomitribe_http_signatures_version = "1.5"
|
||||||
{{/hasHttpBasicMethods}}
|
{{/hasHttpSignatureMethods}}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -161,9 +161,9 @@ dependencies {
|
|||||||
{{#hasOAuthMethods}}
|
{{#hasOAuthMethods}}
|
||||||
compile "com.github.scribejava:scribejava-apis:$scribejava_apis_version"
|
compile "com.github.scribejava:scribejava-apis:$scribejava_apis_version"
|
||||||
{{/hasOAuthMethods}}
|
{{/hasOAuthMethods}}
|
||||||
{{#hasHttpBasicMethods}}
|
{{#hasHttpSignatureMethods}}
|
||||||
compile "org.tomitribe:tomitribe-http-signatures:$tomitribe_http_signatures_version"
|
compile "org.tomitribe:tomitribe-http-signatures:$tomitribe_http_signatures_version"
|
||||||
{{/hasHttpBasicMethods}}
|
{{/hasHttpSignatureMethods}}
|
||||||
{{#supportJava6}}
|
{{#supportJava6}}
|
||||||
compile "commons-io:commons-io:$commons_io_version"
|
compile "commons-io:commons-io:$commons_io_version"
|
||||||
compile "org.apache.commons:commons-lang3:$commons_lang3_version"
|
compile "org.apache.commons:commons-lang3:$commons_lang3_version"
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ lazy val root = (project in file(".")).
|
|||||||
{{#hasOAuthMethods}}
|
{{#hasOAuthMethods}}
|
||||||
"com.github.scribejava" % "scribejava-apis" % "6.9.0" % "compile",
|
"com.github.scribejava" % "scribejava-apis" % "6.9.0" % "compile",
|
||||||
{{/hasOAuthMethods}}
|
{{/hasOAuthMethods}}
|
||||||
{{#hasHttpBasicMethods}}
|
{{#hasHttpSignatureMethods}}
|
||||||
"org.tomitribe" % "tomitribe-http-signatures" % "1.3" % "compile",
|
"org.tomitribe" % "tomitribe-http-signatures" % "1.5" % "compile",
|
||||||
{{/hasHttpBasicMethods}}
|
{{/hasHttpSignatureMethods}}
|
||||||
{{^java8}}
|
{{^java8}}
|
||||||
"com.brsanthu" % "migbase64" % "2.2",
|
"com.brsanthu" % "migbase64" % "2.2",
|
||||||
{{/java8}}
|
{{/java8}}
|
||||||
|
|||||||
@@ -183,7 +183,8 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the instance that matches the oneOf child schema, check
|
* Set the instance that matches the oneOf child schema, check
|
||||||
* the instance parameter is valid against the oneOf child schemas.
|
* the instance parameter is valid against the oneOf child schemas:
|
||||||
|
* {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}
|
||||||
*
|
*
|
||||||
* It could be an instance of the 'oneOf' schemas.
|
* It could be an instance of the 'oneOf' schemas.
|
||||||
* The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf).
|
* The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf).
|
||||||
@@ -207,6 +208,28 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
|||||||
throw new RuntimeException("Invalid instance type. Must be {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}");
|
throw new RuntimeException("Invalid instance type. Must be {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the actual instance, which can be the following:
|
||||||
|
* {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}
|
||||||
|
*
|
||||||
|
* @return The actual instance ({{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}})
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Object getActualInstance() {
|
||||||
|
return super.getActualInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
{{#oneOf}}
|
||||||
|
/**
|
||||||
|
* Get the actual instance of `{{{.}}}`. If the actual instanct is not `{{{.}}}`,
|
||||||
|
* the ClassCastException will be thrown.
|
||||||
|
*
|
||||||
|
* @return The actual instance of `{{{.}}}`
|
||||||
|
* @throws ClassCastException if the instance is not `{{{.}}}`
|
||||||
|
*/
|
||||||
|
public {{{.}}} get{{{.}}}() throws ClassCastException {
|
||||||
|
return ({{{.}}})super.getActualInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/oneOf}}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1083,6 +1083,9 @@ public class ApiClient {
|
|||||||
} catch (ApiException e) {
|
} catch (ApiException e) {
|
||||||
callback.onFailure(e, response.code(), response.headers().toMultimap());
|
callback.onFailure(e, response.code(), response.headers().toMultimap());
|
||||||
return;
|
return;
|
||||||
|
} catch (Exception e) {
|
||||||
|
callback.onFailure(new ApiException(e), response.code(), response.headers().toMultimap());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
callback.onSuccess(result, response.code(), response.headers().toMultimap());
|
callback.onSuccess(result, response.code(), response.headers().toMultimap());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,19 +134,19 @@ public class {{classname}} {
|
|||||||
formParams.{{^collectionFormat}}add{{/collectionFormat}}{{#collectionFormat}}put{{/collectionFormat}}("{{baseName}}", {{#isFile}}{{^collectionFormat}}{{#useAbstractionForFiles}}{{paramName}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}new FileSystemResource({{paramName}}){{/useAbstractionForFiles}}{{/collectionFormat}}{{/isFile}}{{#isFile}}{{#collectionFormat}}{{paramName}}.stream(){{^useAbstractionForFiles}}.map(FileSystemResource::new){{/useAbstractionForFiles}}.collect(Collectors.toList()){{/collectionFormat}}{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}});{{#hasMore}}
|
formParams.{{^collectionFormat}}add{{/collectionFormat}}{{#collectionFormat}}put{{/collectionFormat}}("{{baseName}}", {{#isFile}}{{^collectionFormat}}{{#useAbstractionForFiles}}{{paramName}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}new FileSystemResource({{paramName}}){{/useAbstractionForFiles}}{{/collectionFormat}}{{/isFile}}{{#isFile}}{{#collectionFormat}}{{paramName}}.stream(){{^useAbstractionForFiles}}.map(FileSystemResource::new){{/useAbstractionForFiles}}.collect(Collectors.toList()){{/collectionFormat}}{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}});{{#hasMore}}
|
||||||
{{/hasMore}}{{/formParams}}{{/hasFormParams}}
|
{{/hasMore}}{{/formParams}}{{/hasFormParams}}
|
||||||
|
|
||||||
final String[] accepts = { {{#hasProduces}}
|
final String[] localVarAccepts = { {{#hasProduces}}
|
||||||
{{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
|
{{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
|
||||||
{{/hasProduces}}};
|
{{/hasProduces}} };
|
||||||
final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
|
final List<MediaType> localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
|
||||||
final String[] contentTypes = { {{#hasConsumes}}
|
final String[] contentTypes = { {{#hasConsumes}}
|
||||||
{{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}
|
{{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}
|
||||||
{{/hasConsumes}}};
|
{{/hasConsumes}} };
|
||||||
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
|
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||||
|
|
||||||
String[] authNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };
|
String[] authNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };
|
||||||
|
|
||||||
{{#returnType}}ParameterizedTypeReference<{{{returnType}}}> returnType = new ParameterizedTypeReference<{{{returnType}}}>() {};{{/returnType}}{{^returnType}}ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {};{{/returnType}}
|
{{#returnType}}ParameterizedTypeReference<{{{returnType}}}> returnType = new ParameterizedTypeReference<{{{returnType}}}>() {};{{/returnType}}{{^returnType}}ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {};{{/returnType}}
|
||||||
return apiClient.invokeAPI(path, HttpMethod.{{httpMethod}}, queryParams, postBody, headerParams, cookieParams, formParams, accept, contentType, authNames, returnType);
|
return apiClient.invokeAPI(path, HttpMethod.{{httpMethod}}, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, contentType, authNames, returnType);
|
||||||
}
|
}
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,32 @@
|
|||||||
package {{apiPackage}};
|
package {{apiPackage}};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The exception that can be used to store the HTTP status code returned by an API response.
|
||||||
|
*/
|
||||||
{{>generatedAnnotation}}
|
{{>generatedAnnotation}}
|
||||||
public class ApiException extends Exception{
|
public class ApiException extends Exception {
|
||||||
|
|
||||||
|
/** The HTTP status code. */
|
||||||
private int code;
|
private int code;
|
||||||
public ApiException (int code, String msg) {
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param code The HTTP status code.
|
||||||
|
* @param msg The error message.
|
||||||
|
*/
|
||||||
|
public ApiException(int code, String msg) {
|
||||||
super(msg);
|
super(msg);
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the HTTP status code.
|
||||||
|
*
|
||||||
|
* @return The HTTP status code.
|
||||||
|
*/
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,32 @@
|
|||||||
package {{apiPackage}};
|
package {{apiPackage}};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The exception that can be used to store the HTTP status code returned by an API response.
|
||||||
|
*/
|
||||||
{{>generatedAnnotation}}
|
{{>generatedAnnotation}}
|
||||||
public class ApiException extends Exception{
|
public class ApiException extends Exception {
|
||||||
|
|
||||||
|
/** The HTTP status code. */
|
||||||
private int code;
|
private int code;
|
||||||
public ApiException (int code, String msg) {
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param code The HTTP status code.
|
||||||
|
* @param msg The error message.
|
||||||
|
*/
|
||||||
|
public ApiException(int code, String msg) {
|
||||||
super(msg);
|
super(msg);
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the HTTP status code.
|
||||||
|
*
|
||||||
|
* @return The HTTP status code.
|
||||||
|
*/
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,32 @@
|
|||||||
package {{apiPackage}};
|
package {{apiPackage}};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The exception that can be used to store the HTTP status code returned by an API response.
|
||||||
|
*/
|
||||||
{{>generatedAnnotation}}
|
{{>generatedAnnotation}}
|
||||||
public class ApiException extends Exception{
|
public class ApiException extends Exception {
|
||||||
|
|
||||||
|
/** The HTTP status code. */
|
||||||
private int code;
|
private int code;
|
||||||
public ApiException (int code, String msg) {
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param code The HTTP status code.
|
||||||
|
* @param msg The error message.
|
||||||
|
*/
|
||||||
|
public ApiException(int code, String msg) {
|
||||||
super(msg);
|
super(msg);
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the HTTP status code.
|
||||||
|
*
|
||||||
|
* @return The HTTP status code.
|
||||||
|
*/
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -541,12 +541,15 @@
|
|||||||
{{/usePromises}} };
|
{{/usePromises}} };
|
||||||
|
|
||||||
{{#emitJSDoc}} /**
|
{{#emitJSDoc}} /**
|
||||||
* Parses an ISO-8601 string representation of a date value.
|
* Parses an ISO-8601 string representation or epoch representation of a date value.
|
||||||
* @param {String} str The date value as a string.
|
* @param {String} str The date value as a string.
|
||||||
* @returns {Date} The parsed date object.
|
* @returns {Date} The parsed date object.
|
||||||
*/
|
*/
|
||||||
{{/emitJSDoc}} exports.parseDate = function(str) {
|
{{/emitJSDoc}} exports.parseDate = function(str) {
|
||||||
return new Date(str.replace(/T/i, ' '));
|
if (isNaN(str)) {
|
||||||
|
return new Date(str.replace(/T/i, ' '));
|
||||||
|
}
|
||||||
|
return new Date(+str);
|
||||||
};
|
};
|
||||||
|
|
||||||
{{#emitJSDoc}} /**
|
{{#emitJSDoc}} /**
|
||||||
|
|||||||
@@ -519,12 +519,15 @@ class ApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{{#emitJSDoc}}/**
|
{{#emitJSDoc}}/**
|
||||||
* Parses an ISO-8601 string representation of a date value.
|
* Parses an ISO-8601 string representation or epoch representation of a date value.
|
||||||
* @param {String} str The date value as a string.
|
* @param {String} str The date value as a string.
|
||||||
* @returns {Date} The parsed date object.
|
* @returns {Date} The parsed date object.
|
||||||
*/{{/emitJSDoc}}
|
*/{{/emitJSDoc}}
|
||||||
static parseDate(str) {
|
static parseDate(str) {
|
||||||
return new Date(str);
|
if (isNaN(str)) {
|
||||||
|
return new Date(str);
|
||||||
|
}
|
||||||
|
return new Date(+str);
|
||||||
}
|
}
|
||||||
|
|
||||||
{{#emitJSDoc}}/**
|
{{#emitJSDoc}}/**
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace {{packageName}}
|
|||||||
/// <param name="args"></param>
|
/// <param name="args"></param>
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
CreateWebHostBuilder(args).Build().Run();
|
CreateHostBuilder(args).Build().Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -22,7 +22,7 @@ namespace {{packageName}}
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="args"></param>
|
/// <param name="args"></param>
|
||||||
/// <returns>IHostBuilder</returns>
|
/// <returns>IHostBuilder</returns>
|
||||||
public static IHostBuilder CreateWebHostBuilder(string[] args) =>
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||||
Host.CreateDefaultBuilder(args)
|
Host.CreateDefaultBuilder(args)
|
||||||
.ConfigureWebHostDefaults(webBuilder =>
|
.ConfigureWebHostDefaults(webBuilder =>
|
||||||
{
|
{
|
||||||
@@ -30,4 +30,4 @@ namespace {{packageName}}
|
|||||||
.UseUrls("http://0.0.0.0:{{#serverPort}}{{serverPort}}{{/serverPort}}{{^serverPort}}8080{{/serverPort}}/");
|
.UseUrls("http://0.0.0.0:{{#serverPort}}{{serverPort}}{{/serverPort}}{{^serverPort}}8080{{/serverPort}}/");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -448,7 +448,7 @@ namespace {{packageName}}.Client
|
|||||||
}
|
}
|
||||||
|
|
||||||
{{#supportsAsync}}
|
{{#supportsAsync}}
|
||||||
private async Task<ApiResponse<T>> ExecAsync<T>(RestRequest req, IReadableConfiguration configuration)
|
private async Task<ApiResponse<T>> ExecAsync<T>(RestRequest req, IReadableConfiguration configuration, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
|
||||||
{
|
{
|
||||||
RestClient client = new RestClient(_baseUrl);
|
RestClient client = new RestClient(_baseUrl);
|
||||||
|
|
||||||
@@ -479,7 +479,7 @@ namespace {{packageName}}.Client
|
|||||||
|
|
||||||
InterceptRequest(req);
|
InterceptRequest(req);
|
||||||
|
|
||||||
var response = await client.ExecuteAsync<T>(req);
|
var response = await client.ExecuteAsync<T>(req, cancellationToken);
|
||||||
|
|
||||||
InterceptResponse(req, response);
|
InterceptResponse(req, response);
|
||||||
|
|
||||||
@@ -526,11 +526,12 @@ namespace {{packageName}}.Client
|
|||||||
/// <param name="options">The additional request options.</param>
|
/// <param name="options">The additional request options.</param>
|
||||||
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
|
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
|
||||||
/// GlobalConfiguration has been done before calling this method.</param>
|
/// GlobalConfiguration has been done before calling this method.</param>
|
||||||
|
/// <param name="cancellationToken">Token that enables callers to cancel the request.</param>
|
||||||
/// <returns>A Task containing ApiResponse</returns>
|
/// <returns>A Task containing ApiResponse</returns>
|
||||||
public Task<ApiResponse<T>> GetAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
|
public Task<ApiResponse<T>> GetAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
|
||||||
{
|
{
|
||||||
var config = configuration ?? GlobalConfiguration.Instance;
|
var config = configuration ?? GlobalConfiguration.Instance;
|
||||||
return ExecAsync<T>(NewRequest(HttpMethod.Get, path, options, config), config);
|
return ExecAsync<T>(NewRequest(HttpMethod.Get, path, options, config), config, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -540,11 +541,12 @@ namespace {{packageName}}.Client
|
|||||||
/// <param name="options">The additional request options.</param>
|
/// <param name="options">The additional request options.</param>
|
||||||
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
|
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
|
||||||
/// GlobalConfiguration has been done before calling this method.</param>
|
/// GlobalConfiguration has been done before calling this method.</param>
|
||||||
|
/// <param name="cancellationToken">Token that enables callers to cancel the request.</param>
|
||||||
/// <returns>A Task containing ApiResponse</returns>
|
/// <returns>A Task containing ApiResponse</returns>
|
||||||
public Task<ApiResponse<T>> PostAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
|
public Task<ApiResponse<T>> PostAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
|
||||||
{
|
{
|
||||||
var config = configuration ?? GlobalConfiguration.Instance;
|
var config = configuration ?? GlobalConfiguration.Instance;
|
||||||
return ExecAsync<T>(NewRequest(HttpMethod.Post, path, options, config), config);
|
return ExecAsync<T>(NewRequest(HttpMethod.Post, path, options, config), config, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -554,11 +556,12 @@ namespace {{packageName}}.Client
|
|||||||
/// <param name="options">The additional request options.</param>
|
/// <param name="options">The additional request options.</param>
|
||||||
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
|
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
|
||||||
/// GlobalConfiguration has been done before calling this method.</param>
|
/// GlobalConfiguration has been done before calling this method.</param>
|
||||||
|
/// <param name="cancellationToken">Token that enables callers to cancel the request.</param>
|
||||||
/// <returns>A Task containing ApiResponse</returns>
|
/// <returns>A Task containing ApiResponse</returns>
|
||||||
public Task<ApiResponse<T>> PutAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
|
public Task<ApiResponse<T>> PutAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
|
||||||
{
|
{
|
||||||
var config = configuration ?? GlobalConfiguration.Instance;
|
var config = configuration ?? GlobalConfiguration.Instance;
|
||||||
return ExecAsync<T>(NewRequest(HttpMethod.Put, path, options, config), config);
|
return ExecAsync<T>(NewRequest(HttpMethod.Put, path, options, config), config, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -568,11 +571,12 @@ namespace {{packageName}}.Client
|
|||||||
/// <param name="options">The additional request options.</param>
|
/// <param name="options">The additional request options.</param>
|
||||||
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
|
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
|
||||||
/// GlobalConfiguration has been done before calling this method.</param>
|
/// GlobalConfiguration has been done before calling this method.</param>
|
||||||
|
/// <param name="cancellationToken">Token that enables callers to cancel the request.</param>
|
||||||
/// <returns>A Task containing ApiResponse</returns>
|
/// <returns>A Task containing ApiResponse</returns>
|
||||||
public Task<ApiResponse<T>> DeleteAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
|
public Task<ApiResponse<T>> DeleteAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
|
||||||
{
|
{
|
||||||
var config = configuration ?? GlobalConfiguration.Instance;
|
var config = configuration ?? GlobalConfiguration.Instance;
|
||||||
return ExecAsync<T>(NewRequest(HttpMethod.Delete, path, options, config), config);
|
return ExecAsync<T>(NewRequest(HttpMethod.Delete, path, options, config), config, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -582,11 +586,12 @@ namespace {{packageName}}.Client
|
|||||||
/// <param name="options">The additional request options.</param>
|
/// <param name="options">The additional request options.</param>
|
||||||
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
|
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
|
||||||
/// GlobalConfiguration has been done before calling this method.</param>
|
/// GlobalConfiguration has been done before calling this method.</param>
|
||||||
|
/// <param name="cancellationToken">Token that enables callers to cancel the request.</param>
|
||||||
/// <returns>A Task containing ApiResponse</returns>
|
/// <returns>A Task containing ApiResponse</returns>
|
||||||
public Task<ApiResponse<T>> HeadAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
|
public Task<ApiResponse<T>> HeadAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
|
||||||
{
|
{
|
||||||
var config = configuration ?? GlobalConfiguration.Instance;
|
var config = configuration ?? GlobalConfiguration.Instance;
|
||||||
return ExecAsync<T>(NewRequest(HttpMethod.Head, path, options, config), config);
|
return ExecAsync<T>(NewRequest(HttpMethod.Head, path, options, config), config, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -596,11 +601,12 @@ namespace {{packageName}}.Client
|
|||||||
/// <param name="options">The additional request options.</param>
|
/// <param name="options">The additional request options.</param>
|
||||||
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
|
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
|
||||||
/// GlobalConfiguration has been done before calling this method.</param>
|
/// GlobalConfiguration has been done before calling this method.</param>
|
||||||
|
/// <param name="cancellationToken">Token that enables callers to cancel the request.</param>
|
||||||
/// <returns>A Task containing ApiResponse</returns>
|
/// <returns>A Task containing ApiResponse</returns>
|
||||||
public Task<ApiResponse<T>> OptionsAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
|
public Task<ApiResponse<T>> OptionsAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
|
||||||
{
|
{
|
||||||
var config = configuration ?? GlobalConfiguration.Instance;
|
var config = configuration ?? GlobalConfiguration.Instance;
|
||||||
return ExecAsync<T>(NewRequest(HttpMethod.Options, path, options, config), config);
|
return ExecAsync<T>(NewRequest(HttpMethod.Options, path, options, config), config, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -610,11 +616,12 @@ namespace {{packageName}}.Client
|
|||||||
/// <param name="options">The additional request options.</param>
|
/// <param name="options">The additional request options.</param>
|
||||||
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
|
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
|
||||||
/// GlobalConfiguration has been done before calling this method.</param>
|
/// GlobalConfiguration has been done before calling this method.</param>
|
||||||
|
/// <param name="cancellationToken">Token that enables callers to cancel the request.</param>
|
||||||
/// <returns>A Task containing ApiResponse</returns>
|
/// <returns>A Task containing ApiResponse</returns>
|
||||||
public Task<ApiResponse<T>> PatchAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
|
public Task<ApiResponse<T>> PatchAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
|
||||||
{
|
{
|
||||||
var config = configuration ?? GlobalConfiguration.Instance;
|
var config = configuration ?? GlobalConfiguration.Instance;
|
||||||
return ExecAsync<T>(NewRequest(HttpMethod.Patch, path, options, config), config);
|
return ExecAsync<T>(NewRequest(HttpMethod.Patch, path, options, config), config, cancellationToken);
|
||||||
}
|
}
|
||||||
#endregion IAsynchronousClient
|
#endregion IAsynchronousClient
|
||||||
{{/supportsAsync}}
|
{{/supportsAsync}}
|
||||||
|
|||||||
@@ -21,6 +21,12 @@ namespace {{packageName}}.Client
|
|||||||
/// <value>The error content (Http response body).</value>
|
/// <value>The error content (Http response body).</value>
|
||||||
public object ErrorContent { get; private set; }
|
public object ErrorContent { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the HTTP headers
|
||||||
|
/// </summary>
|
||||||
|
/// <value>HTTP headers</value>
|
||||||
|
public Multimap<string, string> Headers { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ApiException"/> class.
|
/// Initializes a new instance of the <see cref="ApiException"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -42,10 +48,12 @@ namespace {{packageName}}.Client
|
|||||||
/// <param name="errorCode">HTTP status code.</param>
|
/// <param name="errorCode">HTTP status code.</param>
|
||||||
/// <param name="message">Error message.</param>
|
/// <param name="message">Error message.</param>
|
||||||
/// <param name="errorContent">Error content.</param>
|
/// <param name="errorContent">Error content.</param>
|
||||||
public ApiException(int errorCode, string message, object errorContent = null) : base(message)
|
/// <param name="headers">HTTP Headers.</param>
|
||||||
|
public ApiException(int errorCode, string message, object errorContent = null, Multimap<string, string> headers = null) : base(message)
|
||||||
{
|
{
|
||||||
this.ErrorCode = errorCode;
|
this.ErrorCode = errorCode;
|
||||||
this.ErrorContent = errorContent;
|
this.ErrorContent = errorContent;
|
||||||
|
this.Headers = headers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace {{packageName}}.Client
|
|||||||
{
|
{
|
||||||
return new ApiException(status,
|
return new ApiException(status,
|
||||||
string.Format("Error calling {0}: {1}", methodName, response.RawContent),
|
string.Format("Error calling {0}: {1}", methodName, response.RawContent),
|
||||||
response.RawContent);
|
response.RawContent, response.Headers);
|
||||||
}
|
}
|
||||||
{{^netStandard}}if (status == 0)
|
{{^netStandard}}if (status == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,9 +19,10 @@ namespace {{packageName}}.Client
|
|||||||
/// <param name="path">The relative path to invoke.</param>
|
/// <param name="path">The relative path to invoke.</param>
|
||||||
/// <param name="options">The request parameters to pass along to the client.</param>
|
/// <param name="options">The request parameters to pass along to the client.</param>
|
||||||
/// <param name="configuration">Per-request configurable settings.</param>
|
/// <param name="configuration">Per-request configurable settings.</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||||
/// <typeparam name="T">The return type.</typeparam>
|
/// <typeparam name="T">The return type.</typeparam>
|
||||||
/// <returns>A task eventually representing the response data, decorated with <see cref="ApiResponse{T}"/></returns>
|
/// <returns>A task eventually representing the response data, decorated with <see cref="ApiResponse{T}"/></returns>
|
||||||
Task<ApiResponse<T>> GetAsync<T>(String path, RequestOptions options, IReadableConfiguration configuration = null);
|
Task<ApiResponse<T>> GetAsync<T>(String path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Executes a non-blocking call to some <paramref name="path"/> using the POST http verb.
|
/// Executes a non-blocking call to some <paramref name="path"/> using the POST http verb.
|
||||||
@@ -29,9 +30,10 @@ namespace {{packageName}}.Client
|
|||||||
/// <param name="path">The relative path to invoke.</param>
|
/// <param name="path">The relative path to invoke.</param>
|
||||||
/// <param name="options">The request parameters to pass along to the client.</param>
|
/// <param name="options">The request parameters to pass along to the client.</param>
|
||||||
/// <param name="configuration">Per-request configurable settings.</param>
|
/// <param name="configuration">Per-request configurable settings.</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||||
/// <typeparam name="T">The return type.</typeparam>
|
/// <typeparam name="T">The return type.</typeparam>
|
||||||
/// <returns>A task eventually representing the response data, decorated with <see cref="ApiResponse{T}"/></returns>
|
/// <returns>A task eventually representing the response data, decorated with <see cref="ApiResponse{T}"/></returns>
|
||||||
Task<ApiResponse<T>> PostAsync<T>(String path, RequestOptions options, IReadableConfiguration configuration = null);
|
Task<ApiResponse<T>> PostAsync<T>(String path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Executes a non-blocking call to some <paramref name="path"/> using the PUT http verb.
|
/// Executes a non-blocking call to some <paramref name="path"/> using the PUT http verb.
|
||||||
@@ -39,9 +41,10 @@ namespace {{packageName}}.Client
|
|||||||
/// <param name="path">The relative path to invoke.</param>
|
/// <param name="path">The relative path to invoke.</param>
|
||||||
/// <param name="options">The request parameters to pass along to the client.</param>
|
/// <param name="options">The request parameters to pass along to the client.</param>
|
||||||
/// <param name="configuration">Per-request configurable settings.</param>
|
/// <param name="configuration">Per-request configurable settings.</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||||
/// <typeparam name="T">The return type.</typeparam>
|
/// <typeparam name="T">The return type.</typeparam>
|
||||||
/// <returns>A task eventually representing the response data, decorated with <see cref="ApiResponse{T}"/></returns>
|
/// <returns>A task eventually representing the response data, decorated with <see cref="ApiResponse{T}"/></returns>
|
||||||
Task<ApiResponse<T>> PutAsync<T>(String path, RequestOptions options, IReadableConfiguration configuration = null);
|
Task<ApiResponse<T>> PutAsync<T>(String path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Executes a non-blocking call to some <paramref name="path"/> using the DELETE http verb.
|
/// Executes a non-blocking call to some <paramref name="path"/> using the DELETE http verb.
|
||||||
@@ -49,9 +52,10 @@ namespace {{packageName}}.Client
|
|||||||
/// <param name="path">The relative path to invoke.</param>
|
/// <param name="path">The relative path to invoke.</param>
|
||||||
/// <param name="options">The request parameters to pass along to the client.</param>
|
/// <param name="options">The request parameters to pass along to the client.</param>
|
||||||
/// <param name="configuration">Per-request configurable settings.</param>
|
/// <param name="configuration">Per-request configurable settings.</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||||
/// <typeparam name="T">The return type.</typeparam>
|
/// <typeparam name="T">The return type.</typeparam>
|
||||||
/// <returns>A task eventually representing the response data, decorated with <see cref="ApiResponse{T}"/></returns>
|
/// <returns>A task eventually representing the response data, decorated with <see cref="ApiResponse{T}"/></returns>
|
||||||
Task<ApiResponse<T>> DeleteAsync<T>(String path, RequestOptions options, IReadableConfiguration configuration = null);
|
Task<ApiResponse<T>> DeleteAsync<T>(String path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Executes a non-blocking call to some <paramref name="path"/> using the HEAD http verb.
|
/// Executes a non-blocking call to some <paramref name="path"/> using the HEAD http verb.
|
||||||
@@ -59,9 +63,10 @@ namespace {{packageName}}.Client
|
|||||||
/// <param name="path">The relative path to invoke.</param>
|
/// <param name="path">The relative path to invoke.</param>
|
||||||
/// <param name="options">The request parameters to pass along to the client.</param>
|
/// <param name="options">The request parameters to pass along to the client.</param>
|
||||||
/// <param name="configuration">Per-request configurable settings.</param>
|
/// <param name="configuration">Per-request configurable settings.</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||||
/// <typeparam name="T">The return type.</typeparam>
|
/// <typeparam name="T">The return type.</typeparam>
|
||||||
/// <returns>A task eventually representing the response data, decorated with <see cref="ApiResponse{T}"/></returns>
|
/// <returns>A task eventually representing the response data, decorated with <see cref="ApiResponse{T}"/></returns>
|
||||||
Task<ApiResponse<T>> HeadAsync<T>(String path, RequestOptions options, IReadableConfiguration configuration = null);
|
Task<ApiResponse<T>> HeadAsync<T>(String path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Executes a non-blocking call to some <paramref name="path"/> using the OPTIONS http verb.
|
/// Executes a non-blocking call to some <paramref name="path"/> using the OPTIONS http verb.
|
||||||
@@ -69,9 +74,10 @@ namespace {{packageName}}.Client
|
|||||||
/// <param name="path">The relative path to invoke.</param>
|
/// <param name="path">The relative path to invoke.</param>
|
||||||
/// <param name="options">The request parameters to pass along to the client.</param>
|
/// <param name="options">The request parameters to pass along to the client.</param>
|
||||||
/// <param name="configuration">Per-request configurable settings.</param>
|
/// <param name="configuration">Per-request configurable settings.</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||||
/// <typeparam name="T">The return type.</typeparam>
|
/// <typeparam name="T">The return type.</typeparam>
|
||||||
/// <returns>A task eventually representing the response data, decorated with <see cref="ApiResponse{T}"/></returns>
|
/// <returns>A task eventually representing the response data, decorated with <see cref="ApiResponse{T}"/></returns>
|
||||||
Task<ApiResponse<T>> OptionsAsync<T>(String path, RequestOptions options, IReadableConfiguration configuration = null);
|
Task<ApiResponse<T>> OptionsAsync<T>(String path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Executes a non-blocking call to some <paramref name="path"/> using the PATCH http verb.
|
/// Executes a non-blocking call to some <paramref name="path"/> using the PATCH http verb.
|
||||||
@@ -79,9 +85,10 @@ namespace {{packageName}}.Client
|
|||||||
/// <param name="path">The relative path to invoke.</param>
|
/// <param name="path">The relative path to invoke.</param>
|
||||||
/// <param name="options">The request parameters to pass along to the client.</param>
|
/// <param name="options">The request parameters to pass along to the client.</param>
|
||||||
/// <param name="configuration">Per-request configurable settings.</param>
|
/// <param name="configuration">Per-request configurable settings.</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||||
/// <typeparam name="T">The return type.</typeparam>
|
/// <typeparam name="T">The return type.</typeparam>
|
||||||
/// <returns>A task eventually representing the response data, decorated with <see cref="ApiResponse{T}"/></returns>
|
/// <returns>A task eventually representing the response data, decorated with <see cref="ApiResponse{T}"/></returns>
|
||||||
Task<ApiResponse<T>> PatchAsync<T>(String path, RequestOptions options, IReadableConfiguration configuration = null);
|
Task<ApiResponse<T>> PatchAsync<T>(String path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{{^supportsAsync}}*/{{/supportsAsync}}
|
{{^supportsAsync}}*/{{/supportsAsync}}
|
||||||
|
|||||||
@@ -61,9 +61,12 @@ namespace {{packageName}}.{{apiPackage}}
|
|||||||
/// {{notes}}
|
/// {{notes}}
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
||||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
{{#allParams}}
|
||||||
{{/allParams}}/// <returns>Task of {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}void{{/returnType}}</returns>
|
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
||||||
{{#returnType}}System.Threading.Tasks.Task<{{{returnType}}}>{{/returnType}}{{^returnType}}System.Threading.Tasks.Task{{/returnType}} {{operationId}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
{{/allParams}}
|
||||||
|
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||||
|
/// <returns>Task of {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}void{{/returnType}}</returns>
|
||||||
|
{{#returnType}}System.Threading.Tasks.Task<{{{returnType}}}>{{/returnType}}{{^returnType}}System.Threading.Tasks.Task{{/returnType}} {{operationId}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// {{summary}}
|
/// {{summary}}
|
||||||
@@ -72,9 +75,12 @@ namespace {{packageName}}.{{apiPackage}}
|
|||||||
/// {{notes}}
|
/// {{notes}}
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
||||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
{{#allParams}}
|
||||||
{{/allParams}}/// <returns>Task of ApiResponse{{#returnType}} ({{returnType}}){{/returnType}}</returns>
|
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
||||||
System.Threading.Tasks.Task<ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>> {{operationId}}AsyncWithHttpInfo ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
{{/allParams}}
|
||||||
|
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||||
|
/// <returns>Task of ApiResponse{{#returnType}} ({{returnType}}){{/returnType}}</returns>
|
||||||
|
System.Threading.Tasks.Task<ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>> {{operationId}}WithHttpInfoAsync ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
#endregion Asynchronous Operations
|
#endregion Asynchronous Operations
|
||||||
}
|
}
|
||||||
@@ -376,22 +382,27 @@ namespace {{packageName}}.{{apiPackage}}
|
|||||||
/// {{summary}} {{notes}}
|
/// {{summary}} {{notes}}
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
||||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
{{#allParams}}
|
||||||
{{/allParams}}/// <returns>Task of {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}void{{/returnType}}</returns>
|
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
||||||
{{#returnType}}public async System.Threading.Tasks.Task<{{{returnType}}}>{{/returnType}}{{^returnType}}public async System.Threading.Tasks.Task{{/returnType}} {{operationId}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
{{/allParams}}
|
||||||
|
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||||
|
/// <returns>Task of {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}void{{/returnType}}</returns>
|
||||||
|
{{#returnType}}public async System.Threading.Tasks.Task<{{{returnType}}}>{{/returnType}}{{^returnType}}public async System.Threading.Tasks.Task{{/returnType}} {{operationId}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
|
||||||
{
|
{
|
||||||
{{#returnType}}{{packageName}}.Client.ApiResponse<{{{returnType}}}> localVarResponse = await {{operationId}}AsyncWithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
{{#returnType}}{{packageName}}.Client.ApiResponse<{{{returnType}}}> localVarResponse = await {{operationId}}WithHttpInfoAsync({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}cancellationToken);
|
||||||
return localVarResponse.Data;{{/returnType}}{{^returnType}}await {{operationId}}AsyncWithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{/returnType}}
|
return localVarResponse.Data;{{/returnType}}{{^returnType}}await {{operationId}}WithHttpInfoAsync({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}cancellationToken);{{/returnType}}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// {{summary}} {{notes}}
|
/// {{summary}} {{notes}}
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
/// <exception cref="{{packageName}}.Client.ApiException">Thrown when fails to make API call</exception>
|
||||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
{{#allParams}}
|
||||||
{{/allParams}}/// <returns>Task of ApiResponse{{#returnType}} ({{returnType}}){{/returnType}}</returns>
|
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
||||||
public async System.Threading.Tasks.Task<{{packageName}}.Client.ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>> {{operationId}}AsyncWithHttpInfo ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
{{/allParams}}
|
||||||
|
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||||
|
/// <returns>Task of ApiResponse{{#returnType}} ({{returnType}}){{/returnType}}</returns>
|
||||||
|
public async System.Threading.Tasks.Task<{{packageName}}.Client.ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>> {{operationId}}WithHttpInfoAsync ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
|
||||||
{
|
{
|
||||||
{{#allParams}}
|
{{#allParams}}
|
||||||
{{#required}}
|
{{#required}}
|
||||||
@@ -534,7 +545,7 @@ namespace {{packageName}}.{{apiPackage}}
|
|||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
|
|
||||||
var localVarResponse = await this.AsynchronousClient.{{#lambda.titlecase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.titlecase}}Async<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>("{{{path}}}", localVarRequestOptions, this.Configuration);
|
var localVarResponse = await this.AsynchronousClient.{{#lambda.titlecase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.titlecase}}Async<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>("{{{path}}}", localVarRequestOptions, this.Configuration, cancellationToken);
|
||||||
|
|
||||||
if (this.ExceptionFactory != null)
|
if (this.ExceptionFactory != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,9 +23,9 @@
|
|||||||
{{#termsOfService}}
|
{{#termsOfService}}
|
||||||
<copyright>{{termsOfService}}</copyright>
|
<copyright>{{termsOfService}}</copyright>
|
||||||
{{/termsOfService}}
|
{{/termsOfService}}
|
||||||
{{#licenseUrl}}
|
{{#license}}
|
||||||
<licenseUrl>{{licenseUrl}}</licenseUrl>
|
<license type="expression">{{{license}}}</license>
|
||||||
{{/licenseUrl}}
|
{{/license}}
|
||||||
|
|
||||||
<!-- Dependencies are automatically installed when the package is installed -->
|
<!-- Dependencies are automatically installed when the package is installed -->
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ namespace {{packageName}}.{{apiPackage}}
|
|||||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
||||||
{{/allParams}}/// <param name="cancellationToken">Cancellation Token to cancel request (optional) </param>
|
{{/allParams}}/// <param name="cancellationToken">Cancellation Token to cancel request (optional) </param>
|
||||||
/// <returns>Task of ApiResponse{{#returnType}} ({{returnType}}){{/returnType}}</returns>
|
/// <returns>Task of ApiResponse{{#returnType}} ({{returnType}}){{/returnType}}</returns>
|
||||||
System.Threading.Tasks.Task<ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>> {{operationId}}AsyncWithHttpInfo ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}CancellationToken cancellationToken = default(CancellationToken));
|
System.Threading.Tasks.Task<ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>> {{operationId}}WithHttpInfoAsync ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}CancellationToken cancellationToken = default(CancellationToken));
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
#endregion Asynchronous Operations
|
#endregion Asynchronous Operations
|
||||||
{{/supportsAsync}}
|
{{/supportsAsync}}
|
||||||
@@ -340,8 +340,8 @@ namespace {{packageName}}.{{apiPackage}}
|
|||||||
/// <returns>Task of {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}void{{/returnType}}</returns>
|
/// <returns>Task of {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}void{{/returnType}}</returns>
|
||||||
{{#returnType}}public async System.Threading.Tasks.Task<{{{returnType}}}>{{/returnType}}{{^returnType}}public async System.Threading.Tasks.Task{{/returnType}} {{operationId}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}CancellationToken cancellationToken = default(CancellationToken))
|
{{#returnType}}public async System.Threading.Tasks.Task<{{{returnType}}}>{{/returnType}}{{^returnType}}public async System.Threading.Tasks.Task{{/returnType}} {{operationId}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}CancellationToken cancellationToken = default(CancellationToken))
|
||||||
{
|
{
|
||||||
{{#returnType}}ApiResponse<{{{returnType}}}> localVarResponse = await {{operationId}}AsyncWithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}cancellationToken);
|
{{#returnType}}ApiResponse<{{{returnType}}}> localVarResponse = await {{operationId}}WithHttpInfoAsync({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}cancellationToken);
|
||||||
return localVarResponse.Data;{{/returnType}}{{^returnType}}await {{operationId}}AsyncWithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}cancellationToken);{{/returnType}}
|
return localVarResponse.Data;{{/returnType}}{{^returnType}}await {{operationId}}WithHttpInfoAsync({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}cancellationToken);{{/returnType}}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,7 +352,7 @@ namespace {{packageName}}.{{apiPackage}}
|
|||||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
||||||
{{/allParams}}/// <param name="cancellationToken">Cancellation Token to cancel request (optional) </param>
|
{{/allParams}}/// <param name="cancellationToken">Cancellation Token to cancel request (optional) </param>
|
||||||
/// <returns>Task of ApiResponse{{#returnType}} ({{returnType}}){{/returnType}}</returns>
|
/// <returns>Task of ApiResponse{{#returnType}} ({{returnType}}){{/returnType}}</returns>
|
||||||
public async System.Threading.Tasks.Task<ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>> {{operationId}}AsyncWithHttpInfo ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}CancellationToken cancellationToken = default(CancellationToken))
|
public async System.Threading.Tasks.Task<ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>> {{operationId}}WithHttpInfoAsync ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = default({{{dataType}}}){{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}CancellationToken cancellationToken = default(CancellationToken))
|
||||||
{
|
{
|
||||||
{{#allParams}}
|
{{#allParams}}
|
||||||
{{#required}}
|
{{#required}}
|
||||||
|
|||||||
@@ -23,9 +23,9 @@
|
|||||||
{{#termsOfService}}
|
{{#termsOfService}}
|
||||||
<copyright>{{termsOfService}}</copyright>
|
<copyright>{{termsOfService}}</copyright>
|
||||||
{{/termsOfService}}
|
{{/termsOfService}}
|
||||||
{{#licenseUrl}}
|
{{#license}}
|
||||||
<licenseUrl>{{licenseUrl}}</licenseUrl>
|
<license type="expression">{{{license}}}</license>
|
||||||
{{/licenseUrl}}
|
{{/license}}
|
||||||
|
|
||||||
<!-- Dependencies are automatically installed when the package is installed -->
|
<!-- Dependencies are automatically installed when the package is installed -->
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|||||||
@@ -89,19 +89,19 @@ class {{classname}} {
|
|||||||
(json['{{baseName}}'] as Map).cast<String, {{items.datatype}}>();
|
(json['{{baseName}}'] as Map).cast<String, {{items.datatype}}>();
|
||||||
{{/isMapContainer}}
|
{{/isMapContainer}}
|
||||||
{{^isMapContainer}}
|
{{^isMapContainer}}
|
||||||
{{#isDouble}}
|
{{#isNumber}}
|
||||||
{{name}} = (json['{{baseName}}'] == null) ?
|
{{name}} = (json['{{baseName}}'] == null) ?
|
||||||
null :
|
null :
|
||||||
json['{{baseName}}'].toDouble();
|
json['{{baseName}}'].toDouble();
|
||||||
{{/isDouble}}
|
{{/isNumber}}
|
||||||
{{^isDouble}}
|
{{^isNumber}}
|
||||||
{{^isEnum}}
|
{{^isEnum}}
|
||||||
{{name}} = json['{{baseName}}'];
|
{{name}} = json['{{baseName}}'];
|
||||||
{{/isEnum}}
|
{{/isEnum}}
|
||||||
{{#isEnum}}
|
{{#isEnum}}
|
||||||
{{name}} = {{classname}}{{{enumName}}}.fromJson(json['{{baseName}}']);
|
{{name}} = {{classname}}{{{enumName}}}.fromJson(json['{{baseName}}']);
|
||||||
{{/isEnum}}
|
{{/isEnum}}
|
||||||
{{/isDouble}}
|
{{/isNumber}}
|
||||||
{{/isMapContainer}}
|
{{/isMapContainer}}
|
||||||
{{/isListContainer}}
|
{{/isListContainer}}
|
||||||
{{/complexType}}
|
{{/complexType}}
|
||||||
|
|||||||
@@ -26,12 +26,14 @@ type api{{operationId}}Request struct {
|
|||||||
{{paramName}} {{^isPathParam}}*{{/isPathParam}}{{{dataType}}}{{/allParams}}
|
{{paramName}} {{^isPathParam}}*{{/isPathParam}}{{{dataType}}}{{/allParams}}
|
||||||
}
|
}
|
||||||
|
|
||||||
{{#allParams}}{{^isPathParam}}
|
{{#allParams}}
|
||||||
|
{{^isPathParam}}
|
||||||
func (r api{{operationId}}Request) {{vendorExtensions.x-export-param-name}}({{paramName}} {{{dataType}}}) api{{operationId}}Request {
|
func (r api{{operationId}}Request) {{vendorExtensions.x-export-param-name}}({{paramName}} {{{dataType}}}) api{{operationId}}Request {
|
||||||
r.{{paramName}} = &{{paramName}}
|
r.{{paramName}} = &{{paramName}}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
{{/isPathParam}}{{/allParams}}
|
{{/isPathParam}}
|
||||||
|
{{/allParams}}
|
||||||
/*
|
/*
|
||||||
{{operationId}}{{#summary}} {{{.}}}{{/summary}}{{^summary}} Method for {{operationId}}{{/summary}}
|
{{operationId}}{{#summary}} {{{.}}}{{/summary}}{{^summary}} Method for {{operationId}}{{/summary}}
|
||||||
{{#notes}}
|
{{#notes}}
|
||||||
@@ -51,7 +53,9 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx _context.Context{{#pathParam
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
Execute executes the request
|
Execute executes the request
|
||||||
{{#returnType}} @return {{{.}}}{{/returnType}}
|
{{#returnType}}
|
||||||
|
@return {{{.}}}
|
||||||
|
{{/returnType}}
|
||||||
*/
|
*/
|
||||||
func (r api{{operationId}}Request) Execute() ({{#returnType}}{{{.}}}, {{/returnType}}*_nethttp.Response, error) {
|
func (r api{{operationId}}Request) Execute() ({{#returnType}}{{{.}}}, {{/returnType}}*_nethttp.Response, error) {
|
||||||
var (
|
var (
|
||||||
@@ -60,7 +64,9 @@ func (r api{{operationId}}Request) Execute() ({{#returnType}}{{{.}}}, {{/returnT
|
|||||||
localVarFormFileName string
|
localVarFormFileName string
|
||||||
localVarFileName string
|
localVarFileName string
|
||||||
localVarFileBytes []byte
|
localVarFileBytes []byte
|
||||||
{{#returnType}}localVarReturnValue {{{.}}}{{/returnType}}
|
{{#returnType}}
|
||||||
|
localVarReturnValue {{{.}}}
|
||||||
|
{{/returnType}}
|
||||||
)
|
)
|
||||||
|
|
||||||
localBasePath, err := r.apiService.client.cfg.ServerURLWithContext(r.ctx, "{{{classname}}}Service.{{{nickname}}}")
|
localBasePath, err := r.apiService.client.cfg.ServerURLWithContext(r.ctx, "{{{classname}}}Service.{{{nickname}}}")
|
||||||
@@ -75,10 +81,12 @@ func (r api{{operationId}}Request) Execute() ({{#returnType}}{{{.}}}, {{/returnT
|
|||||||
localVarQueryParams := _neturl.Values{}
|
localVarQueryParams := _neturl.Values{}
|
||||||
localVarFormParams := _neturl.Values{}
|
localVarFormParams := _neturl.Values{}
|
||||||
{{#allParams}}
|
{{#allParams}}
|
||||||
{{#required}}{{^isPathParam}}
|
{{#required}}
|
||||||
|
{{^isPathParam}}
|
||||||
if r.{{paramName}} == nil {
|
if r.{{paramName}} == nil {
|
||||||
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} is required and must be specified")
|
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} is required and must be specified")
|
||||||
}{{/isPathParam}}
|
}
|
||||||
|
{{/isPathParam}}
|
||||||
{{#minItems}}
|
{{#minItems}}
|
||||||
if len({{^isPathParam}}*{{/isPathParam}}r.{{paramName}}) < {{minItems}} {
|
if len({{^isPathParam}}*{{/isPathParam}}r.{{paramName}}) < {{minItems}} {
|
||||||
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must have at least {{minItems}} elements")
|
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must have at least {{minItems}} elements")
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ func (dst *{{classname}}) UnmarshalJSON(data []byte) error {
|
|||||||
{{/isNullable}}
|
{{/isNullable}}
|
||||||
{{#discriminator}}
|
{{#discriminator}}
|
||||||
{{#mappedModels}}
|
{{#mappedModels}}
|
||||||
{{#-first}}
|
{{#-first}}
|
||||||
// use discriminator value to speed up the lookup
|
// use discriminator value to speed up the lookup
|
||||||
var jsonDict map[string]interface{}
|
var jsonDict map[string]interface{}
|
||||||
err := json.Unmarshal(data, &jsonDict)
|
err := json.Unmarshal(data, &jsonDict)
|
||||||
@@ -25,7 +25,7 @@ func (dst *{{classname}}) UnmarshalJSON(data []byte) error {
|
|||||||
return fmt.Errorf("Failed to unmarshal JSON into map for the discrimintor lookup.")
|
return fmt.Errorf("Failed to unmarshal JSON into map for the discrimintor lookup.")
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/-first}}
|
{{/-first}}
|
||||||
// check if the discriminator value is '{{{mappingName}}}'
|
// check if the discriminator value is '{{{mappingName}}}'
|
||||||
if jsonDict["{{{propertyBaseName}}}"] == "{{{mappingName}}}" {
|
if jsonDict["{{{propertyBaseName}}}"] == "{{{mappingName}}}" {
|
||||||
// try to unmarshal JSON data into {{{modelName}}}
|
// try to unmarshal JSON data into {{{modelName}}}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ const (
|
|||||||
// The 'Host' header, as defined in RFC 2616, section 14.23.
|
// The 'Host' header, as defined in RFC 2616, section 14.23.
|
||||||
HttpHeaderHost string = "Host"
|
HttpHeaderHost string = "Host"
|
||||||
// The 'Date' header.
|
// The 'Date' header.
|
||||||
HttpHeaderDate string = "Date"
|
HttpHeaderDate string = "Date"
|
||||||
// The digest header, as defined in RFC 3230, section 4.3.2.
|
// The digest header, as defined in RFC 3230, section 4.3.2.
|
||||||
HttpHeaderDigest string = "Digest"
|
HttpHeaderDigest string = "Digest"
|
||||||
// The HTTP Authorization header, as defined in RFC 7235, section 4.2.
|
// The HTTP Authorization header, as defined in RFC 7235, section 4.2.
|
||||||
@@ -106,7 +106,7 @@ type HttpSignatureAuth struct {
|
|||||||
SigningScheme string // The signature scheme, when signing HTTP requests. Supported value is 'hs2019'.
|
SigningScheme string // The signature scheme, when signing HTTP requests. Supported value is 'hs2019'.
|
||||||
// The signature algorithm, when signing HTTP requests.
|
// The signature algorithm, when signing HTTP requests.
|
||||||
// Supported values are RSASSA-PKCS1-v1_5, RSASSA-PSS.
|
// Supported values are RSASSA-PKCS1-v1_5, RSASSA-PSS.
|
||||||
SigningAlgorithm string
|
SigningAlgorithm string
|
||||||
SignedHeaders []string // A list of HTTP headers included when generating the signature for the message.
|
SignedHeaders []string // A list of HTTP headers included when generating the signature for the message.
|
||||||
// SignatureMaxValidity specifies the maximum duration of the signature validity.
|
// SignatureMaxValidity specifies the maximum duration of the signature validity.
|
||||||
// The value is used to set the '(expires)' signature parameter in the HTTP request.
|
// The value is used to set the '(expires)' signature parameter in the HTTP request.
|
||||||
|
|||||||
@@ -41,32 +41,49 @@ func (c *{{classname}}Controller) {{nickname}}(w http.ResponseWriter, r *http.Re
|
|||||||
{{/hasFormParams}}{{#hasPathParams}}
|
{{/hasFormParams}}{{#hasPathParams}}
|
||||||
params := mux.Vars(r){{/hasPathParams}}{{#hasQueryParams}}
|
params := mux.Vars(r){{/hasPathParams}}{{#hasQueryParams}}
|
||||||
query := r.URL.Query(){{/hasQueryParams}}{{#allParams}}{{#isPathParam}}{{#isLong}}
|
query := r.URL.Query(){{/hasQueryParams}}{{#allParams}}{{#isPathParam}}{{#isLong}}
|
||||||
{{paramName}}, err := parseIntParameter(params["{{paramName}}"])
|
{{paramName}}, err := parseInt64Parameter(params["{{paramName}}"])
|
||||||
|
if err != nil {
|
||||||
|
w.WriteHeader(500)
|
||||||
|
return
|
||||||
|
}{{/isLong}}{{#isInteger}}
|
||||||
|
{{paramName}}, err := parseInt32Parameter(params["{{paramName}}"])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(500)
|
w.WriteHeader(500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
{{/isLong}}{{^isLong}}
|
{{/isInteger}}{{^isLong}}{{^isInteger}}
|
||||||
{{paramName}} := params["{{paramName}}"]{{/isLong}}{{/isPathParam}}{{#isQueryParam}}{{#isLong}}
|
{{paramName}} := params["{{paramName}}"]{{/isInteger}}{{/isLong}}{{/isPathParam}}{{#isQueryParam}}{{#isLong}}
|
||||||
{{paramName}}, err := parseIntParameter(query.Get("{{paramName}}"))
|
{{paramName}}, err := parseInt64Parameter(query.Get("{{paramName}}"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(500)
|
w.WriteHeader(500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
{{/isLong}}{{^isLong}}
|
{{/isLong}}{{#isInteger}}
|
||||||
{{paramName}} := {{#isListContainer}}strings.Split({{/isListContainer}}query.Get("{{paramName}}"){{#isListContainer}}, ","){{/isListContainer}}{{/isLong}}{{/isQueryParam}}{{#isFormParam}}{{#isFile}}
|
{{paramName}}, err := parseInt32Parameter(query.Get("{{paramName}}"))
|
||||||
|
if err != nil {
|
||||||
|
w.WriteHeader(500)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
{{/isInteger}}{{^isLong}}{{^isInteger}}
|
||||||
|
{{paramName}} := {{#isListContainer}}strings.Split({{/isListContainer}}query.Get("{{paramName}}"){{#isListContainer}}, ","){{/isListContainer}}{{/isInteger}}{{/isLong}}{{/isQueryParam}}{{#isFormParam}}{{#isFile}}
|
||||||
{{paramName}}, err := ReadFormFileToTempFile(r, "{{paramName}}")
|
{{paramName}}, err := ReadFormFileToTempFile(r, "{{paramName}}")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(500)
|
w.WriteHeader(500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
{{/isFile}}{{#isLong}}
|
{{/isFile}}{{#isLong}}
|
||||||
{{paramName}}, err := parseIntParameter( r.FormValue("{{paramName}}"))
|
{{paramName}}, err := parseInt64Parameter( r.FormValue("{{paramName}}"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(500)
|
w.WriteHeader(500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
{{/isLong}}{{^isFile}}{{^isLong}}
|
{{/isLong}}{{#isInteger}}
|
||||||
|
{{paramName}}, err := parseInt32Parameter( r.FormValue("{{paramName}}"))
|
||||||
|
if err != nil {
|
||||||
|
w.WriteHeader(500)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
{{/isInteger}}{{^isFile}}{{^isLong}}
|
||||||
{{paramName}} := r.FormValue("{{paramName}}"){{/isLong}}{{/isFile}}{{/isFormParam}}{{#isHeaderParam}}
|
{{paramName}} := r.FormValue("{{paramName}}"){{/isLong}}{{/isFile}}{{/isFormParam}}{{#isHeaderParam}}
|
||||||
{{paramName}} := r.Header.Get("{{paramName}}"){{/isHeaderParam}}{{#isBodyParam}}
|
{{paramName}} := r.Header.Get("{{paramName}}"){{/isHeaderParam}}{{#isBodyParam}}
|
||||||
{{paramName}} := &{{dataType}}{}
|
{{paramName}} := &{{dataType}}{}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ type {{{name}}} {{^format}}{{dataType}}{{/format}}{{#format}}{{{format}}}{{/form
|
|||||||
const (
|
const (
|
||||||
{{#allowableValues}}
|
{{#allowableValues}}
|
||||||
{{#enumVars}}
|
{{#enumVars}}
|
||||||
{{name}} {{{classname}}} = {{{value}}}
|
{{#enumClassPrefix}}{{{classname.toUpperCase}}}_{{/enumClassPrefix}}{{name}} {{{classname}}} = {{{value}}}
|
||||||
{{/enumVars}}
|
{{/enumVars}}
|
||||||
{{/allowableValues}}
|
{{/allowableValues}}
|
||||||
){{/isEnum}}{{^isEnum}}{{#description}}
|
){{/isEnum}}{{^isEnum}}{{#description}}
|
||||||
|
|||||||
@@ -88,7 +88,16 @@ func ReadFormFileToTempFile(r *http.Request, key string) (*os.File, error) {
|
|||||||
return file, nil
|
return file, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseIntParameter parses a sting parameter to an int64
|
// parseInt64Parameter parses a sting parameter to an int64
|
||||||
func parseIntParameter(param string) (int64, error) {
|
func parseInt64Parameter(param string) (int64, error) {
|
||||||
return strconv.ParseInt(param, 10, 64)
|
return strconv.ParseInt(param, 10, 64)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// parseInt32Parameter parses a sting parameter to an int32
|
||||||
|
func parseInt32Parameter(param string) (int32, error) {
|
||||||
|
val, err := strconv.ParseInt(param, 10, 32)
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
return int32(val), nil
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
_ioutil "io/ioutil"
|
_ioutil "io/ioutil"
|
||||||
_nethttp "net/http"
|
_nethttp "net/http"
|
||||||
_neturl "net/url"
|
_neturl "net/url"
|
||||||
|
_bytes "bytes"
|
||||||
{{#imports}} "{{import}}"
|
{{#imports}} "{{import}}"
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
)
|
)
|
||||||
@@ -309,6 +310,7 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx _context.Context{{#hasParams
|
|||||||
|
|
||||||
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
|
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
|
||||||
localVarHTTPResponse.Body.Close()
|
localVarHTTPResponse.Body.Close()
|
||||||
|
localVarHTTPResponse.Body = _ioutil.NopCloser(_bytes.NewBuffer(localVarBody))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, err
|
return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,32 @@
|
|||||||
package {{apiPackage}};
|
package {{apiPackage}};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The exception that can be used to store the HTTP status code returned by an API response.
|
||||||
|
*/
|
||||||
{{>generatedAnnotation}}
|
{{>generatedAnnotation}}
|
||||||
public class ApiException extends Exception{
|
public class ApiException extends Exception {
|
||||||
|
|
||||||
|
/** The HTTP status code. */
|
||||||
private int code;
|
private int code;
|
||||||
public ApiException (int code, String msg) {
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param code The HTTP status code.
|
||||||
|
* @param msg The error message.
|
||||||
|
*/
|
||||||
|
public ApiException(int code, String msg) {
|
||||||
super(msg);
|
super(msg);
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the HTTP status code.
|
||||||
|
*
|
||||||
|
* @return The HTTP status code.
|
||||||
|
*/
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ buildscript {
|
|||||||
{{#useRxJava2}}
|
{{#useRxJava2}}
|
||||||
ext.rxJava2Version = '2.2.17'
|
ext.rxJava2Version = '2.2.17'
|
||||||
{{/useRxJava2}}
|
{{/useRxJava2}}
|
||||||
|
{{#useRxJava3}}
|
||||||
|
ext.rxJava3Version = '3.0.4'
|
||||||
|
{{/useRxJava3}}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven { url "https://repo1.maven.org/maven2" }
|
maven { url "https://repo1.maven.org/maven2" }
|
||||||
@@ -98,6 +101,10 @@ dependencies {
|
|||||||
compile "io.reactivex.rxjava2:rxjava:$rxJava2Version"
|
compile "io.reactivex.rxjava2:rxjava:$rxJava2Version"
|
||||||
compile "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
|
compile "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
|
||||||
{{/useRxJava2}}
|
{{/useRxJava2}}
|
||||||
|
{{#useRxJava3}}
|
||||||
|
compile "io.reactivex.rxjava3:rxjava:$rxJava3Version"
|
||||||
|
compile "com.squareup.retrofit2:adapter-rxjava3:2.9.0"
|
||||||
|
{{/useRxJava3}}
|
||||||
compile "com.squareup.retrofit2:retrofit:$retrofitVersion"
|
compile "com.squareup.retrofit2:retrofit:$retrofitVersion"
|
||||||
{{#gson}}
|
{{#gson}}
|
||||||
compile "com.squareup.retrofit2:converter-gson:$retrofitVersion"
|
compile "com.squareup.retrofit2:converter-gson:$retrofitVersion"
|
||||||
|
|||||||
@@ -24,10 +24,16 @@ import rx.Observable
|
|||||||
{{#useRxJava2}}
|
{{#useRxJava2}}
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
{{/useRxJava2}}
|
{{/useRxJava2}}
|
||||||
|
{{#useRxJava3}}
|
||||||
|
import io.reactivex.rxjava3.core.Single;
|
||||||
|
{{/useRxJava3}}
|
||||||
{{^returnType}}
|
{{^returnType}}
|
||||||
{{#useRxJava2}}
|
{{#useRxJava2}}
|
||||||
import io.reactivex.Completable
|
import io.reactivex.Completable
|
||||||
{{/useRxJava2}}
|
{{/useRxJava2}}
|
||||||
|
{{#useRxJava3}}
|
||||||
|
import io.reactivex.rxjava3.core.Completable;
|
||||||
|
{{/useRxJava3}}
|
||||||
{{/returnType}}
|
{{/returnType}}
|
||||||
{{/doNotUseRxAndCoroutines}}
|
{{/doNotUseRxAndCoroutines}}
|
||||||
|
|
||||||
@@ -35,6 +41,12 @@ import io.reactivex.Completable
|
|||||||
{{/imports}}
|
{{/imports}}
|
||||||
|
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
|
{{#x-kotlin-multipart-import}}
|
||||||
|
{{^isMultipart}}
|
||||||
|
import okhttp3.MultipartBody
|
||||||
|
|
||||||
|
{{/isMultipart}}
|
||||||
|
{{/x-kotlin-multipart-import}}
|
||||||
interface {{classname}} {
|
interface {{classname}} {
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
/**
|
/**
|
||||||
@@ -66,8 +78,8 @@ interface {{classname}} {
|
|||||||
{{/prioritizedContentTypes}}
|
{{/prioritizedContentTypes}}
|
||||||
{{/formParams}}
|
{{/formParams}}
|
||||||
@{{httpMethod}}("{{{path}}}")
|
@{{httpMethod}}("{{{path}}}")
|
||||||
{{^doNotUseRxAndCoroutines}}{{#useCoroutines}}suspend {{/useCoroutines}}{{/doNotUseRxAndCoroutines}}fun {{operationId}}({{^allParams}}){{/allParams}}{{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, {{/hasMore}}{{^hasMore}}){{/hasMore}}{{/allParams}}: {{^doNotUseRxAndCoroutines}}{{#useRxJava}}Observable<{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}{{/isResponseFile}}>{{/useRxJava}}{{#useRxJava2}}{{#returnType}}Single<{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}>{{/returnType}}{{^returnType}}Completable{{/returnType}}{{/useRxJava2}}{{#useCoroutines}}Response<{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}{{/isResponseFile}}>{{/useCoroutines}}{{/doNotUseRxAndCoroutines}}{{#doNotUseRxAndCoroutines}}Call<{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}{{/isResponseFile}}>{{/doNotUseRxAndCoroutines}}
|
{{^doNotUseRxAndCoroutines}}{{#useCoroutines}}suspend {{/useCoroutines}}{{/doNotUseRxAndCoroutines}}fun {{operationId}}({{^allParams}}){{/allParams}}{{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, {{/hasMore}}{{^hasMore}}){{/hasMore}}{{/allParams}}: {{^doNotUseRxAndCoroutines}}{{#useRxJava}}Observable<{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}{{/isResponseFile}}>{{/useRxJava}}{{#useRxJava2}}{{#returnType}}Single<{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}>{{/returnType}}{{^returnType}}Completable{{/returnType}}{{/useRxJava2}}{{#useRxJava3}}{{#returnType}}Single<{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}>{{/returnType}}{{^returnType}}Completable{{/returnType}}{{/useRxJava3}}{{#useCoroutines}}Response<{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}{{/isResponseFile}}>{{/useCoroutines}}{{/doNotUseRxAndCoroutines}}{{#doNotUseRxAndCoroutines}}Call<{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}{{/isResponseFile}}>{{/doNotUseRxAndCoroutines}}
|
||||||
|
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
}
|
}
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory
|
|||||||
{{#useRxJava2}}
|
{{#useRxJava2}}
|
||||||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
|
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
|
||||||
{{/useRxJava2}}
|
{{/useRxJava2}}
|
||||||
|
{{#useRxJava3}}
|
||||||
|
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory
|
||||||
|
{{/useRxJava3}}
|
||||||
{{#gson}}
|
{{#gson}}
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.google.gson.GsonBuilder
|
import com.google.gson.GsonBuilder
|
||||||
@@ -45,7 +48,8 @@ import retrofit2.converter.moshi.MoshiConverterFactory
|
|||||||
{{#nonPublicApi}}internal {{/nonPublicApi}}class ApiClient(
|
{{#nonPublicApi}}internal {{/nonPublicApi}}class ApiClient(
|
||||||
private var baseUrl: String = defaultBasePath,
|
private var baseUrl: String = defaultBasePath,
|
||||||
private val okHttpClientBuilder: OkHttpClient.Builder? = null,
|
private val okHttpClientBuilder: OkHttpClient.Builder? = null,
|
||||||
private val serializerBuilder: {{#gson}}Gson{{/gson}}{{#moshi}}Moshi.{{/moshi}}Builder = Serializer.{{#gson}}gson{{/gson}}{{#moshi}}moshi{{/moshi}}Builder
|
private val serializerBuilder: {{#gson}}Gson{{/gson}}{{#moshi}}Moshi.{{/moshi}}Builder = Serializer.{{#gson}}gson{{/gson}}{{#moshi}}moshi{{/moshi}}Builder,
|
||||||
|
private val okHttpClient : OkHttpClient? = null
|
||||||
) {
|
) {
|
||||||
private val apiAuthorizations = mutableMapOf<String, Interceptor>()
|
private val apiAuthorizations = mutableMapOf<String, Interceptor>()
|
||||||
var logger: ((String) -> Unit)? = null
|
var logger: ((String) -> Unit)? = null
|
||||||
@@ -62,7 +66,9 @@ import retrofit2.converter.moshi.MoshiConverterFactory
|
|||||||
{{/useRxJava}}
|
{{/useRxJava}}
|
||||||
{{#useRxJava2}}
|
{{#useRxJava2}}
|
||||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||||
{{/useRxJava2}}
|
{{/useRxJava2}}{{#useRxJava3}}
|
||||||
|
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
|
||||||
|
{{/useRxJava3}}
|
||||||
{{#moshi}}
|
{{#moshi}}
|
||||||
.addConverterFactory(MoshiConverterFactory.create(serializerBuilder.build()))
|
.addConverterFactory(MoshiConverterFactory.create(serializerBuilder.build()))
|
||||||
{{/moshi}}
|
{{/moshi}}
|
||||||
@@ -281,7 +287,9 @@ import retrofit2.converter.moshi.MoshiConverterFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun <S> createService(serviceClass: Class<S>): S {
|
fun <S> createService(serviceClass: Class<S>): S {
|
||||||
return retrofitBuilder.client(clientBuilder.build()).build().create(serviceClass)
|
var usedClient: OkHttpClient? = null
|
||||||
|
this.okHttpClient?.let { usedClient = it } ?: run {usedClient = clientBuilder.build()}
|
||||||
|
return retrofitBuilder.client(usedClient).build().create(serviceClass)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun normalizeBaseUrl() {
|
private fun normalizeBaseUrl() {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
APP_NAME=Lumen
|
||||||
APP_ENV=local
|
APP_ENV=local
|
||||||
APP_DEBUG=true
|
|
||||||
APP_KEY=
|
APP_KEY=
|
||||||
|
APP_DEBUG=true
|
||||||
|
APP_URL=http://localhost
|
||||||
APP_TIMEZONE=UTC
|
APP_TIMEZONE=UTC
|
||||||
|
|
||||||
LOG_CHANNEL=stack
|
LOG_CHANNEL=stack
|
||||||
@@ -14,4 +16,4 @@ DB_USERNAME=homestead
|
|||||||
DB_PASSWORD=secret
|
DB_PASSWORD=secret
|
||||||
|
|
||||||
CACHE_DRIVER=file
|
CACHE_DRIVER=file
|
||||||
QUEUE_DRIVER=sync
|
QUEUE_CONNECTION=sync
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
{{>licenseInfoLumen}}
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
{{>licenseInfoLumen}}
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use App\User;
|
use App\User;
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
{{>licenseInfoLumen}}
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
||||||
* https://openapi-generator.tech
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
{{>licenseInfoLumen}}
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
||||||
* https://openapi-generator.tech
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Laravel\Lumen\Routing\Controller as BaseController;
|
use Laravel\Lumen\Routing\Controller as BaseController;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
{{>licenseInfoLumen}}
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
class DatabaseSeeder extends Seeder
|
class DatabaseSeeder extends Seeder
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
{{>licenseInfoLumen}}
|
||||||
namespace App\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
{{>licenseInfoLumen}}
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use Laravel\Lumen\Providers\EventServiceProvider as ServiceProvider;
|
use Laravel\Lumen\Providers\EventServiceProvider as ServiceProvider;
|
||||||
@@ -12,8 +13,8 @@ class EventServiceProvider extends ServiceProvider
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $listen = [
|
protected $listen = [
|
||||||
'App\Events\ExampleEvent' => [
|
\App\Events\ExampleEvent::class => [
|
||||||
'App\Listeners\ExampleListener',
|
\App\Listeners\ExampleListener::class,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
{{>licenseInfoLumen}}
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
class ExampleController extends Controller
|
class ExampleController extends Controller
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
{{>licenseInfoLumen}}
|
||||||
namespace App\Events;
|
namespace App\Events;
|
||||||
|
|
||||||
class ExampleEvent extends Event
|
class ExampleEvent extends Event
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
{{>licenseInfoLumen}}
|
||||||
namespace App\Jobs;
|
namespace App\Jobs;
|
||||||
|
|
||||||
class ExampleJob extends Job
|
class ExampleJob extends Job
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
{{>licenseInfoLumen}}
|
||||||
namespace App\Listeners;
|
namespace App\Listeners;
|
||||||
|
|
||||||
use App\Events\ExampleEvent;
|
use App\Events\ExampleEvent;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
|
||||||
class ExampleListener
|
class ExampleListener
|
||||||
{
|
{
|
||||||
@@ -21,7 +22,7 @@ class ExampleListener
|
|||||||
/**
|
/**
|
||||||
* Handle the event.
|
* Handle the event.
|
||||||
*
|
*
|
||||||
* @param ExampleEvent $event
|
* @param \App\Events\ExampleEvent $event
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function handle(ExampleEvent $event)
|
public function handle(ExampleEvent $event)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
{{>licenseInfoLumen}}
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
{{>licenseInfoLumen}}
|
||||||
use Laravel\Lumen\Testing\DatabaseMigrations;
|
use Laravel\Lumen\Testing\DatabaseMigrations;
|
||||||
use Laravel\Lumen\Testing\DatabaseTransactions;
|
use Laravel\Lumen\Testing\DatabaseTransactions;
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
{{>licenseInfoLumen}}
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
||||||
* https://openapi-generator.tech
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Exceptions;
|
namespace App\Exceptions;
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use Illuminate\Validation\ValidationException;
|
|
||||||
use Illuminate\Auth\Access\AuthorizationException;
|
use Illuminate\Auth\Access\AuthorizationException;
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
use Illuminate\Validation\ValidationException;
|
||||||
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
|
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
class Handler extends ExceptionHandler
|
class Handler extends ExceptionHandler
|
||||||
{
|
{
|
||||||
@@ -34,23 +29,27 @@ class Handler extends ExceptionHandler
|
|||||||
*
|
*
|
||||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||||
*
|
*
|
||||||
* @param \Exception $e
|
* @param \Throwable $exception
|
||||||
* @return void
|
* @return void
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function report(Exception $e)
|
public function report(Throwable $exception)
|
||||||
{
|
{
|
||||||
parent::report($e);
|
parent::report($exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render an exception into an HTTP response.
|
* Render an exception into an HTTP response.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
* @param \Exception $e
|
* @param \Throwable $exception
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse
|
||||||
|
*
|
||||||
|
* @throws \Throwable
|
||||||
*/
|
*/
|
||||||
public function render($request, Exception $e)
|
public function render($request, Throwable $exception)
|
||||||
{
|
{
|
||||||
return parent::render($request, $e);
|
return parent::render($request, $exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
{{>licenseInfoLumen}}
|
||||||
namespace App\Jobs;
|
namespace App\Jobs;
|
||||||
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
abstract class Job implements ShouldQueue
|
abstract class Job implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
{{>licenseInfoLumen}}
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
||||||
* https://openapi-generator.tech
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Console;
|
namespace App\Console;
|
||||||
|
|
||||||
use Illuminate\Console\Scheduling\Schedule;
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
|
|||||||
@@ -1,17 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
{{>licenseInfoLumen}}
|
||||||
|
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||||
|
|
||||||
|
use App\User;
|
||||||
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Model Factories
|
| Model Factories
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| Here you may define all of your model factories. Model factories give
|
| This directory should contain each of the model factory definitions for
|
||||||
| you a convenient way to create models for testing and seeding your
|
| your application. Factories provide a convenient way to generate new
|
||||||
| database. Just tell the factory how a default model should look.
|
| model instances for testing / seeding your application's database.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$factory->define(App\User::class, function (Faker\Generator $faker) {
|
$factory->define(User::class, function (Faker $faker) {
|
||||||
return [
|
return [
|
||||||
'name' => $faker->name,
|
'name' => $faker->name,
|
||||||
'email' => $faker->email,
|
'email' => $faker->email,
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
abstract class TestCase extends Laravel\Lumen\Testing\TestCase
|
{{>licenseInfoLumen}}
|
||||||
|
use Laravel\Lumen\Testing\TestCase as BaseTestCase;
|
||||||
|
|
||||||
|
abstract class TestCase extends BaseTestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Creates the application.
|
* Creates the application.
|
||||||
|
|||||||
@@ -1,22 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
{{>licenseInfoLumen}}
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
||||||
* https://openapi-generator.tech
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App;
|
namespace App;
|
||||||
|
|
||||||
use Illuminate\Auth\Authenticatable;
|
use Illuminate\Auth\Authenticatable;
|
||||||
use Laravel\Lumen\Auth\Authorizable;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
|
||||||
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
|
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
|
||||||
|
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Laravel\Lumen\Auth\Authorizable;
|
||||||
|
|
||||||
class User extends Model implements
|
class User extends Model implements AuthenticatableContract, AuthorizableContract
|
||||||
AuthenticatableContract,
|
|
||||||
AuthorizableContract
|
|
||||||
{
|
{
|
||||||
use Authenticatable, Authorizable;
|
use Authenticatable, Authorizable;
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
{{>licenseInfoLumen}}
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
||||||
* https://openapi-generator.tech
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
|
|
||||||
require_once __DIR__.'/../vendor/autoload.php';
|
require_once __DIR__.'/../vendor/autoload.php';
|
||||||
|
|
||||||
try {
|
(new Laravel\Lumen\Bootstrap\LoadEnvironmentVariables(
|
||||||
(new Dotenv\Dotenv(__DIR__.'/../'))->load();
|
dirname(__DIR__)
|
||||||
} catch (Dotenv\Exception\InvalidPathException $e) {
|
))->bootstrap();
|
||||||
//
|
|
||||||
}
|
date_default_timezone_set(env('APP_TIMEZONE', 'UTC'));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@@ -26,7 +21,7 @@ try {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$app = new Laravel\Lumen\Application(
|
$app = new Laravel\Lumen\Application(
|
||||||
realpath(__DIR__.'/../')
|
dirname(__DIR__)
|
||||||
);
|
);
|
||||||
|
|
||||||
// $app->withFacades();
|
// $app->withFacades();
|
||||||
@@ -54,6 +49,19 @@ $app->singleton(
|
|||||||
App\Console\Kernel::class
|
App\Console\Kernel::class
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Register Config Files
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Now we will register the "app" configuration file. If the file exists in
|
||||||
|
| your configuration directory it will be loaded; otherwise, we'll load
|
||||||
|
| the default version. You may register other files below as needed.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$app->configure('app');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Register Middleware
|
| Register Middleware
|
||||||
@@ -66,7 +74,7 @@ $app->singleton(
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// $app->middleware([
|
// $app->middleware([
|
||||||
// App\Http\Middleware\ExampleMiddleware::class
|
// App\Http\Middleware\ExampleMiddleware::class
|
||||||
// ]);
|
// ]);
|
||||||
|
|
||||||
// $app->routeMiddleware([
|
// $app->routeMiddleware([
|
||||||
@@ -105,6 +113,4 @@ $app->router->group([
|
|||||||
require __DIR__.'/../routes/web.php';
|
require __DIR__.'/../routes/web.php';
|
||||||
});
|
});
|
||||||
|
|
||||||
$app->withFacades();
|
|
||||||
|
|
||||||
return $app;
|
return $app;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env php
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
{{>licenseInfoLumen}}
|
||||||
use Symfony\Component\Console\Input\ArgvInput;
|
use Symfony\Component\Console\Input\ArgvInput;
|
||||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||||
|
|
||||||
|
|||||||
@@ -24,29 +24,26 @@
|
|||||||
],
|
],
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.1.3",
|
"php": "^7.2.5",
|
||||||
"laravel/lumen-framework": "5.6.*",
|
"laravel/lumen-framework": "^7.2"
|
||||||
"vlucas/phpdotenv": "~2.2"
|
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"fzaninotto/faker": "~1.4",
|
"fzaninotto/faker": "^1.9",
|
||||||
"phpunit/phpunit": "~7.0",
|
"mockery/mockery": "^1.3",
|
||||||
"mockery/mockery": "~1.0"
|
"phpunit/phpunit": "^8.0 || ^9.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
"classmap": [
|
||||||
|
"database/seeds",
|
||||||
|
"database/factories"
|
||||||
|
],
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"App\\": "app/"
|
"App\\": "app/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"classmap": [
|
"classmap": [
|
||||||
"tests/",
|
"tests/"
|
||||||
"database/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"post-root-package-install": [
|
|
||||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
@@ -55,5 +52,10 @@
|
|||||||
"optimize-autoloader": true
|
"optimize-autoloader": true
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"prefer-stable": true
|
"prefer-stable": true,
|
||||||
|
"scripts": {
|
||||||
|
"post-root-package-install": [
|
||||||
|
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[*.{yml,yaml}]
|
||||||
|
indent_size = 2
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore
|
/vendor
|
||||||
|
/.idea
|
||||||
composer.phar
|
Homestead.json
|
||||||
/vendor/
|
Homestead.yaml
|
||||||
|
.env
|
||||||
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
|
.phpunit.result.cache
|
||||||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
|
|
||||||
# composer.lock
|
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
{{>licenseInfoLumen}}
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
||||||
* https://openapi-generator.tech
|
|
||||||
* Do not edit the class manually.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Create The Application
|
| Create The Application
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* {{{appName}}}
|
* {{{appName}}}
|
||||||
* {{{appDescription}}}
|
* {{{appDescription}}}
|
||||||
* PHP version 7.1.3
|
* PHP version 7.2.5
|
||||||
*
|
*
|
||||||
* {{#version}}The version of the OpenAPI document: {{{version}}}{{/version}}
|
* {{#version}}The version of the OpenAPI document: {{{version}}}{{/version}}
|
||||||
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
|
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
|
||||||
|
|||||||
3
modules/openapi-generator/src/main/resources/php-lumen/licenseInfoLumen.mustache
vendored
Normal file
3
modules/openapi-generator/src/main/resources/php-lumen/licenseInfoLumen.mustache
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
/**
|
||||||
|
* The Lumen framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||||
|
*/
|
||||||
@@ -1,14 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<phpunit backupGlobals="false"
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
backupStaticAttributes="false"
|
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
|
||||||
bootstrap="bootstrap/app.php"
|
bootstrap="vendor/autoload.php"
|
||||||
colors="true"
|
colors="true">
|
||||||
convertErrorsToExceptions="true"
|
|
||||||
convertNoticesToExceptions="true"
|
|
||||||
convertWarningsToExceptions="true"
|
|
||||||
processIsolation="false"
|
|
||||||
stopOnFailure="false"
|
|
||||||
syntaxCheck="false">
|
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="Application Test Suite">
|
<testsuite name="Application Test Suite">
|
||||||
<directory suffix="Test.php">./tests</directory>
|
<directory suffix="Test.php">./tests</directory>
|
||||||
@@ -20,9 +14,8 @@
|
|||||||
</whitelist>
|
</whitelist>
|
||||||
</filter>
|
</filter>
|
||||||
<php>
|
<php>
|
||||||
<ini name="error_reporting" value="E_ALL" />
|
|
||||||
<env name="APP_ENV" value="testing"/>
|
<env name="APP_ENV" value="testing"/>
|
||||||
<env name="CACHE_DRIVER" value="array"/>
|
<env name="CACHE_DRIVER" value="array"/>
|
||||||
<env name="QUEUE_DRIVER" value="sync"/>
|
<env name="QUEUE_CONNECTION" value="sync"/>
|
||||||
</php>
|
</php>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# OpenAPITools generated server
|
# OpenAPITools generated server
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
* PHP 7.1.3 or newer
|
* PHP 7.2.5 or newer
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the
|
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the
|
||||||
@@ -18,9 +18,15 @@ This example uses the [Lumen Framework](http://lumen.laravel.com/). To see how
|
|||||||
Switch to the generated Lumen server stub directory.
|
Switch to the generated Lumen server stub directory.
|
||||||
Using `composer update` to install the framework and dependencies via [Composer](http://getcomposer.org/).
|
Using `composer update` to install the framework and dependencies via [Composer](http://getcomposer.org/).
|
||||||
|
|
||||||
|
### Init App Config
|
||||||
|
Use `.env.example` as starting point for a new application config:
|
||||||
|
```console
|
||||||
|
$ composer run post-root-package-install
|
||||||
|
```
|
||||||
|
|
||||||
## Note
|
## Note
|
||||||
|
|
||||||
The `composer update` should be the first thing to do right after generating Lumen server stub. The autoload.php will be generated only after excuting `composer update`.
|
The `composer update` should be the first thing to do right after generating Lumen server stub. The autoload.php will be generated only after executing `composer update`.
|
||||||
Or there would be errors during service or model migration.
|
Or there would be errors during service or model migration.
|
||||||
|
|
||||||
### Running the generated server stub
|
### Running the generated server stub
|
||||||
|
|||||||
@@ -1,11 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
{{>licenseInfo}}
|
{{>licenseInfo}}
|
||||||
|
{{>licenseInfoLumen}}
|
||||||
{{#apiInfo}}/**
|
{{#apiInfo}}/**
|
||||||
* {{appName}}
|
* {{appName}}
|
||||||
* @version {{appVersion}}
|
* @version {{appVersion}}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Routes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here is where you can register all of the routes for an application.
|
||||||
|
| It is a breeze. Simply tell Lumen the URIs it should respond to
|
||||||
|
| and give it the Closure to call when that URI is requested.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
$router->get('/', function () use ($router) {
|
$router->get('/', function () use ($router) {
|
||||||
return $router->app->version();
|
return $router->app->version();
|
||||||
});
|
});
|
||||||
@@ -19,8 +31,8 @@ $router->get('/', function () use ($router) {
|
|||||||
* Notes: {{notes}}
|
* Notes: {{notes}}
|
||||||
*/
|
*/
|
||||||
$router->{{httpMethod}}('{{{basePathWithoutHost}}}{{{path}}}', '{{classname}}@{{operationId}}');
|
$router->{{httpMethod}}('{{{basePathWithoutHost}}}{{{path}}}', '{{classname}}@{{operationId}}');
|
||||||
|
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
{{/apis}}
|
{{/apis}}
|
||||||
{{/apiInfo}}
|
{{/apiInfo}}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user