forked from loafle/openapi-generator-original
Compare commits
11 Commits
v6.0.1
...
jaxrs-jers
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a9c6ffe62 | ||
|
|
8348a00db9 | ||
|
|
7fc9d73b13 | ||
|
|
4bfe8045a9 | ||
|
|
f60d0e2efa | ||
|
|
50c7917d92 | ||
|
|
49d21c4d7a | ||
|
|
204fd645c8 | ||
|
|
a703c58f65 | ||
|
|
9f8c1249b9 | ||
|
|
99bfefab8c |
5
.github/CODEOWNERS
vendored
5
.github/CODEOWNERS
vendored
@@ -28,8 +28,3 @@ modules/openapi-generator-cli/**/* @jimschubert
|
||||
modules/openapi-generator-gradle-plugin/**/* @jimschubert
|
||||
modules/openapi-generator-maven-plugin/**/* @jimschubert
|
||||
|
||||
# Martin Delille
|
||||
/Users/martin/dev/clone/openapi-generator/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQtClientCodegen.java @martindelille
|
||||
/Users/martin/dev/clone/openapi-generator/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQtAbstractCodegen.java @martindelille
|
||||
/Users/martin/dev/clone/openapi-generator/modules/openapi-generator/src/main/resources/cpp-qt-client @martindelille
|
||||
/Users/martin/dev/clone/openapi-generator/samples/client/petstore/cpp-qt @martindelille
|
||||
|
||||
1
.github/PULL_REQUEST_TEMPLATE.md
vendored
1
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -16,5 +16,4 @@
|
||||
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` (6.0.1) (patch release), `6.1.x` (breaking changes with fallbacks), `7.0.x` (breaking changes without fallbacks)
|
||||
- [ ] If your PR is targeting a particular programming language, @mention the [technical committee](https://github.com/openapitools/openapi-generator/#62---openapi-generator-technical-committee) members, so they are more likely to review the pull request.
|
||||
|
||||
1
.github/workflows/gradle-test.yaml
vendored
1
.github/workflows/gradle-test.yaml
vendored
@@ -32,7 +32,6 @@ jobs:
|
||||
- samples/openapi3/client/petstore/java/jersey2-java8-special-characters
|
||||
- samples/openapi3/client/petstore/java/jersey2-java8
|
||||
- samples/client/petstore/java/okhttp-gson
|
||||
- samples/client/petstore/java/okhttp-gson-group-parameter
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-java@v3
|
||||
|
||||
43
.github/workflows/samples-jdk17.yaml
vendored
43
.github/workflows/samples-jdk17.yaml
vendored
@@ -1,43 +0,0 @@
|
||||
name: Samples JDK17
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
# clients
|
||||
- samples/openapi3/client/petstore/spring-cloud-3
|
||||
# servers
|
||||
- samples/openapi3/server/petstore/springboot-3
|
||||
pull_request:
|
||||
paths:
|
||||
# clients
|
||||
- samples/openapi3/client/petstore/spring-cloud-3
|
||||
# servers
|
||||
- samples/openapi3/server/petstore/springboot-3
|
||||
jobs:
|
||||
build:
|
||||
name: Build with JDK17
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
sample:
|
||||
# clients
|
||||
- samples/openapi3/client/petstore/spring-cloud-3
|
||||
# servers
|
||||
- samples/openapi3/server/petstore/springboot-3
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
- name: Cache maven dependencies
|
||||
uses: actions/cache@v3
|
||||
env:
|
||||
cache-name: maven-repository
|
||||
with:
|
||||
path: |
|
||||
~/.m2
|
||||
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
|
||||
- name: Build
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: mvn clean package
|
||||
32
.github/workflows/samples-php7.yaml
vendored
32
.github/workflows/samples-php7.yaml
vendored
@@ -1,32 +0,0 @@
|
||||
name: Samples PHP 7.x
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- samples/server/petstore/php-laravel/lib/
|
||||
pull_request:
|
||||
paths:
|
||||
- samples/server/petstore/php-laravel/lib/
|
||||
jobs:
|
||||
build:
|
||||
name: Build PHP projects
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
sample:
|
||||
# servers
|
||||
- samples/server/petstore/php-laravel/lib/
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup PHP with tools
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '7.4'
|
||||
tools: php-cs-fixer, phpunit
|
||||
- name: composer install
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: composer install
|
||||
- name: phpunit
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: vendor/bin/phpunit
|
||||
32
.github/workflows/samples-php8.yaml
vendored
32
.github/workflows/samples-php8.yaml
vendored
@@ -1,32 +0,0 @@
|
||||
name: Samples PHP 8.x
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- samples/server/petstore/php-symfony/SymfonyBundle-php/
|
||||
pull_request:
|
||||
paths:
|
||||
- samples/server/petstore/php-symfony/SymfonyBundle-php/
|
||||
jobs:
|
||||
build:
|
||||
name: Build PHP projects
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
sample:
|
||||
# servers
|
||||
- samples/server/petstore/php-symfony/SymfonyBundle-php/
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup PHP with tools
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.1'
|
||||
tools: php-cs-fixer, phpunit
|
||||
- name: composer install
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: composer install
|
||||
- name: phpunit
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: vendor/bin/phpunit
|
||||
1
.github/workflows/samples-spring.yaml
vendored
1
.github/workflows/samples-spring.yaml
vendored
@@ -40,7 +40,6 @@ jobs:
|
||||
- samples/server/petstore/spring-boot-nullable-set
|
||||
- samples/server/petstore/spring-boot-defaultInterface-unhandledException
|
||||
- samples/openapi3/server/petstore/spring-boot-oneof
|
||||
- samples/server/petstore/springboot-virtualan
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-java@v3
|
||||
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -222,8 +222,6 @@ samples/server/petstore/haskell-yesod/stack.yaml.lock
|
||||
.Rproj.user
|
||||
samples/client/petstore/R/**/petstore.Rcheck/
|
||||
samples/client/petstore/R/**/*.tar.gz
|
||||
samples/client/petstore/R/R.Rproj
|
||||
samples/client/petstore/R/man/
|
||||
|
||||
# elixir
|
||||
samples/client/petstore/elixir/_build/
|
||||
@@ -268,6 +266,3 @@ samples/client/petstore/crystal/lib
|
||||
|
||||
# Go
|
||||
samples/openapi3/client/petstore/go/privatekey.pem
|
||||
|
||||
## OCaml
|
||||
samples/client/petstore/ocaml/_build/
|
||||
|
||||
137
.gitpod.yml
137
.gitpod.yml
@@ -1,137 +0,0 @@
|
||||
## Learn more about this file at 'https://www.gitpod.io/docs/references/gitpod-yml'
|
||||
##
|
||||
## This '.gitpod.yml' file when placed at the root of a project instructs
|
||||
## Gitpod how to prepare & build the project, start development environments
|
||||
## and configure continuous prebuilds. Prebuilds when enabled builds a project
|
||||
## like a CI server so you can start coding right away - no more waiting for
|
||||
## dependencies to download and builds to finish when reviewing pull-requests
|
||||
## or hacking on something new.
|
||||
##
|
||||
## With Gitpod you can develop software from any device (even iPads) via
|
||||
## desktop or browser based versions of VS Code or any JetBrains IDE and
|
||||
## customise it to your individual needs - from themes to extensions, you
|
||||
## have full control.
|
||||
##
|
||||
## The easiest way to try out Gitpod is install the browser extenion:
|
||||
## 'https://www.gitpod.io/docs/browser-extension' or by prefixing
|
||||
## 'https://gitpod.io#' to the source control URL of any project.
|
||||
##
|
||||
## For example: 'https://gitpod.io#https://github.com/gitpod-io/gitpod'
|
||||
|
||||
|
||||
## The 'image' section defines which Docker image Gitpod should use.
|
||||
## By default, Gitpod uses a standard Docker Image called 'workspace-full'
|
||||
## which can be found at 'https://github.com/gitpod-io/workspace-images'
|
||||
##
|
||||
## Workspaces started based on this default image come pre-installed with
|
||||
## Docker, Go, Java, Node.js, C/C++, Python, Ruby, Rust, PHP as well as
|
||||
## tools such as Homebrew, Tailscale, Nginx and several more.
|
||||
##
|
||||
## If this image does not include the tools needed for your project then
|
||||
## a public Docker image or your own Docker file can be configured.
|
||||
##
|
||||
## Learn more about images at 'https://www.gitpod.io/docs/config-docker'
|
||||
|
||||
#image: node:buster # use 'https://hub.docker.com/_/node'
|
||||
#
|
||||
#image: # leave image undefined if using a Dockerfile
|
||||
# file: .gitpod.Dockerfile # relative path to the Dockerfile from the
|
||||
# # root of the project
|
||||
|
||||
## The 'tasks' section defines how Gitpod prepares and builds this project
|
||||
## or how Gitpod can start development servers. With Gitpod, there are three
|
||||
## types of tasks:
|
||||
##
|
||||
## - before: Use this for tasks that need to run before init and before command.
|
||||
## - init: Use this to configure prebuilds of heavy-lifting tasks such as
|
||||
## downloading dependencies or compiling source code.
|
||||
## - command: Use this to start your database or application when the workspace starts.
|
||||
##
|
||||
## Learn more about these tasks at 'https://www.gitpod.io/docs/config-start-tasks'
|
||||
|
||||
#tasks:
|
||||
# - before: |
|
||||
# # commands to execute...
|
||||
#
|
||||
# - init: |
|
||||
# # sudo apt-get install python3 # can be used to install operating system
|
||||
# # dependencies but these are not kept after the
|
||||
# # prebuild completes thus Gitpod recommends moving
|
||||
# # operating system dependency installation steps
|
||||
# # to a custom Dockerfile to make prebuilds faster
|
||||
# # and to keep your codebase DRY.
|
||||
# # 'https://www.gitpod.io/docs/config-docker'
|
||||
#
|
||||
# # pip install -r requirements.txt # install codebase dependencies
|
||||
# # cmake # precompile codebase
|
||||
#
|
||||
# - name: Web Server
|
||||
# openMode: split-left
|
||||
# env:
|
||||
# WEBSERVER_PORT: 8080
|
||||
# command: |
|
||||
# python3 -m http.server $WEBSERVER_PORT
|
||||
#
|
||||
# - name: Web Browser
|
||||
# openMode: split-right
|
||||
# env:
|
||||
# WEBSERVER_PORT: 8080
|
||||
# command: |
|
||||
# gp await-port $WEBSERVER_PORT
|
||||
# lynx `gp url`
|
||||
|
||||
tasks:
|
||||
- init: ./mvnw package -DskipTests
|
||||
|
||||
## The 'ports' section defines various ports your may listen on are
|
||||
## configured in Gitpod on an authenticated URL. By default, all ports
|
||||
## are in private visibility state.
|
||||
##
|
||||
## Learn more about ports at 'https://www.gitpod.io/docs/config-ports'
|
||||
|
||||
#ports:
|
||||
# - port: 8080 # alternatively configure entire ranges via '8080-8090'
|
||||
# visibility: private # either 'public' or 'private' (default)
|
||||
# onOpen: open-browser # either 'open-browser', 'open-preview' or 'ignore'
|
||||
|
||||
|
||||
## The 'vscode' section defines a list of Visual Studio Code extensions from
|
||||
## the OpenVSX.org registry to be installed upon workspace startup. OpenVSX
|
||||
## is an open alternative to the proprietary Visual Studio Code Marketplace
|
||||
## and extensions can be added by sending a pull-request with the extension
|
||||
## identifier to https://github.com/open-vsx/publish-extensions
|
||||
##
|
||||
## The identifier of an extension is always ${publisher}.${name}.
|
||||
##
|
||||
## For example: 'vscodevim.vim'
|
||||
##
|
||||
## Learn more at 'https://www.gitpod.io/docs/ides-and-editors/vscode'
|
||||
|
||||
vscode:
|
||||
extensions:
|
||||
- redhat.java
|
||||
- vscjava.vscode-java-pack
|
||||
|
||||
## The 'github' section defines configuration of continuous prebuilds
|
||||
## for GitHub repositories when the GitHub application
|
||||
## 'https://github.com/apps/gitpod-io' is installed in GitHub and granted
|
||||
## permissions to access the repository.
|
||||
##
|
||||
## Learn more at 'https://www.gitpod.io/docs/prebuilds'
|
||||
|
||||
github:
|
||||
prebuilds:
|
||||
# enable for the default branch
|
||||
master: true
|
||||
# enable for all branches in this repo
|
||||
branches: true
|
||||
# enable for pull requests coming from this repo
|
||||
pullRequests: true
|
||||
# enable for pull requests coming from forks
|
||||
pullRequestsFromForks: true
|
||||
# add a check to pull requests
|
||||
addCheck: true
|
||||
# add a "Review in Gitpod" button as a comment to pull requests
|
||||
addComment: true
|
||||
# add a "Review in Gitpod" button to the pull request's description
|
||||
addBadge: false
|
||||
20
.travis.yml
20
.travis.yml
@@ -108,9 +108,9 @@ before_install:
|
||||
#- curl -f -L -o ./rebar3 https://s3.amazonaws.com/rebar3/rebar3 && chmod +x ./rebar3 && ./rebar3 version && export PATH="${TRAVIS_BUILD_DIR}:$PATH"
|
||||
# install C++ tools
|
||||
- sudo apt install -y --no-install-recommends valgrind cmake build-essential
|
||||
- cmake --version
|
||||
# install Qt5
|
||||
#- sudo apt install -y --no-install-recommends qt5-default
|
||||
- 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)
|
||||
@@ -225,14 +225,14 @@ after_success:
|
||||
fi;
|
||||
fi;
|
||||
## publish latest website, variables below are secure environment variables which are unavailable to PRs from forks.
|
||||
- if [ "$TRAVIS_BRANCH" = "master" ] && [ -z $TRAVIS_TAG ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
||||
cd website;
|
||||
git config --global user.name "${GH_NAME}";
|
||||
git config --global user.email "${GH_EMAIL}";
|
||||
echo "machine github.com login ${GH_NAME} password ${GH_TOKEN}" > ~/.netrc;
|
||||
yarn install;
|
||||
GIT_USER="${GH_NAME}" yarn run publish-gh-pages;
|
||||
fi;
|
||||
#- if [ "$TRAVIS_BRANCH" = "master" ] && [ -z $TRAVIS_TAG ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
||||
# cd website;
|
||||
# git config --global user.name "${GH_NAME}";
|
||||
# git config --global user.email "${GH_EMAIL}";
|
||||
# echo "machine github.com login ${GH_NAME} password ${GH_TOKEN}" > ~/.netrc;
|
||||
# yarn install;
|
||||
# GIT_USER="${GH_NAME}" yarn run publish-gh-pages;
|
||||
# fi;
|
||||
|
||||
env:
|
||||
- DOCKER_GENERATOR_IMAGE_NAME=openapitools/openapi-generator-online DOCKER_CODEGEN_CLI_IMAGE_NAME=openapitools/openapi-generator-cli NODE_ENV=test CC=gcc-5 CXX=g++-5
|
||||
|
||||
@@ -80,7 +80,6 @@ elif [ "$NODE_INDEX" = "4" ]; then
|
||||
#mvn --no-snapshot-updates --quiet verify -Psamples.circleci.node4 -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
||||
(cd samples/openapi3/client/petstore/python && make test)
|
||||
(cd samples/openapi3/client/petstore/python-experimental && make test)
|
||||
(cd samples/openapi3/client/3_0_3_unit_test/python-experimental && make test)
|
||||
|
||||
else
|
||||
echo "Running node $NODE_INDEX to test 'samples.circleci.others' defined in pom.xml ..."
|
||||
|
||||
47
README.md
47
README.md
@@ -3,31 +3,20 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.openapitools%22%20AND%20a%3A%22openapi-generator%22) [](./LICENSE) [](https://opencollective.com/openapi_generator) [](https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g) [](https://twitter.com/oas_generator) [](https://gitpod.io/#https://github.com/OpenAPITools/openapi-generator)
|
||||
[](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.openapitools%22%20AND%20a%3A%22openapi-generator%22) [](./LICENSE) [](https://opencollective.com/openapi_generator) [](https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g) [](https://twitter.com/oas_generator)
|
||||
|
||||
</div>
|
||||
|
||||
<div align="center">
|
||||
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`6.0.1`):
|
||||
[](https://travis-ci.com/OpenAPITools/openapi-generator)
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`6.0.x`):
|
||||
[](https://app.travis-ci.com/github/OpenAPITools/openapi-generator/builds)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator)
|
||||
[](https://cloud.drone.io/OpenAPITools/openapi-generator)
|
||||
[](https://app.bitrise.io/app/4a2b10a819d12b67)
|
||||
[](https://github.com/OpenAPITools/openapi-generator/actions?query=workflow%3A%22Check+Supported+Java+Versions%22)
|
||||
|
||||
[6.1.x](https://github.com/OpenAPITools/openapi-generator/tree/6.1.x) (`6.1.x`):
|
||||
[](https://travis-ci.com/OpenAPITools/openapi-generator)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator)
|
||||
[](https://app.bitrise.io/app/4a2b10a819d12b67)
|
||||
|
||||
[7.0.x](https://github.com/OpenAPITools/openapi-generator/tree/7.0.x) (`7.0.x`):
|
||||
[](https://travis-ci.com/OpenAPITools/openapi-generator)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator)
|
||||
[](https://app.bitrise.io/app/4a2b10a819d12b67)
|
||||
|
||||
</div>
|
||||
|
||||
<div align="center">
|
||||
@@ -61,8 +50,6 @@ If you find OpenAPI Generator useful for work, please consider asking your compa
|
||||
[<img src="https://openapi-generator.tech/img/companies/pexa.png" width="128" height="128">](https://www.pexa.com.au/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
|
||||
[<img src="https://openapi-generator.tech/img/companies/numary.png" width="128" height="128">](https://www.numary.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
|
||||
[<img src="https://openapi-generator.tech/img/companies/onesignal.png" width="128" height="128">](https://www.onesignal.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
|
||||
[<img src="https://openapi-generator.tech/img/companies/virtualansoftware.png" width="128" height="128">](https://www.virtualansoftware.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
|
||||
[<img src="https://openapi-generator.tech/img/companies/mergedev.jpeg" width="128" height="128">](https://www.merge.dev/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)
|
||||
|
||||
#### Thank you GoDaddy for sponsoring the domain names, Linode for sponsoring the VPS and Checkly for sponsoring the API monitoring
|
||||
|
||||
@@ -118,11 +105,8 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
|
||||
|
||||
| OpenAPI Generator Version | Release Date | Notes |
|
||||
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------------------------------------- |
|
||||
| 7.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.0.0-SNAPSHOT/) | Feb/Mar 2023 | Major release with breaking changes (no fallback) |
|
||||
| 6.1.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/6.1.0-SNAPSHOT/) | 26.07 2022 | Minor release with breaking changes (with fallbac) |
|
||||
| 6.0.1 (upcoming patch release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/6.0.1-SNAPSHOT/) | 26.06 2022 | Patch release (enhancements, bug fixes, etc) |
|
||||
| [6.0.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v6.0.0) (latest stable release) | 26.05.2022 | Major release with breaking changes (no fallback) |
|
||||
| [5.4.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v5.4.0) | 31.01.2022 | Minor release with breaking changes (with fallback) |
|
||||
| 6.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/6.0.0-SNAPSHOT/) | Feb/Mar 2022 | Major release with breaking changes (no fallback) |
|
||||
| [5.4.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v5.4.0) (latest stable release) | 31.01.2021 | Minor release with breaking changes (with fallback) |
|
||||
| [4.3.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.3.1) | 06.05.2020 | Patch release (enhancements, bug fixes, etc) |
|
||||
|
||||
OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0
|
||||
@@ -179,16 +163,16 @@ See the different versions of the [openapi-generator-cli](https://search.maven.o
|
||||
<!-- RELEASE_VERSION -->
|
||||
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum):
|
||||
|
||||
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.0.1/openapi-generator-cli-6.0.1.jar`
|
||||
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.4.0/openapi-generator-cli-5.4.0.jar`
|
||||
|
||||
For **Mac/Linux** users:
|
||||
```sh
|
||||
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.0.1/openapi-generator-cli-6.0.1.jar -O openapi-generator-cli.jar
|
||||
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.4.0/openapi-generator-cli-5.4.0.jar -O openapi-generator-cli.jar
|
||||
```
|
||||
|
||||
For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
|
||||
```
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.0.1/openapi-generator-cli-6.0.1.jar
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.4.0/openapi-generator-cli-5.4.0.jar
|
||||
```
|
||||
|
||||
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
|
||||
@@ -413,7 +397,7 @@ openapi-generator-cli version
|
||||
To use a specific version of "openapi-generator-cli"
|
||||
|
||||
```sh
|
||||
openapi-generator-cli version-manager set 6.0.1
|
||||
openapi-generator-cli version-manager set 5.4.0
|
||||
```
|
||||
|
||||
Or install it as dev-dependency:
|
||||
@@ -437,7 +421,7 @@ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generat
|
||||
(if you're on Windows, replace the last command with `java -jar modules\openapi-generator-cli\target\openapi-generator-cli.jar generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g php -o c:\temp\php_api_client`)
|
||||
|
||||
<!-- RELEASE_VERSION -->
|
||||
You can also download the JAR (latest release) directly from [maven.org](https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.0.1/openapi-generator-cli-6.0.1.jar)
|
||||
You can also download the JAR (latest release) directly from [maven.org](https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.4.0/openapi-generator-cli-5.4.0.jar)
|
||||
<!-- /RELEASE_VERSION -->
|
||||
|
||||
To get a list of **general** options available, please run `java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help generate`
|
||||
@@ -578,7 +562,6 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- [Aalborg University](https://www.aau.dk)
|
||||
- [Adaptant Solutions AG](https://www.adaptant.io/)
|
||||
- [adesso SE](https://www.adesso.de/)
|
||||
- [Adyen](https://www.adyen.com/)
|
||||
- [Agoda](https://www.agoda.com/)
|
||||
- [Airthings](https://www.airthings.com/)
|
||||
- [Allianz](https://www.allianz.com)
|
||||
@@ -607,7 +590,6 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- [Cupix](https://www.cupix.com/)
|
||||
- [Datadog](https://www.datadoghq.com)
|
||||
- [DB Systel](https://www.dbsystel.de)
|
||||
- [Deeporute.ai](https://www.deeproute.ai/)
|
||||
- [Devsupply](https://www.devsupply.com/)
|
||||
- [DocSpring](https://docspring.com/)
|
||||
- [dwango](https://dwango.co.jp/)
|
||||
@@ -615,7 +597,6 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- [Element AI](https://www.elementai.com/)
|
||||
- [Embotics](https://www.embotics.com/)
|
||||
- [emineo](https://www.emineo.ch)
|
||||
- [fastly](https://www.fastly.com/)
|
||||
- [Fenergo](https://www.fenergo.com/)
|
||||
- [freee](https://corp.freee.co.jp/en/)
|
||||
- [FreshCells](https://www.freshcells.de/)
|
||||
@@ -665,7 +646,6 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- [Prometheus/Alertmanager](https://github.com/prometheus/alertmanager)
|
||||
- [Qavar](https://www.qavar.com)
|
||||
- [QEDIT](https://qed-it.com)
|
||||
- [Qovery](https://qovery.com)
|
||||
- [Qulix Systems](https://www.qulix.com)
|
||||
- [Raksul](https://corp.raksul.com)
|
||||
- [Raiffeisen Schweiz Genossenschaft](https://www.raiffeisen.ch)
|
||||
@@ -684,7 +664,6 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- [Translucent ApS](https://www.translucent.dk)
|
||||
- [TravelTime platform](https://www.traveltimeplatform.com/)
|
||||
- [TribalScale](https://www.tribalscale.com)
|
||||
- [Trifork](https://trifork.com)
|
||||
- [TUI InfoTec GmbH](http://www.tui-infotec.com/)
|
||||
- [Twitter](https://twitter.com)
|
||||
- [unblu inc.](https://www.unblu.com/)
|
||||
@@ -701,7 +680,6 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- [YITU Technology](https://www.yitutech.com/)
|
||||
- [Yelp](https://www.yelp.com/)
|
||||
- [Zalando](https://www.zalando.com)
|
||||
- [3DS Outscale](https://www.outscale.com/)
|
||||
|
||||
## [5 - Presentations/Videos/Tutorials/Books](#table-of-contents)
|
||||
|
||||
@@ -869,8 +847,6 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- 2022-03-15 - [OpenAPI Specでハイフン区切りのEnum値をOpenAPI Generatorで出力すると、ハイフン区切りのまま出力される](https://qiita.com/yuji38kwmt/items/824d74d4889055ab37d8) by [yuji38kwmt](https://qiita.com/yuji38kwmt)
|
||||
- 2022-04-01 - [OpenAPI Generatorのコード生成とSpring Frameworkのカスタムデータバインディングを共存させる](https://techblog.zozo.com/entry/coexistence-of-openapi-and-spring) in [ZOZO Tech Blog](https://techblog.zozo.com/)
|
||||
- 2022-04-06 - [Effective Software Development using OpenAPI Generator](https://apexlabs.ai/post/openapi-generator) by Ajil Oommen (Senior Flutter Developer)
|
||||
- 2022-05-13 - [A Path From an API To Client Libraries](https://www.youtube.com/watch?v=XC8oVn_efTw) by [Filip Srnec](https://www.devoxx.co.uk/talk/?id=11211) at Infobip
|
||||
- 2022-06-01 - [API First, using OpenAPI and Spring Boot](https://medium.com/xgeeks/api-first-using-openapi-and-spring-boot-2602c04bb0d3) by [Micael Estrázulas Vianna](https://estrazulas.medium.com/)
|
||||
|
||||
## [6 - About Us](#table-of-contents)
|
||||
|
||||
@@ -1019,7 +995,6 @@ Here is a list of template creators:
|
||||
* PHP Slim: @jfastnacht
|
||||
* PHP Slim4: [@ybelenko](https://github.com/ybelenko)
|
||||
* PHP Symfony: @ksm2
|
||||
* PHP Symfony6: @BenjaminHae
|
||||
* Python FastAPI: @krjakbrjak
|
||||
* Python AIOHTTP:
|
||||
* Ruby on Rails 5: @zlx
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
generatorName: aspnetcore
|
||||
outputDir: samples/server/petstore/aspnetcore-3.0
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/aspnetcore/petstore.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/aspnetcore/3.0
|
||||
additionalProperties:
|
||||
packageGuid: '{3C799344-F285-4669-8FD5-7ED9B795D5C5}'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
generatorName: aspnetcore
|
||||
outputDir: samples/server/petstore/aspnetcore-3.1
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/aspnetcore/petstore.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/aspnetcore/3.0
|
||||
additionalProperties:
|
||||
packageGuid: '{3C799344-F285-4669-8FD5-7ED9B795D5C5}'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
generatorName: aspnetcore
|
||||
outputDir: samples/server/petstore/aspnetcore-5.0
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/aspnetcore/petstore.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/aspnetcore/3.0
|
||||
additionalProperties:
|
||||
packageGuid: '{3C799344-F285-4669-8FD5-7ED9B795D5C5}'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
generatorName: aspnetcore
|
||||
outputDir: samples/server/petstore/aspnetcore-6.0
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/aspnetcore/petstore.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/aspnetcore/3.0
|
||||
additionalProperties:
|
||||
packageGuid: '{3C799344-F285-4669-8FD5-7ED9B795D5C5}'
|
||||
|
||||
@@ -9,5 +9,3 @@ typeMappings:
|
||||
additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
||||
enumUnknownDefaultCase: "true"
|
||||
reservedWordsMappings:
|
||||
class: "classField"
|
||||
@@ -8,5 +8,3 @@ additionalProperties:
|
||||
test: "spock"
|
||||
requiredPropertiesInConstructor: "true"
|
||||
useAuth: "false"
|
||||
generateControllerAsAbstract: "false"
|
||||
generateOperationsToReturnNotImplemented: "true"
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
generatorName: java
|
||||
outputDir: samples/client/petstore/java/okhttp-gson-group-parameter
|
||||
library: okhttp-gson
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/java/petstore-group-parameter.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/Java
|
||||
additionalProperties:
|
||||
artifactId: petstore-okhttp-gson-group-parameter
|
||||
hideGenerationTimestamp: "true"
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
useSingleRequestParameter: true
|
||||
@@ -1,9 +0,0 @@
|
||||
generatorName: kotlin
|
||||
outputDir: samples/client/petstore/kotlin-allOff-discriminator
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/issue_10792.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
|
||||
additionalProperties:
|
||||
artifactId: kotlin-allOff-discriminator
|
||||
serializableModel: "false"
|
||||
dateLibrary: java8
|
||||
enumUnknownDefaultCase: true
|
||||
@@ -1,6 +1,6 @@
|
||||
generatorName: typescript-angular
|
||||
outputDir: samples/client/petstore/typescript-angular/default
|
||||
outputDir: samples/client/petstore/typescript-angular-v2/default
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/typescript-angular
|
||||
additionalProperties:
|
||||
ngVersion: 13.3.2
|
||||
ngVersion: "2"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
generatorName: typescript-angular
|
||||
outputDir: samples/client/petstore/typescript-angular/npm
|
||||
outputDir: samples/client/petstore/typescript-angular-v4.3/npm
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/typescript-angular
|
||||
additionalProperties:
|
||||
npmVersion: 0.0.1
|
||||
ngVersion: 13.3.2
|
||||
ngVersion: "4.3"
|
||||
npmName: '@openapitools/angular2-typescript-petstore'
|
||||
npmRepository: https://skimdb.npmjs.com/registry
|
||||
snapshot: false
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
generatorName: typescript-angular
|
||||
outputDir: samples/client/petstore/typescript-angular/with-interfaces
|
||||
outputDir: samples/client/petstore/typescript-angular-v2/with-interfaces
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/typescript-angular
|
||||
additionalProperties:
|
||||
withInterfaces: "true"
|
||||
ngVersion: 13.3.2
|
||||
ngVersion: "2"
|
||||
|
||||
@@ -2,5 +2,3 @@ generatorName: scala-akka-http-server
|
||||
outputDir: samples/server/petstore/scala-akka-http-server
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/scala-akka-http-server
|
||||
additionalProperties:
|
||||
artifactId: openapi-scala-akka-http-server
|
||||
@@ -2,5 +2,3 @@ generatorName: php-laravel
|
||||
outputDir: samples/server/petstore/php-laravel
|
||||
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-laravel
|
||||
gitUserId: openapitools
|
||||
gitRepoId: petstore
|
||||
|
||||
@@ -2,5 +2,3 @@ generatorName: php-symfony
|
||||
outputDir: samples/server/petstore/php-symfony/SymfonyBundle-php
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/php-symfony
|
||||
gitUserId: openapitools
|
||||
gitRepoId: petstore
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
generatorName: python-experimental
|
||||
outputDir: samples/openapi3/client/3_0_3_unit_test/python-experimental
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/python-experimental
|
||||
additionalProperties:
|
||||
packageName: unit_test_api
|
||||
@@ -1,11 +1,6 @@
|
||||
generatorName: r
|
||||
outputDir: samples/client/petstore/R
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/r/petstore.yaml
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/r
|
||||
httpUserAgent: PetstoreAgent
|
||||
additionalProperties:
|
||||
packageName: petstore
|
||||
exceptionPackage: rlang
|
||||
useRlangExceptionHandling: true
|
||||
returnExceptionOnFailure: true
|
||||
errorObjectType: "ModelApiResponse"
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/openapi3/server/petstore/springboot-3
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
groupId: org.openapitools.openapi3
|
||||
documentationProvider: springdoc
|
||||
artifactId: springboot
|
||||
snapshotVersion: "true"
|
||||
useSpringBoot3: true
|
||||
useBeanValidation: true
|
||||
hideGenerationTimestamp: "true"
|
||||
@@ -4,7 +4,7 @@ library: spring-boot
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
documentationProvider: springdoc
|
||||
documentationProvider: springfox
|
||||
apiPackage: org.openapitools.virtualan.api
|
||||
modelPackage: org.openapitools.virtualan.model
|
||||
virtualService: true
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
generatorName: spring
|
||||
library: spring-cloud
|
||||
outputDir: samples/openapi3/client/petstore/spring-cloud-3
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
groupId: org.openapitools.openapi3
|
||||
documentationProvider: springdoc
|
||||
artifactId: spring-cloud-oas3
|
||||
useSpringBoot3: "true"
|
||||
interfaceOnly: "true"
|
||||
singleContentTypes: "true"
|
||||
hideGenerationTimestamp: "true"
|
||||
@@ -1,10 +0,0 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/client/petstore/spring-cloud-feign-without-url
|
||||
library: spring-cloud
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
documentationProvider: springfox
|
||||
artifactId: petstore-spring-cloud
|
||||
hideGenerationTimestamp: "true"
|
||||
useFeignClientUrl: "false"
|
||||
@@ -0,0 +1,10 @@
|
||||
generatorName: typescript-angular
|
||||
outputDir: samples/client/petstore/typescript-angular-v10-provided-in-root/builds/with-npm
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/typescript-angular
|
||||
additionalProperties:
|
||||
ngVersion: 10.0.0
|
||||
npmVersion: 1.0.0
|
||||
npmName: '@openapitools/typescript-angular-petstore'
|
||||
npmRepository: https://skimdb.npmjs.com/registry
|
||||
snapshot: false
|
||||
@@ -1,7 +1,6 @@
|
||||
generatorName: typescript-angular
|
||||
outputDir: samples/client/petstore/typescript-angular-v13-provided-in-any/builds/default
|
||||
outputDir: samples/client/petstore/typescript-angular-v10-provided-in-root/builds/default
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/typescript-angular
|
||||
additionalProperties:
|
||||
ngVersion: 13.0.1
|
||||
providedIn: any
|
||||
ngVersion: 10.0.0
|
||||
@@ -1,6 +1,6 @@
|
||||
generatorName: typescript-angular
|
||||
outputDir: samples/client/petstore/typescript-angular-v12-oneOf/builds/default
|
||||
outputDir: samples/client/petstore/typescript-angular-v11-oneOf/builds/default
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOfArrayMapImport.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/typescript-angular
|
||||
additionalProperties:
|
||||
ngVersion: 12.2.0
|
||||
ngVersion: 11.0.0
|
||||
@@ -0,0 +1,10 @@
|
||||
generatorName: typescript-angular
|
||||
outputDir: samples/client/petstore/typescript-angular-v11-provided-in-root/builds/with-npm
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/typescript-angular
|
||||
additionalProperties:
|
||||
ngVersion: 11.0.0
|
||||
npmVersion: 1.0.0
|
||||
npmName: '@openapitools/typescript-angular-petstore'
|
||||
npmRepository: https://skimdb.npmjs.com/registry
|
||||
snapshot: false
|
||||
6
bin/configs/typescript-angular-v11-provided-in-root.yaml
Normal file
6
bin/configs/typescript-angular-v11-provided-in-root.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
generatorName: typescript-angular
|
||||
outputDir: samples/client/petstore/typescript-angular-v11-provided-in-root/builds/default
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/typescript-angular
|
||||
additionalProperties:
|
||||
ngVersion: 11.0.0
|
||||
@@ -1,6 +0,0 @@
|
||||
generatorName: typescript-angular
|
||||
outputDir: samples/client/petstore/typescript-angular-v13-oneOf/builds/default
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOfArrayMapImport.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/typescript-angular
|
||||
additionalProperties:
|
||||
ngVersion: 13.0.1
|
||||
@@ -1,7 +1,7 @@
|
||||
generatorName: typescript-angular
|
||||
outputDir: samples/client/petstore/typescript-angular-v12-provided-in-any/builds/default
|
||||
outputDir: samples/client/petstore/typescript-angular-v9-provided-in-any/builds/default
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/typescript-angular
|
||||
additionalProperties:
|
||||
ngVersion: 12.2.0
|
||||
ngVersion: 9.0.0
|
||||
providedIn: any
|
||||
@@ -0,0 +1,10 @@
|
||||
generatorName: typescript-angular
|
||||
outputDir: samples/client/petstore/typescript-angular-v9-provided-in-root/builds/with-npm
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/typescript-angular
|
||||
additionalProperties:
|
||||
ngVersion: 9.0.0
|
||||
npmVersion: 1.0.0
|
||||
npmName: '@openapitools/typescript-angular-petstore'
|
||||
npmRepository: https://skimdb.npmjs.com/registry
|
||||
snapshot: false
|
||||
6
bin/configs/typescript-angular-v9-provided-in-root.yaml
Normal file
6
bin/configs/typescript-angular-v9-provided-in-root.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
generatorName: typescript-angular
|
||||
outputDir: samples/client/petstore/typescript-angular-v9-provided-in-root/builds/default
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/typescript-angular
|
||||
additionalProperties:
|
||||
ngVersion: 9.0.0
|
||||
@@ -55,8 +55,6 @@ else
|
||||
echo "Please press CTRL+C to stop or the script will continue in 5 seconds."
|
||||
|
||||
sleep 5
|
||||
# delete the 3_0_3 python-experimental tests because they are autogenerated our tooling needs to see differences
|
||||
rm -rf "${root}/samples/openapi3/client/3_0_3_unit_test/python-experimental/test"
|
||||
|
||||
if [ ${#files[@]} -eq 0 ]; then
|
||||
files=("${root}"/bin/configs/*.yaml)
|
||||
|
||||
@@ -38,7 +38,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| Type/Alias | Imports |
|
||||
| ---------- | ------- |
|
||||
|OAIHttpFileElement|#include "OAIHttpFileElement.h"|
|
||||
|QJsonValue|#include <QJsonValue>|
|
||||
|
||||
|
||||
## INSTANTIATION TYPES
|
||||
|
||||
@@ -54,7 +54,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<li>TArray</li>
|
||||
<li>TArray<uint8></li>
|
||||
<li>TMap</li>
|
||||
<li>TSet</li>
|
||||
<li>TSharedPtr<FJsonObject></li>
|
||||
<li>TSharedPtr<FJsonValue></li>
|
||||
<li>bool</li>
|
||||
|
||||
@@ -195,7 +195,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|BasicAuth|✓|OAS2,OAS3
|
||||
|ApiKey|✓|OAS2,OAS3
|
||||
|OpenIDConnect|✗|OAS3
|
||||
|BearerToken|✓|OAS3
|
||||
|BearerToken|✗|OAS3
|
||||
|OAuth2_Implicit|✓|OAS2,OAS3
|
||||
|OAuth2_Password|✗|OAS2,OAS3
|
||||
|OAuth2_ClientCredentials|✗|OAS2,OAS3
|
||||
|
||||
@@ -80,7 +80,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|scmUrl|SCM URL in generated pom.xml| |https://github.com/openapitools/openapi-generator|
|
||||
|serializableModel|boolean - toggle "implements Serializable" for generated models| |false|
|
||||
|singleContentTypes|Whether to select only one produces/consumes content-type by operation.| |false|
|
||||
|skipDefaultInterface|Whether to skip generation of default implementations for java8 interfaces| |false|
|
||||
|skipDefaultInterface|Whether to generate default implementations for java8 interfaces| |false|
|
||||
|snapshotVersion|Uses a SNAPSHOT version.|<dl><dt>**true**</dt><dd>Use a SnapShot Version</dd><dt>**false**</dt><dd>Use a Release Version</dd></dl>|null|
|
||||
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||
@@ -89,9 +89,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|title|server title name or client service name| |OpenAPI Spring|
|
||||
|unhandledException|Declare operation methods to throw a generic exception and allow unhandled exceptions (useful for Spring `@ControllerAdvice` directives).| |false|
|
||||
|useBeanValidation|Use BeanValidation API annotations| |true|
|
||||
|useFeignClientUrl|Whether to generate Feign client with url parameter.| |true|
|
||||
|useOptional|Use Optional container for optional parameters| |false|
|
||||
|useSpringBoot3|Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports).| |true|
|
||||
|useSpringController|Annotate the generated API as a Spring Controller| |false|
|
||||
|useSwaggerUI|Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies| |true|
|
||||
|useTags|use tags for creating interface and controller classnames| |false|
|
||||
|
||||
@@ -22,9 +22,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |org.openapitools.api|
|
||||
|applicationName|Micronaut application name (Defaults to the artifactId value)| |openapi-micronaut-client|
|
||||
|artifactDescription|artifact description in generated pom.xml| |OpenAPI Java|
|
||||
|artifactId|artifactId in generated pom.xml. This also becomes part of the generated library's filename| |openapi-micronaut-client|
|
||||
|artifactId|artifactId in generated pom.xml. This also becomes part of the generated library's filename| |openapi-micronaut|
|
||||
|artifactUrl|artifact URL in generated pom.xml| |https://github.com/openapitools/openapi-generator|
|
||||
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename| |1.0.0|
|
||||
|bigDecimalAsString|Treat BigDecimal values as Strings to avoid precision loss.| |false|
|
||||
@@ -44,8 +43,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.</dd></dl>|false|
|
||||
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|
||||
|generateOperationOnlyForFirstTag|When false, the operation method will be duplicated in each of the tags if multiple tags are assigned to this operation. If true, each operation will be generated only once in the first assigned tag.| |false|
|
||||
|generateSwaggerAnnotations|Specify if you want to generate swagger annotations and which version|<dl><dt>**swagger2**</dt><dd>Use io.swagger.core.v3:swagger-annotations for annotating operations and schemas</dd><dt>**true**</dt><dd>Equivalent to "swagger2"</dd><dt>**false**</dt><dd>Do not generate swagger annotations</dd><dt>**swagger1**</dt><dd>Use io.swagger:swagger-annotations for annotating operations and schemas</dd></dl>|false|
|
||||
|groupId|groupId in generated pom.xml| |org.openapitools|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |false|
|
||||
|ignoreAnyOfInEnum|Ignore anyOf keyword in enum| |false|
|
||||
@@ -55,7 +52,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|licenseName|The name of the license| |Unlicense|
|
||||
|licenseUrl|The URL of the license| |http://unlicense.org|
|
||||
|micronautVersion|Micronaut version, only >=3.0.0 versions are supported| |3.4.3|
|
||||
|micronautVersion|Micronaut version, only >=3.0.0 versions are supported| |3.3.1|
|
||||
|modelPackage|package for generated models| |org.openapitools.model|
|
||||
|openApiNullable|Enable OpenAPI Jackson Nullable library| |true|
|
||||
|parentArtifactId|parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null|
|
||||
|
||||
@@ -21,7 +21,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations)| |null|
|
||||
|additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|applicationName|Micronaut application name (Defaults to the artifactId value)| |openapi-micronaut|
|
||||
|artifactDescription|artifact description in generated pom.xml| |OpenAPI Java|
|
||||
|artifactId|artifactId in generated pom.xml. This also becomes part of the generated library's filename| |openapi-micronaut|
|
||||
|artifactUrl|artifact URL in generated pom.xml| |https://github.com/openapitools/openapi-generator|
|
||||
@@ -45,9 +44,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|fullJavaUtil|whether to use fully qualified name for classes under java.util. This option only works for Java API client| |false|
|
||||
|generateControllerAsAbstract|Generate an abstract class for controller to be extended. (apiPackage is then used for the abstract class, and controllerPackage is used for implementation that extends it.)| |false|
|
||||
|generateControllerFromExamples|Generate the implementation of controller and tests from parameter and return examples that will verify that the api works as desired (for testing)| |false|
|
||||
|generateOperationOnlyForFirstTag|When false, the operation method will be duplicated in each of the tags if multiple tags are assigned to this operation. If true, each operation will be generated only once in the first assigned tag.| |true|
|
||||
|generateOperationsToReturnNotImplemented|Return HTTP 501 Not Implemented instead of an empty response in the generated controller methods.| |true|
|
||||
|generateSwaggerAnnotations|Specify if you want to generate swagger annotations and which version|<dl><dt>**swagger2**</dt><dd>Use io.swagger.core.v3:swagger-annotations for annotating operations and schemas</dd><dt>**true**</dt><dd>Equivalent to "swagger2"</dd><dt>**false**</dt><dd>Do not generate swagger annotations</dd><dt>**swagger1**</dt><dd>Use io.swagger:swagger-annotations for annotating operations and schemas</dd></dl>|swagger2|
|
||||
|groupId|groupId in generated pom.xml| |org.openapitools|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |false|
|
||||
|ignoreAnyOfInEnum|Ignore anyOf keyword in enum| |false|
|
||||
@@ -57,7 +53,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|licenseName|The name of the license| |Unlicense|
|
||||
|licenseUrl|The URL of the license| |http://unlicense.org|
|
||||
|micronautVersion|Micronaut version, only >=3.0.0 versions are supported| |3.4.3|
|
||||
|micronautVersion|Micronaut version, only >=3.0.0 versions are supported| |3.3.1|
|
||||
|modelPackage|package for generated models| |org.openapitools.model|
|
||||
|openApiNullable|Enable OpenAPI Jackson Nullable library| |true|
|
||||
|parentArtifactId|parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null|
|
||||
|
||||
@@ -85,7 +85,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|useRuntimeException|Use RuntimeException instead of Exception| |false|
|
||||
|useRxJava2|Whether to use the RxJava2 adapter with the retrofit2 library. IMPORTANT: This option has been deprecated.| |false|
|
||||
|useRxJava3|Whether to use the RxJava3 adapter with the retrofit2 library. IMPORTANT: This option has been deprecated.| |false|
|
||||
|useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter. ONLY jersey2, jersey3, okhttp-gson support this option.| |false|
|
||||
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
|
||||
|
||||
## SUPPORTED VENDOR EXTENSIONS
|
||||
|
||||
@@ -47,7 +47,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|implicitHeadersRegex|Skip header parameters that matches given regex in the generated API methods using @ApiImplicitParams annotation. Note: this parameter is ignored when implicitHeaders=true| |null|
|
||||
|invokerPackage|root package for generated code| |org.openapitools.api|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|library|library template (sub-template)|<dl><dt>**jersey1**</dt><dd>Jersey core 1.x</dd><dt>**jersey2**</dt><dd>Jersey core 2.x</dd></dl>|jersey2|
|
||||
|library|library template (sub-template)|<dl><dt>**jersey1**</dt><dd>Jersey core 1.x</dd><dt>**jersey2**</dt><dd>Jersey core 2.x</dd><dt>**jersey3**</dt><dd>Jersey core 3.x</dd></dl>|jersey2|
|
||||
|licenseName|The name of the license| |Unlicense|
|
||||
|licenseUrl|The URL of the license| |http://unlicense.org|
|
||||
|modelPackage|package for generated models| |org.openapitools.model|
|
||||
|
||||
@@ -26,12 +26,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase|
|
||||
|generateRoomModels|Generate Android Room database models in addition to API models (JVM Volley library only)| |false|
|
||||
|groupId|Generated artifact package's organization (i.e. maven groupId).| |org.openapitools|
|
||||
|idea|Add IntellJ Idea plugin and mark Kotlin main and test folders as source folders.| |false|
|
||||
|library|Library template (sub-template) to use|<dl><dt>**jvm-ktor**</dt><dd>Platform: Java Virtual Machine. HTTP client: Ktor 1.6.7. JSON processing: Gson, Jackson (default).</dd><dt>**jvm-okhttp4**</dt><dd>[DEFAULT] Platform: Java Virtual Machine. HTTP client: OkHttp 4.2.0 (Android 5.0+ and Java 8+). JSON processing: Moshi 1.8.0.</dd><dt>**jvm-okhttp3**</dt><dd>Platform: Java Virtual Machine. HTTP client: OkHttp 3.12.4 (Android 2.3+ and Java 7+). JSON processing: Moshi 1.8.0.</dd><dt>**jvm-retrofit2**</dt><dd>Platform: Java Virtual Machine. HTTP client: Retrofit 2.6.2.</dd><dt>**multiplatform**</dt><dd>Platform: Kotlin multiplatform. HTTP client: Ktor 1.6.7. JSON processing: Kotlinx Serialization: 1.2.1.</dd><dt>**jvm-volley**</dt><dd>Platform: JVM for Android. HTTP client: Volley 1.2.1. JSON processing: gson 2.8.9</dd></dl>|jvm-okhttp4|
|
||||
|modelMutable|Create mutable models| |false|
|
||||
|moshiCodeGen|Whether to enable codegen with the Moshi library. Refer to the [official Moshi doc](https://github.com/square/moshi#codegen) for more info.| |false|
|
||||
|omitGradlePluginVersions|Whether to declare Gradle plugin versions in build files.| |false|
|
||||
|omitGradleWrapper|Whether to omit Gradle wrapper for creating a sub project.| |false|
|
||||
|packageName|Generated artifact package name.| |org.openapitools.client|
|
||||
|parcelizeModels|toggle "@Parcelize" for generated models| |null|
|
||||
|requestDateConverter|JVM-Option. Defines in how to handle date-time objects that are used for a request (as query or parameter)|<dl><dt>**toJson**</dt><dd>[DEFAULT] Date formatter option using a json converter.</dd><dt>**toString**</dt><dd>Use the 'toString'-method of the date-time object to retrieve the related string representation.</dd></dl>|toJson|
|
||||
|
||||
@@ -18,7 +18,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|errorObjectType|Error object type.| |null|
|
||||
|exceptionPackage|Specify the exception handling package|<dl><dt>**default**</dt><dd>Use stop() for raising exceptions.</dd><dt>**rlang**</dt><dd>Use rlang package for exceptions.</dd></dl>|default|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||
|packageName|R package name (convention: lowercase).| |openapi|
|
||||
@@ -52,7 +51,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<ul class="column-ul">
|
||||
<li>apiresponse</li>
|
||||
<li>break</li>
|
||||
<li>data_file</li>
|
||||
<li>else</li>
|
||||
<li>false</li>
|
||||
<li>for</li>
|
||||
|
||||
@@ -11,7 +11,7 @@ title: Documentation for the spring Generator
|
||||
| generator type | SERVER | |
|
||||
| generator language | Java | |
|
||||
| generator default templating engine | mustache | |
|
||||
| helpTxt | Generates a Java SpringBoot Server application using the SpringDoc integration. | |
|
||||
| helpTxt | Generates a Java SpringBoot Server application using the SpringFox integration. | |
|
||||
|
||||
## CONFIG OPTIONS
|
||||
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.
|
||||
@@ -73,7 +73,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|scmUrl|SCM URL in generated pom.xml| |https://github.com/openapitools/openapi-generator|
|
||||
|serializableModel|boolean - toggle "implements Serializable" for generated models| |false|
|
||||
|singleContentTypes|Whether to select only one produces/consumes content-type by operation.| |false|
|
||||
|skipDefaultInterface|Whether to skip generation of default implementations for java8 interfaces| |false|
|
||||
|skipDefaultInterface|Whether to generate default implementations for java8 interfaces| |false|
|
||||
|snapshotVersion|Uses a SNAPSHOT version.|<dl><dt>**true**</dt><dd>Use a SnapShot Version</dd><dt>**false**</dt><dd>Use a Release Version</dd></dl>|null|
|
||||
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||
@@ -82,9 +82,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|title|server title name or client service name| |OpenAPI Spring|
|
||||
|unhandledException|Declare operation methods to throw a generic exception and allow unhandled exceptions (useful for Spring `@ControllerAdvice` directives).| |false|
|
||||
|useBeanValidation|Use BeanValidation API annotations| |true|
|
||||
|useFeignClientUrl|Whether to generate Feign client with url parameter.| |true|
|
||||
|useOptional|Use Optional container for optional parameters| |false|
|
||||
|useSpringBoot3|Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports).| |true|
|
||||
|useSpringController|Annotate the generated API as a Spring Controller| |false|
|
||||
|useSwaggerUI|Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies| |true|
|
||||
|useTags|use tags for creating interface and controller classnames| |false|
|
||||
|
||||
@@ -53,7 +53,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|swiftUseApiNamespace|Flag to make all the API classes inner-class of {{projectName}}API| |null|
|
||||
|useBacktickEscapes|Escape reserved words using backticks (default: false)| |false|
|
||||
|useClasses|Use final classes for models instead of structs (default: false)| |false|
|
||||
|useJsonEncodable|Make models conform to JSONEncodable protocol (default: true)| |true|
|
||||
|useSPMFileStructure|Use SPM file structure and set the source path to Sources/{{projectName}} (default: false).| |null|
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
||||
@@ -103,18 +103,18 @@ docker run --rm \
|
||||
<!-- RELEASE_VERSION -->
|
||||
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum):
|
||||
|
||||
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.0.1/openapi-generator-cli-6.0.1.jar`
|
||||
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.3.0/openapi-generator-cli-5.3.0.jar`
|
||||
|
||||
For **Mac/Linux** users:
|
||||
|
||||
```bash
|
||||
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.0.1/openapi-generator-cli-6.0.1.jar -O openapi-generator-cli.jar
|
||||
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.3.0/openapi-generator-cli-5.3.0.jar -O openapi-generator-cli.jar
|
||||
```
|
||||
|
||||
For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
|
||||
|
||||
```powershell
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.0.1/openapi-generator-cli-6.0.1.jar
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.3.0/openapi-generator-cli-5.3.0.jar
|
||||
```
|
||||
<!-- /RELEASE_VERSION -->
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.0.0</version>
|
||||
<version>5.1.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.0.1</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -71,15 +71,9 @@ public class ConfigHelp extends OpenApiGeneratorCommand {
|
||||
@Option(name = {"--import-mappings"}, title = "import mappings", description = "displays the default import mappings (types and aliases, and what imports they will pull into the template)")
|
||||
private Boolean importMappings;
|
||||
|
||||
@Option(name = {"--schema-mappings"}, title = "schema mappings", description = "display the schema mappings (none)")
|
||||
private Boolean schemaMappings;
|
||||
|
||||
@Option(name = {"--inline-schema-name-mappings"}, title = "inline schema name mappings", description = "displays the inline schema name mappings (none)")
|
||||
private Boolean inlineSchemaNameMappings;
|
||||
|
||||
@Option(name = {"--inline-schema-name-defaults"}, title = "inline schema name defaults", description = "default values used when naming inline schema name")
|
||||
private Boolean inlineSchemaNameDefaults;
|
||||
|
||||
@Option(name = {"--metadata"}, title = "metadata", description = "displays the generator metadata like the help txt for the generator and generator type etc")
|
||||
private Boolean metadata;
|
||||
|
||||
@@ -458,18 +452,6 @@ public class ConfigHelp extends OpenApiGeneratorCommand {
|
||||
sb.append(newline);
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(schemaMappings)) {
|
||||
sb.append(newline).append("SCHEMA MAPPING").append(newline).append(newline);
|
||||
Map<String, String> map = config.schemaMapping()
|
||||
.entrySet()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> {
|
||||
throw new IllegalStateException(String.format(Locale.ROOT, "Duplicated options! %s and %s", a, b));
|
||||
}, TreeMap::new));
|
||||
writePlainTextFromMap(sb, map, optIndent, optNestedIndent, "Scheme", "Mapped to");
|
||||
sb.append(newline);
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(inlineSchemaNameMappings)) {
|
||||
sb.append(newline).append("INLINE SCHEMA NAME MAPPING").append(newline).append(newline);
|
||||
Map<String, String> map = config.inlineSchemaNameMapping()
|
||||
@@ -482,18 +464,6 @@ public class ConfigHelp extends OpenApiGeneratorCommand {
|
||||
sb.append(newline);
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(inlineSchemaNameDefaults)) {
|
||||
sb.append(newline).append("INLINE SCHEMA NAME DEFAULTS").append(newline).append(newline);
|
||||
Map<String, String> map = config.inlineSchemaNameDefault()
|
||||
.entrySet()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> {
|
||||
throw new IllegalStateException(String.format(Locale.ROOT, "Duplicated options! %s and %s", a, b));
|
||||
}, TreeMap::new));
|
||||
writePlainTextFromMap(sb, map, optIndent, optNestedIndent, "Inline scheme naming convention", "Defaulted to");
|
||||
sb.append(newline);
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(instantiationTypes)) {
|
||||
sb.append(newline).append("INSTANTIATION TYPES").append(newline).append(newline);
|
||||
Map<String, String> map = config.instantiationTypes()
|
||||
|
||||
@@ -159,13 +159,6 @@ public class Generate extends OpenApiGeneratorCommand {
|
||||
+ " You can also have multiple occurrences of this option.")
|
||||
private List<String> importMappings = new ArrayList<>();
|
||||
|
||||
@Option(
|
||||
name = {"--schema-mappings"},
|
||||
title = "schema mappings",
|
||||
description = "specifies mappings between the schema and the new name in the format of schema_a=Cat,schema_b=Bird."
|
||||
+ " You can also have multiple occurrences of this option.")
|
||||
private List<String> schemaMappings = new ArrayList<>();
|
||||
|
||||
@Option(
|
||||
name = {"--inline-schema-name-mappings"},
|
||||
title = "inline schema name mappings",
|
||||
@@ -173,13 +166,6 @@ public class Generate extends OpenApiGeneratorCommand {
|
||||
+ " You can also have multiple occurrences of this option.")
|
||||
private List<String> inlineSchemaNameMappings = new ArrayList<>();
|
||||
|
||||
@Option(
|
||||
name = {"--inline-schema-name-defaults"},
|
||||
title = "inline schema name defaults",
|
||||
description = "specifies the default values used when naming inline schema as such array items in the format of arrayItemSuffix=_inner,mapItemSuffix=_value. "
|
||||
+ " ONLY arrayItemSuffix, mapItemSuffix at the moment.")
|
||||
private List<String> inlineSchemaNameDefaults = new ArrayList<>();
|
||||
|
||||
@Option(
|
||||
name = {"--server-variables"},
|
||||
title = "server variables",
|
||||
@@ -444,9 +430,7 @@ public class Generate extends OpenApiGeneratorCommand {
|
||||
}
|
||||
applyInstantiationTypesKvpList(instantiationTypes, configurator);
|
||||
applyImportMappingsKvpList(importMappings, configurator);
|
||||
applySchemaMappingsKvpList(schemaMappings, configurator);
|
||||
applyInlineSchemaNameMappingsKvpList(inlineSchemaNameMappings, configurator);
|
||||
applyInlineSchemaNameDefaultsKvpList(inlineSchemaNameDefaults, configurator);
|
||||
applyTypeMappingsKvpList(typeMappings, configurator);
|
||||
applyAdditionalPropertiesKvpList(additionalProperties, configurator);
|
||||
applyLanguageSpecificPrimitivesCsvList(languageSpecificPrimitives, configurator);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.0.1</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -50,11 +50,9 @@ public final class GeneratorSettings implements Serializable {
|
||||
private final Map<String, String> typeMappings;
|
||||
private final Map<String, Object> additionalProperties;
|
||||
private final Map<String, String> importMappings;
|
||||
private final Map<String, String> schemaMappings;
|
||||
private final Map<String, String> inlineSchemaNameMappings;
|
||||
private final Map<String, String> inlineSchemaNameDefaults;
|
||||
private final Set<String> languageSpecificPrimitives;
|
||||
private final Map<String, String> reservedWordsMappings;
|
||||
private final Map<String, String> reservedWordMappings;
|
||||
private final Map<String, String> serverVariables;
|
||||
|
||||
private String gitHost;
|
||||
@@ -237,15 +235,6 @@ public final class GeneratorSettings implements Serializable {
|
||||
return importMappings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets schema mappings between a schema and the new name.
|
||||
*
|
||||
* @return the schema mappings
|
||||
*/
|
||||
public Map<String, String> getSchemaMappings() {
|
||||
return schemaMappings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets inline schema name mappings between an inline schema name and the new name.
|
||||
*
|
||||
@@ -255,15 +244,6 @@ public final class GeneratorSettings implements Serializable {
|
||||
return inlineSchemaNameMappings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets inline schema name defaults between an inline schema naming convention and the default values.
|
||||
*
|
||||
* @return the inline schema name defaults
|
||||
*/
|
||||
public Map<String, String> getInlineSchemaNameDefaults() {
|
||||
return inlineSchemaNameDefaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets language specific primitives. These are in addition to the "base" primitives defined in a generator.
|
||||
* <p>
|
||||
@@ -288,8 +268,8 @@ public final class GeneratorSettings implements Serializable {
|
||||
*
|
||||
* @return the reserved word mappings
|
||||
*/
|
||||
public Map<String, String> getReservedWordsMappings() {
|
||||
return reservedWordsMappings;
|
||||
public Map<String, String> getReservedWordMappings() {
|
||||
return reservedWordMappings;
|
||||
}
|
||||
|
||||
|
||||
@@ -379,11 +359,9 @@ public final class GeneratorSettings implements Serializable {
|
||||
instantiationTypes = Collections.unmodifiableMap(builder.instantiationTypes);
|
||||
typeMappings = Collections.unmodifiableMap(builder.typeMappings);
|
||||
importMappings = Collections.unmodifiableMap(builder.importMappings);
|
||||
schemaMappings = Collections.unmodifiableMap(builder.schemaMappings);
|
||||
inlineSchemaNameMappings = Collections.unmodifiableMap(builder.inlineSchemaNameMappings);
|
||||
inlineSchemaNameDefaults = Collections.unmodifiableMap(builder.inlineSchemaNameDefaults);
|
||||
languageSpecificPrimitives = Collections.unmodifiableSet(builder.languageSpecificPrimitives);
|
||||
reservedWordsMappings = Collections.unmodifiableMap(builder.reservedWordsMappings);
|
||||
reservedWordMappings = Collections.unmodifiableMap(builder.reservedWordMappings);
|
||||
serverVariables = Collections.unmodifiableMap(builder.serverVariables);
|
||||
gitHost = builder.gitHost;
|
||||
gitUserId = builder.gitUserId;
|
||||
@@ -452,11 +430,9 @@ public final class GeneratorSettings implements Serializable {
|
||||
typeMappings = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
additionalProperties = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
importMappings = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
schemaMappings = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
inlineSchemaNameMappings = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
inlineSchemaNameDefaults = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
languageSpecificPrimitives = Collections.unmodifiableSet(new HashSet<>(0));
|
||||
reservedWordsMappings = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
reservedWordMappings = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
serverVariables = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
}
|
||||
|
||||
@@ -506,20 +482,14 @@ public final class GeneratorSettings implements Serializable {
|
||||
if (copy.getImportMappings() != null) {
|
||||
builder.importMappings.putAll(copy.getImportMappings());
|
||||
}
|
||||
if (copy.getSchemaMappings() != null) {
|
||||
builder.schemaMappings.putAll(copy.getSchemaMappings());
|
||||
}
|
||||
if (copy.getInlineSchemaNameMappings() != null) {
|
||||
builder.inlineSchemaNameMappings.putAll(copy.getInlineSchemaNameMappings());
|
||||
}
|
||||
if (copy.getInlineSchemaNameDefaults() != null) {
|
||||
builder.inlineSchemaNameDefaults.putAll(copy.getInlineSchemaNameDefaults());
|
||||
}
|
||||
if (copy.getLanguageSpecificPrimitives() != null) {
|
||||
builder.languageSpecificPrimitives.addAll(copy.getLanguageSpecificPrimitives());
|
||||
}
|
||||
if (copy.getReservedWordsMappings() != null) {
|
||||
builder.reservedWordsMappings.putAll(copy.getReservedWordsMappings());
|
||||
if (copy.getReservedWordMappings() != null) {
|
||||
builder.reservedWordMappings.putAll(copy.getReservedWordMappings());
|
||||
}
|
||||
if (copy.getServerVariables() != null) {
|
||||
builder.serverVariables.putAll(copy.getServerVariables());
|
||||
@@ -554,11 +524,9 @@ public final class GeneratorSettings implements Serializable {
|
||||
private Map<String, String> typeMappings;
|
||||
private Map<String, Object> additionalProperties;
|
||||
private Map<String, String> importMappings;
|
||||
private Map<String, String> schemaMappings;
|
||||
private Map<String, String> inlineSchemaNameMappings;
|
||||
private Map<String, String> inlineSchemaNameDefaults;
|
||||
private Set<String> languageSpecificPrimitives;
|
||||
private Map<String, String> reservedWordsMappings;
|
||||
private Map<String, String> reservedWordMappings;
|
||||
private Map<String, String> serverVariables;
|
||||
private String gitHost;
|
||||
private String gitUserId;
|
||||
@@ -574,11 +542,9 @@ public final class GeneratorSettings implements Serializable {
|
||||
typeMappings = new HashMap<>();
|
||||
additionalProperties = new HashMap<>();
|
||||
importMappings = new HashMap<>();
|
||||
schemaMappings = new HashMap<>();
|
||||
inlineSchemaNameMappings = new HashMap<>();
|
||||
inlineSchemaNameDefaults = new HashMap<>();
|
||||
languageSpecificPrimitives = new HashSet<>();
|
||||
reservedWordsMappings = new HashMap<>();
|
||||
reservedWordMappings = new HashMap<>();
|
||||
serverVariables = new HashMap<>();
|
||||
|
||||
gitHost = DEFAULT_GIT_HOST;
|
||||
@@ -793,32 +759,6 @@ public final class GeneratorSettings implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code schemaMappings} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param schemaMappings the {@code schemaMappings} to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withSchemaMappings(Map<String, String> schemaMappings) {
|
||||
this.schemaMappings = schemaMappings;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a single {@code schemaMappings} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param key A key for some schema mapping
|
||||
* @param value The value of some schema mapping
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withSchemaMapping(String key, String value) {
|
||||
if (this.schemaMappings == null) {
|
||||
this.schemaMappings = new HashMap<>();
|
||||
}
|
||||
this.schemaMappings.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code importMappings} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
@@ -845,32 +785,6 @@ public final class GeneratorSettings implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code inlineSchemaNameDefaults} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param inlineSchemaNameDefaults the {@code inlineSchemaNameDefaults} to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withInlineSchemaNameDefaults(Map<String, String> inlineSchemaNameDefaults) {
|
||||
this.inlineSchemaNameDefaults = inlineSchemaNameDefaults;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a single {@code inlineSchemaNameDefaults} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param key Default naming convention
|
||||
* @param value The value
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withInlineSchemaNameDefault(String key, String value) {
|
||||
if (this.inlineSchemaNameDefaults == null) {
|
||||
this.inlineSchemaNameDefaults = new HashMap<>();
|
||||
}
|
||||
this.inlineSchemaNameDefaults.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code inlineSchemaNameMappings} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
@@ -885,8 +799,8 @@ public final class GeneratorSettings implements Serializable {
|
||||
/**
|
||||
* Sets a single {@code inlineSchemaNameMappings} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param key A key for the inline schema mapping
|
||||
* @param value The value of inline schema mapping
|
||||
* @param key A key for some import mapping
|
||||
* @param value The value of some import mapping
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withInlineSchemaNameMapping(String key, String value) {
|
||||
@@ -923,28 +837,28 @@ public final class GeneratorSettings implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code reservedWordsMappings} and returns a reference to this Builder so that the methods can be chained together.
|
||||
* Sets the {@code reservedWordMappings} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param reservedWordsMappings the {@code reservedWordsMappings} to set
|
||||
* @param reservedWordMappings the {@code reservedWordMappings} to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withReservedWordsMappings(Map<String, String> reservedWordsMappings) {
|
||||
this.reservedWordsMappings = reservedWordsMappings;
|
||||
public Builder withReservedWordMappings(Map<String, String> reservedWordMappings) {
|
||||
this.reservedWordMappings = reservedWordMappings;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a single {@code reservedWordsMappings} and returns a reference to this Builder so that the methods can be chained together.
|
||||
* Sets a single {@code reservedWordMappings} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param key A key for some reserved word mapping
|
||||
* @param value The value of some reserved word mapping
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withReservedWordMapping(String key, String value) {
|
||||
if (this.reservedWordsMappings == null) {
|
||||
this.reservedWordsMappings = new HashMap<>();
|
||||
if (this.reservedWordMappings == null) {
|
||||
this.reservedWordMappings = new HashMap<>();
|
||||
}
|
||||
this.reservedWordsMappings.put(key, value);
|
||||
this.reservedWordMappings.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1052,7 +966,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
", additionalProperties=" + additionalProperties +
|
||||
", importMappings=" + importMappings +
|
||||
", languageSpecificPrimitives=" + languageSpecificPrimitives +
|
||||
", reservedWordsMappings=" + reservedWordsMappings +
|
||||
", reservedWordMappings=" + reservedWordMappings +
|
||||
", gitHost='" + gitHost + '\'' +
|
||||
", gitUserId='" + gitUserId + '\'' +
|
||||
", gitRepoId='" + gitRepoId + '\'' +
|
||||
@@ -1082,11 +996,9 @@ public final class GeneratorSettings implements Serializable {
|
||||
Objects.equals(getTypeMappings(), that.getTypeMappings()) &&
|
||||
Objects.equals(getAdditionalProperties(), that.getAdditionalProperties()) &&
|
||||
Objects.equals(getImportMappings(), that.getImportMappings()) &&
|
||||
Objects.equals(getSchemaMappings(), that.getSchemaMappings()) &&
|
||||
Objects.equals(getInlineSchemaNameMappings(), that.getInlineSchemaNameMappings()) &&
|
||||
Objects.equals(getInlineSchemaNameDefaults(), that.getInlineSchemaNameDefaults()) &&
|
||||
Objects.equals(getLanguageSpecificPrimitives(), that.getLanguageSpecificPrimitives()) &&
|
||||
Objects.equals(getReservedWordsMappings(), that.getReservedWordsMappings()) &&
|
||||
Objects.equals(getReservedWordMappings(), that.getReservedWordMappings()) &&
|
||||
Objects.equals(getGitHost(), that.getGitHost()) &&
|
||||
Objects.equals(getGitUserId(), that.getGitUserId()) &&
|
||||
Objects.equals(getGitRepoId(), that.getGitRepoId()) &&
|
||||
@@ -1113,11 +1025,9 @@ public final class GeneratorSettings implements Serializable {
|
||||
getTypeMappings(),
|
||||
getAdditionalProperties(),
|
||||
getImportMappings(),
|
||||
getSchemaMappings(),
|
||||
getInlineSchemaNameMappings(),
|
||||
getInlineSchemaNameDefaults(),
|
||||
getLanguageSpecificPrimitives(),
|
||||
getReservedWordsMappings(),
|
||||
getReservedWordMappings(),
|
||||
getGitHost(),
|
||||
getGitUserId(),
|
||||
getGitRepoId(),
|
||||
|
||||
@@ -97,7 +97,7 @@ task validateGoodSpec(type: org.openapitools.generator.gradle.plugin.tasks.Valid
|
||||
[source,group]
|
||||
----
|
||||
plugins {
|
||||
id "org.openapi.generator" version "6.0.1"
|
||||
id "org.openapi.generator" version "5.3.0"
|
||||
}
|
||||
----
|
||||
|
||||
@@ -113,7 +113,7 @@ buildscript {
|
||||
// url "https://plugins.gradle.org/m2/"
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:6.0.1"
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:5.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -695,7 +695,7 @@ buildscript {
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||
classpath('org.openapitools:openapi-generator-gradle-plugin:6.0.1') {
|
||||
classpath('org.openapitools:openapi-generator-gradle-plugin:5.3.0') {
|
||||
exclude group: 'com.google.guava'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=6.0.1
|
||||
openApiGeneratorVersion=6.0.0-SNAPSHOT
|
||||
# /RELEASE_VERSION
|
||||
|
||||
# BEGIN placeholders
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.0.1</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -18,5 +18,5 @@ gradle generateGoWithInvalidSpec # expected outcome: BUILD FAILED
|
||||
The samples can be tested against other versions of the plugin using the `openApiGeneratorVersion` property. For example:
|
||||
|
||||
```bash
|
||||
gradle -PopenApiGeneratorVersion=6.0.1 openApiValidate
|
||||
gradle -PopenApiGeneratorVersion=5.3.0 openApiValidate
|
||||
```
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=6.0.1
|
||||
openApiGeneratorVersion=6.0.0-SNAPSHOT
|
||||
# /RELEASE_VERSION
|
||||
|
||||
@@ -113,9 +113,7 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
|
||||
serverVariables.set(generate.serverVariables)
|
||||
languageSpecificPrimitives.set(generate.languageSpecificPrimitives)
|
||||
importMappings.set(generate.importMappings)
|
||||
schemaMappings.set(generate.schemaMappings)
|
||||
inlineSchemaNameMappings.set(generate.inlineSchemaNameMappings)
|
||||
inlineSchemaNameDefaults.set(generate.inlineSchemaNameDefaults)
|
||||
invokerPackage.set(generate.invokerPackage)
|
||||
groupId.set(generate.groupId)
|
||||
id.set(generate.id)
|
||||
|
||||
@@ -141,21 +141,11 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
|
||||
*/
|
||||
val importMappings = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* Specifies mappings between a given schema and the new one
|
||||
*/
|
||||
val schemaMappings = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* Specifies mappings between an inline schema name and the new name
|
||||
*/
|
||||
val inlineSchemaNameMappings = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* Specifies default values for inline schema naming convention
|
||||
*/
|
||||
val inlineSchemaNameDefaults = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* Root package for generated code.
|
||||
*/
|
||||
|
||||
@@ -219,13 +219,6 @@ open class GenerateTask : DefaultTask() {
|
||||
@Input
|
||||
val importMappings = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* Specifies mappings between a given schema and the new one.
|
||||
*/
|
||||
@Optional
|
||||
@Input
|
||||
val schemaMappings = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* Specifies mappings between the inline scheme name and the new name
|
||||
*/
|
||||
@@ -233,13 +226,6 @@ open class GenerateTask : DefaultTask() {
|
||||
@Input
|
||||
val inlineSchemaNameMappings = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* Specifies default values for inline schema naming convention
|
||||
*/
|
||||
@Optional
|
||||
@Input
|
||||
val inlineSchemaNameDefaults = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* Root package for generated code.
|
||||
*/
|
||||
@@ -699,24 +685,12 @@ open class GenerateTask : DefaultTask() {
|
||||
}
|
||||
}
|
||||
|
||||
if (schemaMappings.isPresent) {
|
||||
schemaMappings.get().forEach { entry ->
|
||||
configurator.addSchemaMapping(entry.key, entry.value)
|
||||
}
|
||||
}
|
||||
|
||||
if (inlineSchemaNameMappings.isPresent) {
|
||||
inlineSchemaNameMappings.get().forEach { entry ->
|
||||
configurator.addInlineSchemaNameMapping(entry.key, entry.value)
|
||||
}
|
||||
}
|
||||
|
||||
if (inlineSchemaNameDefaults.isPresent) {
|
||||
inlineSchemaNameDefaults.get().forEach { entry ->
|
||||
configurator.addInlineSchemaNameDefault(entry.key, entry.value)
|
||||
}
|
||||
}
|
||||
|
||||
if (typeMappings.isPresent) {
|
||||
typeMappings.get().forEach { entry ->
|
||||
configurator.addTypeMapping(entry.key, entry.value)
|
||||
|
||||
@@ -12,7 +12,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.0.1</version>
|
||||
<version>5.4.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.0.1</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.0.1</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.0.1</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.0.1</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.0.1</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.0.1</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.0.1</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
invoker.goals = -nsu clean generate-sources
|
||||
# The expected result of the build, possible values are "success" (default) and "failure"
|
||||
invoker.buildResult = success
|
||||
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2022 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.openapitools.maven.its</groupId>
|
||||
<artifactId>jaxrs-jersey3</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.javadoc.skip>true</maven.javadoc.skip>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.10.1</version>
|
||||
<configuration>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>@project.groupId@</groupId>
|
||||
<artifactId>@project.artifactId@</artifactId>
|
||||
<version>@project.version@</version>
|
||||
<configuration>
|
||||
<inputSpec>https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml</inputSpec>
|
||||
<generatorName>jaxrs-jersey</generatorName>
|
||||
<library>jersey3</library>
|
||||
<dateLibrary>java8</dateLibrary>
|
||||
<output>${basedir}/out</output>
|
||||
<templateDirectory>${project.basedir}/templates</templateDirectory>
|
||||
<configOptions>
|
||||
</configOptions>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>remote</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
21
modules/openapi-generator-maven-plugin/src/it/jaxrs-jersey3/templates/README.mustache
vendored
Normal file
21
modules/openapi-generator-maven-plugin/src/it/jaxrs-jersey3/templates/README.mustache
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# TEST TEST TEST
|
||||
|
||||
# {{artifactId}}
|
||||
|
||||
{{appName}}
|
||||
|
||||
- API version: {{appVersion}}
|
||||
{{^hideGenerationTimestamp}}
|
||||
|
||||
- Build date: {{generatedDate}}
|
||||
{{/hideGenerationTimestamp}}
|
||||
|
||||
{{#appDescriptionWithNewLines}}{{{appDescriptionWithNewLines}}}{{/appDescriptionWithNewLines}}
|
||||
|
||||
{{#infoUrl}}
|
||||
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
||||
{{/infoUrl}}
|
||||
|
||||
*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)*
|
||||
|
||||
… etc.
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2022 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
File readme = new File(basedir, "out/README.md")
|
||||
|
||||
assert readme.isFile()
|
||||
assert readme.text.contains("# TEST TEST TEST")
|
||||
assert readme.text.contains("# openapi-jaxrs-server")
|
||||
assert readme.text.contains("OpenAPI Petstore")
|
||||
|
||||
File mavenPomXml = new File(basedir, "out/pom.xml")
|
||||
assert mavenPomXml.isFile()
|
||||
|
||||
File petApi = new File(basedir, "out/src/gen/java/org/openapitools/api/PetApi.java")
|
||||
assert petApi.isFile()
|
||||
assert petApi.text.contains("import org.openapitools.api.PetApiService;")
|
||||
|
||||
File petApiService = new File(basedir, "out/src/gen/java/org/openapitools/api/PetApiService.java")
|
||||
assert petApiService.isFile()
|
||||
assert petApiService.text.contains("import jakarta.ws.rs.core.Response;")
|
||||
|
||||
File petModel = new File(basedir, "out/src/gen/java/org/openapitools/model/Pet.java")
|
||||
assert petModel.isFile()
|
||||
assert petModel.text.contains("public class Pet")
|
||||
@@ -298,24 +298,12 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
@Parameter(name = "importMappings", property = "openapi.generator.maven.plugin.importMappings")
|
||||
private List<String> importMappings;
|
||||
|
||||
/**
|
||||
* A map of scheme and the new one
|
||||
*/
|
||||
@Parameter(name = "schemaMappings", property = "openapi.generator.maven.plugin.schemaMappings")
|
||||
private List<String> schemaMappings;
|
||||
|
||||
/**
|
||||
* A map of inline scheme names and the new names
|
||||
*/
|
||||
@Parameter(name = "inlineSchemaNameMappings", property = "openapi.generator.maven.plugin.inlineSchemaNameMappings")
|
||||
private List<String> inlineSchemaNameMappings;
|
||||
|
||||
/**
|
||||
* A map of inline scheme naming convention and the value
|
||||
*/
|
||||
@Parameter(name = "inlineSchemaNameDefaults", property = "openapi.generator.maven.plugin.inlineSchemaNameDefaults")
|
||||
private List<String> inlineSchemaNameDefaults;
|
||||
|
||||
/**
|
||||
* A map of swagger spec types and the generated code types to use for them
|
||||
*/
|
||||
@@ -343,7 +331,7 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
/**
|
||||
* A map of reserved names and how they should be escaped
|
||||
*/
|
||||
@Parameter(name = "reservedWordsMappings", property = "openapi.generator.maven.plugin.reservedWordsMappings")
|
||||
@Parameter(name = "reservedWordsMappings", property = "openapi.generator.maven.plugin.reservedWordMappings")
|
||||
private List<String> reservedWordsMappings;
|
||||
|
||||
/**
|
||||
@@ -677,24 +665,12 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
configurator);
|
||||
}
|
||||
|
||||
// Retained for backwards-compatibility with configOptions -> schema-mappings
|
||||
if (schemaMappings == null && configOptions.containsKey("schema-mappings")) {
|
||||
applySchemaMappingsKvp(configOptions.get("schema-mappings").toString(),
|
||||
configurator);
|
||||
}
|
||||
|
||||
// Retained for backwards-compatibility with configOptions -> inline-schema-name-mappings
|
||||
if (inlineSchemaNameMappings == null && configOptions.containsKey("inline-schema-name-mappings")) {
|
||||
if (importMappings == null && configOptions.containsKey("inline-schema-name-mappings")) {
|
||||
applyInlineSchemaNameMappingsKvp(configOptions.get("inline-schema-name-mappings").toString(),
|
||||
configurator);
|
||||
}
|
||||
|
||||
// Retained for backwards-compatibility with configOptions -> inline-schema-name-defaults
|
||||
if (inlineSchemaNameDefaults == null && configOptions.containsKey("inline-schema-name-defaults")) {
|
||||
applyInlineSchemaNameDefaultsKvp(configOptions.get("inline-schema-name-defaults").toString(),
|
||||
configurator);
|
||||
}
|
||||
|
||||
// Retained for backwards-compatibility with configOptions -> type-mappings
|
||||
if (typeMappings == null && configOptions.containsKey("type-mappings")) {
|
||||
applyTypeMappingsKvp(configOptions.get("type-mappings").toString(), configurator);
|
||||
@@ -733,21 +709,11 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
applyImportMappingsKvpList(importMappings, configurator);
|
||||
}
|
||||
|
||||
// Apply Schema Mappings
|
||||
if (schemaMappings != null && (configOptions == null || !configOptions.containsKey("schema-mappings"))) {
|
||||
applySchemaMappingsKvpList(schemaMappings, configurator);
|
||||
}
|
||||
|
||||
// Apply Inline Schema Name Mappings
|
||||
if (inlineSchemaNameMappings != null && (configOptions == null || !configOptions.containsKey("inline-schema-name-mappings"))) {
|
||||
applyInlineSchemaNameMappingsKvpList(inlineSchemaNameMappings, configurator);
|
||||
}
|
||||
|
||||
// Apply Inline Schema Name Defaults
|
||||
if (inlineSchemaNameDefaults != null && (configOptions == null || !configOptions.containsKey("inline-schema-name-defaults"))) {
|
||||
applyInlineSchemaNameDefaultsKvpList(inlineSchemaNameDefaults, configurator);
|
||||
}
|
||||
|
||||
// Apply Type Mappings
|
||||
if (typeMappings != null && (configOptions == null || !configOptions.containsKey("type-mappings"))) {
|
||||
applyTypeMappingsKvpList(typeMappings, configurator);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.0.1</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.0.1</version>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -141,12 +141,8 @@ public interface CodegenConfig {
|
||||
|
||||
Map<String, String> importMapping();
|
||||
|
||||
Map<String, String> schemaMapping();
|
||||
|
||||
Map<String, String> inlineSchemaNameMapping();
|
||||
|
||||
Map<String, String> inlineSchemaNameDefault();
|
||||
|
||||
Map<String, String> apiTemplateFiles();
|
||||
|
||||
Map<String, String> modelTemplateFiles();
|
||||
@@ -313,7 +309,7 @@ public interface CodegenConfig {
|
||||
|
||||
void setRemoveEnumValuePrefix(boolean removeEnumValuePrefix);
|
||||
|
||||
Schema unaliasSchema(Schema schema, Map<String, String> schemaMappings);
|
||||
Schema unaliasSchema(Schema schema, Map<String, String> usedImportMappings);
|
||||
|
||||
String defaultTemplatingEngine();
|
||||
|
||||
|
||||
@@ -398,7 +398,4 @@ public class CodegenConstants {
|
||||
public static final String USE_ONEOF_DISCRIMINATOR_LOOKUP_DESC = "Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and only one match in oneOf's schemas) will be skipped.";
|
||||
public static final String INIT_REQUIRED_VARS = "initRequiredVars";
|
||||
public static final String INIT_REQUIRED_VARS_DESC = "If set to true then the required variables are included as positional arguments in __init__ and _from_openapi_data methods. Note: this can break some composition use cases. To learn more read PR #8802.";
|
||||
|
||||
public static final String ERROR_OBJECT_TYPE = "errorObjectType";
|
||||
|
||||
}
|
||||
|
||||
@@ -109,7 +109,6 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
public Map<String, Object> vendorExtensions = new HashMap<>();
|
||||
private CodegenComposedSchemas composedSchemas;
|
||||
private boolean hasMultipleTypes = false;
|
||||
public HashMap<String, SchemaTestCase> testCases = new HashMap<>();
|
||||
|
||||
/**
|
||||
* The type of the value for the additionalProperties keyword in the OAS document.
|
||||
|
||||
@@ -27,7 +27,7 @@ public class CodegenOperation {
|
||||
public boolean hasAuthMethods, hasConsumes, hasProduces, hasParams, hasOptionalParams, hasRequiredParams,
|
||||
returnTypeIsPrimitive, returnSimpleType, subresourceOperation, isMap,
|
||||
isArray, isMultipart,
|
||||
isResponseBinary = false, isResponseFile = false, isResponseOptional = false, hasReference = false,
|
||||
isResponseBinary = false, isResponseFile = false, hasReference = false,
|
||||
isRestfulIndex, isRestfulShow, isRestfulCreate, isRestfulUpdate, isRestfulDestroy,
|
||||
isRestful, isDeprecated, isCallbackRequest, uniqueItems, hasDefaultResponse = false,
|
||||
hasErrorResponseObject; // if 4xx, 5xx responses have at least one error object defined
|
||||
@@ -302,7 +302,6 @@ public class CodegenOperation {
|
||||
sb.append(", isMultipart=").append(isMultipart);
|
||||
sb.append(", isResponseBinary=").append(isResponseBinary);
|
||||
sb.append(", isResponseFile=").append(isResponseFile);
|
||||
sb.append(", isResponseFile=").append(isResponseOptional);
|
||||
sb.append(", hasReference=").append(hasReference);
|
||||
sb.append(", hasDefaultResponse=").append(hasDefaultResponse);
|
||||
sb.append(", hasErrorResponseObject=").append(hasErrorResponseObject);
|
||||
@@ -378,7 +377,6 @@ public class CodegenOperation {
|
||||
isMultipart == that.isMultipart &&
|
||||
isResponseBinary == that.isResponseBinary &&
|
||||
isResponseFile == that.isResponseFile &&
|
||||
isResponseOptional == that.isResponseOptional &&
|
||||
hasReference == that.hasReference &&
|
||||
hasDefaultResponse == that.hasDefaultResponse &&
|
||||
hasErrorResponseObject == that.hasErrorResponseObject &&
|
||||
@@ -439,14 +437,14 @@ public class CodegenOperation {
|
||||
|
||||
return Objects.hash(responseHeaders, hasAuthMethods, hasConsumes, hasProduces, hasParams, hasOptionalParams,
|
||||
hasRequiredParams, returnTypeIsPrimitive, returnSimpleType, subresourceOperation, isMap,
|
||||
isArray, isMultipart, isResponseBinary, isResponseFile, isResponseOptional, hasReference,
|
||||
hasDefaultResponse, isRestfulIndex, isRestfulShow, isRestfulCreate, isRestfulUpdate, isRestfulDestroy,
|
||||
isRestful, isDeprecated, isCallbackRequest, uniqueItems, path, operationId, returnType, httpMethod,
|
||||
returnBaseType, returnContainer, summary, unescapedNotes, notes, baseName, defaultResponse,
|
||||
discriminator, consumes, produces, prioritizedContentTypes, servers, bodyParam, allParams, bodyParams,
|
||||
pathParams, queryParams, headerParams, formParams, cookieParams, requiredParams, optionalParams,
|
||||
authMethods, tags, responses, callbacks, imports, examples, requestBodyExamples, externalDocs,
|
||||
vendorExtensions, nickname, operationIdOriginal, operationIdLowerCase, operationIdCamelCase,
|
||||
operationIdSnakeCase, hasErrorResponseObject);
|
||||
isArray, isMultipart, isResponseBinary, isResponseFile, hasReference, hasDefaultResponse, isRestfulIndex,
|
||||
isRestfulShow, isRestfulCreate, isRestfulUpdate, isRestfulDestroy, isRestful, isDeprecated,
|
||||
isCallbackRequest, uniqueItems, path, operationId, returnType, httpMethod, returnBaseType,
|
||||
returnContainer, summary, unescapedNotes, notes, baseName, defaultResponse, discriminator, consumes,
|
||||
produces, prioritizedContentTypes, servers, bodyParam, allParams, bodyParams, pathParams, queryParams,
|
||||
headerParams, formParams, cookieParams, requiredParams, optionalParams, authMethods, tags,
|
||||
responses, callbacks, imports, examples, requestBodyExamples, externalDocs, vendorExtensions,
|
||||
nickname, operationIdOriginal, operationIdLowerCase, operationIdCamelCase, operationIdSnakeCase,
|
||||
hasErrorResponseObject);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.openapitools.codegen.CodegenDiscriminator.MappedModel;
|
||||
import org.openapitools.codegen.api.TemplatingEngineAdapter;
|
||||
import org.openapitools.codegen.config.GlobalSettings;
|
||||
import org.openapitools.codegen.examples.ExampleGenerator;
|
||||
import org.openapitools.codegen.languages.RustServerCodegen;
|
||||
import org.openapitools.codegen.meta.FeatureSet;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
@@ -153,12 +152,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
protected Set<String> reservedWords;
|
||||
protected Set<String> languageSpecificPrimitives = new HashSet<>();
|
||||
protected Map<String, String> importMapping = new HashMap<>();
|
||||
// a map to store the mappping between a schema and the new one
|
||||
protected Map<String, String> schemaMapping = new HashMap<>();
|
||||
// a map to store the mappping between inline schema and the name provided by the user
|
||||
protected Map<String, String> inlineSchemaNameMapping = new HashMap<>();
|
||||
// a map to store the inline schema naming conventions
|
||||
protected Map<String, String> inlineSchemaNameDefault = new HashMap<>();
|
||||
protected String modelPackage = "", apiPackage = "", fileSuffix;
|
||||
protected String modelNamePrefix = "", modelNameSuffix = "";
|
||||
protected String apiNamePrefix = "", apiNameSuffix = "Api";
|
||||
@@ -1062,21 +1057,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return importMapping;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> schemaMapping() {
|
||||
return schemaMapping;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> inlineSchemaNameMapping() {
|
||||
return inlineSchemaNameMapping;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> inlineSchemaNameDefault() {
|
||||
return inlineSchemaNameDefault;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String testPackage() {
|
||||
return testPackage;
|
||||
@@ -1947,49 +1932,16 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the content type, style, and explode of the parameter based on the encoding specified
|
||||
* in the request body.
|
||||
* Sets the content type of the parameter based on the encoding specified in the request body.
|
||||
*
|
||||
* @param codegenParameter Codegen parameter
|
||||
* @param mediaType MediaType from the request body
|
||||
*/
|
||||
public void setParameterEncodingValues(CodegenParameter codegenParameter, MediaType mediaType) {
|
||||
public void setParameterContentType(CodegenParameter codegenParameter, MediaType mediaType) {
|
||||
if (mediaType != null && mediaType.getEncoding() != null) {
|
||||
Encoding encoding = mediaType.getEncoding().get(codegenParameter.baseName);
|
||||
if (encoding != null) {
|
||||
boolean styleGiven = true;
|
||||
Encoding.StyleEnum style = encoding.getStyle();
|
||||
if(style == null || style == Encoding.StyleEnum.FORM) {
|
||||
// (Unfortunately, swagger-parser-v3 will always provide 'form'
|
||||
// when style is not specified, so we can't detect that)
|
||||
style = Encoding.StyleEnum.FORM;
|
||||
styleGiven = false;
|
||||
}
|
||||
boolean explodeGiven = true;
|
||||
Boolean explode = encoding.getExplode();
|
||||
if(explode == null) {
|
||||
explode = style == Encoding.StyleEnum.FORM; // Default to True when form, False otherwise
|
||||
explodeGiven = false;
|
||||
}
|
||||
|
||||
if(!styleGiven && !explodeGiven) {
|
||||
// Ignore contentType if style or explode are specified.
|
||||
codegenParameter.contentType = encoding.getContentType();
|
||||
}
|
||||
|
||||
codegenParameter.style = style.toString();
|
||||
codegenParameter.isDeepObject = Encoding.StyleEnum.DEEP_OBJECT == style;
|
||||
|
||||
if(codegenParameter.isContainer) {
|
||||
codegenParameter.isExplode = explode;
|
||||
String collectionFormat = getCollectionFormat(codegenParameter);
|
||||
codegenParameter.collectionFormat = StringUtils.isEmpty(collectionFormat) ? "csv" : collectionFormat;
|
||||
codegenParameter.isCollectionFormatMulti = "multi".equals(collectionFormat);
|
||||
} else {
|
||||
codegenParameter.isExplode = false;
|
||||
codegenParameter.collectionFormat = null;
|
||||
codegenParameter.isCollectionFormatMulti = false;
|
||||
}
|
||||
codegenParameter.contentType = encoding.getContentType();
|
||||
} else {
|
||||
LOGGER.debug("encoding not specified for {}", codegenParameter.baseName);
|
||||
}
|
||||
@@ -2198,8 +2150,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Schema unaliasSchema(Schema schema, Map<String, String> schemaMappings) {
|
||||
return ModelUtils.unaliasSchema(this.openAPI, schema, schemaMappings);
|
||||
public Schema unaliasSchema(Schema schema, Map<String, String> usedImportMappings) {
|
||||
return ModelUtils.unaliasSchema(this.openAPI, schema, usedImportMappings);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2209,13 +2161,13 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* @return the string representation of the schema type.
|
||||
*/
|
||||
protected String getSingleSchemaType(Schema schema) {
|
||||
Schema unaliasSchema = unaliasSchema(schema, schemaMapping);
|
||||
Schema unaliasSchema = unaliasSchema(schema, importMapping);
|
||||
|
||||
if (StringUtils.isNotBlank(unaliasSchema.get$ref())) { // reference to another definition/schema
|
||||
// get the schema/model name from $ref
|
||||
String schemaName = ModelUtils.getSimpleRef(unaliasSchema.get$ref());
|
||||
if (StringUtils.isNotEmpty(schemaName)) {
|
||||
if (schemaMapping.containsKey(schemaName)) {
|
||||
if (importMapping.containsKey(schemaName)) {
|
||||
return schemaName;
|
||||
}
|
||||
return getAlias(schemaName);
|
||||
@@ -2311,8 +2263,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
} else if (ModelUtils.isAnyType(schema)) {
|
||||
return "AnyType";
|
||||
} else if (StringUtils.isNotEmpty(schema.getType())) {
|
||||
if (!schemaMapping.containsKey(schema.getType())) {
|
||||
LOGGER.warn("Unknown type found in the schema: {}. To map it, please use the schema mapping option (e.g. --schema-mappings in CLI)", schema.getType());
|
||||
if (!importMapping.containsKey(schema.getType())) {
|
||||
LOGGER.warn("Unknown type found in the schema: {}", schema.getType());
|
||||
}
|
||||
return schema.getType();
|
||||
}
|
||||
@@ -2538,7 +2490,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
m.interfaces = new ArrayList<>();
|
||||
|
||||
for (Schema interfaceSchema : interfaces) {
|
||||
interfaceSchema = unaliasSchema(interfaceSchema, schemaMapping);
|
||||
interfaceSchema = unaliasSchema(interfaceSchema, importMapping);
|
||||
|
||||
if (StringUtils.isBlank(interfaceSchema.get$ref())) {
|
||||
// primitive type
|
||||
@@ -2703,52 +2655,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
setAddProps(schema, m);
|
||||
}
|
||||
|
||||
protected String toTestCaseName(String specTestCaseName) {
|
||||
return specTestCaseName;
|
||||
}
|
||||
|
||||
/**
|
||||
* A method that allows generators to pre-process test example payloads
|
||||
* This can be useful if one needs to change how values like null in string are represnted
|
||||
* @param data the test data payload
|
||||
* @return the updated test data payload
|
||||
*/
|
||||
protected Object processTestExampleData(Object data) {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes any test cases if they exist in the components.x-test-examples vendor extensions
|
||||
* If they exist then cast them to java class instances and return them back in a map
|
||||
* @param schemaName the component schema name that the test cases are for
|
||||
* @param vendorExtensions the extensions that may or may not hold the data
|
||||
*/
|
||||
private HashMap<String, SchemaTestCase> extractSchemaTestCases(String schemaName, HashMap<String, Object> vendorExtensions) {
|
||||
String testExamplesKey = "x-schema-test-examples";
|
||||
// schemaName to a map of test case name to test case
|
||||
if (vendorExtensions == null || !vendorExtensions.containsKey(testExamplesKey)) {
|
||||
return null;
|
||||
}
|
||||
HashMap<String, SchemaTestCase> schemaTestCases = new HashMap<>();
|
||||
LinkedHashMap<String, Object> schemaNameToTestCases = (LinkedHashMap<String, Object>) vendorExtensions.get(testExamplesKey);
|
||||
|
||||
if (!schemaNameToTestCases.containsKey(schemaName)) {
|
||||
return null;
|
||||
}
|
||||
LinkedHashMap<String, LinkedHashMap<String, Object>> testNameToTesCase = (LinkedHashMap<String, LinkedHashMap<String, Object>>) schemaNameToTestCases.get(schemaName);
|
||||
for (Entry<String, LinkedHashMap<String, Object>> entry: testNameToTesCase.entrySet()) {
|
||||
LinkedHashMap<String, Object> testExample = (LinkedHashMap<String, Object>) entry.getValue();
|
||||
String nameInSnakeCase = toTestCaseName(entry.getKey());
|
||||
Object data = processTestExampleData(testExample.get("data"));
|
||||
SchemaTestCase testCase = new SchemaTestCase(
|
||||
(String) testExample.getOrDefault("description", ""),
|
||||
new ObjectWithTypeBooleans(data),
|
||||
(boolean) testExample.get("valid")
|
||||
);
|
||||
schemaTestCases.put(nameInSnakeCase, testCase);
|
||||
}
|
||||
return schemaTestCases;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert OAS Model object to Codegen Model object.
|
||||
@@ -2766,7 +2672,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
// unalias schema
|
||||
schema = unaliasSchema(schema, schemaMapping);
|
||||
schema = unaliasSchema(schema, importMapping);
|
||||
if (schema == null) {
|
||||
LOGGER.warn("Schema {} not found", name);
|
||||
return null;
|
||||
@@ -2774,11 +2680,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
CodegenModel m = CodegenModelFactory.newInstance(CodegenModelType.MODEL);
|
||||
ModelUtils.syncValidationProperties(schema, m);
|
||||
if (openAPI != null) {
|
||||
HashMap<String, Object> vendorExtensions = (HashMap<String, Object>) openAPI.getComponents().getExtensions();
|
||||
HashMap<String, SchemaTestCase> schemaTestCases = extractSchemaTestCases(name, vendorExtensions);
|
||||
m.testCases = schemaTestCases;
|
||||
}
|
||||
|
||||
if (reservedWords.contains(name)) {
|
||||
m.name = escapeReservedWord(name);
|
||||
@@ -3439,7 +3340,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
property.maxItems = p.getMaxProperties();
|
||||
|
||||
// handle inner property
|
||||
Schema innerSchema = unaliasSchema(getAdditionalProperties(p), schemaMapping);
|
||||
Schema innerSchema = unaliasSchema(getAdditionalProperties(p), importMapping);
|
||||
if (innerSchema == null) {
|
||||
LOGGER.error("Undefined map inner type for `{}`. Default to String.", p.getName());
|
||||
innerSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to undefined type");
|
||||
@@ -3542,7 +3443,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return cpc;
|
||||
}
|
||||
// unalias schema
|
||||
p = unaliasSchema(p, schemaMapping);
|
||||
p = unaliasSchema(p, importMapping);
|
||||
|
||||
CodegenProperty property = CodegenModelFactory.newInstance(CodegenModelType.PROPERTY);
|
||||
ModelUtils.syncValidationProperties(p, property);
|
||||
@@ -3710,7 +3611,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
itemName = property.name;
|
||||
}
|
||||
ArraySchema arraySchema = (ArraySchema) p;
|
||||
Schema innerSchema = unaliasSchema(getSchemaItems(arraySchema), schemaMapping);
|
||||
Schema innerSchema = unaliasSchema(getSchemaItems(arraySchema), importMapping);
|
||||
CodegenProperty cp = fromProperty(itemName, innerSchema);
|
||||
updatePropertyForArray(property, cp);
|
||||
} else if (ModelUtils.isTypeObjectSchema(p)) {
|
||||
@@ -3949,14 +3850,14 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* @param schemas a map of the schemas in the openapi spec
|
||||
* @param op endpoint CodegenOperation
|
||||
* @param methodResponse the default ApiResponse for the endpoint
|
||||
* @param schemaMappings mappings of external types to be omitted by unaliasing
|
||||
* @param importMappings mappings of external types to be omitted by unaliasing
|
||||
*/
|
||||
protected void handleMethodResponse(Operation operation,
|
||||
Map<String, Schema> schemas,
|
||||
CodegenOperation op,
|
||||
ApiResponse methodResponse,
|
||||
Map<String, String> schemaMappings) {
|
||||
Schema responseSchema = unaliasSchema(ModelUtils.getSchemaFromResponse(methodResponse), schemaMapping);
|
||||
Map<String, String> importMappings) {
|
||||
Schema responseSchema = unaliasSchema(ModelUtils.getSchemaFromResponse(methodResponse), importMapping);
|
||||
|
||||
if (responseSchema != null) {
|
||||
CodegenProperty cm = fromProperty("response", responseSchema);
|
||||
@@ -4143,13 +4044,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
op.hasErrorResponseObject = Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// check if the operation can both return a 2xx response with a body and without
|
||||
if (op.responses.stream().anyMatch(response -> response.is2xx && response.dataType != null) &&
|
||||
op.responses.stream().anyMatch(response -> response.is2xx && response.dataType == null)) {
|
||||
op.isResponseOptional = Boolean.TRUE;
|
||||
}
|
||||
|
||||
op.responses.sort((a, b) -> {
|
||||
int aScore = a.isWildcard() ? 2 : a.isRange() ? 1 : 0;
|
||||
int bScore = b.isWildcard() ? 2 : b.isRange() ? 1 : 0;
|
||||
@@ -4193,7 +4087,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
formParams = fromRequestBodyToFormParameters(requestBody, imports);
|
||||
op.isMultipart = contentType.startsWith("multipart");
|
||||
for (CodegenParameter cp : formParams) {
|
||||
setParameterEncodingValues(cp, requestBody.getContent().get(contentType));
|
||||
setParameterContentType(cp, requestBody.getContent().get(contentType));
|
||||
postProcessParameter(cp);
|
||||
}
|
||||
// add form parameters to the beginning of all parameter list
|
||||
@@ -4395,7 +4289,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
Schema responseSchema;
|
||||
if (this.openAPI != null && this.openAPI.getComponents() != null) {
|
||||
responseSchema = unaliasSchema(ModelUtils.getSchemaFromResponse(response), schemaMapping);
|
||||
responseSchema = unaliasSchema(ModelUtils.getSchemaFromResponse(response), importMapping);
|
||||
} else { // no model/alias defined
|
||||
responseSchema = ModelUtils.getSchemaFromResponse(response);
|
||||
}
|
||||
@@ -4681,24 +4575,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
Schema parameterSchema;
|
||||
|
||||
// the parameter model name is obtained from the schema $ref
|
||||
// e.g. #/components/schemas/list_pageQuery_parameter => toModelName(list_pageQuery_parameter)
|
||||
String parameterModelName = null;
|
||||
|
||||
if (parameter.getSchema() != null) {
|
||||
parameterSchema = parameter.getSchema();
|
||||
parameterModelName = getParameterDataType(parameter, parameterSchema);
|
||||
CodegenProperty prop;
|
||||
if (this instanceof RustServerCodegen) {
|
||||
// for rust server, we need to do somethings special as it uses
|
||||
// $ref (e.g. #components/schemas/Pet) to determine whether it's a model
|
||||
prop = fromProperty(parameter.getName(), parameterSchema);
|
||||
} else if (getUseInlineModelResolver()) {
|
||||
prop = fromProperty(parameter.getName(), getReferencedSchemaWhenNotEnum(parameterSchema));
|
||||
} else {
|
||||
prop = fromProperty(parameter.getName(), parameterSchema);
|
||||
}
|
||||
CodegenProperty prop = fromProperty(parameter.getName(), parameterSchema);
|
||||
codegenParameter.setSchema(prop);
|
||||
} else if (parameter.getContent() != null) {
|
||||
Content content = parameter.getContent();
|
||||
@@ -4708,7 +4587,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
Map.Entry<String, MediaType> entry = content.entrySet().iterator().next();
|
||||
codegenParameter.contentType = entry.getKey();
|
||||
parameterSchema = entry.getValue().getSchema();
|
||||
parameterModelName = getParameterDataType(parameter, parameterSchema);
|
||||
} else {
|
||||
parameterSchema = null;
|
||||
}
|
||||
@@ -4733,20 +4611,13 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return codegenParameter;
|
||||
}
|
||||
|
||||
// TODO need to reivew replacing empty map with schemaMapping instead
|
||||
parameterSchema = unaliasSchema(parameterSchema, Collections.emptyMap());
|
||||
if (parameterSchema == null) {
|
||||
LOGGER.warn("warning! Schema not found for parameter \" {} \"", parameter.getName());
|
||||
LOGGER.warn("warning! Schema not found for parameter \" {} \", using String", parameter.getName());
|
||||
parameterSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to missing type definition.");
|
||||
finishUpdatingParameter(codegenParameter, parameter);
|
||||
return codegenParameter;
|
||||
}
|
||||
|
||||
if (getUseInlineModelResolver() && !(this instanceof RustServerCodegen)) {
|
||||
// for rust server, we cannot run the following as it uses
|
||||
// $ref (e.g. #components/schemas/Pet) to determine whether it's a model
|
||||
parameterSchema = getReferencedSchemaWhenNotEnum(parameterSchema);
|
||||
}
|
||||
|
||||
ModelUtils.syncValidationProperties(parameterSchema, codegenParameter);
|
||||
codegenParameter.setTypeProperties(parameterSchema);
|
||||
codegenParameter.setComposedSchemas(getComposedSchemas(parameterSchema));
|
||||
@@ -4846,8 +4717,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
//}
|
||||
//codegenProperty.required = true;
|
||||
|
||||
if (parameterModelName != null) {
|
||||
codegenParameter.dataType = parameterModelName;
|
||||
String parameterDataType = this.getParameterDataType(parameter, parameterSchema);
|
||||
if (parameterDataType != null) {
|
||||
codegenParameter.dataType = parameterDataType;
|
||||
if (ModelUtils.isObjectSchema(parameterSchema)) {
|
||||
codegenProperty.complexType = codegenParameter.dataType;
|
||||
}
|
||||
@@ -4899,17 +4771,13 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// https://swagger.io/docs/specification/serialization/
|
||||
if (schema != null) {
|
||||
Map<String, Schema<?>> properties = schema.getProperties();
|
||||
if (properties != null) {
|
||||
codegenParameter.items.vars =
|
||||
properties.entrySet().stream()
|
||||
.map(entry -> {
|
||||
CodegenProperty property = fromProperty(entry.getKey(), entry.getValue());
|
||||
property.baseName = codegenParameter.baseName + "[" + entry.getKey() + "]";
|
||||
return property;
|
||||
}).collect(Collectors.toList());
|
||||
} else {
|
||||
//LOGGER.error("properties is null: {}", schema);
|
||||
}
|
||||
codegenParameter.items.vars =
|
||||
properties.entrySet().stream()
|
||||
.map(entry -> {
|
||||
CodegenProperty property = fromProperty(entry.getKey(), entry.getValue());
|
||||
property.baseName = codegenParameter.baseName + "[" + entry.getKey() + "]";
|
||||
return property;
|
||||
}).collect(Collectors.toList());
|
||||
} else {
|
||||
LOGGER.warn(
|
||||
"No object schema found for deepObject parameter{} deepObject won't have specific properties",
|
||||
@@ -4921,16 +4789,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return codegenParameter;
|
||||
}
|
||||
|
||||
private Schema getReferencedSchemaWhenNotEnum(Schema parameterSchema) {
|
||||
Schema referencedSchema = ModelUtils.getReferencedSchema(openAPI, parameterSchema);
|
||||
if (referencedSchema.getEnum() != null && !referencedSchema.getEnum().isEmpty()) {
|
||||
referencedSchema = parameterSchema;
|
||||
}
|
||||
return referencedSchema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data type of parameter.
|
||||
* Returns the data type of a parameter.
|
||||
* Returns null by default to use the CodegenProperty.datatype value
|
||||
*
|
||||
* @param parameter Parameter
|
||||
@@ -4938,9 +4798,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* @return data type
|
||||
*/
|
||||
protected String getParameterDataType(Parameter parameter, Schema schema) {
|
||||
Schema unaliasSchema = ModelUtils.unaliasSchema(openAPI, schema);
|
||||
if (unaliasSchema.get$ref() != null) {
|
||||
return toModelName(ModelUtils.getSimpleRef(unaliasSchema.get$ref()));
|
||||
if (parameter.get$ref() != null) {
|
||||
String refName = ModelUtils.getSimpleRef(parameter.get$ref());
|
||||
return toModelName(refName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -5303,13 +5163,13 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
addImport(m.imports, type);
|
||||
}
|
||||
|
||||
protected void addImport(Set<String> importsToBeAddedTo, String type) {
|
||||
private void addImport(Set<String> importsToBeAddedTo, String type) {
|
||||
if (shouldAddImport(type)) {
|
||||
importsToBeAddedTo.add(type);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean shouldAddImport(String type) {
|
||||
private boolean shouldAddImport(String type) {
|
||||
return type != null && needToImport(type);
|
||||
}
|
||||
|
||||
@@ -5322,7 +5182,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
protected Map<String, Schema> unaliasPropertySchema(Map<String, Schema> properties) {
|
||||
if (properties != null) {
|
||||
for (String key : properties.keySet()) {
|
||||
properties.put(key, unaliasSchema(properties.get(key), schemaMapping()));
|
||||
properties.put(key, unaliasSchema(properties.get(key), importMapping()));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6253,7 +6113,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// skip as it implies `consumes` in OAS2 is not defined
|
||||
continue;
|
||||
} else {
|
||||
mediaType.put("mediaType", escapeQuotationMark(key));
|
||||
mediaType.put("mediaType", escapeText(escapeQuotationMark(key)));
|
||||
}
|
||||
mediaTypeList.add(mediaType);
|
||||
}
|
||||
@@ -6319,7 +6179,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
for (String key : produces) {
|
||||
// escape quotation to avoid code injection, "*/*" is a special case, do nothing
|
||||
String encodedKey = "*/*".equals(key) ? key : escapeQuotationMark(key);
|
||||
String encodedKey = "*/*".equals(key) ? key : escapeText(escapeQuotationMark(key));
|
||||
//Only unique media types should be added to "produces"
|
||||
if (!existingMediaTypes.contains(encodedKey)) {
|
||||
Map<String, String> mediaType = new HashMap<>();
|
||||
@@ -6432,7 +6292,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
LOGGER.debug("Debugging fromFormProperty {}: {}", name, propertySchema);
|
||||
CodegenProperty codegenProperty = fromProperty(name, propertySchema);
|
||||
|
||||
Schema ps = unaliasSchema(propertySchema, schemaMapping);
|
||||
Schema ps = unaliasSchema(propertySchema, importMapping);
|
||||
ModelUtils.syncValidationProperties(ps, codegenParameter);
|
||||
codegenParameter.setTypeProperties(ps);
|
||||
codegenParameter.setComposedSchemas(getComposedSchemas(ps));
|
||||
@@ -6538,12 +6398,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
LOGGER.warn("Could not compute datatypeWithEnum from {}, {}", arrayInnerProperty.baseType, arrayInnerProperty.enumName);
|
||||
}
|
||||
// end of hoisting
|
||||
|
||||
// collectionFormat for form parameter does not consider
|
||||
// style and explode from encoding at this point
|
||||
//TODO fix collectionFormat for form parameters
|
||||
//collectionFormat = getCollectionFormat(s);
|
||||
String collectionFormat = getCollectionFormat(codegenParameter);
|
||||
// default to csv:
|
||||
codegenParameter.collectionFormat = StringUtils.isEmpty(collectionFormat) ? "csv" : collectionFormat;
|
||||
codegenParameter.isCollectionFormatMulti = "multi".equals(collectionFormat);
|
||||
|
||||
// recursively add import
|
||||
while (arrayInnerProperty != null) {
|
||||
@@ -6585,6 +6444,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// set nullable
|
||||
setParameterNullable(codegenParameter, codegenProperty);
|
||||
|
||||
//TODO collectionFormat for form parameter not yet supported
|
||||
//codegenParameter.collectionFormat = getCollectionFormat(propertySchema);
|
||||
return codegenParameter;
|
||||
}
|
||||
|
||||
@@ -6895,8 +6756,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
enc.getContentType(),
|
||||
headers,
|
||||
enc.getStyle().toString(),
|
||||
enc.getExplode() == null ? false : enc.getExplode().booleanValue(),
|
||||
enc.getAllowReserved() == null ? false : enc.getAllowReserved().booleanValue()
|
||||
enc.getExplode().booleanValue(),
|
||||
enc.getAllowReserved().booleanValue()
|
||||
);
|
||||
String propName = encodingEntry.getKey();
|
||||
ceMap.put(propName, ce);
|
||||
@@ -6943,7 +6804,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
name = ModelUtils.getSimpleRef(schema.get$ref());
|
||||
}
|
||||
|
||||
Schema unaliasedSchema = unaliasSchema(schema, schemaMapping);
|
||||
Schema unaliasedSchema = unaliasSchema(schema, importMapping);
|
||||
schema = ModelUtils.getReferencedSchema(this.openAPI, schema);
|
||||
|
||||
ModelUtils.syncValidationProperties(unaliasedSchema, codegenParameter);
|
||||
@@ -7506,30 +7367,14 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds OAPI 2.0 collectionFormat value based on style and explode values
|
||||
* Returns null by default but can be overwritten to return a valid collectionFormat
|
||||
* for the {@link CodegenParameter}.
|
||||
*
|
||||
* @param codegenParameter parameter
|
||||
* @return string for a collectionFormat.
|
||||
*/
|
||||
protected String getCollectionFormat(CodegenParameter codegenParameter) {
|
||||
if ("form".equals(codegenParameter.style)) {
|
||||
// Ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#style-values
|
||||
if (codegenParameter.isExplode) {
|
||||
return "multi";
|
||||
} else {
|
||||
return "csv";
|
||||
}
|
||||
} else if ("simple".equals(codegenParameter.style)) {
|
||||
return "csv";
|
||||
} else if ("pipeDelimited".equals(codegenParameter.style)) {
|
||||
return "pipes";
|
||||
} else if ("spaceDelimited".equals(codegenParameter.style)) {
|
||||
return "ssv";
|
||||
} else {
|
||||
// Doesn't map to any of the collectionFormat strings
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private CodegenComposedSchemas getComposedSchemas(Schema schema) {
|
||||
|
||||
@@ -441,19 +441,6 @@ public class DefaultGenerator implements Generator {
|
||||
// process models only
|
||||
for (String name : modelKeys) {
|
||||
try {
|
||||
//don't generate models that have an import mapping
|
||||
if (config.schemaMapping().containsKey(name)) {
|
||||
LOGGER.debug("Model {} not imported due to import mapping", name);
|
||||
|
||||
for (String templateName : config.modelTemplateFiles().keySet()) {
|
||||
// HACK: Because this returns early, could lead to some invalid model reporting.
|
||||
String filename = config.modelFilename(templateName, name);
|
||||
Path path = java.nio.file.Paths.get(filename);
|
||||
this.templateProcessor.skip(path,"Skipped prior to model processing due to schema mapping." );
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// don't generate models that are not used as object (e.g. form parameters)
|
||||
if (unusedModels.contains(name)) {
|
||||
if (Boolean.FALSE.equals(skipFormModel)) {
|
||||
@@ -477,7 +464,7 @@ public class DefaultGenerator implements Generator {
|
||||
// generators may choose to make models for use case 2 + 3
|
||||
Schema refSchema = new Schema();
|
||||
refSchema.set$ref("#/components/schemas/" + name);
|
||||
Schema unaliasedSchema = config.unaliasSchema(refSchema, config.schemaMapping());
|
||||
Schema unaliasedSchema = config.unaliasSchema(refSchema, config.importMapping());
|
||||
if (unaliasedSchema.get$ref() == null) {
|
||||
LOGGER.info("Model {} not generated since it's a free-form object", name);
|
||||
continue;
|
||||
@@ -521,11 +508,6 @@ public class DefaultGenerator implements Generator {
|
||||
ModelsMap models = allProcessedModels.get(modelName);
|
||||
models.put("modelPackage", config.modelPackage());
|
||||
try {
|
||||
//don't generate models that have a schema mapping
|
||||
if (config.schemaMapping().containsKey(modelName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO revise below as we've already performed unaliasing so that the isAlias check may be removed
|
||||
List<ModelMap> modelList = models.getModels();
|
||||
if (modelList != null && !modelList.isEmpty()) {
|
||||
@@ -893,7 +875,6 @@ public class DefaultGenerator implements Generator {
|
||||
if (config.getUseInlineModelResolver()) {
|
||||
InlineModelResolver inlineModelResolver = new InlineModelResolver();
|
||||
inlineModelResolver.setInlineSchemaNameMapping(config.inlineSchemaNameMapping());
|
||||
inlineModelResolver.setInlineSchemaNameDefaults(config.inlineSchemaNameDefault());
|
||||
inlineModelResolver.flatten(openAPI);
|
||||
}
|
||||
|
||||
|
||||
@@ -170,9 +170,6 @@ public interface IJsonSchemaValidationProperties {
|
||||
default void setTypeProperties(Schema p) {
|
||||
if (ModelUtils.isTypeObjectSchema(p)) {
|
||||
setIsMap(true);
|
||||
if (ModelUtils.isModelWithPropertiesOnly(p)) {
|
||||
setIsModel(true);
|
||||
}
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
setIsArray(true);
|
||||
} else if (ModelUtils.isFileSchema(p) && !ModelUtils.isStringSchema(p)) {
|
||||
@@ -222,9 +219,6 @@ public interface IJsonSchemaValidationProperties {
|
||||
setIsNull(true);
|
||||
} else if (ModelUtils.isAnyType(p)) {
|
||||
setIsAnyType(true);
|
||||
if (ModelUtils.isModelWithPropertiesOnly(p)) {
|
||||
setIsModel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ public class InlineModelResolver {
|
||||
private Map<String, Schema> addedModels = new HashMap<>();
|
||||
private Map<String, String> generatedSignature = new HashMap<>();
|
||||
private Map<String, String> inlineSchemaNameMapping = new HashMap<>();
|
||||
private Map<String, String> inlineSchemaNameDefaults = new HashMap<>();
|
||||
private Set<String> inlineSchemaNameMappingValues = new HashSet<>();
|
||||
public boolean resolveInlineEnums = false;
|
||||
|
||||
@@ -61,20 +60,11 @@ public class InlineModelResolver {
|
||||
|
||||
final Logger LOGGER = LoggerFactory.getLogger(InlineModelResolver.class);
|
||||
|
||||
public InlineModelResolver() {
|
||||
this.inlineSchemaNameDefaults.put("arrayItemSuffix", "_inner");
|
||||
this.inlineSchemaNameDefaults.put("mapItemSuffix", "_value");
|
||||
}
|
||||
|
||||
public void setInlineSchemaNameMapping(Map inlineSchemaNameMapping) {
|
||||
this.inlineSchemaNameMapping = inlineSchemaNameMapping;
|
||||
this.inlineSchemaNameMappingValues = new HashSet<>(inlineSchemaNameMapping.values());
|
||||
}
|
||||
|
||||
public void setInlineSchemaNameDefaults(Map inlineSchemaNameDefaults) {
|
||||
this.inlineSchemaNameDefaults.putAll(inlineSchemaNameDefaults);
|
||||
}
|
||||
|
||||
void flatten(OpenAPI openAPI) {
|
||||
this.openAPI = openAPI;
|
||||
|
||||
@@ -100,34 +90,10 @@ public class InlineModelResolver {
|
||||
}
|
||||
|
||||
for (Map.Entry<String, PathItem> pathsEntry : paths.entrySet()) {
|
||||
String pathname = pathsEntry.getKey();
|
||||
PathItem path = pathsEntry.getValue();
|
||||
List<Operation> operations = new ArrayList<>(path.readOperations());
|
||||
|
||||
// use path name (e.g. /foo/bar) and HTTP verb to come up with a name
|
||||
// in case operationId is not defined later in other methods
|
||||
String pathname = pathsEntry.getKey();
|
||||
String name = pathname;
|
||||
if (path.getDelete() != null) {
|
||||
name = pathname + "_delete";
|
||||
} else if (path.getGet() != null) {
|
||||
name = pathname + "_get";
|
||||
} else if (path.getHead() != null) {
|
||||
name = pathname + "_head";
|
||||
} else if (path.getOptions() != null) {
|
||||
name = pathname + "_options";
|
||||
} else if (path.getPatch() != null) {
|
||||
name = pathname + "_patch";
|
||||
} else if (path.getPost() != null) {
|
||||
name = pathname + "_post";
|
||||
} else if (path.getPut() != null) {
|
||||
name = pathname + "_put";
|
||||
} else if (path.getTrace() != null) {
|
||||
name = pathname + "_trace";
|
||||
} else {
|
||||
// no HTTP verb defined?
|
||||
//throw new RuntimeException("No HTTP verb found/detected in the inline model resolver");
|
||||
}
|
||||
|
||||
// Include callback operation as well
|
||||
for (Operation operation : path.readOperations()) {
|
||||
Map<String, Callback> callbacks = operation.getCallbacks();
|
||||
@@ -140,9 +106,9 @@ public class InlineModelResolver {
|
||||
}
|
||||
|
||||
for (Operation operation : operations) {
|
||||
flattenRequestBody(name, operation);
|
||||
flattenParameters(name, operation);
|
||||
flattenResponses(name, operation);
|
||||
flattenRequestBody(pathname, operation);
|
||||
flattenParameters(pathname, operation);
|
||||
flattenResponses(pathname, operation);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,7 +138,7 @@ public class InlineModelResolver {
|
||||
if (m.getAllOf() != null && !m.getAllOf().isEmpty()) {
|
||||
// check to ensure at least of the allOf item is model
|
||||
for (Schema inner : m.getAllOf()) {
|
||||
if (isModelNeeded(ModelUtils.getReferencedSchema(openAPI, inner))) {
|
||||
if (isModelNeeded(inner)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -194,8 +160,7 @@ public class InlineModelResolver {
|
||||
* Recursively gather inline models that need to be generated and
|
||||
* replace inline schemas with $ref to schema to-be-generated.
|
||||
*
|
||||
* @param schema target schema
|
||||
* @param modelPrefix model name (usually the prefix of the inline model name)
|
||||
* @param schema target schema
|
||||
*/
|
||||
private void gatherInlineModels(Schema schema, String modelPrefix) {
|
||||
if (schema.get$ref() != null) {
|
||||
@@ -218,12 +183,13 @@ public class InlineModelResolver {
|
||||
if (props != null) {
|
||||
for (String propName : props.keySet()) {
|
||||
Schema prop = props.get(propName);
|
||||
String schemaName = resolveModelName(prop.getTitle(), modelPrefix + "_" + propName);
|
||||
// Recurse to create $refs for inner models
|
||||
gatherInlineModels(prop, schemaName);
|
||||
//gatherInlineModels(prop, modelPrefix + StringUtils.camelize(propName));
|
||||
gatherInlineModels(prop, modelPrefix + "_" + propName);
|
||||
if (isModelNeeded(prop)) {
|
||||
// If this schema should be split into its own model, do so
|
||||
Schema refSchema = this.makeSchemaInComponents(schemaName, prop);
|
||||
//Schema refSchema = this.makeSchemaResolve(modelPrefix, StringUtils.camelize(propName), prop);
|
||||
Schema refSchema = this.makeSchemaResolve(modelPrefix, "_" + propName, prop);
|
||||
props.put(propName, refSchema);
|
||||
} else if (prop instanceof ComposedSchema) {
|
||||
ComposedSchema m = (ComposedSchema) prop;
|
||||
@@ -240,12 +206,11 @@ public class InlineModelResolver {
|
||||
if (schema.getAdditionalProperties() != null) {
|
||||
if (schema.getAdditionalProperties() instanceof Schema) {
|
||||
Schema inner = (Schema) schema.getAdditionalProperties();
|
||||
String schemaName = resolveModelName(schema.getTitle(), modelPrefix + this.inlineSchemaNameDefaults.get("mapItemSuffix"));
|
||||
// Recurse to create $refs for inner models
|
||||
gatherInlineModels(inner, schemaName);
|
||||
gatherInlineModels(inner, modelPrefix + "_addl_props");
|
||||
if (isModelNeeded(inner)) {
|
||||
// If this schema should be split into its own model, do so
|
||||
Schema refSchema = this.makeSchemaInComponents(schemaName, inner);
|
||||
Schema refSchema = this.makeSchemaResolve(modelPrefix, "_addl_props", inner);
|
||||
schema.setAdditionalProperties(refSchema);
|
||||
}
|
||||
}
|
||||
@@ -266,23 +231,17 @@ public class InlineModelResolver {
|
||||
if (schema instanceof ArraySchema) {
|
||||
ArraySchema array = (ArraySchema) schema;
|
||||
Schema items = array.getItems();
|
||||
/*if (items.getTitle() != null) {
|
||||
LOGGER.info("schema title {}", items);
|
||||
throw new RuntimeException("getTitle for array item is not null");
|
||||
}*/
|
||||
if (items == null) {
|
||||
LOGGER.error("Illegal schema found with array type but no items," +
|
||||
" items must be defined for array schemas:\n " + schema.toString());
|
||||
return;
|
||||
}
|
||||
String schemaName = resolveModelName(items.getTitle(), modelPrefix + this.inlineSchemaNameDefaults.get("arrayItemSuffix"));
|
||||
|
||||
// Recurse to create $refs for inner models
|
||||
gatherInlineModels(items, schemaName);
|
||||
gatherInlineModels(items, modelPrefix + "Items");
|
||||
|
||||
if (isModelNeeded(items)) {
|
||||
// If this schema should be split into its own model, do so
|
||||
Schema refSchema = this.makeSchemaInComponents(schemaName, items);
|
||||
Schema refSchema = this.makeSchemaResolve(modelPrefix, "_inner", items);
|
||||
array.setItems(refSchema);
|
||||
}
|
||||
}
|
||||
@@ -293,11 +252,10 @@ public class InlineModelResolver {
|
||||
List<Schema> newAllOf = new ArrayList<Schema>();
|
||||
boolean atLeastOneModel = false;
|
||||
for (Schema inner : m.getAllOf()) {
|
||||
String schemaName = resolveModelName(inner.getTitle(), modelPrefix + "_allOf");
|
||||
// Recurse to create $refs for inner models
|
||||
gatherInlineModels(inner, schemaName);
|
||||
gatherInlineModels(inner, modelPrefix + "_allOf");
|
||||
if (isModelNeeded(inner)) {
|
||||
Schema refSchema = this.makeSchemaInComponents(schemaName, inner);
|
||||
Schema refSchema = this.makeSchemaResolve(modelPrefix, "_allOf", inner);
|
||||
newAllOf.add(refSchema); // replace with ref
|
||||
atLeastOneModel = true;
|
||||
} else {
|
||||
@@ -320,11 +278,10 @@ public class InlineModelResolver {
|
||||
if (m.getAnyOf() != null) {
|
||||
List<Schema> newAnyOf = new ArrayList<Schema>();
|
||||
for (Schema inner : m.getAnyOf()) {
|
||||
String schemaName = resolveModelName(inner.getTitle(), modelPrefix + "_anyOf");
|
||||
// Recurse to create $refs for inner models
|
||||
gatherInlineModels(inner, schemaName);
|
||||
gatherInlineModels(inner, modelPrefix + "_anyOf");
|
||||
if (isModelNeeded(inner)) {
|
||||
Schema refSchema = this.makeSchemaInComponents(schemaName, inner);
|
||||
Schema refSchema = this.makeSchemaResolve(modelPrefix, "_anyOf", inner);
|
||||
newAnyOf.add(refSchema); // replace with ref
|
||||
} else {
|
||||
newAnyOf.add(inner);
|
||||
@@ -335,11 +292,10 @@ public class InlineModelResolver {
|
||||
if (m.getOneOf() != null) {
|
||||
List<Schema> newOneOf = new ArrayList<Schema>();
|
||||
for (Schema inner : m.getOneOf()) {
|
||||
String schemaName = resolveModelName(inner.getTitle(), modelPrefix + "_oneOf");
|
||||
// Recurse to create $refs for inner models
|
||||
gatherInlineModels(inner, schemaName);
|
||||
gatherInlineModels(inner, modelPrefix + "_oneOf");
|
||||
if (isModelNeeded(inner)) {
|
||||
Schema refSchema = this.makeSchemaInComponents(schemaName, inner);
|
||||
Schema refSchema = this.makeSchemaResolve(modelPrefix, "_oneOf", inner);
|
||||
newOneOf.add(refSchema); // replace with ref
|
||||
} else {
|
||||
newOneOf.add(inner);
|
||||
@@ -351,77 +307,108 @@ public class InlineModelResolver {
|
||||
// Check not schema
|
||||
if (schema.getNot() != null) {
|
||||
Schema not = schema.getNot();
|
||||
String schemaName = resolveModelName(schema.getTitle(), modelPrefix + "_not");
|
||||
// Recurse to create $refs for inner models
|
||||
gatherInlineModels(not, schemaName);
|
||||
gatherInlineModels(not, modelPrefix + "_not");
|
||||
if (isModelNeeded(not)) {
|
||||
Schema refSchema = this.makeSchemaInComponents(schemaName, not);
|
||||
Schema refSchema = this.makeSchemaResolve(modelPrefix, "_not", not);
|
||||
schema.setNot(refSchema);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flatten inline models in content
|
||||
*
|
||||
* @param content target content
|
||||
* @param name backup name if no title is found
|
||||
*/
|
||||
private void flattenContent(Content content, String name) {
|
||||
if (content == null || content.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String contentType : content.keySet()) {
|
||||
MediaType mediaType = content.get(contentType);
|
||||
if (mediaType == null) {
|
||||
continue;
|
||||
}
|
||||
Schema schema = mediaType.getSchema();
|
||||
if (schema == null) {
|
||||
continue;
|
||||
}
|
||||
String schemaName = resolveModelName(schema.getTitle(), name); // name example: testPost_request
|
||||
// Recursively gather/make inline models within this schema if any
|
||||
gatherInlineModels(schema, schemaName);
|
||||
if (isModelNeeded(schema)) {
|
||||
// If this schema should be split into its own model, do so
|
||||
//Schema refSchema = this.makeSchema(schemaName, schema);
|
||||
Schema refSchema = this.makeSchemaInComponents(schemaName, schema);
|
||||
mediaType.setSchema(refSchema);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flatten inline models in RequestBody
|
||||
*
|
||||
* @param modelName inline model name prefix
|
||||
* @param pathname target pathname
|
||||
* @param operation target operation
|
||||
*/
|
||||
private void flattenRequestBody(String modelName, Operation operation) {
|
||||
private void flattenRequestBody(String pathname, Operation operation) {
|
||||
RequestBody requestBody = operation.getRequestBody();
|
||||
if (requestBody == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// unalias $ref
|
||||
if (requestBody.get$ref() != null) {
|
||||
String ref = ModelUtils.getSimpleRef(requestBody.get$ref());
|
||||
requestBody = openAPI.getComponents().getRequestBodies().get(ref);
|
||||
}
|
||||
Schema model = ModelUtils.getSchemaFromRequestBody(requestBody);
|
||||
if (model instanceof ObjectSchema) {
|
||||
Schema obj = model;
|
||||
if (obj.getType() == null || "object".equals(obj.getType())) {
|
||||
if (obj.getProperties() != null && obj.getProperties().size() > 0) {
|
||||
flattenProperties(openAPI, obj.getProperties(), pathname);
|
||||
// for model name, use "title" if defined, otherwise default to 'inline_object'
|
||||
String modelName = resolveModelName(obj.getTitle(), "inline_object");
|
||||
modelName = addSchemas(modelName, model);
|
||||
// create request body
|
||||
RequestBody rb = new RequestBody();
|
||||
rb.setRequired(requestBody.getRequired());
|
||||
Content content = new Content();
|
||||
MediaType mt = new MediaType();
|
||||
Schema schema = new Schema();
|
||||
schema.set$ref(modelName);
|
||||
mt.setSchema(schema);
|
||||
|
||||
flattenContent(requestBody.getContent(),
|
||||
(operation.getOperationId() == null ? modelName : operation.getOperationId()) + "_request");
|
||||
// get "consumes", e.g. application/xml, application/json
|
||||
Set<String> consumes;
|
||||
if (requestBody == null || requestBody.getContent() == null || requestBody.getContent().isEmpty()) {
|
||||
consumes = new HashSet<>();
|
||||
consumes.add("application/json"); // default to application/json
|
||||
LOGGER.info("Default to application/json for inline body schema");
|
||||
} else {
|
||||
consumes = requestBody.getContent().keySet();
|
||||
}
|
||||
|
||||
for (String consume : consumes) {
|
||||
content.addMediaType(consume, mt);
|
||||
}
|
||||
|
||||
rb.setContent(content);
|
||||
|
||||
// add to openapi "components"
|
||||
if (openAPI.getComponents().getRequestBodies() == null) {
|
||||
Map<String, RequestBody> requestBodies = new HashMap<String, RequestBody>();
|
||||
requestBodies.put(modelName, rb);
|
||||
openAPI.getComponents().setRequestBodies(requestBodies);
|
||||
} else {
|
||||
openAPI.getComponents().getRequestBodies().put(modelName, rb);
|
||||
}
|
||||
|
||||
// update requestBody to use $ref instead of inline def
|
||||
requestBody.set$ref(modelName);
|
||||
|
||||
}
|
||||
}
|
||||
} else if (model instanceof ArraySchema) {
|
||||
ArraySchema am = (ArraySchema) model;
|
||||
Schema inner = am.getItems();
|
||||
if (inner instanceof ObjectSchema) {
|
||||
ObjectSchema op = (ObjectSchema) inner;
|
||||
if (op.getProperties() != null && op.getProperties().size() > 0) {
|
||||
flattenProperties(openAPI, op.getProperties(), pathname);
|
||||
// Generate a unique model name based on the title.
|
||||
String modelName = resolveModelName(op.getTitle(), null);
|
||||
Schema innerModel = modelFromProperty(openAPI, op, modelName);
|
||||
String existing = matchGenerated(innerModel);
|
||||
if (existing != null) {
|
||||
Schema schema = new Schema().$ref(existing);
|
||||
schema.setRequired(op.getRequired());
|
||||
am.setItems(schema);
|
||||
} else {
|
||||
modelName = addSchemas(modelName, innerModel);
|
||||
Schema schema = new Schema().$ref(modelName);
|
||||
schema.setRequired(op.getRequired());
|
||||
am.setItems(schema);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flatten inline models in parameters
|
||||
*
|
||||
* @param modelName model name
|
||||
* @param pathname target pathname
|
||||
* @param operation target operation
|
||||
*/
|
||||
private void flattenParameters(String modelName, Operation operation) {
|
||||
private void flattenParameters(String pathname, Operation operation) {
|
||||
List<Parameter> parameters = operation.getParameters();
|
||||
if (parameters == null) {
|
||||
return;
|
||||
@@ -432,19 +419,39 @@ public class InlineModelResolver {
|
||||
continue;
|
||||
}
|
||||
|
||||
Schema parameterSchema = parameter.getSchema();
|
||||
|
||||
if (parameterSchema == null) {
|
||||
continue;
|
||||
}
|
||||
String schemaName = resolveModelName(parameterSchema.getTitle(),
|
||||
(operation.getOperationId() == null ? modelName : operation.getOperationId()) + "_" + parameter.getName() + "_parameter");
|
||||
// Recursively gather/make inline models within this schema if any
|
||||
gatherInlineModels(parameterSchema, schemaName);
|
||||
if (isModelNeeded(parameterSchema)) {
|
||||
// If this schema should be split into its own model, do so
|
||||
Schema refSchema = this.makeSchemaInComponents(schemaName, parameterSchema);
|
||||
parameter.setSchema(refSchema);
|
||||
Schema model = parameter.getSchema();
|
||||
if (model instanceof ObjectSchema) {
|
||||
Schema obj = model;
|
||||
if (obj.getType() == null || "object".equals(obj.getType())) {
|
||||
if (obj.getProperties() != null && obj.getProperties().size() > 0) {
|
||||
flattenProperties(openAPI, obj.getProperties(), pathname);
|
||||
String modelName = resolveModelName(obj.getTitle(), parameter.getName());
|
||||
modelName = addSchemas(modelName, model);
|
||||
parameter.$ref(modelName);
|
||||
}
|
||||
}
|
||||
} else if (model instanceof ArraySchema) {
|
||||
ArraySchema am = (ArraySchema) model;
|
||||
Schema inner = am.getItems();
|
||||
if (inner instanceof ObjectSchema) {
|
||||
ObjectSchema op = (ObjectSchema) inner;
|
||||
if (op.getProperties() != null && op.getProperties().size() > 0) {
|
||||
flattenProperties(openAPI, op.getProperties(), pathname);
|
||||
String modelName = resolveModelName(op.getTitle(), parameter.getName());
|
||||
Schema innerModel = modelFromProperty(openAPI, op, modelName);
|
||||
String existing = matchGenerated(innerModel);
|
||||
if (existing != null) {
|
||||
Schema schema = new Schema().$ref(existing);
|
||||
schema.setRequired(op.getRequired());
|
||||
am.setItems(schema);
|
||||
} else {
|
||||
modelName = addSchemas(modelName, innerModel);
|
||||
Schema schema = new Schema().$ref(modelName);
|
||||
schema.setRequired(op.getRequired());
|
||||
am.setItems(schema);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -452,10 +459,10 @@ public class InlineModelResolver {
|
||||
/**
|
||||
* Flatten inline models in ApiResponses
|
||||
*
|
||||
* @param modelName model name prefix
|
||||
* @param pathname target pathname
|
||||
* @param operation target operation
|
||||
*/
|
||||
private void flattenResponses(String modelName, Operation operation) {
|
||||
private void flattenResponses(String pathname, Operation operation) {
|
||||
ApiResponses responses = operation.getResponses();
|
||||
if (responses == null) {
|
||||
return;
|
||||
@@ -464,9 +471,78 @@ public class InlineModelResolver {
|
||||
for (Map.Entry<String, ApiResponse> responsesEntry : responses.entrySet()) {
|
||||
String key = responsesEntry.getKey();
|
||||
ApiResponse response = responsesEntry.getValue();
|
||||
if (ModelUtils.getSchemaFromResponse(response) == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
flattenContent(response.getContent(),
|
||||
(operation.getOperationId() == null ? modelName : operation.getOperationId()) + "_" + key + "_response");
|
||||
Schema property = ModelUtils.getSchemaFromResponse(response);
|
||||
if (property instanceof ObjectSchema) {
|
||||
ObjectSchema op = (ObjectSchema) property;
|
||||
if (op.getProperties() != null && op.getProperties().size() > 0) {
|
||||
String modelName = resolveModelName(op.getTitle(), "inline_response_" + key);
|
||||
Schema model = modelFromProperty(openAPI, op, modelName);
|
||||
String existing = matchGenerated(model);
|
||||
Content content = response.getContent();
|
||||
for (MediaType mediaType : content.values()) {
|
||||
if (existing != null) {
|
||||
Schema schema = this.makeSchema(existing, property);
|
||||
schema.setRequired(op.getRequired());
|
||||
mediaType.setSchema(schema);
|
||||
} else {
|
||||
modelName = addSchemas(modelName, model);
|
||||
Schema schema = this.makeSchema(modelName, property);
|
||||
schema.setRequired(op.getRequired());
|
||||
mediaType.setSchema(schema);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (property instanceof ArraySchema) {
|
||||
ArraySchema ap = (ArraySchema) property;
|
||||
Schema inner = ap.getItems();
|
||||
if (inner instanceof ObjectSchema) {
|
||||
ObjectSchema op = (ObjectSchema) inner;
|
||||
if (op.getProperties() != null && op.getProperties().size() > 0) {
|
||||
flattenProperties(openAPI, op.getProperties(), pathname);
|
||||
String modelName = resolveModelName(op.getTitle(),
|
||||
"inline_response_" + key);
|
||||
Schema innerModel = modelFromProperty(openAPI, op, modelName);
|
||||
String existing = matchGenerated(innerModel);
|
||||
if (existing != null) {
|
||||
Schema schema = this.makeSchema(existing, op);
|
||||
schema.setRequired(op.getRequired());
|
||||
ap.setItems(schema);
|
||||
} else {
|
||||
modelName = addSchemas(modelName, innerModel);
|
||||
Schema schema = this.makeSchema(modelName, op);
|
||||
schema.setRequired(op.getRequired());
|
||||
ap.setItems(schema);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (property instanceof MapSchema) {
|
||||
MapSchema mp = (MapSchema) property;
|
||||
Schema innerProperty = ModelUtils.getAdditionalProperties(openAPI, mp);
|
||||
if (innerProperty instanceof ObjectSchema) {
|
||||
ObjectSchema op = (ObjectSchema) innerProperty;
|
||||
if (op.getProperties() != null && op.getProperties().size() > 0) {
|
||||
flattenProperties(openAPI, op.getProperties(), pathname);
|
||||
String modelName = resolveModelName(op.getTitle(),
|
||||
"inline_response_" + key);
|
||||
Schema innerModel = modelFromProperty(openAPI, op, modelName);
|
||||
String existing = matchGenerated(innerModel);
|
||||
if (existing != null) {
|
||||
Schema schema = new Schema().$ref(existing);
|
||||
schema.setRequired(op.getRequired());
|
||||
mp.setAdditionalProperties(schema);
|
||||
} else {
|
||||
modelName = addSchemas(modelName, innerModel);
|
||||
Schema schema = new Schema().$ref(modelName);
|
||||
schema.setRequired(op.getRequired());
|
||||
mp.setAdditionalProperties(schema);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -553,8 +629,35 @@ public class InlineModelResolver {
|
||||
flattenComposedChildren(modelName + "_anyOf", m.getAnyOf());
|
||||
flattenComposedChildren(modelName + "_oneOf", m.getOneOf());
|
||||
} else if (model instanceof Schema) {
|
||||
//Schema m = model;
|
||||
//Map<String, Schema> properties = m.getProperties();
|
||||
//flattenProperties(openAPI, properties, modelName);
|
||||
//fixStringModel(m);
|
||||
gatherInlineModels(model, modelName);
|
||||
}
|
||||
|
||||
} /*else if (ModelUtils.isArraySchema(model)) {
|
||||
ArraySchema m = (ArraySchema) model;
|
||||
Schema inner = m.getItems();
|
||||
if (inner instanceof ObjectSchema) {
|
||||
ObjectSchema op = (ObjectSchema) inner;
|
||||
if (op.getProperties() != null && op.getProperties().size() > 0) {
|
||||
String innerModelName = resolveModelName(op.getTitle(), modelName + "_inner");
|
||||
Schema innerModel = modelFromProperty(openAPI, op, innerModelName);
|
||||
String existing = matchGenerated(innerModel);
|
||||
if (existing == null) {
|
||||
openAPI.getComponents().addSchemas(innerModelName, innerModel);
|
||||
addGenerated(innerModelName, innerModel);
|
||||
Schema schema = new Schema().$ref(innerModelName);
|
||||
schema.setRequired(op.getRequired());
|
||||
m.setItems(schema);
|
||||
} else {
|
||||
Schema schema = new Schema().$ref(existing);
|
||||
schema.setRequired(op.getRequired());
|
||||
m.setItems(schema);
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -587,16 +690,16 @@ public class InlineModelResolver {
|
||||
* <p>
|
||||
* e.g. io.schema.User_name => io_schema_User_name
|
||||
*
|
||||
* @param title String title field in the schema if present
|
||||
* @param modelName String model name
|
||||
* @param title String title field in the schema if present
|
||||
* @param key String model name
|
||||
* @return if provided the sanitized {@code title}, else the sanitized {@code key}
|
||||
*/
|
||||
private String resolveModelName(String title, String modelName) {
|
||||
private String resolveModelName(String title, String key) {
|
||||
if (title == null) {
|
||||
if (modelName == null) {
|
||||
if (key == null) {
|
||||
return uniqueName("inline_object");
|
||||
}
|
||||
return uniqueName(sanitizeName(modelName));
|
||||
return uniqueName(sanitizeName(key));
|
||||
} else {
|
||||
return uniqueName(sanitizeName(title));
|
||||
}
|
||||
@@ -628,8 +731,6 @@ public class InlineModelResolver {
|
||||
* Sanitizes the input so that it's valid name for a class or interface
|
||||
* <p>
|
||||
* e.g. 12.schema.User name => _2_schema_User_name
|
||||
*
|
||||
* @param name name to be processed to make sure it's sanitized
|
||||
*/
|
||||
private String sanitizeName(final String name) {
|
||||
return name
|
||||
@@ -637,13 +738,9 @@ public class InlineModelResolver {
|
||||
.replaceAll("[^A-Za-z0-9]", "_"); // e.g. io.schema.User name => io_schema_User_name
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a unique name for the input
|
||||
*
|
||||
* @param name name to be processed to make sure it's unique
|
||||
*/
|
||||
private String uniqueName(final String name) {
|
||||
if (openAPI.getComponents().getSchemas() == null) { // no schema has been created
|
||||
uniqueNames.add(name);
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -651,6 +748,7 @@ public class InlineModelResolver {
|
||||
int count = 0;
|
||||
while (true) {
|
||||
if (!openAPI.getComponents().getSchemas().containsKey(uniqueName) && !uniqueNames.contains(uniqueName)) {
|
||||
uniqueNames.add(uniqueName);
|
||||
return uniqueName;
|
||||
}
|
||||
uniqueName = name + "_" + ++count;
|
||||
@@ -798,6 +896,24 @@ public class InlineModelResolver {
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve namespace conflicts using:
|
||||
* title (if title exists) or
|
||||
* prefix + suffix (if title not specified)
|
||||
*
|
||||
* @param prefix used to form name if no title found in schema
|
||||
* @param suffix used to form name if no title found in schema
|
||||
* @param schema title property used to form name if exists and schema definition used
|
||||
* to create new schema if doesn't exist
|
||||
* @return a new schema or $ref to an existing one if it was already created
|
||||
*/
|
||||
private Schema makeSchemaResolve(String prefix, String suffix, Schema schema) {
|
||||
if (schema.getTitle() == null) {
|
||||
return makeSchemaInComponents(uniqueName(sanitizeName(prefix + suffix)), schema);
|
||||
}
|
||||
return makeSchemaInComponents(uniqueName(sanitizeName(schema.getTitle())), schema);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move schema to components (if new) and return $ref to schema or
|
||||
* existing schema.
|
||||
@@ -819,7 +935,6 @@ public class InlineModelResolver {
|
||||
refSchema = new Schema().$ref(name);
|
||||
}
|
||||
this.copyVendorExtensions(schema, refSchema);
|
||||
|
||||
return refSchema;
|
||||
}
|
||||
|
||||
@@ -871,8 +986,6 @@ public class InlineModelResolver {
|
||||
LOGGER.info("Inline schema created as {}. To have complete control of the model name, set the `title` field or use the inlineSchemaNameMapping option (--inline-schema-name-mapping in CLI).", name);
|
||||
}
|
||||
|
||||
uniqueNames.add(name);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
package org.openapitools.codegen;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ObjectWithTypeBooleans {
|
||||
public boolean isUnboundedInteger;
|
||||
public boolean isNumber;
|
||||
public boolean isString;
|
||||
public boolean isMap;
|
||||
public boolean isArray;
|
||||
public boolean isBoolean;
|
||||
public boolean isNull;
|
||||
public Object value;
|
||||
|
||||
/**
|
||||
* A wrapper class that is used to store payloads to be ingested by schemas
|
||||
* This class includes the payload value in the value property
|
||||
* Other booleans: isUnboundedInteger/isNumber/isString/isMap/isArray/isBoolean/isNull
|
||||
* allow generator templates to decide how to render each payload into code
|
||||
* based upon what type it is. The booleans isX describe the value in value.
|
||||
* @param value the input payload that is stored
|
||||
*/
|
||||
public ObjectWithTypeBooleans(Object value) {
|
||||
Object usedValue = null;
|
||||
if (value instanceof Integer){
|
||||
this.isUnboundedInteger = true;
|
||||
this.value = value;
|
||||
} else if (value instanceof Double || value instanceof Float){
|
||||
this.isNumber = true;
|
||||
this.value = value;
|
||||
} else if (value instanceof String) {
|
||||
this.isString = true;
|
||||
this.value = value;
|
||||
} else if (value instanceof LinkedHashMap) {
|
||||
LinkedHashMap<String, Object> castValue = (LinkedHashMap<String, Object>) value;
|
||||
LinkedHashMap<ObjectWithTypeBooleans, ObjectWithTypeBooleans> castMap = new LinkedHashMap<>();
|
||||
for (Map.Entry entry: castValue.entrySet()) {
|
||||
ObjectWithTypeBooleans entryKey = new ObjectWithTypeBooleans(entry.getKey());
|
||||
ObjectWithTypeBooleans entryValue = new ObjectWithTypeBooleans(entry.getValue());
|
||||
castMap.put(entryKey, entryValue);
|
||||
}
|
||||
this.value = castMap;
|
||||
this.isMap = true;
|
||||
} else if (value instanceof ArrayList) {
|
||||
ArrayList<ObjectWithTypeBooleans> castList = new ArrayList<>();
|
||||
for (Object item: (ArrayList<Object>) value) {
|
||||
castList.add(new ObjectWithTypeBooleans(item));
|
||||
}
|
||||
this.value = castList;
|
||||
this.isArray = true;
|
||||
} else if (value instanceof Boolean) {
|
||||
this.isBoolean = true;
|
||||
this.value = value;
|
||||
} else if (value == null) {
|
||||
this.isNull = true;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package org.openapitools.codegen;
|
||||
|
||||
public class SchemaTestCase {
|
||||
public String description;
|
||||
public ObjectWithTypeBooleans data;
|
||||
// true means the test case should pass, false means it should fail
|
||||
public boolean valid;
|
||||
|
||||
public SchemaTestCase(String description, ObjectWithTypeBooleans data, boolean valid) {
|
||||
this.description = description;
|
||||
this.data = data;
|
||||
this.valid = valid;
|
||||
}
|
||||
}
|
||||
@@ -68,11 +68,9 @@ public class CodegenConfigurator {
|
||||
private Map<String, String> typeMappings = new HashMap<>();
|
||||
private Map<String, Object> additionalProperties = new HashMap<>();
|
||||
private Map<String, String> importMappings = new HashMap<>();
|
||||
private Map<String, String> schemaMappings = new HashMap<>();
|
||||
private Map<String, String> inlineSchemaNameMappings = new HashMap<>();
|
||||
private Map<String, String> inlineSchemaNameDefaults = new HashMap<>();
|
||||
private Set<String> languageSpecificPrimitives = new HashSet<>();
|
||||
private Map<String, String> reservedWordsMappings = new HashMap<>();
|
||||
private Map<String, String> reservedWordMappings = new HashMap<>();
|
||||
private Map<String, String> serverVariables = new HashMap<>();
|
||||
private String auth;
|
||||
|
||||
@@ -114,20 +112,14 @@ public class CodegenConfigurator {
|
||||
if(generatorSettings.getImportMappings() != null) {
|
||||
configurator.importMappings.putAll(generatorSettings.getImportMappings());
|
||||
}
|
||||
if(generatorSettings.getSchemaMappings() != null) {
|
||||
configurator.schemaMappings.putAll(generatorSettings.getSchemaMappings());
|
||||
}
|
||||
if(generatorSettings.getInlineSchemaNameMappings() != null) {
|
||||
configurator.inlineSchemaNameMappings.putAll(generatorSettings.getInlineSchemaNameMappings());
|
||||
}
|
||||
if(generatorSettings.getInlineSchemaNameDefaults() != null) {
|
||||
configurator.inlineSchemaNameDefaults.putAll(generatorSettings.getInlineSchemaNameDefaults());
|
||||
}
|
||||
if(generatorSettings.getLanguageSpecificPrimitives() != null) {
|
||||
configurator.languageSpecificPrimitives.addAll(generatorSettings.getLanguageSpecificPrimitives());
|
||||
}
|
||||
if(generatorSettings.getReservedWordsMappings() != null) {
|
||||
configurator.reservedWordsMappings.putAll(generatorSettings.getReservedWordsMappings());
|
||||
if(generatorSettings.getReservedWordMappings() != null) {
|
||||
configurator.reservedWordMappings.putAll(generatorSettings.getReservedWordMappings());
|
||||
}
|
||||
if(generatorSettings.getServerVariables() != null) {
|
||||
configurator.serverVariables.putAll(generatorSettings.getServerVariables());
|
||||
@@ -181,7 +173,7 @@ public class CodegenConfigurator {
|
||||
}
|
||||
|
||||
public CodegenConfigurator addAdditionalReservedWordMapping(String key, String value) {
|
||||
this.reservedWordsMappings.put(key, value);
|
||||
this.reservedWordMappings.put(key, value);
|
||||
generatorSettingsBuilder.withReservedWordMapping(key, value);
|
||||
return this;
|
||||
}
|
||||
@@ -192,24 +184,12 @@ public class CodegenConfigurator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator addSchemaMapping(String key, String value) {
|
||||
this.schemaMappings.put(key, value);
|
||||
generatorSettingsBuilder.withSchemaMapping(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator addInlineSchemaNameMapping(String key, String value) {
|
||||
this.inlineSchemaNameMappings.put(key, value);
|
||||
generatorSettingsBuilder.withInlineSchemaNameMapping(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator addInlineSchemaNameDefault(String key, String value) {
|
||||
this.inlineSchemaNameDefaults.put(key, value);
|
||||
generatorSettingsBuilder.withInlineSchemaNameDefault(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator addInstantiationType(String key, String value) {
|
||||
this.instantiationTypes.put(key, value);
|
||||
generatorSettingsBuilder.withInstantiationType(key, value);
|
||||
@@ -246,9 +226,9 @@ public class CodegenConfigurator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setReservedWordsMappings(Map<String, String> reservedWordsMappings) {
|
||||
this.reservedWordsMappings = reservedWordsMappings;
|
||||
generatorSettingsBuilder.withReservedWordsMappings(reservedWordsMappings);
|
||||
public CodegenConfigurator setReservedWordsMappings(Map<String, String> reservedWordMappings) {
|
||||
this.reservedWordMappings = reservedWordMappings;
|
||||
generatorSettingsBuilder.withReservedWordMappings(reservedWordMappings);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -364,24 +344,12 @@ public class CodegenConfigurator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setSchemaMappings(Map<String, String> schemaMappings) {
|
||||
this.schemaMappings = schemaMappings;
|
||||
generatorSettingsBuilder.withSchemaMappings(schemaMappings);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setInlineSchemaNameMappings(Map<String, String> inlineSchemaNameMappings) {
|
||||
this.inlineSchemaNameMappings = inlineSchemaNameMappings;
|
||||
generatorSettingsBuilder.withInlineSchemaNameMappings(inlineSchemaNameMappings);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setInlineSchemaNameDefaults(Map<String, String> inlineSchemaNameDefaults) {
|
||||
this.inlineSchemaNameDefaults = inlineSchemaNameDefaults;
|
||||
generatorSettingsBuilder.withInlineSchemaNameDefaults(inlineSchemaNameDefaults);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setInputSpec(String inputSpec) {
|
||||
this.inputSpec = inputSpec;
|
||||
workflowSettingsBuilder.withInputSpec(inputSpec);
|
||||
@@ -658,11 +626,9 @@ public class CodegenConfigurator {
|
||||
config.instantiationTypes().putAll(generatorSettings.getInstantiationTypes());
|
||||
config.typeMapping().putAll(generatorSettings.getTypeMappings());
|
||||
config.importMapping().putAll(generatorSettings.getImportMappings());
|
||||
config.schemaMapping().putAll(generatorSettings.getSchemaMappings());
|
||||
config.inlineSchemaNameMapping().putAll(generatorSettings.getInlineSchemaNameMappings());
|
||||
config.inlineSchemaNameDefault().putAll(generatorSettings.getInlineSchemaNameDefaults());
|
||||
config.languageSpecificPrimitives().addAll(generatorSettings.getLanguageSpecificPrimitives());
|
||||
config.reservedWordsMappings().putAll(generatorSettings.getReservedWordsMappings());
|
||||
config.reservedWordsMappings().putAll(generatorSettings.getReservedWordMappings());
|
||||
config.additionalProperties().putAll(generatorSettings.getAdditionalProperties());
|
||||
|
||||
Map<String, String> serverVariables = generatorSettings.getServerVariables();
|
||||
|
||||
@@ -81,19 +81,6 @@ public final class CodegenConfiguratorUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void applySchemaMappingsKvpList(List<String> schemaMappings, CodegenConfigurator configurator) {
|
||||
for (String propString : schemaMappings) {
|
||||
applySchemaMappingsKvp(propString, configurator);
|
||||
}
|
||||
}
|
||||
|
||||
public static void applySchemaMappingsKvp(String schemaMappings, CodegenConfigurator configurator) {
|
||||
final Map<String, String> map = createMapFromKeyValuePairs(schemaMappings);
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
configurator.addSchemaMapping(entry.getKey().trim(), entry.getValue().trim());
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyInlineSchemaNameMappingsKvpList(List<String> inlineSchemaNameMappings, CodegenConfigurator configurator) {
|
||||
for (String propString : inlineSchemaNameMappings) {
|
||||
applyInlineSchemaNameMappingsKvp(propString, configurator);
|
||||
@@ -107,19 +94,6 @@ public final class CodegenConfiguratorUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyInlineSchemaNameDefaultsKvpList(List<String> inlineSchemaNameDefaults, CodegenConfigurator configurator) {
|
||||
for (String propString : inlineSchemaNameDefaults) {
|
||||
applyInlineSchemaNameDefaultsKvp(propString, configurator);
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyInlineSchemaNameDefaultsKvp(String inlineSchemaNameDefaults, CodegenConfigurator configurator) {
|
||||
final Map<String, String> map = createMapFromKeyValuePairs(inlineSchemaNameDefaults);
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
configurator.addInlineSchemaNameDefault(entry.getKey().trim(), entry.getValue().trim());
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyTypeMappingsKvpList(List<String> typeMappings, CodegenConfigurator configurator) {
|
||||
for (String propString : typeMappings) {
|
||||
applyTypeMappingsKvp(propString, configurator);
|
||||
@@ -172,14 +146,14 @@ public final class CodegenConfiguratorUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyReservedWordsMappingsKvpList(List<String> reservedWordsMappings, CodegenConfigurator configurator) {
|
||||
for (String propString : reservedWordsMappings) {
|
||||
public static void applyReservedWordsMappingsKvpList(List<String> reservedWordMappings, CodegenConfigurator configurator) {
|
||||
for (String propString : reservedWordMappings) {
|
||||
applyReservedWordsMappingsKvp(propString, configurator);
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyReservedWordsMappingsKvp(String reservedWordsMappings, CodegenConfigurator configurator) {
|
||||
final Map<String, String> map = createMapFromKeyValuePairs(reservedWordsMappings);
|
||||
public static void applyReservedWordsMappingsKvp(String reservedWordMappings, CodegenConfigurator configurator) {
|
||||
final Map<String, String> map = createMapFromKeyValuePairs(reservedWordMappings);
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
configurator.addAdditionalReservedWordMapping(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
@@ -1070,10 +1070,10 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
// We need to check if schema-mapping has a different model for this class, so we use it
|
||||
// We need to check if import-mapping has a different model for this class, so we use it
|
||||
// instead of the auto-generated one.
|
||||
if (schemaMapping.containsKey(name)) {
|
||||
return schemaMapping.get(name);
|
||||
if (importMapping.containsKey(name)) {
|
||||
return importMapping.get(name);
|
||||
}
|
||||
|
||||
// memoization and lookup in the cache
|
||||
@@ -1410,15 +1410,8 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
} else {
|
||||
example = "new List<" + p.items.dataType + ">()";
|
||||
}
|
||||
} else if (Boolean.TRUE.equals(p.isModel)) {
|
||||
example = "new " + p.dataType + "()";
|
||||
} else if (Boolean.TRUE.equals(p.isMap)) {
|
||||
if (p.items != null) {
|
||||
example = "new Dictionary<String, " + p.items.dataType + ">";
|
||||
} else {
|
||||
// default to String if item is not defined
|
||||
example = "new Dictionary<String, String>";
|
||||
}
|
||||
example = "new Dictionary<String, " + p.items.dataType + ">";
|
||||
}
|
||||
|
||||
p.example = example;
|
||||
|
||||
@@ -305,18 +305,13 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
|
||||
|
||||
@Override
|
||||
protected boolean isReservedWord(String word) {
|
||||
// consider everything as reserved that is
|
||||
// * a keyword
|
||||
// * a word that has been mapped in the reservedWordsMappings
|
||||
// * a default included type or a type include through some library
|
||||
return super.isReservedWord(word) || reservedWordsMappings().containsKey(word) || defaultIncludes().contains(word);
|
||||
// consider everything as reserved that is either a keyword,
|
||||
// a default included type, or a type include through some library
|
||||
return super.isReservedWord(word) || defaultIncludes().contains(word);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
if (reservedWordsMappings().containsKey(name)) {
|
||||
return reservedWordsMappings().get(name);
|
||||
}
|
||||
return name + "_";
|
||||
}
|
||||
|
||||
@@ -488,7 +483,7 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
Schema<?> schema = ModelUtils.unaliasSchema(this.openAPI, p, schemaMapping);
|
||||
Schema<?> schema = ModelUtils.unaliasSchema(this.openAPI, p, importMapping);
|
||||
Schema<?> target = ModelUtils.isGenerateAliasAsModel() ? p : schema;
|
||||
if (ModelUtils.isArraySchema(target)) {
|
||||
Schema<?> items = getSchemaItems((ArraySchema) schema);
|
||||
|
||||
@@ -177,10 +177,10 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
// We need to check if schema-mapping has a different model for this class, so we use it
|
||||
// We need to check if import-mapping has a different model for this class, so we use it
|
||||
// instead of the auto-generated one.
|
||||
if (schemaMapping.containsKey(name)) {
|
||||
return schemaMapping.get(name);
|
||||
if (importMapping.containsKey(name)) {
|
||||
return importMapping.get(name);
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(modelNamePrefix)) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user