Compare commits

..

No commits in common. "master" and "v7.15.0" have entirely different histories.

8972 changed files with 21446 additions and 41505 deletions

View File

@ -26,7 +26,7 @@ jobs:
- samples/server/petstore/aspnet/fastendpoints-useValidators
steps:
- uses: actions/checkout@v5
- uses: actions/setup-dotnet@v5.0.0
- uses: actions/setup-dotnet@v4.3.1
with:
dotnet-version: '8.0.x'
- name: Build

View File

@ -1,53 +0,0 @@
name: Samples Dart (build, test)
on:
push:
branches:
paths:
#- samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/**
#- samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake_tests/**
#- samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/**
- samples/openapi3/client/petstore/dart-dio/oneof/**
- samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/**
- samples/openapi3/client/petstore/dart-dio/binary_response/**
pull_request:
paths:
#- samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/**
#- samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake_tests/**
#- samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/**
- samples/openapi3/client/petstore/dart-dio/oneof/**
- samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/**
- samples/openapi3/client/petstore/dart-dio/binary_response/**
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
sdk: ["3.9.0"]
sample:
#- samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/
#- samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake_tests/
#- samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/
- samples/openapi3/client/petstore/dart-dio/oneof/
- samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/
- samples/openapi3/client/petstore/dart-dio/binary_response/
steps:
- uses: actions/checkout@v5
- uses: dart-lang/setup-dart@v1
with:
sdk: ${{ matrix.sdk }}
- name: pub get
working-directory: ${{ matrix.sample }}
run: dart pub get
- name: build_runner build
working-directory: ${{ matrix.sample }}
run: dart run build_runner build
- name: test
working-directory: ${{ matrix.sample }}
run: dart test

View File

@ -28,7 +28,7 @@ jobs:
# - samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/
steps:
- uses: actions/checkout@v5
- uses: actions/setup-dotnet@v5.0.0
- uses: actions/setup-dotnet@v4.3.1
with:
dotnet-version: 3.1.*
- name: Build

View File

@ -25,7 +25,7 @@ jobs:
- samples/server/petstore/aspnetcore-6.0-useSwashBuckle
steps:
- uses: actions/checkout@v5
- uses: actions/setup-dotnet@v5.0.0
- uses: actions/setup-dotnet@v4.3.1
with:
dotnet-version: '6.0.x'
- name: Build

View File

@ -19,7 +19,7 @@ jobs:
- samples/client/echo_api/csharp/restsharp/net8/EchoApi
steps:
- uses: actions/checkout@v5
- uses: actions/setup-dotnet@v5.0.0
- uses: actions/setup-dotnet@v4.3.1
with:
dotnet-version: '8.0.x'
- name: Run echo server

View File

@ -19,7 +19,7 @@ jobs:
- samples/client/petstore/csharp/restsharp/net8/useVirtualForHooks/
steps:
- uses: actions/checkout@v5
- uses: actions/setup-dotnet@v5.0.0
- uses: actions/setup-dotnet@v4.3.1
with:
dotnet-version: '8.0.x'
- name: Build

View File

@ -26,7 +26,7 @@ jobs:
- samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management
steps:
- uses: actions/checkout@v5
- uses: actions/setup-dotnet@v5.0.0
- uses: actions/setup-dotnet@v4.3.1
with:
dotnet-version: '8.0.x'
- name: Build

View File

@ -34,7 +34,7 @@ jobs:
- samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate
steps:
- uses: actions/checkout@v5
- uses: actions/setup-dotnet@v5.0.0
- uses: actions/setup-dotnet@v4.3.1
with:
dotnet-version: '8.0.x'
- name: Build

View File

@ -47,7 +47,7 @@ jobs:
#- samples/client/petstore/csharp/unityWebRequest/net9/Petstore
steps:
- uses: actions/checkout@v5
- uses: actions/setup-dotnet@v5.0.0
- uses: actions/setup-dotnet@v4.3.1
with:
dotnet-version: '9.0.101'
- name: Build

View File

@ -17,11 +17,11 @@ jobs:
- samples/client/echo_api/go
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
- uses: actions/setup-go@v5
with:
go-version: "stable"
- name: Setup node.js
uses: actions/setup-node@v5
uses: actions/setup-node@v4
- name: Run echo server
run: |
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server

View File

@ -4,11 +4,9 @@ on:
push:
paths:
- 'samples/openapi3/client/petstore/go/go-petstore-aws-signature/**'
- 'samples/openapi3/client/petstore/go-petstore-withXml/**'
pull_request:
paths:
- 'samples/openapi3/client/petstore/go/go-petstore-aws-signature/**'
- 'samples/openapi3/client/petstore/go-petstore-withXml/**'
jobs:
build:
@ -19,10 +17,9 @@ jobs:
matrix:
sample:
- 'samples/openapi3/client/petstore/go/go-petstore-aws-signature/'
- 'samples/openapi3/client/petstore/go-petstore-withXml/'
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
- uses: actions/setup-go@v5
- run: go version
- name: Install Dependencies
working-directory: ${{ matrix.sample }}

View File

@ -22,7 +22,7 @@ jobs:
- samples/server/petstore/go-gin-api-server-interface-only/
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
- uses: actions/setup-go@v5
with:
go-version: "stable"
- run: go version

View File

@ -28,7 +28,7 @@ jobs:
- samples/server/others/go-server/no-body-path-params/
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
- uses: actions/setup-go@v5
with:
go-version: "stable"
- run: go version
@ -49,7 +49,7 @@ jobs:
steps:
- uses: actions/checkout@v5
- name: Set up Go
uses: actions/setup-go@v6
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Install Dependencies

View File

@ -36,7 +36,7 @@ jobs:
~/.m2
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
- name: Setup node.js
uses: actions/setup-node@v5
uses: actions/setup-node@v4
- name: Run echo server
run: |
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server

View File

@ -37,7 +37,7 @@ jobs:
~/.m2
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
- name: Setup node.js
uses: actions/setup-node@v5
uses: actions/setup-node@v4
- name: Run echo server
run: |
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server

View File

@ -43,7 +43,7 @@ jobs:
~/.m2
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
- name: Setup node.js
uses: actions/setup-node@v5
uses: actions/setup-node@v4
- name: Run echo server
run: |
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server

View File

@ -42,7 +42,7 @@ jobs:
- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 11
java-version: 8
- name: Cache maven dependencies
uses: actions/cache@v4
env:

View File

@ -33,7 +33,6 @@ jobs:
- samples/client/petstore/kotlin-moshi-codegen
- samples/client/petstore/kotlin-multiplatform
- samples/client/petstore/kotlin-multiplatform-kotlinx-datetime
- samples/client/petstore/kotlin-multiplatform-allOf-discriminator
- samples/client/petstore/kotlin-nonpublic
- samples/client/petstore/kotlin-nullable
- samples/client/petstore/kotlin-retrofit2
@ -70,7 +69,7 @@ jobs:
- samples/client/others/kotlin-jvm-okhttp-parameter-tests
- samples/client/others/kotlin-jvm-okhttp-path-comments
- samples/client/others/kotlin-integer-enum
- samples/client/petstore/kotlin-allOf-discriminator-kotlinx-serialization
- samples/client/petstore/kotlin-allOff-discriminator-kotlinx-serialization
steps:
- uses: actions/checkout@v5
- uses: actions/setup-java@v5

View File

@ -40,7 +40,7 @@ jobs:
build-root-directory: ${{ matrix.sample }}
arguments: wrapper
- name: Setup node.js
uses: actions/setup-node@v5
uses: actions/setup-node@v4
- name: Run echo server
run: |
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server

View File

@ -4,15 +4,9 @@ on:
push:
paths:
- 'samples/client/petstore/ocaml/**'
- 'samples/client/petstore/ocaml-fake-petstore/**'
- 'samples/client/petstore/ocaml-oneOf-primitive/**'
- 'samples/client/petstore/ocaml-additional-properties/**'
pull_request:
paths:
- 'samples/client/petstore/ocaml/**'
- 'samples/client/petstore/ocaml-fake-petstore/**'
- 'samples/client/petstore/ocaml-oneOf-primitive/**'
- 'samples/client/petstore/ocaml-additional-properties/**'
jobs:
build:
@ -23,9 +17,6 @@ jobs:
matrix:
sample:
- 'samples/client/petstore/ocaml/'
- 'samples/client/petstore/ocaml-fake-petstore/'
- 'samples/client/petstore/ocaml-oneOf-primitive/'
- 'samples/client/petstore/ocaml-additional-properties/'
steps:
- uses: actions/checkout@v5
- name: Set-up OCaml

View File

@ -1,48 +0,0 @@
name: Samples PHP (Server) Syntax Checker
on:
push:
paths:
- samples/server/petstore/php-symfony/SymfonyBundle-php/**
#- samples/server/petstore/php-laravel/**
- samples/server/petstore/php-flight/**
- samples/server/petstore/php-mezzio-ph-modern/**
- samples/server/petstore/php-mezzio-ph/**
- samples/server/petstore/php-slim4/**
pull_request:
paths:
- samples/server/petstore/php-symfony/SymfonyBundle-php/**
#- samples/server/petstore/php-laravel/**
- samples/server/petstore/php-flight/**
- samples/server/petstore/php-mezzio-ph-modern/**
- samples/server/petstore/php-mezzio-ph/**
- samples/server/petstore/php-slim4/**
jobs:
build:
name: Build PHP projects
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
sample:
# servers
- samples/server/petstore/php-symfony/SymfonyBundle-php/
#- samples/server/petstore/php-laravel/
- samples/server/petstore/php-flight/
- samples/server/petstore/php-mezzio-ph-modern/
- samples/server/petstore/php-mezzio-ph/
- samples/server/petstore/php-slim4/
steps:
- uses: actions/checkout@v5
- name: Setup PHP with tools
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
- name: php -l
working-directory: ${{ matrix.sample }}
run: find . -name "*.php" -exec php -l {} +

View File

@ -20,7 +20,7 @@ jobs:
- "3.12"
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install

View File

@ -25,11 +25,11 @@ jobs:
- "3.13"
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Setup node.js
uses: actions/setup-node@v5
uses: actions/setup-node@v4
- name: Run echo server
run: |
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server

View File

@ -19,7 +19,7 @@ jobs:
- samples/server/petstore/python-fastapi/
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install dependencies

View File

@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install validator
@ -45,7 +45,7 @@ jobs:
SWAGGER_BASE_PATH: /v2
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
- uses: actions/setup-python@v5
id: py
with:
python-version: ${{ matrix.python-version }}

View File

@ -24,11 +24,11 @@ jobs:
- "3.12"
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Setup node.js
uses: actions/setup-node@v5
uses: actions/setup-node@v4
- name: Run echo server
run: |
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server

View File

@ -32,7 +32,7 @@ jobs:
SWAGGER_BASE_PATH: /v2
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
- uses: actions/setup-python@v5
id: py
with:
python-version: ${{ matrix.python-version }}

View File

@ -19,7 +19,7 @@ jobs:
- samples/server/petstore/python-aiohttp-srclayout/
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Test

View File

@ -26,7 +26,7 @@ jobs:
steps:
- uses: actions/checkout@v5
- name: Setup node.js
uses: actions/setup-node@v5
uses: actions/setup-node@v4
- name: Run echo server
run: |
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server

View File

@ -1,72 +0,0 @@
name: Samples Rust Clients
on:
push:
paths:
- "samples/client/others/rust/**"
- "samples/client/petstore/rust-server/**"
pull_request:
paths:
- "samples/client/others/rust/**"
- "samples/client/petstore/rust/**"
jobs:
build:
name: Build Rust
runs-on: ubuntu-latest
services:
petstore-api:
image: swaggerapi/petstore
ports:
- 80:8080
env:
SWAGGER_HOST: http://petstore.swagger.io
SWAGGER_BASE_PATH: /v2
strategy:
fail-fast: false
matrix:
sample:
# these folders contain sub-projects of rust clients, servers
- samples/client/others/rust/
- samples/client/petstore/rust/
steps:
- uses: actions/checkout@v5
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
cache-targets: false # Don't cache workspace target directories as they don't exist
cache-directories:
${{ matrix.sample }}/target
workspaces: |
${{ matrix.sample }}/output/*
- name: Build
working-directory: ${{ matrix.sample }}
run: cargo build --all-targets --all-features
- name: Tests
working-directory: ${{ matrix.sample }}
run: |
set -e
# Iterate through each example and test various features
for package in $(find . -maxdepth 1 -mindepth 1 -type d)
do
# Not all versions have a client example
if test -f examples/client/main.rs; then
cargo build --example client --features="client"
fi
# Test the CLI works if present
if test -f bin/cli.rs; then
cargo build --bin ${package##*/} --features cli
target/debug/${package##*/} --help
fi
cargo fmt
cargo test
cargo clippy
cargo doc
done

View File

@ -1,12 +1,16 @@
name: Samples Rust Servers
name: Samples Rust
on:
push:
paths:
- "samples/client/others/rust/**"
- "samples/server/petstore/rust-server/**"
- "samples/client/petstore/rust-server/**"
- "samples/server/petstore/rust-axum/**"
pull_request:
paths:
- "samples/client/others/rust/**"
- "samples/client/petstore/rust/**"
- "samples/server/petstore/rust-server/**"
- "samples/server/petstore/rust-axum/**"
@ -19,6 +23,8 @@ jobs:
matrix:
sample:
# these folders contain sub-projects of rust clients, servers
- samples/client/others/rust/
- samples/client/petstore/rust/
- samples/server/petstore/rust-server/
- samples/server/petstore/rust-server-deprecated/
- samples/server/petstore/rust-axum/
@ -44,10 +50,19 @@ jobs:
working-directory: ${{ matrix.sample }}
run: |
set -e
# Skip samples/client/petstore/rust/ as its tests are failing.
if [[ "${{ matrix.sample }}" == "samples/client/petstore/rust/" ]]; then
echo "Skipping tests for samples/client/petstore/rust/"
exit 0
fi
# Iterate through each example and test various features
for package in $(find . -maxdepth 1 -mindepth 1 -type d)
do
# Not all versions have a client example
if test -f examples/client/main.rs; then
cargo build --example client --features="client"
fi
# Not all versions have a server example
if test -f examples/server/main.rs; then
cargo build --example server --features="server"

View File

@ -24,7 +24,6 @@ jobs:
- samples/client/petstore/scalaz
- samples/client/petstore/scala-pekko
- samples/client/petstore/scala-http4s
- samples/client/petstore/scala-sttp4-jsoniter
#- samples/client/petstore/scala-sttp
#- samples/client/petstore/scala-sttp-circe
# servers

View File

@ -22,7 +22,7 @@ jobs:
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

View File

@ -22,7 +22,7 @@ jobs:
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

View File

@ -21,7 +21,7 @@ jobs:
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

View File

@ -22,7 +22,7 @@ jobs:
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

View File

@ -18,7 +18,7 @@ jobs:
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

View File

@ -20,7 +20,7 @@ jobs:
steps:
- uses: actions/checkout@v5
- name: Setup node
uses: actions/setup-node@v5
uses: actions/setup-node@v4
- name: Install dependencies
working-directory: ${{ matrix.sample }}
run: |

3
.gitignore vendored
View File

@ -296,9 +296,6 @@ samples/openapi3/client/petstore/go/privatekey.pem
## OCaml
samples/client/petstore/ocaml/_build/
samples/client/petstore/ocaml-fake-petstore/_build/
samples/client/petstore/ocaml-oneOf-primitive/_build/
samples/client/petstore/ocaml-additional-properties/_build/
# jetbrain http client
samples/client/jetbrains/adyen/checkout71/http/client/Apis/http-client.private.env.json

219
.travis.yml Normal file
View File

@ -0,0 +1,219 @@
sudo: required
language: java
jdk:
- openjdk11
# See https://docs.travis-ci.com/user/languages/java/#caching
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
# Avoid caching our built dependencies between runs.
- rm -fr $HOME/.m2/repository/org/openapitools/
cache:
yarn: true
directories:
- $HOME/.m2
- $HOME/.ivy2
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $HOME/samples/client/petstore/javascript/node_modules
- $HOME/samples/client/petstore/php/OpenAPIToolsClient-php/vendor
- $HOME/samples/client/petstore/ruby/vendor/bundle
- $HOME/samples/client/petstore/python/.venv/
- $HOME/samples/server/petstore/rust-server/target
- $HOME/samples/server/petstore/rust-axum/target
- $HOME/perl5
- $HOME/.cargo
- $HOME/.pub-cache
- $HOME/samples/server/petstore/cpp-pistache/pistache
- $HOME/.rvm/gems/ruby-2.4.1
- $HOME/website/node_modules/
- $HOME/.cache/deno
- $HOME/.phpenv/versions/8.1.4
#services:
# - docker
# comment out the host table change to use the public petstore server
addons:
#apt:
# sources:
# - ubuntu-toolchain-r-test
# packages:
# - g++-5
#chrome: stable
hosts:
- petstore.swagger.io
before_install:
# - sudo rm -rf /var/lib/apt/lists/*
# - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) edge"
# - sudo apt-get update
# #- sudo apt-get install -qqy --no-install-recommends google-chrome-stable
# #- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
# - mkdir -vp ~/.docker/cli-plugins/
# - curl --silent -L "https://github.com/docker/buildx/releases/download/v0.3.0/buildx-v0.3.0.linux-amd64" > ~/.docker/cli-plugins/docker-buildx
# - chmod a+x ~/.docker/cli-plugins/docker-buildx
# # to run petstore server locally via docker
#- echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin || true
#- docker pull swaggerapi/petstore
#- docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore
#- docker ps -a
# comment out crystal installation as the tests will run on circleci or github action instead
# install crystal
#- echo 'deb http://download.opensuse.org/repositories/devel:/languages:/crystal/xUbuntu_16.04/ /' | sudo tee /etc/apt/sources.list.d/devel:languages:crystal.list
#- curl -fsSL https://download.opensuse.org/repositories/devel:languages:crystal/xUbuntu_16.04/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/devel_languages_crystal.gpg > /dev/null
#- sudo apt update
#- sudo apt install crystal
#- crystal --version
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.22.0
- export PATH="$HOME/.yarn/bin:$PATH"
# install rust
#- curl https://sh.rustup.rs -sSf | sh -s -- -y -v
## required when sudo: required for the Ruby petstore tests
#- gem install bundler -v 2.3.26
## set python 3.6.3 as default
#- source ~/virtualenv/python3.6/bin/activate
# -- skip bash test to shorten build time
# Add bats test framework and cURL for Bash script integration tests
#- sudo add-apt-repository ppa:duggan/bats --yes
#- sudo apt-get update -qq
#- sudo apt-get install -qq bats
#- sudo apt-get install -qq curl
# -- skip bash test end
# install dart
#- sudo apt-get update
#- sudo apt-get install apt-transport-https
#- sudo sh -c 'curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -'
#- sudo sh -c 'curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'
#- sudo apt-get update
#- sudo apt-get install dart
# switch to php8
#- sudo apt-get install -f libonig-dev libzip-dev
#- git clone https://github.com/php-build/php-build $(phpenv root)/plugins/php-build
#- git clone https://github.com/ngyuki/phpenv-composer.git $(phpenv root)/plugins/phpenv-composer
#- if [ $(ls -A "$HOME/.phpenv/versions/8.1.4" | wc -l) -eq 0 ]; then
# phpenv install 8.1.4;
# fi;
#- phpenv rehash
#- phpenv versions
##- phpenv global 7.2.15
#- phpenv global 8.1.4
#- php -v
# comment out below as installation failed in travis
# Add rebar3 build tool and recent Erlang/OTP for Erlang petstore server tests.
# - Travis CI does not support rebar3 [yet](https://github.com/travis-ci/travis-ci/issues/6506#issuecomment-275189490).
# - Rely on `kerl` for [pre-compiled versions available](https://docs.travis-ci.com/user/languages/erlang#Choosing-OTP-releases-to-test-against). Rely on installation path chosen by [`travis-erlang-builder`](https://github.com/travis-ci/travis-erlang-builder/blob/e6d016b1a91ca7ecac5a5a46395bde917ea13d36/bin/compile#L18).
# - . ~/otp/18.2.1/activate && erl -version
#- 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
# install boost
#- sudo apt install -y --no-install-recommends libboost-all-dev
# perl dep
#- cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
#- cpanm --quiet --no-interactive Test::Exception Test::More Log::Any LWP::UserAgent URI::Query Module::Runtime DateTime Module::Find Moose::Role JSON || echo "Ignored failure from cpanm"
# show host table to confirm petstore.swagger.io is mapped to localhost
- cat /etc/hosts
# show java version
- java -version
- if [ "$TRAVIS_BRANCH" = "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
openssl aes-256-cbc -K $encrypted_6e2c8bba47c6_key -iv $encrypted_6e2c8bba47c6_iv -in sec.gpg.enc -out sec.gpg -d ;
gpg --keyserver keyserver.ubuntu.com --recv-key $SIGNING_KEY ;
gpg --check-trustdb ;
fi;
- pushd .; cd website; yarn install; popd
script:
# fail fast
- set -e
# show docker buildx version
#- docker buildx version
# run integration tests defined in maven pom.xml
# WARN: Travis will timeout after 10 minutes of no stdout/stderr activity, which is problematic with mvn --quiet.
# show "error" only to reduce the log size
- ./mvnw -e --no-snapshot-updates --quiet --batch-mode --show-version clean install -DskipTests -Dmaven.javadoc.skip=true -Dorg.slf4j.simpleLogger.defaultLogLevel=error
after_success:
# push to maven repo
- if [ $SONATYPE_USERNAME ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
if [ "$TRAVIS_BRANCH" = "master" ] && [ -z $TRAVIS_TAG ]; then
echo "Publishing from branch $TRAVIS_BRANCH";
./mvnw clean deploy --quiet -DskipTests=true -B -U -P release --settings CI/settings.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error;
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
pushd .;
cd modules/openapi-generator-gradle-plugin;
./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" publishPluginMavenPublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository;
echo "Finished ./gradlew publishPluginMavenPublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository";
popd;
elif [ -z $TRAVIS_TAG ] && [[ "$TRAVIS_BRANCH" =~ ^[0-9]+\.[0-9]+\.x$ ]]; then
echo "Publishing from branch $TRAVIS_BRANCH";
./mvnw clean deploy --quiet --settings CI/settings.xml -Dorg.slf4j.simpleLogger.defaultLogLevel=error;
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
pushd .;
cd modules/openapi-generator-gradle-plugin;
./gradlew -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" publishPluginMavenPublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository;
echo "Finished ./gradlew publishPluginMavenPublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository";
popd;
fi;
if [ -n $TRAVIS_TAG ] && [[ "$TRAVIS_TAG" =~ ^[v][0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Publishing the gradle plugin to Gradle Portal on tag $TRAVIS_TAG (only)";
pushd .;
cd modules/openapi-generator-gradle-plugin;
./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" publishPlugins -Dgradle.publish.key=$GRADLE_PUBLISH_KEY -Dgradle.publish.secret=$GRADLE_PUBLISH_SECRET;
echo "Finished ./gradlew publishPlugins (plugin portal)";
popd;
fi;
fi;
# ## docker: build and push openapi-generator-online to DockerHub
# - if [ $DOCKER_HUB_USERNAME ]; then
# echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin;
# export cli_version=$(\mvn -o org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -v '\[');
# export build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ");
# docker buildx create --use;
# if [ ! -z "$TRAVIS_TAG" ]; then
# docker buildx build --push --platform linux/amd64,linux/arm64 --label=org.opencontainers.image.created=$build_date --label=org.opencontainers.image.title=openapi-generator-online --label=org.opencontainers.image.revision=$TRAVIS_COMMIT --label=org.opencontainers.image.version=$cli_version -t $DOCKER_GENERATOR_IMAGE_NAME:latest -t $DOCKER_GENERATOR_IMAGE_NAME:$TRAVIS_TAG -t $DOCKER_GENERATOR_IMAGE_NAME -t $DOCKER_GENERATOR_IMAGE_NAME:latest-release ./modules/openapi-generator-online;
# echo "Built and tagged $DOCKER_GENERATOR_IMAGE_NAME";
# fi;
# if [ -z "$TRAVIS_TAG" ] && [ "$TRAVIS_BRANCH" = "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
# docker buildx build --push --platform linux/amd64,linux/arm64 --label=org.opencontainers.image.created=$build_date --label=org.opencontainers.image.title=openapi-generator-online --label=org.opencontainers.image.revision=$TRAVIS_COMMIT --label=org.opencontainers.image.version=$cli_version -t $DOCKER_GENERATOR_IMAGE_NAME ./modules/openapi-generator-online;
# echo "Pushed to $DOCKER_GENERATOR_IMAGE_NAME for master";
# fi;
# fi;
## ## docker: build cli image and push to Docker Hub
# - if [ $DOCKER_HUB_USERNAME ]; then
# echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin;
# cp docker-entrypoint.sh ./modules/openapi-generator-cli;
# export cli_version=$(\mvn -o org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -v '\[');
# export build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ");
# docker buildx create --use;
# docker buildx build --platform linux/amd64,linux/arm64 --label=org.opencontainers.image.created=$build_date --label=org.opencontainers.image.title=openapi-generator-cli --label=org.opencontainers.image.revision=$TRAVIS_COMMIT --label=org.opencontainers.image.version=$cli_version -t $DOCKER_CODEGEN_CLI_IMAGE_NAME ./modules/openapi-generator-cli;
# if [ ! -z "$TRAVIS_TAG" ]; then
# docker buildx build --push --platform linux/amd64,linux/arm64 --label=org.opencontainers.image.created=$build_date --label=org.opencontainers.image.title=openapi-generator-cli --label=org.opencontainers.image.revision=$TRAVIS_COMMIT --label=org.opencontainers.image.version=$cli_version -t $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest -t $DOCKER_CODEGEN_CLI_IMAGE_NAME:$TRAVIS_TAG -t $DOCKER_CODEGEN_CLI_IMAGE_NAME -t $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest-release ./modules/openapi-generator-cli;
# echo "Built and tagged $DOCKER_GENERATOR_IMAGE_NAME";
# fi;
# if [ -z "$TRAVIS_TAG" ] && [ "$TRAVIS_BRANCH" = "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
# docker buildx build --push --platform linux/amd64,linux/arm64 --label=org.opencontainers.image.created=$build_date --label=org.opencontainers.image.title=openapi-generator-cli --label=org.opencontainers.image.revision=$TRAVIS_COMMIT --label=org.opencontainers.image.version=$cli_version -t $DOCKER_CODEGEN_CLI_IMAGE_NAME ./modules/openapi-generator-cli;
# echo "Pushed to $DOCKER_CODEGEN_CLI_IMAGE_NAME";
# fi;
# fi;
# ## NOTE; we will do the followign manually instead as the page doesn't need to be updated in every single travis build
## 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
# sed -i "s/Vector{UInt8}/Vector\{UInt8\}/g" docs/generators/julia-client.md;
# sed -i "s/Vector{UInt8}/Vector\{UInt8\}/g" docs/generators/julia-server.md;
# 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

View File

@ -15,7 +15,7 @@
<div align="center">
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.16.0`):
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.15.0`):
[![Build Status](https://api.travis-ci.com/OpenAPITools/openapi-generator.svg?branch=master&status=passed)](https://app.travis-ci.com/github/OpenAPITools/openapi-generator/builds)
[![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator)
[![Windows Test](https://ci.appveyor.com/api/projects/status/github/openapitools/openapi-generator?branch=master&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/openapi-generator)
@ -150,8 +150,8 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
| OpenAPI Generator Version | Release Date | Notes |
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------------------------------------- |
| 7.16.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.16.0-SNAPSHOT/) | 22.09.2025 | Minor release with breaking changes (with fallback) |
| [7.15.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.15.0) (latest stable release) | 22.08.2025 | Minor release with breaking changes (with fallback) |
| 7.15.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.15.0-SNAPSHOT/) | 29.07.2025 | Minor release with breaking changes (with fallback) |
| [7.14.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.14.0) (latest stable release) | 25.06.2025 | Minor release with breaking changes (with fallback) |
| [6.6.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v6.6.0) | 11.05.2023 | Minor release with breaking changes (with 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) |
| [4.3.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.3.1) | 06.05.2020 | Patch release (enhancements, bug fixes, etc) |
@ -214,16 +214,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 11 runtime at a minimum):
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.15.0/openapi-generator-cli-7.15.0.jar`
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.14.0/openapi-generator-cli-7.14.0.jar`
For **Mac/Linux** users:
```sh
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.15.0/openapi-generator-cli-7.15.0.jar -O openapi-generator-cli.jar
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.14.0/openapi-generator-cli-7.14.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/7.15.0/openapi-generator-cli-7.15.0.jar
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.14.0/openapi-generator-cli-7.14.0.jar
```
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
@ -458,7 +458,7 @@ openapi-generator-cli version
To use a specific version of "openapi-generator-cli"
```sh
openapi-generator-cli version-manager set 7.15.0
openapi-generator-cli version-manager set 7.14.0
```
Or install it as dev-dependency:
@ -482,7 +482,7 @@ pip install openapi-generator-cli
To install a specific version
```
pip install openapi-generator-cli==7.15.0
pip install openapi-generator-cli==7.14.0
```
You can also install with [jdk4py](https://github.com/activeviam/jdk4py) instead of java binary. (python>=3.10 is required)
@ -508,7 +508,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/7.15.0/openapi-generator-cli-7.15.0.jar)
You can also download the JAR (latest release) directly from [maven.org](https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.14.0/openapi-generator-cli-7.14.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`
@ -1099,7 +1099,6 @@ Here is a list of template creators:
* Scala (Akka): @cchafer
* Scala (sttp): @chameleon82
* Scala (sttp4): @flsh86
* Scala (scala-sttp4-jsoniter): @lbialy
* Scala (Pekko): @mickaelmagniez
* Scala (http4s): @JennyLeahy
* Swift: @tkqubo
@ -1265,7 +1264,7 @@ If you want to join the committee, please kindly apply by sending an email to te
| Nim | |
| NodeJS/Javascript | @CodeNinjai (2017/07) @frol (2017/07) @cliffano (2017/07) |
| ObjC | |
| OCaml | @cgensoul (2019/08), @sir4ur0n (2025/08) |
| OCaml | @cgensoul (2019/08) |
| Perl | @wing328 (2017/07) [:heart:](https://www.patreon.com/wing328) @yue9944882 (2019/06) |
| PHP | @jebentier (2017/07), @dkarlovi (2017/07), @mandrean (2017/08), @jfastnacht (2017/09), [@ybelenko](https://github.com/ybelenko) (2018/07), @renepardon (2018/12) |
| PowerShell | @wing328 (2020/05) |

View File

@ -1,9 +0,0 @@
generatorName: go
outputDir: samples/openapi3/client/petstore/go-petstore-withXml
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-addpet-only.yaml
templateDir: modules/openapi-generator/src/main/resources/go
additionalProperties:
enumClassPrefix: "true"
packageName: petstore
disallowAdditionalPropertiesIfNotPresent: false
withXml: false

View File

@ -1,9 +1,9 @@
generatorName: kotlin
outputDir: samples/client/petstore/kotlin-allOf-discriminator-kotlinx-serialization
outputDir: samples/client/petstore/kotlin-allOff-discriminator-kotlinx-serialization
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/polymorphism.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
additionalProperties:
artifactId: kotlin-allOf-discriminator
artifactId: kotlin-allOff-discriminator
serializableModel: "false"
dateLibrary: java8
enumUnknownDefaultCase: true

View File

@ -1,9 +1,9 @@
generatorName: kotlin
outputDir: samples/client/petstore/kotlin-allOf-discriminator
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-allOf-discriminator
artifactId: kotlin-allOff-discriminator
serializableModel: "false"
dateLibrary: java8
enumUnknownDefaultCase: true

View File

@ -1,8 +0,0 @@
generatorName: kotlin
outputDir: samples/client/petstore/kotlin-multiplatform-allOf-discriminator
library: multiplatform
dateLibrary: kotlinx-datetime
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/polymorphism.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
additionalProperties:
artifactId: kotlin-multiplatform-allOf-discriminator

View File

@ -1,6 +0,0 @@
generatorName: ocaml
outputDir: samples/client/petstore/ocaml-additional-properties
inputSpec: modules/openapi-generator/src/test/resources/3_0/ocaml/additional-properties.yaml
templateDir: modules/openapi-generator/src/main/resources/ocaml
additionalProperties:
packageName: petstore_client

View File

@ -1,6 +0,0 @@
generatorName: ocaml
outputDir: samples/client/petstore/ocaml-fake-petstore
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/ocaml
additionalProperties:
packageName: petstore_client

View File

@ -1,6 +0,0 @@
generatorName: ocaml
outputDir: samples/client/petstore/ocaml-oneOf-primitive
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf_primitive.yaml
templateDir: modules/openapi-generator/src/main/resources/ocaml
additionalProperties:
packageName: petstore_client

View File

@ -13,5 +13,3 @@ additionalProperties:
nameMappings:
_type: underscore_type
type_: type_with_underscore
openapiNormalizer:
SIMPLIFY_ONEOF_ANYOF_ENUM: false

View File

@ -13,5 +13,3 @@ nameMappings:
modelNameMappings:
# The OpenAPI spec ApiResponse conflicts with the internal ApiResponse
ApiResponse: ModelApiResponse
openapiNormalizer:
SIMPLIFY_ONEOF_ANYOF_ENUM: false

View File

@ -1,6 +0,0 @@
generatorName: scala-sttp4-jsoniter
outputDir: samples/client/petstore/scala-sttp4-jsoniter
inputSpec: modules/openapi-generator/src/test/resources/3_0/scala/scala-sttp4-jsoniter/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/scala-sttp4-jsoniter
additionalProperties:
hideGenerationTimestamp: "true"

View File

@ -564,15 +564,6 @@ Example:
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/simplifyAnyOfStringAndEnumString_test.yaml -o /tmp/java-okhttp/ --openapi-normalizer SIMPLIFY_ANYOF_STRING_AND_ENUM_STRING=true
```
- `SIMPLIFY_ONEOF_ANYOF_ENUM`: when set to true, oneOf/anyOf with only enum sub-schemas all containing enum values will be converted to a single enum
This is enabled by default
Example:
```
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/simplifyOneOfWithEnums_test.yaml -o /tmp/java-okhttp/ --openapi-normalizer SIMPLIFY_ONEOF_ANYOF_ENUM=true
```
- `SIMPLIFY_BOOLEAN_ENUM`: when set to `true`, convert boolean enum to just enum.
Example:

View File

@ -96,7 +96,7 @@ mvn integration-test
### Which Swift generator is still actively maintained?
Please use `swift5` generator because Swift 4.x is deprecated.
There is a new `swift6` generator, that is now stable, try it and give us your feedback.
There is a new `swift6` generator, that is currently in beta, try it and give us your feedback.
### How do I implement bearer token authentication with URLSession on the Swift 5 API client?

View File

@ -65,11 +65,10 @@ The following generators are available:
* [scala-pekko](generators/scala-pekko.md)
* [scala-sttp](generators/scala-sttp.md)
* [scala-sttp4 (beta)](generators/scala-sttp4.md)
* [scala-sttp4-jsoniter (beta)](generators/scala-sttp4-jsoniter.md)
* [scalaz](generators/scalaz.md)
* [swift-combine](generators/swift-combine.md)
* [swift5](generators/swift5.md)
* [swift6](generators/swift6.md)
* [swift6 (beta)](generators/swift6.md)
* [typescript (experimental)](generators/typescript.md)
* [typescript-angular](generators/typescript-angular.md)
* [typescript-aurelia](generators/typescript-aurelia.md)

View File

@ -37,7 +37,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|pubRepository|Repository in generated pubspec| |null|
|pubVersion|Version in generated pubspec| |1.0.0|
|serializationLibrary|Specify serialization library|<dl><dt>**built_value**</dt><dd>[DEFAULT] built_value</dd><dt>**json_serializable**</dt><dd>[BETA] json_serializable</dd></dl>|built_value|
|skipCopyWith|Skip CopyWith when using Json Serializable for serialization| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|sourceFolder|source folder for generated code| |src|

View File

@ -68,7 +68,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|
|interfaceOnly|Whether to generate only API interface stubs without the server files.| |false|
|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>|false|
|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>**spring-boot**</dt><dd>Spring-boot Server application.</dd><dt>**spring-cloud**</dt><dd>Spring-Cloud-Feign client with Spring-Boot auto-configured settings.</dd><dt>**spring-http-interface**</dt><dd>Spring 6 HTTP interfaces (testing)</dd></dl>|spring-boot|
|licenseName|The name of the license| |Unlicense|
|licenseUrl|The URL of the license| |http://unlicense.org|
@ -103,7 +103,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useFeignClientContextId|Whether to generate Feign client with contextId parameter.| |true|
|useFeignClientUrl|Whether to generate Feign client with url parameter.| |true|
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |true|
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
|useOptional|Use Optional container for optional parameters| |false|
|useResponseEntity|Use the `ResponseEntity` type to wrap return values of generated API methods. If disabled, method are annotated using a `@ResponseStatus` annotation, which has the status of the first response declared in the Api definition| |true|
|useSealed|Whether to generate sealed model interfaces and classes| |false|

View File

@ -209,8 +209,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|Polymorphism|✗|OAS2,OAS3
|Union|✗|OAS3
|allOf|✗|OAS2,OAS3
|anyOf||OAS3
|oneOf||OAS3
|anyOf||OAS3
|oneOf||OAS3
|not|✗|OAS3
### Security Feature

View File

@ -1,260 +0,0 @@
---
title: Documentation for the scala-sttp4-jsoniter Generator
---
## METADATA
| Property | Value | Notes |
| -------- | ----- | ----- |
| generator name | scala-sttp4-jsoniter | pass this to the generate command after -g |
| generator stability | BETA | |
| generator type | CLIENT | |
| generator language | Scala | |
| generator default templating engine | mustache | |
| helpTxt | Generates a Scala client library (beta) based on Sttp4 and Jsoniter-Scala. | |
## 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.
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|apiPackage|package for generated api classes| |null|
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
|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|
|jsoniterVersion|The version of jsoniter-scala library| |2.31.1|
|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|
|mainPackage|Top-level package name, which defines 'apiPackage', 'modelPackage', 'invokerPackage'| |org.openapitools.client|
|modelPackage|package for generated models| |null|
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|separateErrorChannel|Whether to return response as F[Either[ResponseError[ErrorType], ReturnType]]] or to flatten response's error raising them through enclosing monad (F[ReturnType]).| |true|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|sourceFolder|source folder for generated code| |null|
|sttpClientVersion|The version of sttp client| |4.0.0-RC1|
## IMPORT MAPPING
| Type/Alias | Imports |
| ---------- | ------- |
|Array|java.util.List|
|ArrayList|java.util.ArrayList|
|BigDecimal|scala.math.BigDecimal|
|Date|java.util.Date|
|DateTime|org.joda.time.*|
|File|java.io.File|
|HashMap|java.util.HashMap|
|ListBuffer|scala.collection.mutable.ListBuffer|
|ListSet|scala.collection.immutable.ListSet|
|LocalDate|org.joda.time.*|
|LocalDateTime|org.joda.time.*|
|LocalTime|org.joda.time.*|
|Seq|scala.collection.immutable.Seq|
|Set|scala.collection.immutable.Set|
|Timestamp|java.sql.Timestamp|
|URI|java.net.URI|
|UUID|java.util.UUID|
|io.circe.Json|com.github.plokhotnyuk.jsoniter_scala.circe.JsoniterScalaCodec.*|
## INSTANTIATION TYPES
| Type/Alias | Instantiated By |
| ---------- | --------------- |
|array|ListBuffer|
|map|Map|
|set|Set|
## LANGUAGE PRIMITIVES
<ul class="column-ul">
<li>Any</li>
<li>Array</li>
<li>Boolean</li>
<li>Byte</li>
<li>Double</li>
<li>Float</li>
<li>Int</li>
<li>List</li>
<li>Long</li>
<li>Map</li>
<li>Object</li>
<li>Seq</li>
<li>String</li>
<li>boolean</li>
</ul>
## RESERVED WORDS
<ul class="column-ul">
<li>Either</li>
<li>Method</li>
<li>Request</li>
<li>abstract</li>
<li>case</li>
<li>catch</li>
<li>class</li>
<li>clone</li>
<li>def</li>
<li>do</li>
<li>else</li>
<li>enum</li>
<li>export</li>
<li>extends</li>
<li>false</li>
<li>final</li>
<li>finally</li>
<li>for</li>
<li>forSome</li>
<li>given</li>
<li>if</li>
<li>implicit</li>
<li>import</li>
<li>lazy</li>
<li>match</li>
<li>new</li>
<li>null</li>
<li>object</li>
<li>override</li>
<li>package</li>
<li>private</li>
<li>protected</li>
<li>return</li>
<li>sealed</li>
<li>super</li>
<li>then</li>
<li>this</li>
<li>throw</li>
<li>trait</li>
<li>true</li>
<li>try</li>
<li>type</li>
<li>using</li>
<li>val</li>
<li>var</li>
<li>while</li>
<li>with</li>
<li>yield</li>
</ul>
## FEATURE SET
### Client Modification Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|BasePath|✓|ToolingExtension
|Authorizations|✗|ToolingExtension
|UserAgent|✓|ToolingExtension
|MockServer|✗|ToolingExtension
### Data Type Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Custom|✗|OAS2,OAS3
|Int32|✓|OAS2,OAS3
|Int64|✓|OAS2,OAS3
|Float|✓|OAS2,OAS3
|Double|✓|OAS2,OAS3
|Decimal|✓|ToolingExtension
|String|✓|OAS2,OAS3
|Byte|✓|OAS2,OAS3
|Binary|✓|OAS2,OAS3
|Boolean|✓|OAS2,OAS3
|Date|✓|OAS2,OAS3
|DateTime|✓|OAS2,OAS3
|Password|✓|OAS2,OAS3
|File|✓|OAS2
|Uuid|✗|
|Array|✓|OAS2,OAS3
|Null|✗|OAS3
|AnyType|✗|OAS2,OAS3
|Object|✓|OAS2,OAS3
|Maps|✓|ToolingExtension
|CollectionFormat|✓|OAS2
|CollectionFormatMulti|✓|OAS2
|Enum|✓|OAS2,OAS3
|ArrayOfEnum|✓|ToolingExtension
|ArrayOfModel|✓|ToolingExtension
|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
|ArrayOfCollectionOfModel|✓|ToolingExtension
|ArrayOfCollectionOfEnum|✓|ToolingExtension
|MapOfEnum|✓|ToolingExtension
|MapOfModel|✓|ToolingExtension
|MapOfCollectionOfPrimitives|✓|ToolingExtension
|MapOfCollectionOfModel|✓|ToolingExtension
|MapOfCollectionOfEnum|✓|ToolingExtension
### Documentation Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Readme|✓|ToolingExtension
|Model|✓|ToolingExtension
|Api|✓|ToolingExtension
### Global Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Host|✓|OAS2,OAS3
|BasePath|✓|OAS2,OAS3
|Info|✓|OAS2,OAS3
|Schemes|✗|OAS2,OAS3
|PartialSchemes|✓|OAS2,OAS3
|Consumes|✓|OAS2
|Produces|✓|OAS2
|ExternalDocumentation|✓|OAS2,OAS3
|Examples|✓|OAS2,OAS3
|XMLStructureDefinitions|✗|OAS2,OAS3
|MultiServer|✗|OAS3
|ParameterizedServer|✗|OAS3
|ParameterStyling|✗|OAS3
|Callbacks|✗|OAS3
|LinkObjects|✗|OAS3
### Parameter Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Path|✓|OAS2,OAS3
|Query|✓|OAS2,OAS3
|Header|✓|OAS2,OAS3
|Body|✓|OAS2
|FormUnencoded|✓|OAS2
|FormMultipart|✓|OAS2
|Cookie|✓|OAS3
### Schema Support Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Simple|✓|OAS2,OAS3
|Composite|✓|OAS2,OAS3
|Polymorphism|✗|OAS2,OAS3
|Union|✗|OAS3
|allOf|✗|OAS2,OAS3
|anyOf|✗|OAS3
|oneOf|✗|OAS3
|not|✗|OAS3
### Security Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|BasicAuth|✓|OAS2,OAS3
|ApiKey|✓|OAS2,OAS3
|OpenIDConnect|✗|OAS3
|BearerToken|✓|OAS3
|OAuth2_Implicit|✗|OAS2,OAS3
|OAuth2_Password|✗|OAS2,OAS3
|OAuth2_ClientCredentials|✗|OAS2,OAS3
|OAuth2_AuthorizationCode|✗|OAS2,OAS3
|SignatureAuth|✗|OAS3
|AWSV4Signature|✗|ToolingExtension
### Wire Format Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|JSON|✓|OAS2,OAS3
|XML|✓|OAS2,OAS3
|PROTOBUF|✗|ToolingExtension
|Custom|✓|OAS2,OAS3

View File

@ -61,7 +61,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|
|interfaceOnly|Whether to generate only API interface stubs without the server files.| |false|
|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>|false|
|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>**spring-boot**</dt><dd>Spring-boot Server application.</dd><dt>**spring-cloud**</dt><dd>Spring-Cloud-Feign client with Spring-Boot auto-configured settings.</dd><dt>**spring-http-interface**</dt><dd>Spring 6 HTTP interfaces (testing)</dd></dl>|spring-boot|
|licenseName|The name of the license| |Unlicense|
|licenseUrl|The URL of the license| |http://unlicense.org|
@ -96,7 +96,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useFeignClientContextId|Whether to generate Feign client with contextId parameter.| |true|
|useFeignClientUrl|Whether to generate Feign client with url parameter.| |true|
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |true|
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
|useOptional|Use Optional container for optional parameters| |false|
|useResponseEntity|Use the `ResponseEntity` type to wrap return values of generated API methods. If disabled, method are annotated using a `@ResponseStatus` annotation, which has the status of the first response declared in the Api definition| |true|
|useSealed|Whether to generate sealed model interfaces and classes| |false|

View File

@ -7,7 +7,7 @@ title: Documentation for the swift6 Generator
| Property | Value | Notes |
| -------- | ----- | ----- |
| generator name | swift6 | pass this to the generate command after -g |
| generator stability | STABLE | |
| generator stability | BETA | |
| generator type | CLIENT | |
| generator language | Swift | |
| generator default templating engine | mustache | |

View File

@ -22,7 +22,7 @@ npm install @openapitools/openapi-generator-cli -g
To install a specific version of the tool, pass the version during installation:
<!-- RELEASE_VERSION -->
```bash
openapi-generator-cli version-manager set 7.15.0
openapi-generator-cli version-manager set 7.14.0
```
<!-- /RELEASE_VERSION -->
To install the tool as a dev dependency in your current project:
@ -119,18 +119,18 @@ docker run --rm \
<!-- RELEASE_VERSION -->
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 11 runtime at a minimum):
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.15.0/openapi-generator-cli-7.15.0.jar`
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.14.0/openapi-generator-cli-7.14.0.jar`
For **Mac/Linux** users:
```bash
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.15.0/openapi-generator-cli-7.15.0.jar -O openapi-generator-cli.jar
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.14.0/openapi-generator-cli-7.14.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/7.15.0/openapi-generator-cli-7.15.0.jar
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.14.0/openapi-generator-cli-7.14.0.jar
```
<!-- /RELEASE_VERSION -->

View File

@ -16,7 +16,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>7.15.0</version>
<version>7.14.0</version>
<executions>
<execution>
<goals>

View File

@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>7.16.0-SNAPSHOT</version>
<version>7.15.0</version>
<!-- /RELEASE_VERSION -->
<relativePath>../../pom.xml</relativePath>
</parent>

View File

@ -6,7 +6,7 @@
<artifactId>openapi-generator-project</artifactId>
<groupId>org.openapitools</groupId>
<!-- RELEASE_VERSION -->
<version>7.16.0-SNAPSHOT</version>
<version>7.15.0</version>
<!-- /RELEASE_VERSION -->
<relativePath>../../pom.xml</relativePath>
</parent>

View File

@ -97,7 +97,7 @@ task validateGoodSpec(type: org.openapitools.generator.gradle.plugin.tasks.Valid
[source,group]
----
plugins {
id "org.openapi.generator" version "7.15.0"
id "org.openapi.generator" version "7.14.0"
}
----
@ -113,7 +113,7 @@ buildscript {
// url "https://plugins.gradle.org/m2/"
}
dependencies {
classpath "org.openapitools:openapi-generator-gradle-plugin:7.15.0"
classpath "org.openapitools:openapi-generator-gradle-plugin:7.14.0"
}
}
@ -759,7 +759,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath('org.openapitools:openapi-generator-gradle-plugin:7.15.0') {
classpath('org.openapitools:openapi-generator-gradle-plugin:7.14.0') {
exclude group: 'com.google.guava'
}
}

View File

@ -1,5 +1,5 @@
# RELEASE_VERSION
openApiGeneratorVersion=7.16.0-SNAPSHOT
openApiGeneratorVersion=7.15.0
# /RELEASE_VERSION
# BEGIN placeholders

View File

@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>7.16.0-SNAPSHOT</version>
<version>7.15.0</version>
<!-- /RELEASE_VERSION -->
<relativePath>../../pom.xml</relativePath>
</parent>

View File

@ -19,5 +19,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=7.15.0 openApiValidate
gradle -PopenApiGeneratorVersion=7.14.0 openApiValidate
```

View File

@ -1,3 +1,3 @@
# RELEASE_VERSION
openApiGeneratorVersion=7.16.0-SNAPSHOT
openApiGeneratorVersion=7.15.0
# /RELEASE_VERSION

View File

@ -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>7.15.0</version>
<version>7.14.0</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>

View File

@ -13,7 +13,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.16.0-SNAPSHOT</version>
<version>7.15.0</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>

View File

@ -15,7 +15,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.16.0-SNAPSHOT</version>
<version>7.15.0</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>

View File

@ -19,7 +19,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.16.0-SNAPSHOT</version>
<version>7.15.0</version>
<!-- /RELEASE_VERSION -->
<dependencies>
<dependency>

View File

@ -13,7 +13,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.16.0-SNAPSHOT</version>
<version>7.15.0</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>

View File

@ -13,7 +13,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.16.0-SNAPSHOT</version>
<version>7.15.0</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>

View File

@ -20,7 +20,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>7.16.0-SNAPSHOT</version>
<version>7.15.0</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>

View File

@ -5,7 +5,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>7.16.0-SNAPSHOT</version>
<version>7.15.0</version>
<!-- /RELEASE_VERSION -->
<relativePath>../../pom.xml</relativePath>
</parent>

View File

@ -321,12 +321,6 @@ public class CodeGenMojo extends AbstractMojo {
@Parameter(name = "generateAliasAsModel", property = "openapi.generator.maven.plugin.generateAliasAsModel")
private Boolean generateAliasAsModel;
/**
* Only write output files that have changed.
*/
@Parameter(name = "minimalUpdate", property = "openapi.generator.maven.plugin.minimalUpdate")
private Boolean minimalUpdate;
/**
* A map of language-specific parameters as passed with the -c option to the command line
*/
@ -704,10 +698,6 @@ public class CodeGenMojo extends AbstractMojo {
configurator.setGenerateAliasAsModel(generateAliasAsModel);
}
if (minimalUpdate != null) {
configurator.setEnableMinimalUpdate(minimalUpdate);
}
if (isNotEmpty(generatorName)) {
configurator.setGeneratorName(generatorName);
} else {

View File

@ -38,7 +38,6 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -89,17 +88,6 @@ public class CodeGenMojoTest extends BaseTestCase {
assertEquals("joda", configOptions.get("dateLibrary"));
}
public void testMinimalUpdateConfiguration() throws Exception {
// GIVEN
CodeGenMojo mojo = loadMojo(newTempFolder(), "src/test/resources/minimal-update", null);
// WHEN
mojo.execute();
// THEN
assertEquals(Boolean.TRUE, getVariableValueFromObject(mojo, "minimalUpdate"));
}
public void testHashGenerationFileContainsExecutionId() throws Exception {
// GIVEN
final Path tempDir = newTempFolder();
@ -148,50 +136,6 @@ public class CodeGenMojoTest extends BaseTestCase {
assertFalse("src directory should not have been regenerated", Files.exists(generatedDir.resolve("src")));
}
public void testMinimalUpdate() throws Exception {
//GIVEN
/* Set up the mojo */
final Path tempDir = newTempFolder();
final CodeGenMojo mojo = loadMojo(tempDir, "src/test/resources/minimal-update", null, "executionId");
/* Perform an initial generation */
mojo.execute();
/* Collect last modified times of generated files */
final Path generatedDir = tempDir.resolve("target/generated-sources/minimal-update");
assertTrue("Generated directory should exist", Files.exists(generatedDir));
Map<Path, Long> lastModifiedTimes = new HashMap<>();
try (Stream<Path> files = Files.walk(generatedDir)) {
files
.filter(Files::isRegularFile)
.filter(path -> !path.getFileName().toString().endsWith(".sha256"))
.filter(path -> !path.getFileName().toString().equals("FILES"))
.forEach(file -> {
try {
lastModifiedTimes.put(file, Files.getLastModifiedTime(file).toMillis());
} catch (IOException e) {
throw new RuntimeException(e);
}
});
}
assertTrue("Should have recorded last modified times for more than 3 files", lastModifiedTimes.size() > 3);
// WHEN
/* Execute the mojo again */
mojo.execute();
// THEN
/* Verify that file modification times haven't changed (files weren't touched) */
for (Map.Entry<Path, Long> entry : lastModifiedTimes.entrySet()) {
Path file = entry.getKey();
Long originalTime = entry.getValue();
Long currentTime = Files.getLastModifiedTime(file).toMillis();
assertEquals("File " + file + " should not have been modified (minimal update should skip unchanged files)",
originalTime, currentTime);
}
}
/**
* For a Pom file which refers to an input file which will be on the classpath, as opposed to a file path,
* test that the generated source is regenerated when the hash has changed.

View File

@ -1,52 +0,0 @@
<!--
~ Copyright 2020, 2021 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>
<modelVersion>4.0.0</modelVersion>
<groupId>minimal.update.test</groupId>
<artifactId>minimal-update-test</artifactId>
<packaging>jar</packaging>
<version>1.0.0-SNAPSHOT</version>
<name>OpenAPI Generator Minimal Update Test</name>
<url>https://openapi-generator.tech/</url>
<build>
<finalName>minimal-update-test</finalName>
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<configuration>
<inputSpec>petstore-on-classpath.yaml</inputSpec>
<generatorName>spring</generatorName>
<output>${basedir}/target/generated-sources/minimal-update</output>
<minimalUpdate>true</minimalUpdate>
<configOptions>
<hideGenerationTimestamp>true</hideGenerationTimestamp>
</configOptions>
</configuration>
<executions>
<execution>
<id>executionId</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>7.16.0-SNAPSHOT</version>
<version>7.15.0</version>
<!-- /RELEASE_VERSION -->
<relativePath>../../pom.xml</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<!-- RELEASE_VERSION -->
<version>7.16.0-SNAPSHOT</version>
<version>7.15.0</version>
<!-- /RELEASE_VERSION -->
<relativePath>../../pom.xml</relativePath>
</parent>

View File

@ -88,9 +88,6 @@ public class OpenAPINormalizer {
// when set to true, boolean enum will be converted to just boolean
final String SIMPLIFY_BOOLEAN_ENUM = "SIMPLIFY_BOOLEAN_ENUM";
// when set to true, oneOf/anyOf with enum sub-schemas containing single values will be converted to a single enum
final String SIMPLIFY_ONEOF_ANYOF_ENUM = "SIMPLIFY_ONEOF_ANYOF_ENUM";
// when set to a string value, tags in all operations will be reset to the string value provided
final String SET_TAGS_FOR_ALL_OPERATIONS = "SET_TAGS_FOR_ALL_OPERATIONS";
String setTagsForAllOperations;
@ -208,12 +205,11 @@ public class OpenAPINormalizer {
ruleNames.add(FILTER);
ruleNames.add(SET_CONTAINER_TO_NULLABLE);
ruleNames.add(SET_PRIMITIVE_TYPES_TO_NULLABLE);
ruleNames.add(SIMPLIFY_ONEOF_ANYOF_ENUM);
// rules that are default to true
rules.put(SIMPLIFY_ONEOF_ANYOF, true);
rules.put(SIMPLIFY_BOOLEAN_ENUM, true);
rules.put(SIMPLIFY_ONEOF_ANYOF_ENUM, true);
processRules(inputRules);
@ -976,8 +972,6 @@ public class OpenAPINormalizer {
// Remove duplicate oneOf entries
ModelUtils.deduplicateOneOfSchema(schema);
schema = processSimplifyOneOfEnum(schema);
// simplify first as the schema may no longer be a oneOf after processing the rule below
schema = processSimplifyOneOf(schema);
@ -1006,11 +1000,6 @@ public class OpenAPINormalizer {
}
protected Schema normalizeAnyOf(Schema schema, Set<Schema> visitedSchemas) {
//transform anyOf into enums if needed
schema = processSimplifyAnyOfEnum(schema);
if (schema.getAnyOf() == null) {
return schema;
}
for (int i = 0; i < schema.getAnyOf().size(); i++) {
// normalize anyOf sub schemas one by one
Object item = schema.getAnyOf().get(i);
@ -1286,161 +1275,6 @@ public class OpenAPINormalizer {
}
/**
* If the schema is anyOf and all sub-schemas are enums (with one or more values),
* then simplify it to a single enum schema containing all the values.
*
* @param schema Schema
* @return Schema
*/
protected Schema processSimplifyAnyOfEnum(Schema schema) {
if (!getRule(SIMPLIFY_ONEOF_ANYOF_ENUM)) {
return schema;
}
if (schema.getAnyOf() == null || schema.getAnyOf().isEmpty()) {
return schema;
}
if(schema.getOneOf() != null && !schema.getOneOf().isEmpty() ||
schema.getAllOf() != null && !schema.getAllOf().isEmpty() ||
schema.getNot() != null) {
//only convert to enum if anyOf is the only composition
return schema;
}
return simplifyComposedSchemaWithEnums(schema, schema.getAnyOf(), "anyOf");
}
/**
* If the schema is oneOf and all sub-schemas are enums (with one or more values),
* then simplify it to a single enum schema containing all the values.
*
* @param schema Schema
* @return Schema
*/
protected Schema processSimplifyOneOfEnum(Schema schema) {
if (!getRule(SIMPLIFY_ONEOF_ANYOF_ENUM)) {
return schema;
}
if (schema.getOneOf() == null || schema.getOneOf().isEmpty()) {
return schema;
}
if(schema.getAnyOf() != null && !schema.getAnyOf().isEmpty() ||
schema.getAllOf() != null && !schema.getAllOf().isEmpty() ||
schema.getNot() != null) {
//only convert to enum if oneOf is the only composition
return schema;
}
return simplifyComposedSchemaWithEnums(schema, schema.getOneOf(), "oneOf");
}
/**
* Simplifies a composed schema (oneOf/anyOf) where all sub-schemas are enums
* to a single enum schema containing all the values.
*
* @param schema Schema to modify
* @param subSchemas List of sub-schemas to check
* @param schemaType Type of composed schema ("oneOf" or "anyOf")
* @return Simplified schema
*/
protected Schema simplifyComposedSchemaWithEnums(Schema schema, List<Object> subSchemas, String composedType) {
Map<Object, String> enumValues = new LinkedHashMap<>();
if(schema.getTypes() != null && schema.getTypes().size() > 1) {
// we cannot handle enums with multiple types
return schema;
}
if(subSchemas.size() < 2) {
//do not process if there's less than 2 sub-schemas. It will be normalized later, and this prevents
//named enum schemas from being converted to inline enum schemas
return schema;
}
String schemaType = ModelUtils.getType(schema);
for (Object item : subSchemas) {
if (!(item instanceof Schema)) {
return schema;
}
Schema subSchema = ModelUtils.getReferencedSchema(openAPI, (Schema) item);
// Check if this sub-schema has an enum (with one or more values)
if (subSchema.getEnum() == null || subSchema.getEnum().isEmpty()) {
return schema;
}
// Ensure all sub-schemas have the same type (if type is specified)
if(subSchema.getTypes() != null && subSchema.getTypes().size() > 1) {
// we cannot handle enums with multiple types
return schema;
}
String subSchemaType = ModelUtils.getType(subSchema);
if (subSchemaType != null) {
if (schemaType == null) {
schemaType = subSchemaType;
} else if (!schemaType.equals(subSchema.getType())) {
return schema;
}
}
// Add all enum values from this sub-schema to our collection
if(subSchema.getEnum().size() == 1) {
String description = subSchema.getTitle() == null ? "" : subSchema.getTitle();
if(subSchema.getDescription() != null) {
if(!description.isEmpty()) {
description += " - ";
}
description += subSchema.getDescription();
}
enumValues.put(subSchema.getEnum().get(0), description);
} else {
for(Object e: subSchema.getEnum()) {
enumValues.put(e, "");
}
}
}
return createSimplifiedEnumSchema(schema, enumValues, schemaType, composedType);
}
/**
* Creates a simplified enum schema from collected enum values.
*
* @param originalSchema Original schema to modify
* @param enumValues Collected enum values
* @param schemaType Consistent type across sub-schemas
* @param composedType Type of composed schema being simplified
* @return Simplified enum schema
*/
protected Schema createSimplifiedEnumSchema(Schema originalSchema, Map<Object, String> enumValues, String schemaType, String composedType) {
// Clear the composed schema type
if ("oneOf".equals(composedType)) {
originalSchema.setOneOf(null);
} else if ("anyOf".equals(composedType)) {
originalSchema.setAnyOf(null);
}
if (ModelUtils.getType(originalSchema) == null && schemaType != null) {
//if type was specified in subschemas, keep it in the main schema
ModelUtils.setType(originalSchema, schemaType);
}
originalSchema.setEnum(new ArrayList<>(enumValues.keySet()));
if(enumValues.values().stream().anyMatch(e -> !e.isEmpty())) {
//set x-enum-descriptions only if there's at least one non-empty description
originalSchema.addExtension("x-enum-descriptions", new ArrayList<>(enumValues.values()));
}
LOGGER.debug("Simplified {} with enum sub-schemas to single enum: {}", composedType, originalSchema);
return originalSchema;
}
/**
* If the schema is oneOf and the sub-schemas is null, set `nullable: true`
* instead.

View File

@ -47,7 +47,6 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.ModelUtils.getSchemaItems;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -1603,28 +1602,33 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen {
/**
* Provides C# strongly typed declaration for simple arrays of some type and arrays of arrays of some type.
*
* @param items The input array property
* @param arr The input array property
* @return The type declaration when the type is an array of arrays.
*/
private String getTypeDeclarationForArray(Schema<?> items) {
return getTypeDeclaration(items);
private String getArrayTypeDeclaration(Schema arr) {
// TODO: collection type here should be fully qualified namespace to avoid model conflicts
// This supports arrays of arrays.
String arrayType = typeMapping.get("array");
StringBuilder instantiationType = new StringBuilder(arrayType);
Schema<?> items = ModelUtils.getSchemaItems(arr);
String nestedType = getTypeDeclaration(items);
// TODO: We may want to differentiate here between generics and primitive arrays.
instantiationType.append("<").append(nestedType).append(">");
return instantiationType.toString();
}
@Override
public String toInstantiationType(Schema p) {
if (ModelUtils.isArraySchema(p)) {
return getTypeDeclarationForArray(p);
return getArrayTypeDeclaration(p);
}
return super.toInstantiationType(p);
}
@Override
public String getTypeDeclaration(Schema p) {
Schema<?> schema = unaliasSchema(p);
Schema<?> target = ModelUtils.isGenerateAliasAsModel() ? p : schema;
if (ModelUtils.isArraySchema(target)) {
Schema<?> items = getSchemaItems(schema);
return getSchemaType(target) + "<" + getTypeDeclarationForArray(items) + ">";
if (ModelUtils.isArraySchema(p)) {
return getArrayTypeDeclaration(p);
} else if (ModelUtils.isMapSchema(p)) {
// Should we also support maps of maps?
Schema<?> inner = ModelUtils.getAdditionalProperties(p);

View File

@ -800,9 +800,6 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
if (withXml) {
goDataTag += " xml:" + "\"" + cp.baseName;
if (cp.isXmlWrapped) {
goDataTag += ">" + ("".equals(cp.xmlName) ? cp.baseName : cp.xmlName);
}
if (cp.isXmlAttribute) {
goDataTag += ",attr";
}

View File

@ -1,5 +1,6 @@
/*
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
* Copyright 2018 SmartBear Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -528,21 +529,6 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
if (identifier.matches("[a-zA-Z_$][\\w_$]+") && !isReservedWord(identifier)) {
return identifier;
}
// below code block only for scala-sttp4-jsoniter for backward copmatibility
if (this instanceof ScalaSttp4JsoniterClientCodegen) {
if (identifier.matches("[0-9]*")) {
return escapeReservedWord(identifier);
}
if (!capitalized || StringUtils.isNumeric(name)) {
// starts with a small letter, could be a keyword or a number
return escapeReservedWord(identifier);
} else {
// no keywords start with large letter
return identifier;
}
}
return escapeReservedWord(identifier);
}

View File

@ -1748,7 +1748,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
@Override
protected void updateModelForObject(CodegenModel m, Schema schema) {
/*
/**
* we have a custom version of this function so we only set isMap to true if
* ModelUtils.isMapSchema
* In other generators, isMap is true for all type object schemas

View File

@ -1058,7 +1058,7 @@ public class CSharpReducedClientCodegen extends AbstractCSharpCodegen {
@Override
public String toInstantiationType(Schema schema) {
if (ModelUtils.isMapSchema(schema)) {
Schema<?> additionalProperties = ModelUtils.getAdditionalProperties(schema);
Schema additionalProperties = ModelUtils.getAdditionalProperties(schema);
String inner = getSchemaType(additionalProperties);
if (ModelUtils.isMapSchema(additionalProperties)) {
inner = toInstantiationType(additionalProperties);

View File

@ -69,9 +69,7 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
private static final String DIO_IMPORT = "package:dio/dio.dart";
public static final String FINAL_PROPERTIES = "finalProperties";
public static final String SKIP_COPY_WITH = "skipCopyWith";
public static final String FINAL_PROPERTIES_DEFAULT_VALUE = "true";
public static final String SKIP_COPY_WITH_DEFAULT_VALUE = "false";
private static final String CLIENT_NAME = "clientName";
@ -140,11 +138,6 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
final CliOption finalProperties = CliOption.newBoolean(FINAL_PROPERTIES, "Whether properties are marked as final when using Json Serializable for serialization");
finalProperties.setDefault("true");
cliOptions.add(finalProperties);
// skip CopyWith option
final CliOption skipCopyWith = CliOption.newBoolean(SKIP_COPY_WITH, "Skip CopyWith when using Json Serializable for serialization");
skipCopyWith.setDefault("false");
cliOptions.add(skipCopyWith);
}
@Override
@ -189,13 +182,6 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
additionalProperties.put(FINAL_PROPERTIES, Boolean.parseBoolean(additionalProperties.get(FINAL_PROPERTIES).toString()));
}
if (!additionalProperties.containsKey(SKIP_COPY_WITH)) {
additionalProperties.put(SKIP_COPY_WITH, Boolean.parseBoolean(SKIP_COPY_WITH_DEFAULT_VALUE));
LOGGER.debug("skipCopyWith not set, using default {}", SKIP_COPY_WITH_DEFAULT_VALUE);
} else {
additionalProperties.put(SKIP_COPY_WITH, Boolean.parseBoolean(additionalProperties.get(SKIP_COPY_WITH).toString()));
}
if (!additionalProperties.containsKey(CLIENT_NAME)) {
final String name = org.openapitools.codegen.utils.StringUtils.camelize(pubName);
additionalProperties.put(CLIENT_NAME, name);

View File

@ -966,7 +966,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
@Override
public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs) {
objs = super.postProcessAllModels(objs);
if (getSerializationLibrary() == SERIALIZATION_LIBRARY_TYPE.kotlinx_serialization || getLibrary().equals(MULTIPLATFORM)) {
if (getSerializationLibrary() == SERIALIZATION_LIBRARY_TYPE.kotlinx_serialization) {
// The loop removes unneeded variables so commas are handled correctly in the related templates
for (Map.Entry<String, ModelsMap> modelsMap : objs.entrySet()) {
for (ModelMap mo : modelsMap.getValue().getModels()) {
@ -976,7 +976,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
continue;
}
// Remove discriminator property from the base class, it is not needed in the generated code
getAllVarProperties(cm).forEach(list -> list.removeIf(var -> var.name.equals(discriminator.getPropertyName())));
getAllVarProperties(cm).forEach(list -> list.removeIf(var -> var.name == discriminator.getPropertyName()));
for (CodegenDiscriminator.MappedModel mappedModel : discriminator.getMappedModels()) {
// Add the mapping name to additionalProperties.disciminatorValue
@ -989,7 +989,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
}
additionalProperties.discriminatorValue = mappedModel.getMappingName();
// Remove the discriminator property from the derived class, it is not needed in the generated code
getAllVarProperties(mappedModel.getModel()).forEach(list -> list.removeIf(prop -> prop.name.equals(discriminator.getPropertyName())));
getAllVarProperties(mappedModel.getModel()).forEach(list -> list.removeIf(prop -> prop.name == discriminator.getPropertyName()));
}
}

View File

@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Mustache.Lambda;
import com.samskivert.mustache.Template;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import lombok.Getter;
@ -424,7 +425,6 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
importMapping.put("JsonProperty", "com.fasterxml.jackson.annotation.JsonProperty");
importMapping.put("JsonSubTypes", "com.fasterxml.jackson.annotation.JsonSubTypes");
importMapping.put("JsonTypeInfo", "com.fasterxml.jackson.annotation.JsonTypeInfo");
importMapping.put("JsonIgnoreProperties", "com.fasterxml.jackson.annotation.JsonIgnoreProperties");
// import JsonCreator if JsonProperty is imported
// used later in recursive import in postProcessingModels
importMapping.put("com.fasterxml.jackson.annotation.JsonProperty", "com.fasterxml.jackson.annotation.JsonCreator");
@ -827,7 +827,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
}
if (model.discriminator != null && additionalProperties.containsKey("jackson")) {
model.imports.addAll(Arrays.asList("JsonSubTypes", "JsonTypeInfo", "JsonIgnoreProperties"));
model.imports.addAll(Arrays.asList("JsonSubTypes", "JsonTypeInfo"));
}
}

View File

@ -51,6 +51,8 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
static final String X_MODEL_MODULE = "x-model-module";
public static final String CO_HTTP = "cohttp";
@Setter protected String packageName = "openapi";
@Setter protected String packageVersion = "1.0.0";
protected String apiDocPath = "docs/";
@ -95,15 +97,12 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
.excludeSchemaSupportFeatures(
SchemaSupportFeature.Polymorphism
)
.includeSchemaSupportFeatures(
SchemaSupportFeature.oneOf,
SchemaSupportFeature.anyOf
)
.includeClientModificationFeatures(
ClientModificationFeature.BasePath
)
);
outputFolder = "generated-code/ocaml";
modelTemplateFiles.put("model.mustache", ".ml");
@ -134,7 +133,6 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
supportingFiles.add(new SupportingFile("dune.mustache", "", "dune"));
supportingFiles.add(new SupportingFile("dune-project.mustache", "", "dune-project"));
supportingFiles.add(new SupportingFile("readme.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("ocamlformat.mustache", "", ".ocamlformat"));
defaultIncludes = new HashSet<>(
Arrays.asList(
@ -173,7 +171,6 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("short", "int");
typeMapping.put("char", "char");
typeMapping.put("float", "float");
typeMapping.put("decimal", "string");
typeMapping.put("double", "float");
typeMapping.put("integer", "int32");
typeMapping.put("number", "float");
@ -182,7 +179,6 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("any", "Yojson.Safe.t");
typeMapping.put("file", "string");
typeMapping.put("ByteArray", "string");
typeMapping.put("AnyType", "Yojson.Safe.t");
// lib
typeMapping.put("string", "string");
typeMapping.put("UUID", "string");
@ -190,6 +186,15 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("set", "`Set");
typeMapping.put("password", "string");
typeMapping.put("DateTime", "string");
// supportedLibraries.put(CO_HTTP, "HTTP client: CoHttp.");
//
// CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use.");
// libraryOption.setEnum(supportedLibraries);
// // set hyper as the default
// libraryOption.setDefault(CO_HTTP);
// cliOptions.add(libraryOption);
// setLibrary(CO_HTTP);
}
@Override
@ -197,12 +202,13 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
List<String> toRemove = new ArrayList<>();
for (Map.Entry<String, ModelsMap> modelEntry : superobjs.entrySet()) {
// process enum in models
List<ModelMap> models = modelEntry.getValue().getModels();
for (ModelMap mo : models) {
CodegenModel cm = mo.getModel();
// for enum model
if (cm.isEnum && cm.allowableValues != null) {
if (Boolean.TRUE.equals(cm.isEnum) && cm.allowableValues != null) {
toRemove.add(modelEntry.getKey());
} else {
enrichPropertiesWithEnumDefaultValues(cm.getAllVars());
@ -213,15 +219,6 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
enrichPropertiesWithEnumDefaultValues(cm.getVars());
enrichPropertiesWithEnumDefaultValues(cm.getParentVars());
}
if (!cm.oneOf.isEmpty()) {
// Add a boolean if it is a `oneOf`, because Mustache does not let us check if a list is non-empty
cm.getVendorExtensions().put("x-ocaml-isOneOf", true);
}
if (!cm.anyOf.isEmpty()) {
// Add a boolean if it is a `anyOf`, because Mustache does not let us check if a list is non-empty
cm.getVendorExtensions().put("x-ocaml-isAnyOf", true);
}
}
}
@ -245,7 +242,8 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
@Override
protected void updateDataTypeWithEnumForMap(CodegenProperty property) {
CodegenProperty baseItem = property.items;
while (baseItem != null && (baseItem.isMap || baseItem.isArray)) {
while (baseItem != null && (Boolean.TRUE.equals(baseItem.isMap)
|| Boolean.TRUE.equals(baseItem.isArray))) {
baseItem = baseItem.items;
}
@ -262,7 +260,8 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
@Override
protected void updateDataTypeWithEnumForArray(CodegenProperty property) {
CodegenProperty baseItem = property.items;
while (baseItem != null && (baseItem.isMap || baseItem.isArray)) {
while (baseItem != null && (Boolean.TRUE.equals(baseItem.isMap)
|| Boolean.TRUE.equals(baseItem.isArray))) {
baseItem = baseItem.items;
}
if (baseItem != null) {
@ -313,17 +312,19 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
collectEnumSchemas(parentName, sName, schema);
String pName = parentName != null ? parentName + "_" + sName : sName;
if (schema.getProperties() != null) {
String pName = parentName != null ? parentName + "_" + sName : sName;
collectEnumSchemas(pName, schema.getProperties());
}
if (schema.getAdditionalProperties() != null && schema.getAdditionalProperties() instanceof Schema) {
String pName = parentName != null ? parentName + "_" + sName : sName;
collectEnumSchemas(pName, (Schema) schema.getAdditionalProperties());
}
if (ModelUtils.isArraySchema(schema)) {
if (ModelUtils.getSchemaItems(schema) != null) {
String pName = parentName != null ? parentName + "_" + sName : sName;
collectEnumSchemas(pName, ModelUtils.getSchemaItems(schema));
}
}
@ -676,7 +677,7 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
public String toEnumValueName(String name) {
if (reservedWords.contains(name)) {
return escapeReservedWord(name);
} else if (name.chars().anyMatch(character -> specialCharReplacements.containsKey(String.valueOf((char) character)))) {
} else if (((CharSequence) name).chars().anyMatch(character -> specialCharReplacements.keySet().contains(String.valueOf((char) character)))) {
return escape(name, specialCharReplacements, Collections.singletonList("_"), null);
} else {
return name;
@ -722,6 +723,8 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
List<CodegenOperation> operations = objectMap.getOperation();
for (CodegenOperation operation : operations) {
// http method verb conversion, depending on client library (e.g. Hyper: PUT => Put, Reqwest: PUT => put)
//if (CO_HTTP.equals(getLibrary())) {
for (CodegenParameter param : operation.bodyParams) {
if (param.isModel && param.dataType.endsWith(".t")) {
param.vendorExtensions.put(X_MODEL_MODULE, param.dataType.substring(0, param.dataType.lastIndexOf('.')));

View File

@ -546,35 +546,25 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
* @param allowableValues allowable values
*/
public void addUnspecifiedToAllowableValues(Map<String, Object> allowableValues) {
final String UNSPECIFIED = "UNSPECIFIED";
if (startEnumsWithUnspecified) {
if (allowableValues.containsKey("enumVars")) {
List<Map<String, Object>> enumVars = (List<Map<String, Object>>) allowableValues.get("enumVars");
boolean unspecifiedPresent = enumVars.stream()
.anyMatch(e -> {
return UNSPECIFIED.equals(e.get("name"));
});
if (!unspecifiedPresent) {
HashMap<String, Object> unspecifiedEnum = new HashMap<String, Object>();
unspecifiedEnum.put("name", UNSPECIFIED);
unspecifiedEnum.put("isString", "false");
unspecifiedEnum.put("value", "\"" + UNSPECIFIED + "\"");
enumVars.add(0, unspecifiedEnum);
}
HashMap<String, Object> unspecified = new HashMap<String, Object>();
unspecified.put("name", "UNSPECIFIED");
unspecified.put("isString", "false");
unspecified.put("value", "\"UNSPECIFIED\"");
enumVars.add(0, unspecified);
}
if (allowableValues.containsKey("values")) {
List<String> values = (List<String>) allowableValues.get("values");
if (!values.contains(UNSPECIFIED)) {
List<String> modifiableValues = new ArrayList<>(values);
modifiableValues.add(0, UNSPECIFIED);
modifiableValues.add(0, "UNSPECIFIED");
allowableValues.put("values", modifiableValues);
}
}
}
}
/**
* Iterates enum vars and puts index to them

View File

@ -450,15 +450,7 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
CodegenOperation op = super.fromOperation(path, httpMethod, operation, servers);
String underscoredOperationId = underscore(op.operationId);
String axumPath = op.path;
for (CodegenParameter param : op.pathParams) {
// Replace {baseName} with {paramName} for format string
String paramSearch = "{" + param.baseName + "}";
String paramReplace = "{" + param.paramName + "}";
axumPath = axumPath.replace(paramSearch, paramReplace);
}
ArrayList<MethodOperation> pathMethods = pathMethodOpMap.get(axumPath);
ArrayList<MethodOperation> pathMethods = pathMethodOpMap.get(path);
// Prevent multiple declarations of the same operation
if (pathMethods != null && pathMethods.stream().anyMatch(pathMethod ->
@ -471,6 +463,14 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
if (!op.isCallbackRequest) {
// group route by path
String axumPath = op.path;
for (CodegenParameter param : op.pathParams) {
// Replace {baseName} with {paramName} for format string
String paramSearch = "{" + param.baseName + "}";
String paramReplace = "{" + param.paramName + "}";
axumPath = axumPath.replace(paramSearch, paramReplace);
}
pathMethodOpMap
.computeIfAbsent(axumPath, (key) -> new ArrayList<>())
.add(new MethodOperation(

View File

@ -307,69 +307,6 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
mdl.getComposedSchemas().setOneOf(newOneOfs);
}
// Handle anyOf schemas similarly to oneOf
// This is pragmatic since Rust's untagged enum will deserialize to the first matching variant
if (mdl.getComposedSchemas() != null && mdl.getComposedSchemas().getAnyOf() != null
&& !mdl.getComposedSchemas().getAnyOf().isEmpty()) {
List<CodegenProperty> newAnyOfs = mdl.getComposedSchemas().getAnyOf().stream()
.map(CodegenProperty::clone)
.collect(Collectors.toList());
List<Schema> schemas = ModelUtils.getInterfaces(model);
if (newAnyOfs.size() != schemas.size()) {
// For safety reasons, this should never happen unless there is an error in the code
throw new RuntimeException("anyOf size does not match the model");
}
Map<String, String> refsMapping = Optional.ofNullable(model.getDiscriminator())
.map(Discriminator::getMapping).orElse(Collections.emptyMap());
// Reverse mapped references to use as baseName for anyOf, but different keys may point to the same $ref.
// Thus, we group them by the value
Map<String, List<String>> mappedNamesByRef = refsMapping.entrySet().stream()
.collect(Collectors.groupingBy(Map.Entry::getValue,
Collectors.mapping(Map.Entry::getKey, Collectors.toList())
));
for (int i = 0; i < newAnyOfs.size(); i++) {
CodegenProperty anyOf = newAnyOfs.get(i);
Schema schema = schemas.get(i);
if (mappedNamesByRef.containsKey(schema.get$ref())) {
// prefer mapped names if present
// remove mapping not in order not to reuse for the next occurrence of the ref
List<String> names = mappedNamesByRef.get(schema.get$ref());
String mappedName = names.remove(0);
anyOf.setBaseName(mappedName);
anyOf.setName(toModelName(mappedName));
} else if (!org.apache.commons.lang3.StringUtils.isEmpty(schema.get$ref())) {
// use $ref if it's reference
String refName = ModelUtils.getSimpleRef(schema.get$ref());
if (refName != null) {
String modelName = toModelName(refName);
anyOf.setName(modelName);
anyOf.setBaseName(refName);
}
} else if (anyOf.isArray) {
// If the type is an array, extend the name with the inner type to prevent name collisions
// in case multiple arrays with different types are defined. If the user has manually specified
// a name, use that name instead.
String collectionWithTypeName = toModelName(schema.getType()) + anyOf.containerTypeMapped + anyOf.items.dataType;
String anyOfName = Optional.ofNullable(schema.getTitle()).orElse(collectionWithTypeName);
anyOf.setName(anyOfName);
}
else {
// In-placed type (primitive), because there is no mapping or ref for it.
// use camelized `title` if present, otherwise use `type`
String anyOfName = Optional.ofNullable(schema.getTitle()).orElseGet(schema::getType);
anyOf.setName(toModelName(anyOfName));
}
}
// Set anyOf as oneOf for template processing since we want the same output
mdl.getComposedSchemas().setOneOf(newAnyOfs);
}
return mdl;
}
@ -771,9 +708,9 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
}
}
// If we use a file body parameter, we need to include the imports and crates for it
// If we use a file parameter, we need to include the imports and crates for it
// But they should be added only once per file
for (var param: operation.bodyParams) {
for (var param: operation.allParams) {
if (param.isFile && supportAsync && !useAsyncFileStream) {
useAsyncFileStream = true;
additionalProperties.put("useAsyncFileStream", Boolean.TRUE);

View File

@ -1,730 +0,0 @@
/*
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.security.SecurityScheme;
import io.swagger.v3.oas.models.servers.Server;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
import org.openapitools.codegen.meta.features.*;
import org.openapitools.codegen.model.ModelMap;
import org.openapitools.codegen.model.ModelsMap;
import org.openapitools.codegen.model.OperationMap;
import org.openapitools.codegen.model.OperationsMap;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.openapitools.codegen.languages.AbstractJavaCodegen.DATE_LIBRARY;
import java.io.File;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ScalaSttp4JsoniterClientCodegen extends AbstractScalaCodegen implements CodegenConfig {
private static final StringProperty STTP_CLIENT_VERSION = new StringProperty("sttpClientVersion",
"The version of " +
"sttp client",
"4.0.0-RC1");
private static final BooleanProperty USE_SEPARATE_ERROR_CHANNEL = new BooleanProperty("separateErrorChannel",
"Whether to return response as " +
"F[Either[ResponseError[ErrorType], ReturnType]]] or to flatten " +
"response's error raising them through enclosing monad (F[ReturnType]).",
true);
private static final StringProperty JSONITER_VERSION = new StringProperty("jsoniterVersion",
"The version of jsoniter-scala " +
"library",
"2.31.1");
public static final String DEFAULT_PACKAGE_NAME = "org.openapitools.client";
private static final PackageProperty PACKAGE_PROPERTY = new PackageProperty();
private static final List<Property<?>> properties = Arrays.asList(
STTP_CLIENT_VERSION, USE_SEPARATE_ERROR_CHANNEL, JSONITER_VERSION, PACKAGE_PROPERTY);
private static final String jsonClassBaseName = "Json";
private static final String jsonValueClass = "io.circe.Json";
private static final String jsonAstCodecImport = "com.github.plokhotnyuk.jsoniter_scala.circe.JsoniterScalaCodec.*";
private static final Set<String> NO_JSON_CODEC_TYPES = new HashSet<>(Arrays.asList(
"UUID", "URI", "URL", "File", "Path", jsonClassBaseName, jsonValueClass, "BigDecimal"
));
private final Logger LOGGER = LoggerFactory.getLogger(ScalaSttp4JsoniterClientCodegen.class);
protected String groupId = "org.openapitools";
protected String artifactId = "openapi-client";
protected String artifactVersion = "1.0.0";
protected boolean registerNonStandardStatusCodes = true;
protected boolean renderJavadoc = true;
protected boolean removeOAuthSecurities = true;
protected Map<String, String> jsonCodecNeedingTypes = new HashMap<>();
Map<String, ModelsMap> enumRefs = new HashMap<>();
private final Map<String, String> apiNameMappings = new HashMap<>();
private final Set<String> uniqueApiNames = new HashSet<>();
public ScalaSttp4JsoniterClientCodegen() {
super();
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
.stability(Stability.BETA)
.build();
modifyFeatureSet(features -> features
.includeDocumentationFeatures(DocumentationFeature.Readme)
.wireFormatFeatures(EnumSet.of(WireFormatFeature.JSON, WireFormatFeature.XML, WireFormatFeature.Custom))
.securityFeatures(EnumSet.of(
SecurityFeature.BasicAuth,
SecurityFeature.ApiKey,
SecurityFeature.BearerToken))
.excludeGlobalFeatures(
GlobalFeature.XMLStructureDefinitions,
GlobalFeature.Callbacks,
GlobalFeature.LinkObjects)
.excludeSchemaSupportFeatures(
SchemaSupportFeature.Polymorphism)
.includeClientModificationFeatures(
ClientModificationFeature.BasePath,
ClientModificationFeature.UserAgent));
outputFolder = "generated-code/scala-sttp4-jsoniter";
modelTemplateFiles.put("model.mustache", ".scala");
apiTemplateFiles.put("api.mustache", ".scala");
embeddedTemplateDir = templateDir = "scala-sttp4-jsoniter";
// Scala 3 reserved words
reservedWords.addAll(Arrays.asList("enum", "export", "given", "then", "using", "Request", "Method", "Either"));
importMapping.put(jsonValueClass, jsonAstCodecImport);
importMapping.put("BigDecimal", "scala.math.BigDecimal");
additionalProperties.put(CodegenConstants.GROUP_ID, groupId);
additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId);
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, artifactVersion);
additionalProperties.put("jsonCodecNeedingTypes", jsonCodecNeedingTypes.entrySet());
if (renderJavadoc) {
additionalProperties.put("javadocRenderer", new JavadocLambda());
}
additionalProperties.put("fnCapitalize", new CapitalizeLambda());
additionalProperties.put("fnCamelize", new CamelizeLambda(false));
additionalProperties.put("fnEnumEntry", new EnumEntryLambda());
additionalProperties.put("fnCodecName", new CodecNameLambda());
additionalProperties.put("fnHandleDownload", new HandleDownloadLambda());
additionalProperties.put("fnEnumLeaf", new EnumLeafLambda());
// TODO: there is no specific sttp mapping. All Scala Type mappings should be in
// AbstractScala
typeMapping = new HashMap<>();
typeMapping.put("array", "Seq");
typeMapping.put("set", "Set");
typeMapping.put("boolean", "Boolean");
typeMapping.put("string", "String");
typeMapping.put("int", "Int");
typeMapping.put("integer", "Int");
typeMapping.put("long", "Long");
typeMapping.put("float", "Float");
typeMapping.put("byte", "Byte");
typeMapping.put("short", "Short");
typeMapping.put("char", "Char");
typeMapping.put("double", "Double");
typeMapping.put("file", "File");
typeMapping.put("binary", "File");
typeMapping.put("number", "Double");
typeMapping.put("decimal", "BigDecimal");
typeMapping.put("ByteArray", "Array[Byte]");
// actually, these two *are* jsoniter+circe AST specific
typeMapping.put("object", jsonValueClass);
typeMapping.put("AnyType", jsonValueClass);
instantiationTypes.put("array", "ListBuffer");
instantiationTypes.put("map", "Map");
// remove DATE_LIBRARY option, we don't need it
cliOptions.removeIf(option -> option.getOpt().equals(DATE_LIBRARY));
properties.stream()
.map(Property::toCliOptions)
.flatMap(Collection::stream)
.forEach(option -> cliOptions.add(option));
}
@Override
public void processOpts() {
super.processOpts();
properties.forEach(p -> p.updateAdditionalProperties(additionalProperties));
invokerPackage = PACKAGE_PROPERTY.getInvokerPackage(additionalProperties);
apiPackage = PACKAGE_PROPERTY.getApiPackage(additionalProperties);
modelPackage = PACKAGE_PROPERTY.getModelPackage(additionalProperties);
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt"));
final String invokerFolder = (sourceFolder + File.separator + invokerPackage).replace(".", File.separator);
supportingFiles.add(new SupportingFile("jsonSupport.mustache", invokerFolder, "JsonSupport.scala"));
supportingFiles.add(new SupportingFile("additionalTypeSerializers.mustache", invokerFolder,
"AdditionalTypeSerializers.scala"));
supportingFiles.add(new SupportingFile("helpers.mustache", invokerFolder,
"Helpers.scala"));
supportingFiles.add(new SupportingFile("project/build.properties.mustache", "project", "build.properties"));
}
@Override
public String getName() {
return "scala-sttp4-jsoniter";
}
@Override
public String getHelp() {
return "Generates a Scala client library (beta) based on Sttp4 and Jsoniter-Scala.";
}
@Override
public String encodePath(String input) {
String path = super.encodePath(input);
// The parameter names in the URI must be converted to the same case as
// the method parameter.
StringBuffer buf = new StringBuffer(path.length());
Matcher matcher = Pattern.compile("[{](.*?)[}]").matcher(path);
while (matcher.find()) {
matcher.appendReplacement(buf, "\\${" + toParamName(matcher.group(0)).replace("`", "") + "PathParam}");
}
matcher.appendTail(buf);
return buf.toString();
}
@Override
public CodegenOperation fromOperation(String path,
String httpMethod,
Operation operation,
List<Server> servers) {
CodegenOperation op = super.fromOperation(path, httpMethod, operation, servers);
op.path = encodePath(path);
return op;
}
@Override
public CodegenType getTag() {
return CodegenType.CLIENT;
}
@Override
public String escapeReservedWord(String name) {
if (this.reservedWordsMappings().containsKey(name)) {
return this.reservedWordsMappings().get(name);
}
return "`" + name + "`";
}
@Override
public String toApiName(String name) {
// first come, first served
// if a tag name is already mapped, use that mapping
if (apiNameMappings.containsKey(name)) {
return apiNameMappings.get(name);
}
String generatedApiName = super.toApiName(name);
String lowerCasedApiName = generatedApiName.toLowerCase(Locale.ROOT);
// check if the name is unique (case-insensitive)
// if it's unique, add it to the mappings and return the generated name
if (!uniqueApiNames.contains(lowerCasedApiName)) {
uniqueApiNames.add(lowerCasedApiName);
apiNameMappings.put(name, generatedApiName);
return generatedApiName;
} else {
// if the name is not unique, generate a new name with a unique suffix
int i = 0;
while (true) {
String nextGeneratedApiName = super.toApiName(name + i);
String lowerCasedNextGeneratedApiName = nextGeneratedApiName.toLowerCase(Locale.ROOT);
if (!uniqueApiNames.contains(lowerCasedNextGeneratedApiName)) {
uniqueApiNames.add(lowerCasedNextGeneratedApiName);
apiNameMappings.put(name, nextGeneratedApiName);
return nextGeneratedApiName;
}
i++;
}
}
}
@Override
public ModelsMap postProcessModels(ModelsMap objs) {
return objs;
}
/**
* Invoked by {@link DefaultGenerator} after all models have been
* post-processed,
* allowing for a last pass of codegen-specific model cleanup.
*
* @param objs Current state of codegen object model.
* @return An in-place modified state of the codegen object model.
*/
@Override
public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs) {
final Map<String, ModelsMap> processed = super.postProcessAllModels(objs);
postProcessUpdateImports(processed);
return processed;
}
/**
* Update/clean up model imports
* <p>
* append '._" if the import is a Enum class, otherwise
* remove model imports to avoid warnings for importing class in the same
* package in Scala
*
* @param models processed models to be further processed
*/
@SuppressWarnings("unchecked")
private void postProcessUpdateImports(final Map<String, ModelsMap> models) {
final String prefix = modelPackage() + ".";
enumRefs = getEnumRefs(models);
for (String openAPIName : models.keySet()) {
CodegenModel model = ModelUtils.getModelByName(openAPIName, models);
if (model == null) {
LOGGER.warn(
"Expected to retrieve model {} by name, but no model was found. Check your -Dmodels inclusions.",
openAPIName);
continue;
}
ModelsMap objs = models.get(openAPIName);
List<Map<String, String>> imports = objs.getImports();
if (imports == null || imports.isEmpty()) {
continue;
}
List<Map<String, String>> newImports = new ArrayList<>();
boolean foundJsonImport = false;
for (Map<String, String> anImport : imports) {
String importPath = anImport.get("import");
Map<String, String> item = new HashMap<>();
// remove any imports for io.circe.Json, it's a FQCN
// but on the first encounter, add the import for the
// jsoniter-scala circe AST codec as it will be necessary
// for all places where io.circe.Json is used as request body
// or response body
if (importPath.contains(jsonValueClass)) {
if (!foundJsonImport) {
foundJsonImport = true;
item.put("import", jsonAstCodecImport);
newImports.add(item);
}
continue;
}
if (importPath.startsWith(prefix)) {
if (isEnumClass(importPath, enumRefs)) {
item.put("import", importPath.concat(".*"));
newImports.add(item);
}
} else {
item.put("import", importPath);
newImports.add(item);
}
}
// reset imports
objs.setImports(newImports);
}
}
private Map<String, ModelsMap> getEnumRefs(final Map<String, ModelsMap> models) {
Map<String, ModelsMap> enums = new HashMap<>();
for (String key : models.keySet()) {
CodegenModel model = ModelUtils.getModelByName(key, models);
if (model != null && model.isEnum) {
ModelsMap objs = models.get(key);
enums.put(key, objs);
}
}
return enums;
}
private boolean isEnumClass(final String importPath, final Map<String, ModelsMap> enumModels) {
if (enumModels == null || enumModels.isEmpty()) {
return false;
}
for (ModelsMap objs : enumModels.values()) {
List<ModelMap> models = objs.getModels();
if (models == null || models.isEmpty()) {
continue;
}
for (final Map<String, Object> model : models) {
String enumImportPath = (String) model.get("importPath");
if (enumImportPath != null && enumImportPath.equals(importPath)) {
return true;
}
}
}
return false;
}
@Override
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
OperationMap ops = objs.getOperations();
for (CodegenOperation operation : ops.getOperation()) {
if (operation.returnType != null && !NO_JSON_CODEC_TYPES.contains(operation.returnType)) {
String identifier = formatIdentifier(operation.returnType, false) + "Codec";
String type = operation.returnType;
jsonCodecNeedingTypes.put(identifier, type);
}
if (operation.bodyParam != null && !NO_JSON_CODEC_TYPES.contains(operation.bodyParam.dataType)) {
String identifier = formatIdentifier(operation.bodyParam.dataType, false) + "Codec";
String type = operation.bodyParam.dataType;
jsonCodecNeedingTypes.put(identifier, type);
}
}
if (registerNonStandardStatusCodes) {
try {
OperationMap opsMap = objs.getOperations();
HashSet<Integer> unknownCodes = new HashSet<>();
for (CodegenOperation operation : opsMap.getOperation()) {
for (CodegenResponse response : operation.responses) {
if ("default".equals(response.code)) {
continue;
}
try {
int code = Integer.parseInt(response.code);
if (code >= 600) {
unknownCodes.add(code);
}
} catch (NumberFormatException e) {
LOGGER.error("Status code is not an integer : response.code", e);
}
}
}
if (!unknownCodes.isEmpty()) {
additionalProperties.put("unknownStatusCodes", unknownCodes);
}
} catch (Exception e) {
LOGGER.error("Unable to find operations List", e);
}
}
// update imports for enum class
List<Map<String, String>> newImports = new ArrayList<>();
List<Map<String, String>> imports = objs.getImports();
if (imports != null && !imports.isEmpty()) {
for (Map<String, String> anImport : imports) {
String importPath = anImport.get("import");
Map<String, String> item = new HashMap<>();
if (isEnumClass(importPath, enumRefs)) {
item.put("import", importPath.concat(".*"));
Map<String, String> enumClassImport = new HashMap<>();
enumClassImport.put("import", importPath);
newImports.add(item);
newImports.add(enumClassImport);
} else {
item.put("import", importPath);
newImports.add(item);
}
}
}
objs.setImports(newImports);
return super.postProcessOperationsWithModels(objs, allModels);
}
@Override
public List<CodegenSecurity> fromSecurity(Map<String, SecurityScheme> schemes) {
final List<CodegenSecurity> codegenSecurities = super.fromSecurity(schemes);
if (!removeOAuthSecurities) {
return codegenSecurities;
}
// Remove OAuth securities
codegenSecurities.removeIf(security -> security.isOAuth);
if (codegenSecurities.isEmpty()) {
return null;
}
return codegenSecurities;
}
@Override
public String toParamName(String name) {
// obtain the name from parameterNameMapping directly if provided
if (parameterNameMapping.containsKey(name)) {
return parameterNameMapping.get(name);
}
return formatIdentifier(name, false);
}
@Override
public String toEnumName(CodegenProperty property) {
String identifier = formatIdentifier(property.baseName, true);
if (identifier.startsWith("`") && identifier.endsWith("`")) {
// is it numeric?
String unescaped = identifier.substring(1, identifier.length() - 1);
if (StringUtils.isNumeric(unescaped)) {
return identifier; // keep backticks
}
// remove backticks because there are no capitalized reserved words in Scala
return identifier.substring(1, identifier.length() - 1);
} else {
return identifier;
}
}
@Override
public String toDefaultValue(Schema p) {
if (p.getRequired() != null && p.getRequired().contains(p.getName())) {
return "None";
}
if (ModelUtils.isBooleanSchema(p)) {
return null;
} else if (ModelUtils.isDateSchema(p)) {
return null;
} else if (ModelUtils.isDateTimeSchema(p)) {
return null;
} else if (ModelUtils.isNumberSchema(p)) {
return null;
} else if (ModelUtils.isIntegerSchema(p)) {
return null;
} else if (ModelUtils.isMapSchema(p)) {
String inner = getSchemaType(ModelUtils.getAdditionalProperties(p));
return "Map[String, " + inner + "].empty ";
} else if (ModelUtils.isArraySchema(p)) {
String inner = getSchemaType(ModelUtils.getSchemaItems(p));
if (ModelUtils.isSet(p)) {
return "Set[" + inner + "].empty ";
}
return "Seq[" + inner + "].empty ";
} else if (ModelUtils.isStringSchema(p)) {
return null;
} else {
return null;
}
}
/**
* Update datatypeWithEnum for array container
*
* @param property Codegen property
*/
@Override
protected void updateDataTypeWithEnumForArray(CodegenProperty property) {
CodegenProperty baseItem = property.items;
while (baseItem != null && (Boolean.TRUE.equals(baseItem.isMap)
|| Boolean.TRUE.equals(baseItem.isArray))) {
baseItem = baseItem.items;
}
if (baseItem != null) {
// set datetypeWithEnum as only the inner type is enum
property.datatypeWithEnum = toEnumName(baseItem);
// naming the enum with respect to the language enum naming convention
// e.g. remove [], {} from array/map of enum
property.enumName = toEnumName(property);
property._enum = baseItem._enum;
updateCodegenPropertyEnum(property);
}
}
public static abstract class Property<T> {
final String name;
final String description;
final T defaultValue;
public Property(String name, String description, T defaultValue) {
this.name = name;
this.description = description;
this.defaultValue = defaultValue;
}
public abstract List<CliOption> toCliOptions();
public abstract void updateAdditionalProperties(Map<String, Object> additionalProperties);
public abstract T getValue(Map<String, Object> additionalProperties);
public void setValue(Map<String, Object> additionalProperties, T value) {
additionalProperties.put(name, value);
}
}
public static class StringProperty extends Property<String> {
public StringProperty(String name, String description, String defaultValue) {
super(name, description, defaultValue);
}
@Override
public List<CliOption> toCliOptions() {
return Collections.singletonList(CliOption.newString(name, description).defaultValue(defaultValue));
}
@Override
public void updateAdditionalProperties(Map<String, Object> additionalProperties) {
if (!additionalProperties.containsKey(name)) {
additionalProperties.put(name, defaultValue);
}
}
@Override
public String getValue(Map<String, Object> additionalProperties) {
return additionalProperties.getOrDefault(name, defaultValue).toString();
}
}
public static class BooleanProperty extends Property<Boolean> {
public BooleanProperty(String name, String description, Boolean defaultValue) {
super(name, description, defaultValue);
}
@Override
public List<CliOption> toCliOptions() {
return Collections.singletonList(CliOption.newBoolean(name, description, defaultValue));
}
@Override
public void updateAdditionalProperties(Map<String, Object> additionalProperties) {
Boolean value = getValue(additionalProperties);
additionalProperties.put(name, value);
}
@Override
public Boolean getValue(Map<String, Object> additionalProperties) {
return Boolean.valueOf(additionalProperties.getOrDefault(name, defaultValue.toString()).toString());
}
}
public static class PackageProperty extends StringProperty {
public PackageProperty() {
super("mainPackage", "Top-level package name, which defines 'apiPackage', 'modelPackage', " +
"'invokerPackage'", DEFAULT_PACKAGE_NAME);
}
@Override
public void updateAdditionalProperties(Map<String, Object> additionalProperties) {
String mainPackage = getValue(additionalProperties);
if (!additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) {
String apiPackage = mainPackage + ".api";
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);
}
if (!additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) {
String modelPackage = mainPackage + ".model";
additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage);
}
if (!additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
String invokerPackage = mainPackage + ".core";
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
}
}
public String getApiPackage(Map<String, Object> additionalProperties) {
return additionalProperties.getOrDefault(CodegenConstants.API_PACKAGE, DEFAULT_PACKAGE_NAME + ".api")
.toString();
}
public String getModelPackage(Map<String, Object> additionalProperties) {
return additionalProperties.getOrDefault(CodegenConstants.MODEL_PACKAGE, DEFAULT_PACKAGE_NAME + ".model")
.toString();
}
public String getInvokerPackage(Map<String, Object> additionalProperties) {
return additionalProperties.getOrDefault(CodegenConstants.INVOKER_PACKAGE, DEFAULT_PACKAGE_NAME + ".core")
.toString();
}
}
private static class JavadocLambda extends CustomLambda {
@Override
public String formatFragment(String fragment) {
final String[] lines = fragment.split("\\r?\\n");
final StringBuilder sb = new StringBuilder();
sb.append(" /**\n");
for (String line : lines) {
sb.append(" * ").append(line).append("\n");
}
sb.append(" */\n");
return sb.toString();
}
}
private static class CapitalizeLambda extends CustomLambda {
@Override
public String formatFragment(String fragment) {
return StringUtils.capitalize(fragment);
}
}
private static class EnumEntryLambda extends CustomLambda {
@Override
public String formatFragment(String fragment) {
if (fragment.isBlank()) {
return "NotPresent";
}
return "`" + fragment + "`";
}
}
private static class EnumLeafLambda extends CustomLambda {
@Override
public String formatFragment(String fragment) {
if (fragment.isBlank()) {
return "NotPresent";
}
return fragment.replace("`", "");
}
}
private class CodecNameLambda extends CustomLambda {
@Override
public String formatFragment(String fragment) {
// remove backticks because this is used as prefix for Codec generation
return formatIdentifier(fragment, false).replace("`", "") + "Codec";
}
}
private static class HandleDownloadLambda extends CustomLambda {
@Override
public String formatFragment(String fragment) {
if (fragment.equals("asJson[File]")) {
return "asFile(File.createTempFile(\"download\", \".tmp\")).mapWithMetadata((result, metadata) => result.left.map(errStr => ResponseException.DeserializationException(errStr, new Exception(errStr), metadata)))";
} else {
return fragment;
}
}
}
}

View File

@ -188,12 +188,6 @@ public class SpringCodegen extends AbstractJavaCodegen
updateOption(CodegenConstants.API_PACKAGE, apiPackage);
updateOption(CodegenConstants.MODEL_PACKAGE, modelPackage);
// Enable discriminator-based oneOf interface generation by default
useOneOfInterfaces = true;
legacyDiscriminatorBehavior = false;
updateOption(USE_ONE_OF_INTERFACES, String.valueOf(useOneOfInterfaces));
updateOption(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, String.valueOf(legacyDiscriminatorBehavior));
apiTestTemplateFiles.clear(); // TODO: add test template
// spring uses the jackson lib
@ -371,6 +365,9 @@ public class SpringCodegen extends AbstractJavaCodegen
convertPropertyToTypeAndWriteBack(REQUEST_MAPPING_OPTION, RequestMappingMode::valueOf, this::setRequestMappingMode);
useOneOfInterfaces = true;
legacyDiscriminatorBehavior = false;
// Please refrain from updating values of Config Options after super.ProcessOpts() is called
super.processOpts();
@ -1039,12 +1036,6 @@ public class SpringCodegen extends AbstractJavaCodegen
codegenOperation.imports.addAll(provideArgsClassSet);
}
// to prevent inheritors (JavaCamelServerCodegen etc.) mistakenly use it
if (getName().contains("spring")) {
codegenOperation.allParams.stream().filter(CodegenParameter::notRequiredOrIsNullable).findAny()
.ifPresent(p -> codegenOperation.imports.add("Nullable"));
}
if (reactive) {
if (DocumentationProvider.SPRINGFOX.equals(getDocumentationProvider())) {
codegenOperation.imports.add("ApiIgnore");

View File

@ -1342,7 +1342,7 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
System.out.println("# swift5 generator is contributed by Bruno Coelho (https://github.com/4brunu). #");
System.out.println("# Please support his work directly via https://paypal.com/paypalme/4brunu \uD83D\uDE4F #");
System.out.println("# #");
System.out.println("# There is a new swift6 generator, that is now stable. #");
System.out.println("# There is a new swift6 generator, that is currently in beta. #");
System.out.println("# Try it and give us your feedback. #");
System.out.println("# https://openapi-generator.tech/docs/generators/swift6 #");
System.out.println("# #");

View File

@ -142,7 +142,7 @@ public class Swift6ClientCodegen extends DefaultCodegen implements CodegenConfig
this.useOneOfInterfaces = true;
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
.stability(Stability.STABLE)
.stability(Stability.BETA)
.build();
outputFolder = "generated-code" + File.separator + "swift";

View File

@ -559,9 +559,7 @@ public class ModelUtils {
}
// additionalProperties explicitly set to false
if ((schema.getAdditionalProperties() instanceof Boolean && Boolean.FALSE.equals(schema.getAdditionalProperties())) ||
(schema.getAdditionalProperties() instanceof Schema && Boolean.FALSE.equals(((Schema) schema.getAdditionalProperties()).getBooleanSchemaValue()))
) {
if (schema.getAdditionalProperties() instanceof Boolean && Boolean.FALSE.equals(schema.getAdditionalProperties())) {
return false;
}
@ -810,13 +808,7 @@ public class ModelUtils {
(null != schema.getProperties() && !schema.getProperties().isEmpty()) &&
// no additionalProperties is set
(schema.getAdditionalProperties() == null ||
// additionalProperties is boolean and set to false
(schema.getAdditionalProperties() instanceof Boolean && !(Boolean) schema.getAdditionalProperties()) ||
// additionalProperties is a schema with its boolean value set to false
(schema.getAdditionalProperties() instanceof Schema &&
((Schema) schema.getAdditionalProperties()).getBooleanSchemaValue() != null &&
!((Schema) schema.getAdditionalProperties()).getBooleanSchemaValue())
);
(schema.getAdditionalProperties() instanceof Boolean && !(Boolean) schema.getAdditionalProperties()));
}
public static boolean hasValidation(Schema sc) {
@ -1573,7 +1565,6 @@ public class ModelUtils {
List<String> refedWithoutDiscriminator = new ArrayList<>();
if (interfaces != null && !interfaces.isEmpty()) {
List<String> parentNameCandidates = new ArrayList<>(interfaces.size());
for (Schema schema : interfaces) {
// get the actual schema
if (StringUtils.isNotEmpty(schema.get$ref())) {
@ -1581,10 +1572,10 @@ public class ModelUtils {
Schema s = allSchemas.get(parentName);
if (s == null) {
LOGGER.error("Failed to obtain schema from {}", parentName);
parentNameCandidates.add("UNKNOWN_PARENT_NAME");
return "UNKNOWN_PARENT_NAME";
} else if (hasOrInheritsDiscriminator(s, allSchemas, new ArrayList<Schema>())) {
// discriminator.propertyName is used or x-parent is used
parentNameCandidates.add(parentName);
return parentName;
} else {
// not a parent since discriminator.propertyName or x-parent is not set
hasAmbiguousParents = true;
@ -1601,12 +1592,6 @@ public class ModelUtils {
}
}
}
if (parentNameCandidates.size() > 1) {
// unclear which one should be the parent
return null;
} else if (parentNameCandidates.size() == 1) {
return parentNameCandidates.get(0);
}
if (refedWithoutDiscriminator.size() == 1 && nullSchemaChildrenCount == 1) {
// One schema is a $ref and the other is the 'null' type, so the parent is obvious.
// In this particular case there is no need to specify a discriminator.
@ -1941,7 +1926,7 @@ public class ModelUtils {
if (multipleOf != null) target.setMultipleOf(multipleOf);
if (minimum != null) {
if (isIntegerSchema(schema)) {
target.setMinimum(String.valueOf(minimum.toBigInteger()));
target.setMinimum(String.valueOf(minimum.longValue()));
} else {
target.setMinimum(String.valueOf(minimum));
}
@ -1949,7 +1934,7 @@ public class ModelUtils {
}
if (maximum != null) {
if (isIntegerSchema(schema)) {
target.setMaximum(String.valueOf(maximum.toBigInteger()));
target.setMaximum(String.valueOf(maximum.longValue()));
} else {
target.setMaximum(String.valueOf(maximum));
}
@ -2179,22 +2164,6 @@ public class ModelUtils {
}
}
/**
* Set schema type.
* For 3.1 spec, set as types, for 3.0, type
*
* @param schema the schema
* @return schema type
*/
public static void setType(Schema schema, String type) {
if (schema instanceof JsonSchema) {
schema.setTypes(null);
schema.addType(type);
} else {
schema.setType(type);
}
}
/**
* Returns true if any of the common attributes of the schema (e.g. readOnly, default, maximum, etc) is defined.
*

Some files were not shown because too many files have changed in this diff Show More