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.
|
||||
-->
|
||||
|
||||
##### 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
|
||||
|
||||
|
||||
3
.github/PULL_REQUEST_TEMPLATE.md
vendored
3
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -2,8 +2,9 @@
|
||||
|
||||
<!-- Please check the completed items below -->
|
||||
### PR checklist
|
||||
|
||||
|
||||
- [ ] 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.
|
||||
- [ ] 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`
|
||||
|
||||
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-tornado/.venv/
|
||||
|
||||
# PHP
|
||||
samples/server/petstore/php-lumen/lib/composer.lock
|
||||
|
||||
# ts
|
||||
samples/client/petstore/typescript-angular2/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 run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore
|
||||
- docker ps -a
|
||||
# -- skip bash test to shorten build time
|
||||
# Add bats test framework and cURL for Bash script integration tests
|
||||
- sudo add-apt-repository ppa:duggan/bats --yes
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq bats
|
||||
- sudo apt-get install -qq curl
|
||||
#- sudo add-apt-repository ppa:duggan/bats --yes
|
||||
#- sudo apt-get update -qq
|
||||
#- sudo apt-get install -qq bats
|
||||
#- sudo apt-get install -qq curl
|
||||
# -- skip bash test end
|
||||
# install dart
|
||||
#- sudo apt-get update
|
||||
#- sudo apt-get install apt-transport-https
|
||||
@@ -93,9 +95,6 @@ before_install:
|
||||
- phpenv versions
|
||||
- phpenv global 7.2.15
|
||||
- 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
|
||||
# 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).
|
||||
@@ -107,9 +106,11 @@ before_install:
|
||||
# install Qt5
|
||||
- sudo apt install -y --no-install-recommends qt5-default
|
||||
- cmake --version
|
||||
# -- skip perl test to shorten build time
|
||||
# perl dep
|
||||
- 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 --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"
|
||||
# -- skip perl test end
|
||||
# show host table to confirm petstore.swagger.io is mapped to localhost
|
||||
- cat /etc/hosts
|
||||
# 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.
|
||||
- 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
|
||||
# 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:
|
||||
# push to maven repo
|
||||
- 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)
|
||||
- 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.
|
||||
- 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:
|
||||
|
||||
- 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
|
||||
ree/master/samples). For Windows, please install [GIT bash](https://gitforwindows.org/). (If you find that there are new files g
|
||||
/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
|
||||
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)
|
||||
- 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://cloud.drone.io/OpenAPITools/openapi-generator)
|
||||
[](https://app.bitrise.io/app/4a2b10a819d12b67)
|
||||

|
||||
|
||||
</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-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-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)
|
||||
|
||||
|
||||
@@ -15,14 +15,14 @@ install:
|
||||
# install gradle
|
||||
- ps: |
|
||||
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(
|
||||
'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'
|
||||
)
|
||||
[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 JAVA_OPTS=-Xmx4g
|
||||
- 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:
|
||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
||||
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
|
||||
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
|
||||
|
||||
@@ -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)
|
||||
- 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.
|
||||
- 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:
|
||||
|
||||
- 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
|
||||
ree/master/samples). For Windows, please install [GIT bash](https://gitforwindows.org/). (If you find that there are new files g
|
||||
/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
|
||||
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)
|
||||
- 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|
|
||||
|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|
|
||||
|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|
|
||||
|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|
|
||||
|
||||
@@ -5,6 +5,7 @@ sidebar_label: go-server
|
||||
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|enumClassPrefix|Prefix enum with class name| |false|
|
||||
|featureCORS|Enable Cross-Origin Resource Sharing middleware| |false|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||
|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|
|
||||
|useRxJava|Whether to use the RxJava 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
|
||||
|
||||
|
||||
@@ -61,6 +61,35 @@ task validateBadSpec(type: org.openapitools.generator.gradle.plugin.tasks.Valida
|
||||
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
|
||||
|
||||
//# RELEASE_VERSION
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#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
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
# 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.
|
||||
|
||||
```bash
|
||||
gradle openApiGenerate
|
||||
gradle openApiMeta
|
||||
gradle openApiValidate
|
||||
gradle buildGoSdk
|
||||
gradle buildDotnetSdk
|
||||
gradle generateGoWithInvalidSpec
|
||||
gradle openApiGenerate # expected outcome: BUILD SCCESSFUL
|
||||
gradle openApiMeta # expected outcome: BUILD SCCESSFUL
|
||||
gradle openApiValidate # expected outcome: BUILD FAILED
|
||||
gradle buildGoSdk # expected outcome: BUILD SCCESSFUL
|
||||
gradle buildDotnetSdk # expected outcome: BUILD SCCESSFUL
|
||||
gradle generateGoWithInvalidSpec # expected outcome: BUILD FAILED
|
||||
```
|
||||
|
||||
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(
|
||||
"openApiGenerators",
|
||||
OpenApiGeneratorGeneratorsExtension::class.java,
|
||||
project
|
||||
"openApiGenerators",
|
||||
OpenApiGeneratorGeneratorsExtension::class.java,
|
||||
project
|
||||
)
|
||||
|
||||
generate.outputDir.set("$buildDir/generate-resources/main")
|
||||
|
||||
@@ -317,7 +317,7 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
|
||||
}
|
||||
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
fun applyDefaults(){
|
||||
fun applyDefaults() {
|
||||
releaseNote.set("Minor update")
|
||||
modelNamePrefix.set("")
|
||||
modelNameSuffix.set("")
|
||||
|
||||
@@ -19,7 +19,14 @@ package org.openapitools.generator.gradle.plugin.tasks
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.GradleException
|
||||
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.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.options.Option
|
||||
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.GlobalSettings
|
||||
|
||||
|
||||
/**
|
||||
* A task which generates the desired code.
|
||||
*
|
||||
@@ -43,63 +49,73 @@ import org.openapitools.codegen.config.GlobalSettings
|
||||
* @author Jim Schubert
|
||||
*/
|
||||
@Suppress("UnstableApiUsage")
|
||||
@CacheableTask
|
||||
open class GenerateTask : DefaultTask() {
|
||||
|
||||
/**
|
||||
* The verbosity of generation
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val verbose = project.objects.property<Boolean>()
|
||||
|
||||
/**
|
||||
* Whether or not an input specification should be validated upon generation.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val validateSpec = project.objects.property<Boolean>()
|
||||
|
||||
/**
|
||||
* The name of the generator which will handle codegen. (see "openApiGenerators" task)
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val generatorName = project.objects.property<String>()
|
||||
|
||||
/**
|
||||
* The output target directory into which code will be generated.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@get:OutputDirectory
|
||||
val outputDir = project.objects.property<String>()
|
||||
|
||||
@Suppress("unused")
|
||||
@get:Internal
|
||||
@set:Option(option = "input", description = "The input specification.")
|
||||
@Input
|
||||
var input: String? = null
|
||||
set(value) {
|
||||
inputSpec.set(value)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The Open API 2.0/3.x specification location.
|
||||
*/
|
||||
@get:Internal
|
||||
@get:InputFile
|
||||
@PathSensitive(PathSensitivity.RELATIVE)
|
||||
val inputSpec = project.objects.property<String>()
|
||||
|
||||
/**
|
||||
* The template directory holding a custom template.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val templateDir = project.objects.property<String?>()
|
||||
|
||||
/**
|
||||
* Adds authorization headers when fetching the OpenAPI definitions remotely.
|
||||
* 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>()
|
||||
|
||||
/**
|
||||
* Sets specified global properties.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
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"...}
|
||||
* 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>()
|
||||
|
||||
/**
|
||||
* Specifies if the existing files should be overwritten during the generation.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val skipOverwrite = project.objects.property<Boolean?>()
|
||||
|
||||
/**
|
||||
* Package for generated classes (where supported)
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val packageName = project.objects.property<String>()
|
||||
|
||||
/**
|
||||
* Package for generated api classes
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val apiPackage = project.objects.property<String>()
|
||||
|
||||
/**
|
||||
* Package for generated models
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val modelPackage = project.objects.property<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>()
|
||||
|
||||
/**
|
||||
* Suffix that will be appended to all model names. Default is the empty string.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val modelNameSuffix = project.objects.property<String>()
|
||||
|
||||
/**
|
||||
* Sets instantiation type mappings.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val instantiationTypes = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* Sets mappings between OpenAPI spec types and generated code types.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
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.
|
||||
* You can also have multiple occurrences of this option.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val additionalProperties = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
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.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val languageSpecificPrimitives = project.objects.listProperty<String>()
|
||||
|
||||
/**
|
||||
* 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>()
|
||||
|
||||
/**
|
||||
* Root package for generated code.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
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.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
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.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
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.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val version = project.objects.property<String>()
|
||||
|
||||
/**
|
||||
* Reference the library template (sub-template) of a generator.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val library = project.objects.property<String?>()
|
||||
|
||||
/**
|
||||
* Git host, e.g. gitlab.com.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val gitHost = project.objects.property<String?>()
|
||||
|
||||
/**
|
||||
* Git user ID, e.g. openapitools.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val gitUserId = project.objects.property<String?>()
|
||||
|
||||
/**
|
||||
* Git repo ID, e.g. openapi-generator.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val gitRepoId = project.objects.property<String?>()
|
||||
|
||||
/**
|
||||
* Release note, default to 'Minor update'.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val releaseNote = project.objects.property<String?>()
|
||||
|
||||
/**
|
||||
* 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?>()
|
||||
|
||||
/**
|
||||
* Specifies how a reserved name should be escaped to.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val reservedWordsMappings = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* 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?>()
|
||||
|
||||
/**
|
||||
* Remove prefix of operationId, e.g. config_getId => getId
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
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.
|
||||
* 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>()
|
||||
|
||||
/**
|
||||
@@ -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.
|
||||
* 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>()
|
||||
|
||||
/**
|
||||
@@ -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.
|
||||
* 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>()
|
||||
|
||||
/**
|
||||
@@ -305,7 +350,8 @@ open class GenerateTask : DefaultTask() {
|
||||
* For more control over generation of individual files, configure an ignore file and
|
||||
* refer to it via [ignoreFileOverride].
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
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
|
||||
* refer to it via [ignoreFileOverride].
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
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
|
||||
* refer to it via [ignoreFileOverride].
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
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
|
||||
* refer to it via [ignoreFileOverride].
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val generateApiDocumentation = project.objects.property<Boolean>()
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val withXml = project.objects.property<Boolean>()
|
||||
|
||||
|
||||
/**
|
||||
* To write all log messages (not just errors) to STDOUT
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
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
|
||||
* generator does not support this functionality.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val enablePostProcessFile = project.objects.property<Boolean>()
|
||||
|
||||
/**
|
||||
* 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>()
|
||||
|
||||
/**
|
||||
@@ -375,19 +427,22 @@ open class GenerateTask : DefaultTask() {
|
||||
* 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.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val generateAliasAsModel = project.objects.property<Boolean>()
|
||||
|
||||
/**
|
||||
* A dynamic map of options specific to a generator.
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val configOptions = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* Templating engine: "mustache" (default) or "handlebars" (beta)
|
||||
*/
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
val engine = project.objects.property<String?>()
|
||||
|
||||
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 org.gradle.api.DefaultTask
|
||||
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.internal.logging.text.StyledTextOutput
|
||||
import org.gradle.internal.logging.text.StyledTextOutputFactory
|
||||
import org.gradle.kotlin.dsl.property
|
||||
import org.openapitools.codegen.*
|
||||
import org.openapitools.codegen.api.TemplatePathLocator
|
||||
import org.openapitools.codegen.CodegenConfig
|
||||
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.GeneratorTemplateContentLocator
|
||||
import org.openapitools.codegen.templating.MustacheEngineAdapter
|
||||
import org.openapitools.codegen.templating.TemplateManagerOptions
|
||||
import java.io.File
|
||||
@@ -39,15 +42,16 @@ import java.nio.charset.Charset
|
||||
*
|
||||
* @author Jim Schubert
|
||||
*/
|
||||
@CacheableTask
|
||||
open class MetaTask : DefaultTask() {
|
||||
|
||||
@get:Internal
|
||||
@get:Input
|
||||
val generatorName = project.objects.property<String>()
|
||||
|
||||
@get:Internal
|
||||
@get:Input
|
||||
val packageName = project.objects.property<String>()
|
||||
|
||||
@get:Internal
|
||||
@get:OutputDirectory
|
||||
val outputFolder = project.objects.property<String>()
|
||||
|
||||
@Suppress("unused")
|
||||
@@ -92,9 +96,9 @@ open class MetaTask : DefaultTask() {
|
||||
val outputFile = File(destinationFolder, it.destinationFilename)
|
||||
|
||||
val templateProcessor = TemplateManager(
|
||||
TemplateManagerOptions(false, false),
|
||||
MustacheEngineAdapter(),
|
||||
arrayOf(CommonTemplateContentLocator("codegen"))
|
||||
TemplateManagerOptions(false, false),
|
||||
MustacheEngineAdapter(),
|
||||
arrayOf(CommonTemplateContentLocator("codegen"))
|
||||
)
|
||||
|
||||
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.GradleException
|
||||
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.Optional
|
||||
import org.gradle.api.tasks.PathSensitive
|
||||
import org.gradle.api.tasks.PathSensitivity
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.api.tasks.options.Option
|
||||
import org.gradle.internal.logging.text.StyledTextOutput
|
||||
@@ -49,10 +54,12 @@ import org.openapitools.codegen.validations.oas.RuleConfiguration
|
||||
* @author Jim Schubert
|
||||
*/
|
||||
open class ValidateTask : DefaultTask() {
|
||||
@get:Internal
|
||||
@get:InputFile
|
||||
@PathSensitive(PathSensitivity.RELATIVE)
|
||||
var inputSpec = project.objects.property<String>()
|
||||
|
||||
@get:Internal
|
||||
@Optional
|
||||
@Input
|
||||
var recommend = project.objects.property<Boolean?>()
|
||||
|
||||
@Suppress("unused")
|
||||
@@ -75,12 +82,11 @@ open class ValidateTask : DefaultTask() {
|
||||
|
||||
val options = ParseOptions()
|
||||
options.isResolve = true
|
||||
|
||||
|
||||
val result = OpenAPIParser().readLocation(spec, null, options)
|
||||
val messages = result.messages.toSet()
|
||||
val out = services.get(StyledTextOutputFactory::class.java).create("openapi")
|
||||
|
||||
|
||||
val ruleConfiguration = RuleConfiguration()
|
||||
ruleConfiguration.isEnableRecommendations = recommendations
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.io.File
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class GenerateTaskDslTest : TestBase() {
|
||||
class GenerateTaskDslTest : TestBase() {
|
||||
override var temp: File = createTempDir(javaClass.simpleName)
|
||||
|
||||
private val defaultBuildGradle = """
|
||||
@@ -46,18 +46,18 @@ class GenerateTaskDslTest : TestBase() {
|
||||
assertTrue(result.output.contains("Successfully generated code to"), "User friendly generate notice is missing.")
|
||||
|
||||
listOf(
|
||||
"build/kotlin/.openapi-generator-ignore",
|
||||
"build/kotlin/docs/PetsApi.md",
|
||||
"build/kotlin/docs/Error.md",
|
||||
"build/kotlin/docs/Pet.md",
|
||||
"build/kotlin/README.md",
|
||||
"build/kotlin/build.gradle",
|
||||
"build/kotlin/.openapi-generator/VERSION",
|
||||
"build/kotlin/settings.gradle",
|
||||
"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/api/PetsApi.kt",
|
||||
"build/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt"
|
||||
"build/kotlin/.openapi-generator-ignore",
|
||||
"build/kotlin/docs/PetsApi.md",
|
||||
"build/kotlin/docs/Error.md",
|
||||
"build/kotlin/docs/Pet.md",
|
||||
"build/kotlin/README.md",
|
||||
"build/kotlin/build.gradle",
|
||||
"build/kotlin/.openapi-generator/VERSION",
|
||||
"build/kotlin/settings.gradle",
|
||||
"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/api/PetsApi.kt",
|
||||
"build/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt"
|
||||
).map {
|
||||
val f = File(temp, it)
|
||||
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}")
|
||||
}
|
||||
|
||||
@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
|
||||
fun `openApiValidate should fail on invalid spec`() {
|
||||
// Arrange
|
||||
@@ -128,10 +183,10 @@ class GenerateTaskDslTest : TestBase() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `openapiGenerate should attempt to set handlebars when specified as engine`(){
|
||||
fun `openapiGenerate should attempt to set handlebars when specified as engine`() {
|
||||
// Arrange
|
||||
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("""
|
||||
@@ -151,16 +206,16 @@ class GenerateTaskDslTest : TestBase() {
|
||||
|
||||
// Act
|
||||
val result = GradleRunner.create()
|
||||
.withProjectDir(temp)
|
||||
.withArguments("openApiGenerate", "--stacktrace")
|
||||
.withPluginClasspath()
|
||||
.buildAndFail()
|
||||
.withProjectDir(temp)
|
||||
.withArguments("openApiGenerate", "--stacktrace")
|
||||
.withPluginClasspath()
|
||||
.buildAndFail()
|
||||
|
||||
// Assert
|
||||
// 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("handlebars"), "Build should have attempted to use handlebars.")
|
||||
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>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<spring-boot-version>2.0.7.RELEASE</spring-boot-version>
|
||||
<springfox-version>2.8.0</springfox-version>
|
||||
<spring-boot-version>2.2.9.RELEASE</spring-boot-version>
|
||||
<springfox-version>3.0.0</springfox-version>
|
||||
<junit-version>4.13</junit-version>
|
||||
<jackson-version>2.10.2</jackson-version>
|
||||
</properties>
|
||||
@@ -105,13 +105,17 @@
|
||||
<version>${springfox-version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
</exclusion>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-models</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
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.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)
|
||||
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}";
|
||||
|
||||
@Autowired
|
||||
@@ -43,7 +43,7 @@ public class GenApiControllerTest {
|
||||
public void getLanguages(String type, String expected) throws Exception {
|
||||
mockMvc.perform(get("/api/gen/" + type))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath("$.[*]").value(hasItem(expected)));
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class GenApiControllerTest {
|
||||
private void getOptions(String type, String name) throws Exception {
|
||||
mockMvc.perform(get("/api/gen/" + type + "/" + name))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath("$.sortParamsByRequiredFlag.opt").value("sortParamsByRequiredFlag"));
|
||||
}
|
||||
|
||||
@@ -88,10 +88,10 @@ public class GenApiControllerTest {
|
||||
|
||||
private void generateAndDownload(String type, String name) throws Exception {
|
||||
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 + "\"}"))
|
||||
.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("$.link").value(matchesPattern("http\\:\\/\\/test.com\\:1234\\/api\\/gen\\/download\\/" + UUID_REGEX)))
|
||||
.andReturn().getResponse().getContentAsString();
|
||||
@@ -107,13 +107,13 @@ public class GenApiControllerTest {
|
||||
@Test
|
||||
public void generateWIthForwardedHeaders() throws Exception {
|
||||
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-Host", "forwarded.com")
|
||||
.header("X-Forwarded-Port", "5678")
|
||||
.content("{\"openAPIUrl\": \"" + OPENAPI_URL + "\"}"))
|
||||
.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("$.link").value(matchesPattern("https\\:\\/\\/forwarded.com\\:5678\\/api\\/gen\\/download\\/" + UUID_REGEX)))
|
||||
.andReturn().getResponse().getContentAsString();
|
||||
|
||||
@@ -5653,8 +5653,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
LOGGER.debug("debugging fromRequestBodyToFormParameters= " + body);
|
||||
Schema schema = ModelUtils.getSchemaFromRequestBody(body);
|
||||
schema = ModelUtils.getReferencedSchema(this.openAPI, schema);
|
||||
if (schema.getProperties() != null && !schema.getProperties().isEmpty()) {
|
||||
Map<String, Schema> properties = schema.getProperties();
|
||||
List<String> allRequired = new ArrayList<String>();
|
||||
Map<String, Schema> properties = new LinkedHashMap<>();
|
||||
addProperties(properties, allRequired, schema);
|
||||
|
||||
if (!properties.isEmpty()) {
|
||||
for (Map.Entry<String, Schema> entry : properties.entrySet()) {
|
||||
CodegenParameter codegenParameter = CodegenModelFactory.newInstance(CodegenModelType.PARAMETER);
|
||||
// key => property name
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
|
||||
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.oas.models.*;
|
||||
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.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponses;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -36,6 +41,17 @@ public class InlineModelResolver {
|
||||
private OpenAPI openapi;
|
||||
private Map<String, Schema> addedModels = new HashMap<String, Schema>();
|
||||
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);
|
||||
|
||||
void flatten(OpenAPI openapi) {
|
||||
@@ -488,15 +504,25 @@ public class InlineModelResolver {
|
||||
}
|
||||
|
||||
private String matchGenerated(Schema model) {
|
||||
String json = Json.pretty(model);
|
||||
if (generatedSignature.containsKey(json)) {
|
||||
return generatedSignature.get(json);
|
||||
try {
|
||||
String json = structureMapper.writeValueAsString(model);
|
||||
if (generatedSignature.containsKey(json)) {
|
||||
return generatedSignature.get(json);
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
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();
|
||||
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();
|
||||
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.setExample(example);
|
||||
model.setName(object.getName());
|
||||
model.setXml(xml);
|
||||
model.setRequired(object.getRequired());
|
||||
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) {
|
||||
flattenProperties(openAPI, properties, path);
|
||||
model.setProperties(properties);
|
||||
|
||||
@@ -798,7 +798,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
Schema<?> items = getSchemaItems((ArraySchema) schema);
|
||||
|
||||
String typeDeclaration = getTypeDeclaration(items);
|
||||
String typeDeclaration = getTypeDeclaration(ModelUtils.unaliasSchema(this.openAPI, items));
|
||||
Object java8obj = additionalProperties.get("java8");
|
||||
if (java8obj != null) {
|
||||
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 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 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 boolean generateBody = true;
|
||||
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.");
|
||||
}
|
||||
|
||||
String regex = pattern.substring(1, i).replace("'", "\'");
|
||||
String regex = pattern.substring(1, i).replace("'", "\'").replace("\"", "\"\"");
|
||||
List<String> modifiers = new ArrayList<String>();
|
||||
|
||||
// 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)) {
|
||||
setWithGoCodegenComment(Boolean.parseBoolean(additionalProperties.get(WITH_GO_CODEGEN_COMMENT).toString()));
|
||||
if (withGoCodegenComment) {
|
||||
additionalProperties.put(WITH_GO_CODEGEN_COMMENT, "true");
|
||||
}
|
||||
additionalProperties.put(WITH_GO_CODEGEN_COMMENT, withGoCodegenComment);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(WITH_AWSV4_SIGNATURE)) {
|
||||
setWithAWSV4Signature(Boolean.parseBoolean(additionalProperties.get(WITH_AWSV4_SIGNATURE).toString()));
|
||||
if (withAWSV4Signature) {
|
||||
additionalProperties.put(WITH_AWSV4_SIGNATURE, "true");
|
||||
}
|
||||
additionalProperties.put(WITH_AWSV4_SIGNATURE, withAWSV4Signature);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(WITH_XML)) {
|
||||
setWithXml(Boolean.parseBoolean(additionalProperties.get(WITH_XML).toString()));
|
||||
if (withXml) {
|
||||
additionalProperties.put(WITH_XML, "true");
|
||||
}
|
||||
additionalProperties.put(WITH_XML, withXml);
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
additionalProperties.put(CodegenConstants.ENUM_CLASS_PREFIX, enumClassPrefix);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.IS_GO_SUBMODULE)) {
|
||||
setIsGoSubmodule(Boolean.parseBoolean(additionalProperties.get(CodegenConstants.IS_GO_SUBMODULE).toString()));
|
||||
if (isGoSubmodule) {
|
||||
additionalProperties.put(CodegenConstants.IS_GO_SUBMODULE, "true");
|
||||
}
|
||||
additionalProperties.put(CodegenConstants.IS_GO_SUBMODULE, isGoSubmodule);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(STRUCT_PREFIX)) {
|
||||
setStructPrefix(Boolean.parseBoolean(additionalProperties.get(STRUCT_PREFIX).toString()));
|
||||
if (structPrefix) {
|
||||
additionalProperties.put(STRUCT_PREFIX, "true");
|
||||
}
|
||||
additionalProperties.put(STRUCT_PREFIX, structPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,12 +17,7 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import org.openapitools.codegen.CliOption;
|
||||
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.*;
|
||||
import org.openapitools.codegen.meta.features.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -83,6 +78,8 @@ public class GoServerCodegen extends AbstractGoCodegen {
|
||||
optFeatureCORS.defaultValue(corsFeatureEnabled.toString());
|
||||
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.
|
||||
* 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.
|
||||
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.
|
||||
*/
|
||||
apiTemplateFiles.put(
|
||||
@@ -166,13 +163,11 @@ public class GoServerCodegen extends AbstractGoCodegen {
|
||||
|
||||
if (additionalProperties.containsKey("serverPort") && additionalProperties.get("serverPort") instanceof Integer) {
|
||||
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 {
|
||||
this.setServerPort(Integer.parseInt(additionalProperties.get("serverPort").toString()));
|
||||
additionalProperties.put("serverPort", serverPort);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
} catch (NumberFormatException e) {
|
||||
LOGGER.warn("serverPort is not a valid integer... defaulting to {}", serverPort);
|
||||
additionalProperties.put("serverPort", serverPort);
|
||||
}
|
||||
@@ -185,6 +180,13 @@ public class GoServerCodegen extends AbstractGoCodegen {
|
||||
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;
|
||||
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_JAVA2 = "useRxJava2";
|
||||
public static final String USE_RX_JAVA3 = "useRxJava3";
|
||||
public static final String USE_COROUTINES = "useCoroutines";
|
||||
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 boolean useRxJava = false;
|
||||
protected boolean useRxJava2 = false;
|
||||
protected boolean useRxJava3 = false;
|
||||
protected boolean useCoroutines = false;
|
||||
// backwards compatibility for openapi configs that specify neither rx1 nor rx2
|
||||
// (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_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."));
|
||||
}
|
||||
|
||||
@@ -216,6 +219,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
public void setUseRxJava(boolean useRxJava) {
|
||||
if (useRxJava) {
|
||||
this.useRxJava2 = false;
|
||||
this.useRxJava3 = false;
|
||||
this.doNotUseRxAndCoroutines = false;
|
||||
this.useCoroutines = false;
|
||||
}
|
||||
@@ -225,16 +229,28 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
public void setUseRxJava2(boolean useRxJava2) {
|
||||
if (useRxJava2) {
|
||||
this.useRxJava = false;
|
||||
this.useRxJava3 = false;
|
||||
this.doNotUseRxAndCoroutines = false;
|
||||
this.useCoroutines = false;
|
||||
}
|
||||
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) {
|
||||
if (doNotUseRxAndCoroutines) {
|
||||
this.useRxJava = false;
|
||||
this.useRxJava2 = false;
|
||||
this.useRxJava3 = false;
|
||||
this.useCoroutines = false;
|
||||
}
|
||||
this.doNotUseRxAndCoroutines = doNotUseRxAndCoroutines;
|
||||
@@ -244,6 +260,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
if (useCoroutines) {
|
||||
this.useRxJava = false;
|
||||
this.useRxJava2 = false;
|
||||
this.useRxJava3 = false;
|
||||
this.doNotUseRxAndCoroutines = false;
|
||||
}
|
||||
this.useCoroutines = useCoroutines;
|
||||
@@ -273,6 +290,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
|
||||
boolean hasRx = additionalProperties.containsKey(USE_RX_JAVA);
|
||||
boolean hasRx2 = additionalProperties.containsKey(USE_RX_JAVA2);
|
||||
boolean hasRx3 = additionalProperties.containsKey(USE_RX_JAVA3);
|
||||
boolean hasCoroutines = additionalProperties.containsKey(USE_COROUTINES);
|
||||
int optionCount = 0;
|
||||
if (hasRx) {
|
||||
@@ -281,6 +299,9 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
if (hasRx2) {
|
||||
optionCount++;
|
||||
}
|
||||
if (hasRx3) {
|
||||
optionCount++;
|
||||
}
|
||||
if (hasCoroutines) {
|
||||
optionCount++;
|
||||
}
|
||||
@@ -288,16 +309,18 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
|
||||
// RxJava & Coroutines
|
||||
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) {
|
||||
this.setUseRxJava(Boolean.valueOf(additionalProperties.get(USE_RX_JAVA).toString()));
|
||||
} else if (hasRx2) {
|
||||
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) {
|
||||
this.setUseCoroutines(Boolean.valueOf(additionalProperties.get(USE_COROUTINES).toString()));
|
||||
}
|
||||
|
||||
if (!hasRx && !hasRx2 && !hasCoroutines) {
|
||||
if (!hasRx && !hasRx2 && !hasRx3 && !hasCoroutines) {
|
||||
setDoNotUseRxAndCoroutines(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("/")) {
|
||||
operation.path = operation.path.substring(1);
|
||||
}
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import org.openapitools.codegen.*;
|
||||
import io.swagger.models.properties.ArrayProperty;
|
||||
import io.swagger.models.properties.MapProperty;
|
||||
import io.swagger.models.properties.Property;
|
||||
import io.swagger.models.parameters.Parameter;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.escape;
|
||||
|
||||
public class MarkdownDocumentationCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
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"));
|
||||
// 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
|
||||
*/
|
||||
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
|
||||
@@ -112,7 +124,11 @@ public class PhpLumenServerCodegen extends AbstractPhpCodegen {
|
||||
* 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("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("composer.mustache", srcBasePath, "composer.json"));
|
||||
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("ExampleTest.php", srcBasePath + File.separator + "tests", "ExampleTest.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
|
||||
|
||||
@@ -148,6 +148,14 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
||||
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
|
||||
public void setActualInstance(Object instance) {
|
||||
{{#isNullable}}
|
||||
@@ -166,4 +174,29 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
||||
{{/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}}
|
||||
scribejava_apis_version = "6.9.0"
|
||||
{{/hasOAuthMethods}}
|
||||
{{#hasHttpBasicMethods}}
|
||||
tomitribe_http_signatures_version = "1.3"
|
||||
{{/hasHttpBasicMethods}}
|
||||
{{#hasHttpSignatureMethods}}
|
||||
tomitribe_http_signatures_version = "1.5"
|
||||
{{/hasHttpSignatureMethods}}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -161,9 +161,9 @@ dependencies {
|
||||
{{#hasOAuthMethods}}
|
||||
compile "com.github.scribejava:scribejava-apis:$scribejava_apis_version"
|
||||
{{/hasOAuthMethods}}
|
||||
{{#hasHttpBasicMethods}}
|
||||
{{#hasHttpSignatureMethods}}
|
||||
compile "org.tomitribe:tomitribe-http-signatures:$tomitribe_http_signatures_version"
|
||||
{{/hasHttpBasicMethods}}
|
||||
{{/hasHttpSignatureMethods}}
|
||||
{{#supportJava6}}
|
||||
compile "commons-io:commons-io:$commons_io_version"
|
||||
compile "org.apache.commons:commons-lang3:$commons_lang3_version"
|
||||
|
||||
@@ -28,9 +28,9 @@ lazy val root = (project in file(".")).
|
||||
{{#hasOAuthMethods}}
|
||||
"com.github.scribejava" % "scribejava-apis" % "6.9.0" % "compile",
|
||||
{{/hasOAuthMethods}}
|
||||
{{#hasHttpBasicMethods}}
|
||||
"org.tomitribe" % "tomitribe-http-signatures" % "1.3" % "compile",
|
||||
{{/hasHttpBasicMethods}}
|
||||
{{#hasHttpSignatureMethods}}
|
||||
"org.tomitribe" % "tomitribe-http-signatures" % "1.5" % "compile",
|
||||
{{/hasHttpSignatureMethods}}
|
||||
{{^java8}}
|
||||
"com.brsanthu" % "migbase64" % "2.2",
|
||||
{{/java8}}
|
||||
|
||||
@@ -183,7 +183,8 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* 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}}");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
callback.onFailure(e, response.code(), response.headers().toMultimap());
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
callback.onFailure(new ApiException(e), response.code(), response.headers().toMultimap());
|
||||
return;
|
||||
}
|
||||
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}}
|
||||
{{/hasMore}}{{/formParams}}{{/hasFormParams}}
|
||||
|
||||
final String[] accepts = { {{#hasProduces}}
|
||||
final String[] localVarAccepts = { {{#hasProduces}}
|
||||
{{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
|
||||
{{/hasProduces}}};
|
||||
final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
|
||||
{{/hasProduces}} };
|
||||
final List<MediaType> localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
|
||||
final String[] contentTypes = { {{#hasConsumes}}
|
||||
{{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}
|
||||
{{/hasConsumes}}};
|
||||
{{/hasConsumes}} };
|
||||
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
|
||||
|
||||
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}}
|
||||
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}}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,32 @@
|
||||
package {{apiPackage}};
|
||||
|
||||
/**
|
||||
* The exception that can be used to store the HTTP status code returned by an API response.
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
public class ApiException extends Exception{
|
||||
public class ApiException extends Exception {
|
||||
|
||||
/** The HTTP status 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);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTTP status code.
|
||||
*
|
||||
* @return The HTTP status code.
|
||||
*/
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,32 @@
|
||||
package {{apiPackage}};
|
||||
|
||||
/**
|
||||
* The exception that can be used to store the HTTP status code returned by an API response.
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
public class ApiException extends Exception{
|
||||
public class ApiException extends Exception {
|
||||
|
||||
/** The HTTP status 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);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTTP status code.
|
||||
*
|
||||
* @return The HTTP status code.
|
||||
*/
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,32 @@
|
||||
package {{apiPackage}};
|
||||
|
||||
/**
|
||||
* The exception that can be used to store the HTTP status code returned by an API response.
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
public class ApiException extends Exception{
|
||||
public class ApiException extends Exception {
|
||||
|
||||
/** The HTTP status 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);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTTP status code.
|
||||
*
|
||||
* @return The HTTP status code.
|
||||
*/
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -541,12 +541,15 @@
|
||||
{{/usePromises}} };
|
||||
|
||||
{{#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.
|
||||
* @returns {Date} The parsed date object.
|
||||
*/
|
||||
{{/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}} /**
|
||||
|
||||
@@ -519,12 +519,15 @@ class ApiClient {
|
||||
}
|
||||
|
||||
{{#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.
|
||||
* @returns {Date} The parsed date object.
|
||||
*/{{/emitJSDoc}}
|
||||
static parseDate(str) {
|
||||
return new Date(str);
|
||||
if (isNaN(str)) {
|
||||
return new Date(str);
|
||||
}
|
||||
return new Date(+str);
|
||||
}
|
||||
|
||||
{{#emitJSDoc}}/**
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace {{packageName}}
|
||||
/// <param name="args"></param>
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
CreateWebHostBuilder(args).Build().Run();
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -22,7 +22,7 @@ namespace {{packageName}}
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
/// <returns>IHostBuilder</returns>
|
||||
public static IHostBuilder CreateWebHostBuilder(string[] args) =>
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
@@ -30,4 +30,4 @@ namespace {{packageName}}
|
||||
.UseUrls("http://0.0.0.0:{{#serverPort}}{{serverPort}}{{/serverPort}}{{^serverPort}}8080{{/serverPort}}/");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -448,7 +448,7 @@ namespace {{packageName}}.Client
|
||||
}
|
||||
|
||||
{{#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);
|
||||
|
||||
@@ -479,7 +479,7 @@ namespace {{packageName}}.Client
|
||||
|
||||
InterceptRequest(req);
|
||||
|
||||
var response = await client.ExecuteAsync<T>(req);
|
||||
var response = await client.ExecuteAsync<T>(req, cancellationToken);
|
||||
|
||||
InterceptResponse(req, response);
|
||||
|
||||
@@ -526,11 +526,12 @@ namespace {{packageName}}.Client
|
||||
/// <param name="options">The additional request options.</param>
|
||||
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
|
||||
/// 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>
|
||||
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;
|
||||
return ExecAsync<T>(NewRequest(HttpMethod.Get, path, options, config), config);
|
||||
return ExecAsync<T>(NewRequest(HttpMethod.Get, path, options, config), config, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -540,11 +541,12 @@ namespace {{packageName}}.Client
|
||||
/// <param name="options">The additional request options.</param>
|
||||
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
|
||||
/// 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>
|
||||
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;
|
||||
return ExecAsync<T>(NewRequest(HttpMethod.Post, path, options, config), config);
|
||||
return ExecAsync<T>(NewRequest(HttpMethod.Post, path, options, config), config, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -554,11 +556,12 @@ namespace {{packageName}}.Client
|
||||
/// <param name="options">The additional request options.</param>
|
||||
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
|
||||
/// 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>
|
||||
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;
|
||||
return ExecAsync<T>(NewRequest(HttpMethod.Put, path, options, config), config);
|
||||
return ExecAsync<T>(NewRequest(HttpMethod.Put, path, options, config), config, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -568,11 +571,12 @@ namespace {{packageName}}.Client
|
||||
/// <param name="options">The additional request options.</param>
|
||||
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
|
||||
/// 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>
|
||||
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;
|
||||
return ExecAsync<T>(NewRequest(HttpMethod.Delete, path, options, config), config);
|
||||
return ExecAsync<T>(NewRequest(HttpMethod.Delete, path, options, config), config, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -582,11 +586,12 @@ namespace {{packageName}}.Client
|
||||
/// <param name="options">The additional request options.</param>
|
||||
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
|
||||
/// 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>
|
||||
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;
|
||||
return ExecAsync<T>(NewRequest(HttpMethod.Head, path, options, config), config);
|
||||
return ExecAsync<T>(NewRequest(HttpMethod.Head, path, options, config), config, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -596,11 +601,12 @@ namespace {{packageName}}.Client
|
||||
/// <param name="options">The additional request options.</param>
|
||||
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
|
||||
/// 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>
|
||||
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;
|
||||
return ExecAsync<T>(NewRequest(HttpMethod.Options, path, options, config), config);
|
||||
return ExecAsync<T>(NewRequest(HttpMethod.Options, path, options, config), config, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -610,11 +616,12 @@ namespace {{packageName}}.Client
|
||||
/// <param name="options">The additional request options.</param>
|
||||
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
|
||||
/// 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>
|
||||
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;
|
||||
return ExecAsync<T>(NewRequest(HttpMethod.Patch, path, options, config), config);
|
||||
return ExecAsync<T>(NewRequest(HttpMethod.Patch, path, options, config), config, cancellationToken);
|
||||
}
|
||||
#endregion IAsynchronousClient
|
||||
{{/supportsAsync}}
|
||||
|
||||
@@ -21,6 +21,12 @@ namespace {{packageName}}.Client
|
||||
/// <value>The error content (Http response body).</value>
|
||||
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>
|
||||
/// Initializes a new instance of the <see cref="ApiException"/> class.
|
||||
/// </summary>
|
||||
@@ -42,10 +48,12 @@ namespace {{packageName}}.Client
|
||||
/// <param name="errorCode">HTTP status code.</param>
|
||||
/// <param name="message">Error message.</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.ErrorContent = errorContent;
|
||||
this.Headers = headers;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace {{packageName}}.Client
|
||||
{
|
||||
return new ApiException(status,
|
||||
string.Format("Error calling {0}: {1}", methodName, response.RawContent),
|
||||
response.RawContent);
|
||||
response.RawContent, response.Headers);
|
||||
}
|
||||
{{^netStandard}}if (status == 0)
|
||||
{
|
||||
|
||||
@@ -19,9 +19,10 @@ namespace {{packageName}}.Client
|
||||
/// <param name="path">The relative path to invoke.</param>
|
||||
/// <param name="options">The request parameters to pass along to the client.</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>
|
||||
/// <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>
|
||||
/// 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="options">The request parameters to pass along to the client.</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>
|
||||
/// <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>
|
||||
/// 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="options">The request parameters to pass along to the client.</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>
|
||||
/// <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>
|
||||
/// 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="options">The request parameters to pass along to the client.</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>
|
||||
/// <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>
|
||||
/// 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="options">The request parameters to pass along to the client.</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>
|
||||
/// <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>
|
||||
/// 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="options">The request parameters to pass along to the client.</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>
|
||||
/// <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>
|
||||
/// 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="options">The request parameters to pass along to the client.</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>
|
||||
/// <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}}
|
||||
|
||||
@@ -61,9 +61,12 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
/// {{notes}}
|
||||
/// </remarks>
|
||||
/// <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}}/// <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}}
|
||||
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
||||
{{/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}}
|
||||
@@ -72,9 +75,12 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
/// {{notes}}
|
||||
/// </remarks>
|
||||
/// <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}}/// <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}}
|
||||
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
||||
{{/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}}
|
||||
#endregion Asynchronous Operations
|
||||
}
|
||||
@@ -376,22 +382,27 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
/// {{summary}} {{notes}}
|
||||
/// </summary>
|
||||
/// <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}}/// <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}}
|
||||
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
||||
{{/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}});
|
||||
return localVarResponse.Data;{{/returnType}}{{^returnType}}await {{operationId}}AsyncWithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{/returnType}}
|
||||
|
||||
{{#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}}WithHttpInfoAsync({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}cancellationToken);{{/returnType}}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// {{summary}} {{notes}}
|
||||
/// </summary>
|
||||
/// <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}}/// <returns>Task of ApiResponse{{#returnType}} ({{returnType}}){{/returnType}}</returns>
|
||||
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="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
||||
{{/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}}
|
||||
{{#required}}
|
||||
@@ -534,7 +545,7 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
|
||||
// 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)
|
||||
{
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
{{#termsOfService}}
|
||||
<copyright>{{termsOfService}}</copyright>
|
||||
{{/termsOfService}}
|
||||
{{#licenseUrl}}
|
||||
<licenseUrl>{{licenseUrl}}</licenseUrl>
|
||||
{{/licenseUrl}}
|
||||
{{#license}}
|
||||
<license type="expression">{{{license}}}</license>
|
||||
{{/license}}
|
||||
|
||||
<!-- Dependencies are automatically installed when the package is installed -->
|
||||
<dependencies>
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
||||
{{/allParams}}/// <param name="cancellationToken">Cancellation Token to cancel request (optional) </param>
|
||||
/// <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}}
|
||||
#endregion Asynchronous Operations
|
||||
{{/supportsAsync}}
|
||||
@@ -340,8 +340,8 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
/// <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}}ApiResponse<{{{returnType}}}> localVarResponse = await {{operationId}}AsyncWithHttpInfo({{#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}}
|
||||
{{#returnType}}ApiResponse<{{{returnType}}}> localVarResponse = await {{operationId}}WithHttpInfoAsync({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#allParams.0}}, {{/allParams.0}}cancellationToken);
|
||||
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="cancellationToken">Cancellation Token to cancel request (optional) </param>
|
||||
/// <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}}
|
||||
{{#required}}
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
{{#termsOfService}}
|
||||
<copyright>{{termsOfService}}</copyright>
|
||||
{{/termsOfService}}
|
||||
{{#licenseUrl}}
|
||||
<licenseUrl>{{licenseUrl}}</licenseUrl>
|
||||
{{/licenseUrl}}
|
||||
{{#license}}
|
||||
<license type="expression">{{{license}}}</license>
|
||||
{{/license}}
|
||||
|
||||
<!-- Dependencies are automatically installed when the package is installed -->
|
||||
<dependencies>
|
||||
|
||||
@@ -89,19 +89,19 @@ class {{classname}} {
|
||||
(json['{{baseName}}'] as Map).cast<String, {{items.datatype}}>();
|
||||
{{/isMapContainer}}
|
||||
{{^isMapContainer}}
|
||||
{{#isDouble}}
|
||||
{{#isNumber}}
|
||||
{{name}} = (json['{{baseName}}'] == null) ?
|
||||
null :
|
||||
json['{{baseName}}'].toDouble();
|
||||
{{/isDouble}}
|
||||
{{^isDouble}}
|
||||
{{/isNumber}}
|
||||
{{^isNumber}}
|
||||
{{^isEnum}}
|
||||
{{name}} = json['{{baseName}}'];
|
||||
{{/isEnum}}
|
||||
{{#isEnum}}
|
||||
{{name}} = {{classname}}{{{enumName}}}.fromJson(json['{{baseName}}']);
|
||||
{{/isEnum}}
|
||||
{{/isDouble}}
|
||||
{{/isNumber}}
|
||||
{{/isMapContainer}}
|
||||
{{/isListContainer}}
|
||||
{{/complexType}}
|
||||
|
||||
@@ -26,12 +26,14 @@ type api{{operationId}}Request struct {
|
||||
{{paramName}} {{^isPathParam}}*{{/isPathParam}}{{{dataType}}}{{/allParams}}
|
||||
}
|
||||
|
||||
{{#allParams}}{{^isPathParam}}
|
||||
{{#allParams}}
|
||||
{{^isPathParam}}
|
||||
func (r api{{operationId}}Request) {{vendorExtensions.x-export-param-name}}({{paramName}} {{{dataType}}}) api{{operationId}}Request {
|
||||
r.{{paramName}} = &{{paramName}}
|
||||
return r
|
||||
}
|
||||
{{/isPathParam}}{{/allParams}}
|
||||
{{/isPathParam}}
|
||||
{{/allParams}}
|
||||
/*
|
||||
{{operationId}}{{#summary}} {{{.}}}{{/summary}}{{^summary}} Method for {{operationId}}{{/summary}}
|
||||
{{#notes}}
|
||||
@@ -51,7 +53,9 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx _context.Context{{#pathParam
|
||||
|
||||
/*
|
||||
Execute executes the request
|
||||
{{#returnType}} @return {{{.}}}{{/returnType}}
|
||||
{{#returnType}}
|
||||
@return {{{.}}}
|
||||
{{/returnType}}
|
||||
*/
|
||||
func (r api{{operationId}}Request) Execute() ({{#returnType}}{{{.}}}, {{/returnType}}*_nethttp.Response, error) {
|
||||
var (
|
||||
@@ -60,7 +64,9 @@ func (r api{{operationId}}Request) Execute() ({{#returnType}}{{{.}}}, {{/returnT
|
||||
localVarFormFileName string
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
{{#returnType}}localVarReturnValue {{{.}}}{{/returnType}}
|
||||
{{#returnType}}
|
||||
localVarReturnValue {{{.}}}
|
||||
{{/returnType}}
|
||||
)
|
||||
|
||||
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{}
|
||||
localVarFormParams := _neturl.Values{}
|
||||
{{#allParams}}
|
||||
{{#required}}{{^isPathParam}}
|
||||
{{#required}}
|
||||
{{^isPathParam}}
|
||||
if r.{{paramName}} == nil {
|
||||
return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} is required and must be specified")
|
||||
}{{/isPathParam}}
|
||||
}
|
||||
{{/isPathParam}}
|
||||
{{#minItems}}
|
||||
if len({{^isPathParam}}*{{/isPathParam}}r.{{paramName}}) < {{minItems}} {
|
||||
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}}
|
||||
{{#discriminator}}
|
||||
{{#mappedModels}}
|
||||
{{#-first}}
|
||||
{{#-first}}
|
||||
// use discriminator value to speed up the lookup
|
||||
var jsonDict map[string]interface{}
|
||||
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.")
|
||||
}
|
||||
|
||||
{{/-first}}
|
||||
{{/-first}}
|
||||
// check if the discriminator value is '{{{mappingName}}}'
|
||||
if jsonDict["{{{propertyBaseName}}}"] == "{{{mappingName}}}" {
|
||||
// try to unmarshal JSON data into {{{modelName}}}
|
||||
|
||||
@@ -40,7 +40,7 @@ const (
|
||||
// The 'Host' header, as defined in RFC 2616, section 14.23.
|
||||
HttpHeaderHost string = "Host"
|
||||
// The 'Date' header.
|
||||
HttpHeaderDate string = "Date"
|
||||
HttpHeaderDate string = "Date"
|
||||
// The digest header, as defined in RFC 3230, section 4.3.2.
|
||||
HttpHeaderDigest string = "Digest"
|
||||
// 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'.
|
||||
// The signature algorithm, when signing HTTP requests.
|
||||
// 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.
|
||||
// SignatureMaxValidity specifies the maximum duration of the signature validity.
|
||||
// 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}}
|
||||
params := mux.Vars(r){{/hasPathParams}}{{#hasQueryParams}}
|
||||
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 {
|
||||
w.WriteHeader(500)
|
||||
return
|
||||
}
|
||||
{{/isLong}}{{^isLong}}
|
||||
{{paramName}} := params["{{paramName}}"]{{/isLong}}{{/isPathParam}}{{#isQueryParam}}{{#isLong}}
|
||||
{{paramName}}, err := parseIntParameter(query.Get("{{paramName}}"))
|
||||
{{/isInteger}}{{^isLong}}{{^isInteger}}
|
||||
{{paramName}} := params["{{paramName}}"]{{/isInteger}}{{/isLong}}{{/isPathParam}}{{#isQueryParam}}{{#isLong}}
|
||||
{{paramName}}, err := parseInt64Parameter(query.Get("{{paramName}}"))
|
||||
if err != nil {
|
||||
w.WriteHeader(500)
|
||||
return
|
||||
}
|
||||
{{/isLong}}{{^isLong}}
|
||||
{{paramName}} := {{#isListContainer}}strings.Split({{/isListContainer}}query.Get("{{paramName}}"){{#isListContainer}}, ","){{/isListContainer}}{{/isLong}}{{/isQueryParam}}{{#isFormParam}}{{#isFile}}
|
||||
{{/isLong}}{{#isInteger}}
|
||||
{{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}}")
|
||||
if err != nil {
|
||||
w.WriteHeader(500)
|
||||
return
|
||||
}
|
||||
{{/isFile}}{{#isLong}}
|
||||
{{paramName}}, err := parseIntParameter( r.FormValue("{{paramName}}"))
|
||||
{{paramName}}, err := parseInt64Parameter( r.FormValue("{{paramName}}"))
|
||||
if err != nil {
|
||||
w.WriteHeader(500)
|
||||
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.Header.Get("{{paramName}}"){{/isHeaderParam}}{{#isBodyParam}}
|
||||
{{paramName}} := &{{dataType}}{}
|
||||
|
||||
@@ -11,7 +11,7 @@ type {{{name}}} {{^format}}{{dataType}}{{/format}}{{#format}}{{{format}}}{{/form
|
||||
const (
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
{{name}} {{{classname}}} = {{{value}}}
|
||||
{{#enumClassPrefix}}{{{classname.toUpperCase}}}_{{/enumClassPrefix}}{{name}} {{{classname}}} = {{{value}}}
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
){{/isEnum}}{{^isEnum}}{{#description}}
|
||||
|
||||
@@ -88,7 +88,16 @@ func ReadFormFileToTempFile(r *http.Request, key string) (*os.File, error) {
|
||||
return file, nil
|
||||
}
|
||||
|
||||
// parseIntParameter parses a sting parameter to an int64
|
||||
func parseIntParameter(param string) (int64, error) {
|
||||
// parseInt64Parameter parses a sting parameter to an int64
|
||||
func parseInt64Parameter(param string) (int64, error) {
|
||||
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"
|
||||
_nethttp "net/http"
|
||||
_neturl "net/url"
|
||||
_bytes "bytes"
|
||||
{{#imports}} "{{import}}"
|
||||
{{/imports}}
|
||||
)
|
||||
@@ -309,6 +310,7 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx _context.Context{{#hasParams
|
||||
|
||||
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
|
||||
localVarHTTPResponse.Body.Close()
|
||||
localVarHTTPResponse.Body = _ioutil.NopCloser(_bytes.NewBuffer(localVarBody))
|
||||
if err != nil {
|
||||
return {{#returnType}}localVarReturnValue, {{/returnType}}localVarHTTPResponse, err
|
||||
}
|
||||
|
||||
@@ -1,10 +1,32 @@
|
||||
package {{apiPackage}};
|
||||
|
||||
/**
|
||||
* The exception that can be used to store the HTTP status code returned by an API response.
|
||||
*/
|
||||
{{>generatedAnnotation}}
|
||||
public class ApiException extends Exception{
|
||||
public class ApiException extends Exception {
|
||||
|
||||
/** The HTTP status 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);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTTP status code.
|
||||
*
|
||||
* @return The HTTP status code.
|
||||
*/
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@ buildscript {
|
||||
{{#useRxJava2}}
|
||||
ext.rxJava2Version = '2.2.17'
|
||||
{{/useRxJava2}}
|
||||
{{#useRxJava3}}
|
||||
ext.rxJava3Version = '3.0.4'
|
||||
{{/useRxJava3}}
|
||||
|
||||
repositories {
|
||||
maven { url "https://repo1.maven.org/maven2" }
|
||||
@@ -98,6 +101,10 @@ dependencies {
|
||||
compile "io.reactivex.rxjava2:rxjava:$rxJava2Version"
|
||||
compile "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
|
||||
{{/useRxJava2}}
|
||||
{{#useRxJava3}}
|
||||
compile "io.reactivex.rxjava3:rxjava:$rxJava3Version"
|
||||
compile "com.squareup.retrofit2:adapter-rxjava3:2.9.0"
|
||||
{{/useRxJava3}}
|
||||
compile "com.squareup.retrofit2:retrofit:$retrofitVersion"
|
||||
{{#gson}}
|
||||
compile "com.squareup.retrofit2:converter-gson:$retrofitVersion"
|
||||
|
||||
@@ -24,10 +24,16 @@ import rx.Observable
|
||||
{{#useRxJava2}}
|
||||
import io.reactivex.Single
|
||||
{{/useRxJava2}}
|
||||
{{#useRxJava3}}
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
{{/useRxJava3}}
|
||||
{{^returnType}}
|
||||
{{#useRxJava2}}
|
||||
import io.reactivex.Completable
|
||||
{{/useRxJava2}}
|
||||
{{#useRxJava3}}
|
||||
import io.reactivex.rxjava3.core.Completable;
|
||||
{{/useRxJava3}}
|
||||
{{/returnType}}
|
||||
{{/doNotUseRxAndCoroutines}}
|
||||
|
||||
@@ -35,6 +41,12 @@ import io.reactivex.Completable
|
||||
{{/imports}}
|
||||
|
||||
{{#operations}}
|
||||
{{#x-kotlin-multipart-import}}
|
||||
{{^isMultipart}}
|
||||
import okhttp3.MultipartBody
|
||||
|
||||
{{/isMultipart}}
|
||||
{{/x-kotlin-multipart-import}}
|
||||
interface {{classname}} {
|
||||
{{#operation}}
|
||||
/**
|
||||
@@ -66,8 +78,8 @@ interface {{classname}} {
|
||||
{{/prioritizedContentTypes}}
|
||||
{{/formParams}}
|
||||
@{{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}}
|
||||
}
|
||||
{{/operations}}
|
||||
{{/operations}}
|
||||
|
||||
@@ -32,6 +32,9 @@ import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory
|
||||
{{#useRxJava2}}
|
||||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
|
||||
{{/useRxJava2}}
|
||||
{{#useRxJava3}}
|
||||
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory
|
||||
{{/useRxJava3}}
|
||||
{{#gson}}
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.GsonBuilder
|
||||
@@ -45,7 +48,8 @@ import retrofit2.converter.moshi.MoshiConverterFactory
|
||||
{{#nonPublicApi}}internal {{/nonPublicApi}}class ApiClient(
|
||||
private var baseUrl: String = defaultBasePath,
|
||||
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>()
|
||||
var logger: ((String) -> Unit)? = null
|
||||
@@ -62,7 +66,9 @@ import retrofit2.converter.moshi.MoshiConverterFactory
|
||||
{{/useRxJava}}
|
||||
{{#useRxJava2}}
|
||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||
{{/useRxJava2}}
|
||||
{{/useRxJava2}}{{#useRxJava3}}
|
||||
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
|
||||
{{/useRxJava3}}
|
||||
{{#moshi}}
|
||||
.addConverterFactory(MoshiConverterFactory.create(serializerBuilder.build()))
|
||||
{{/moshi}}
|
||||
@@ -281,7 +287,9 @@ import retrofit2.converter.moshi.MoshiConverterFactory
|
||||
}
|
||||
|
||||
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() {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
APP_NAME=Lumen
|
||||
APP_ENV=local
|
||||
APP_DEBUG=true
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
APP_TIMEZONE=UTC
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
@@ -14,4 +16,4 @@ DB_USERNAME=homestead
|
||||
DB_PASSWORD=secret
|
||||
|
||||
CACHE_DRIVER=file
|
||||
QUEUE_DRIVER=sync
|
||||
QUEUE_CONNECTION=sync
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
{{>licenseInfoLumen}}
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
{{>licenseInfoLumen}}
|
||||
namespace App\Providers;
|
||||
|
||||
use App\User;
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
{{>licenseInfoLumen}}
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
{{>licenseInfoLumen}}
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Laravel\Lumen\Routing\Controller as BaseController;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
{{>licenseInfoLumen}}
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
{{>licenseInfoLumen}}
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
{{>licenseInfoLumen}}
|
||||
namespace App\Providers;
|
||||
|
||||
use Laravel\Lumen\Providers\EventServiceProvider as ServiceProvider;
|
||||
@@ -12,8 +13,8 @@ class EventServiceProvider extends ServiceProvider
|
||||
* @var array
|
||||
*/
|
||||
protected $listen = [
|
||||
'App\Events\ExampleEvent' => [
|
||||
'App\Listeners\ExampleListener',
|
||||
\App\Events\ExampleEvent::class => [
|
||||
\App\Listeners\ExampleListener::class,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
{{>licenseInfoLumen}}
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
class ExampleController extends Controller
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
{{>licenseInfoLumen}}
|
||||
namespace App\Events;
|
||||
|
||||
class ExampleEvent extends Event
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
{{>licenseInfoLumen}}
|
||||
namespace App\Jobs;
|
||||
|
||||
class ExampleJob extends Job
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<?php
|
||||
|
||||
{{>licenseInfoLumen}}
|
||||
namespace App\Listeners;
|
||||
|
||||
use App\Events\ExampleEvent;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
|
||||
class ExampleListener
|
||||
{
|
||||
@@ -21,7 +22,7 @@ class ExampleListener
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param ExampleEvent $event
|
||||
* @param \App\Events\ExampleEvent $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(ExampleEvent $event)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
{{>licenseInfoLumen}}
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
{{>licenseInfoLumen}}
|
||||
use Laravel\Lumen\Testing\DatabaseMigrations;
|
||||
use Laravel\Lumen\Testing\DatabaseTransactions;
|
||||
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
{{>licenseInfoLumen}}
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
@@ -34,23 +29,27 @@ class Handler extends ExceptionHandler
|
||||
*
|
||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||
*
|
||||
* @param \Exception $e
|
||||
* @param \Throwable $exception
|
||||
* @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.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $e
|
||||
* @return \Illuminate\Http\Response
|
||||
* @param \Throwable $exception
|
||||
* @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
|
||||
|
||||
{{>licenseInfoLumen}}
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
abstract class Job implements ShouldQueue
|
||||
{
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
{{>licenseInfoLumen}}
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
|
||||
@@ -1,17 +1,23 @@
|
||||
<?php
|
||||
|
||||
{{>licenseInfoLumen}}
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use App\User;
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Model Factories
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define all of your model factories. Model factories give
|
||||
| you a convenient way to create models for testing and seeding your
|
||||
| database. Just tell the factory how a default model should look.
|
||||
| This directory should contain each of the model factory definitions for
|
||||
| your application. Factories provide a convenient way to generate new
|
||||
| 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 [
|
||||
'name' => $faker->name,
|
||||
'email' => $faker->email,
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<?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.
|
||||
|
||||
@@ -1,22 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
{{>licenseInfoLumen}}
|
||||
namespace App;
|
||||
|
||||
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\Authenticatable as AuthenticatableContract;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Laravel\Lumen\Auth\Authorizable;
|
||||
|
||||
class User extends Model implements
|
||||
AuthenticatableContract,
|
||||
AuthorizableContract
|
||||
class User extends Model implements AuthenticatableContract, AuthorizableContract
|
||||
{
|
||||
use Authenticatable, Authorizable;
|
||||
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
{{>licenseInfoLumen}}
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
try {
|
||||
(new Dotenv\Dotenv(__DIR__.'/../'))->load();
|
||||
} catch (Dotenv\Exception\InvalidPathException $e) {
|
||||
//
|
||||
}
|
||||
(new Laravel\Lumen\Bootstrap\LoadEnvironmentVariables(
|
||||
dirname(__DIR__)
|
||||
))->bootstrap();
|
||||
|
||||
date_default_timezone_set(env('APP_TIMEZONE', 'UTC'));
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -26,7 +21,7 @@ try {
|
||||
*/
|
||||
|
||||
$app = new Laravel\Lumen\Application(
|
||||
realpath(__DIR__.'/../')
|
||||
dirname(__DIR__)
|
||||
);
|
||||
|
||||
// $app->withFacades();
|
||||
@@ -54,6 +49,19 @@ $app->singleton(
|
||||
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
|
||||
@@ -66,7 +74,7 @@ $app->singleton(
|
||||
*/
|
||||
|
||||
// $app->middleware([
|
||||
// App\Http\Middleware\ExampleMiddleware::class
|
||||
// App\Http\Middleware\ExampleMiddleware::class
|
||||
// ]);
|
||||
|
||||
// $app->routeMiddleware([
|
||||
@@ -105,6 +113,4 @@ $app->router->group([
|
||||
require __DIR__.'/../routes/web.php';
|
||||
});
|
||||
|
||||
$app->withFacades();
|
||||
|
||||
return $app;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
{{>licenseInfoLumen}}
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
|
||||
|
||||
@@ -24,29 +24,26 @@
|
||||
],
|
||||
"type": "project",
|
||||
"require": {
|
||||
"php": ">=7.1.3",
|
||||
"laravel/lumen-framework": "5.6.*",
|
||||
"vlucas/phpdotenv": "~2.2"
|
||||
"php": "^7.2.5",
|
||||
"laravel/lumen-framework": "^7.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"fzaninotto/faker": "~1.4",
|
||||
"phpunit/phpunit": "~7.0",
|
||||
"mockery/mockery": "~1.0"
|
||||
"fzaninotto/faker": "^1.9",
|
||||
"mockery/mockery": "^1.3",
|
||||
"phpunit/phpunit": "^8.0 || ^9.0"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"database/seeds",
|
||||
"database/factories"
|
||||
],
|
||||
"psr-4": {
|
||||
"App\\": "app/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"classmap": [
|
||||
"tests/",
|
||||
"database/"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"post-root-package-install": [
|
||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||
"tests/"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
@@ -55,5 +52,10 @@
|
||||
"optimize-autoloader": true
|
||||
},
|
||||
"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
|
||||
|
||||
composer.phar
|
||||
/vendor/
|
||||
|
||||
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
|
||||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
|
||||
# composer.lock
|
||||
/vendor
|
||||
/.idea
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
.env
|
||||
.phpunit.result.cache
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
{{>licenseInfoLumen}}
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Create The Application
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* {{{appName}}}
|
||||
* {{{appDescription}}}
|
||||
* PHP version 7.1.3
|
||||
* PHP version 7.2.5
|
||||
*
|
||||
* {{#version}}The version of the OpenAPI document: {{{version}}}{{/version}}
|
||||
* {{#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"?>
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="bootstrap/app.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false">
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true">
|
||||
<testsuites>
|
||||
<testsuite name="Application Test Suite">
|
||||
<directory suffix="Test.php">./tests</directory>
|
||||
@@ -20,9 +14,8 @@
|
||||
</whitelist>
|
||||
</filter>
|
||||
<php>
|
||||
<ini name="error_reporting" value="E_ALL" />
|
||||
<env name="APP_ENV" value="testing"/>
|
||||
<env name="CACHE_DRIVER" value="array"/>
|
||||
<env name="QUEUE_DRIVER" value="sync"/>
|
||||
<env name="QUEUE_CONNECTION" value="sync"/>
|
||||
</php>
|
||||
</phpunit>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# OpenAPITools generated server
|
||||
|
||||
## Requirements
|
||||
* PHP 7.1.3 or newer
|
||||
* PHP 7.2.5 or newer
|
||||
|
||||
## Overview
|
||||
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.
|
||||
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
|
||||
|
||||
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.
|
||||
|
||||
### Running the generated server stub
|
||||
|
||||
@@ -1,11 +1,23 @@
|
||||
<?php
|
||||
|
||||
{{>licenseInfo}}
|
||||
{{>licenseInfoLumen}}
|
||||
{{#apiInfo}}/**
|
||||
* {{appName}}
|
||||
* @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) {
|
||||
return $router->app->version();
|
||||
});
|
||||
@@ -19,8 +31,8 @@ $router->get('/', function () use ($router) {
|
||||
* Notes: {{notes}}
|
||||
*/
|
||||
$router->{{httpMethod}}('{{{basePathWithoutHost}}}{{{path}}}', '{{classname}}@{{operationId}}');
|
||||
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user