mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-09-07 14:23:41 +00:00
Compare commits
56 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
6e089f5f03 | ||
|
e62908e30e | ||
|
6164836b57 | ||
|
ee40887d47 | ||
|
1d739f1598 | ||
|
2a556ff24e | ||
|
29a817afdb | ||
|
3029ac62f7 | ||
|
27018b0a0d | ||
|
5544e6acc5 | ||
|
08733aaf25 | ||
|
3f24026b87 | ||
|
27ed27f135 | ||
|
3cc094485d | ||
|
86f107047e | ||
|
2ebda09b9f | ||
|
fde017150e | ||
|
5daef3e901 | ||
|
6e443f1354 | ||
|
babb3e272b | ||
|
d1df75c61d | ||
|
20d5126b17 | ||
|
efd06f5719 | ||
|
c854a23682 | ||
|
1c2fd67cc9 | ||
|
27d3c6f326 | ||
|
eae5088f7c | ||
|
90d6af2bab | ||
|
d8593ef6d7 | ||
|
9148db26fc | ||
|
2cdd9ae687 | ||
|
443fd76529 | ||
|
9c1b680fdf | ||
|
bd0b81d26d | ||
|
afedd3fd33 | ||
|
399547c2ba | ||
|
daa8eb422d | ||
|
e4c9eb36e9 | ||
|
ac5478e909 | ||
|
992e387e27 | ||
|
e903a89ccf | ||
|
ffaeca3204 | ||
|
7c4d7277b4 | ||
|
065eceb824 | ||
|
8ce639ddae | ||
|
ca7e8bd932 | ||
|
e1447bc3dc | ||
|
c134a8adbf | ||
|
9c11fcf6bc | ||
|
6215e6e005 | ||
|
814f406472 | ||
|
3d93cc05ec | ||
|
dc8fac21d9 | ||
|
cd7fe341d3 | ||
|
66c2a287cc | ||
|
20be2decde |
@ -26,7 +26,7 @@ jobs:
|
|||||||
- samples/server/petstore/aspnet/fastendpoints-useValidators
|
- samples/server/petstore/aspnet/fastendpoints-useValidators
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-dotnet@v4.3.1
|
- uses: actions/setup-dotnet@v5.0.0
|
||||||
with:
|
with:
|
||||||
dotnet-version: '8.0.x'
|
dotnet-version: '8.0.x'
|
||||||
- name: Build
|
- name: Build
|
||||||
|
53
.github/workflows/samples-dart-build-test.yaml
vendored
Normal file
53
.github/workflows/samples-dart-build-test.yaml
vendored
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
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
|
@ -28,7 +28,7 @@ jobs:
|
|||||||
# - samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/
|
# - samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-dotnet@v4.3.1
|
- uses: actions/setup-dotnet@v5.0.0
|
||||||
with:
|
with:
|
||||||
dotnet-version: 3.1.*
|
dotnet-version: 3.1.*
|
||||||
- name: Build
|
- name: Build
|
||||||
|
@ -25,7 +25,7 @@ jobs:
|
|||||||
- samples/server/petstore/aspnetcore-6.0-useSwashBuckle
|
- samples/server/petstore/aspnetcore-6.0-useSwashBuckle
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-dotnet@v4.3.1
|
- uses: actions/setup-dotnet@v5.0.0
|
||||||
with:
|
with:
|
||||||
dotnet-version: '6.0.x'
|
dotnet-version: '6.0.x'
|
||||||
- name: Build
|
- name: Build
|
||||||
|
@ -19,7 +19,7 @@ jobs:
|
|||||||
- samples/client/echo_api/csharp/restsharp/net8/EchoApi
|
- samples/client/echo_api/csharp/restsharp/net8/EchoApi
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-dotnet@v4.3.1
|
- uses: actions/setup-dotnet@v5.0.0
|
||||||
with:
|
with:
|
||||||
dotnet-version: '8.0.x'
|
dotnet-version: '8.0.x'
|
||||||
- name: Run echo server
|
- name: Run echo server
|
||||||
|
@ -19,7 +19,7 @@ jobs:
|
|||||||
- samples/client/petstore/csharp/restsharp/net8/useVirtualForHooks/
|
- samples/client/petstore/csharp/restsharp/net8/useVirtualForHooks/
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-dotnet@v4.3.1
|
- uses: actions/setup-dotnet@v5.0.0
|
||||||
with:
|
with:
|
||||||
dotnet-version: '8.0.x'
|
dotnet-version: '8.0.x'
|
||||||
- name: Build
|
- name: Build
|
||||||
|
@ -26,7 +26,7 @@ jobs:
|
|||||||
- samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management
|
- samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-dotnet@v4.3.1
|
- uses: actions/setup-dotnet@v5.0.0
|
||||||
with:
|
with:
|
||||||
dotnet-version: '8.0.x'
|
dotnet-version: '8.0.x'
|
||||||
- name: Build
|
- name: Build
|
||||||
|
2
.github/workflows/samples-dotnet8.yaml
vendored
2
.github/workflows/samples-dotnet8.yaml
vendored
@ -34,7 +34,7 @@ jobs:
|
|||||||
- samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate
|
- samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-dotnet@v4.3.1
|
- uses: actions/setup-dotnet@v5.0.0
|
||||||
with:
|
with:
|
||||||
dotnet-version: '8.0.x'
|
dotnet-version: '8.0.x'
|
||||||
- name: Build
|
- name: Build
|
||||||
|
2
.github/workflows/samples-dotnet9.yaml
vendored
2
.github/workflows/samples-dotnet9.yaml
vendored
@ -47,7 +47,7 @@ jobs:
|
|||||||
#- samples/client/petstore/csharp/unityWebRequest/net9/Petstore
|
#- samples/client/petstore/csharp/unityWebRequest/net9/Petstore
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-dotnet@v4.3.1
|
- uses: actions/setup-dotnet@v5.0.0
|
||||||
with:
|
with:
|
||||||
dotnet-version: '9.0.101'
|
dotnet-version: '9.0.101'
|
||||||
- name: Build
|
- name: Build
|
||||||
|
@ -17,11 +17,11 @@ jobs:
|
|||||||
- samples/client/echo_api/go
|
- samples/client/echo_api/go
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-go@v5
|
- uses: actions/setup-go@v6
|
||||||
with:
|
with:
|
||||||
go-version: "stable"
|
go-version: "stable"
|
||||||
- name: Setup node.js
|
- name: Setup node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v5
|
||||||
- name: Run echo server
|
- name: Run echo server
|
||||||
run: |
|
run: |
|
||||||
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server
|
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server
|
||||||
|
5
.github/workflows/samples-go-client.yaml
vendored
5
.github/workflows/samples-go-client.yaml
vendored
@ -4,9 +4,11 @@ on:
|
|||||||
push:
|
push:
|
||||||
paths:
|
paths:
|
||||||
- 'samples/openapi3/client/petstore/go/go-petstore-aws-signature/**'
|
- 'samples/openapi3/client/petstore/go/go-petstore-aws-signature/**'
|
||||||
|
- 'samples/openapi3/client/petstore/go-petstore-withXml/**'
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- 'samples/openapi3/client/petstore/go/go-petstore-aws-signature/**'
|
- 'samples/openapi3/client/petstore/go/go-petstore-aws-signature/**'
|
||||||
|
- 'samples/openapi3/client/petstore/go-petstore-withXml/**'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@ -17,9 +19,10 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
sample:
|
sample:
|
||||||
- 'samples/openapi3/client/petstore/go/go-petstore-aws-signature/'
|
- 'samples/openapi3/client/petstore/go/go-petstore-aws-signature/'
|
||||||
|
- 'samples/openapi3/client/petstore/go-petstore-withXml/'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-go@v5
|
- uses: actions/setup-go@v6
|
||||||
- run: go version
|
- run: go version
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
working-directory: ${{ matrix.sample }}
|
working-directory: ${{ matrix.sample }}
|
||||||
|
2
.github/workflows/samples-go-gin.yaml
vendored
2
.github/workflows/samples-go-gin.yaml
vendored
@ -22,7 +22,7 @@ jobs:
|
|||||||
- samples/server/petstore/go-gin-api-server-interface-only/
|
- samples/server/petstore/go-gin-api-server-interface-only/
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-go@v5
|
- uses: actions/setup-go@v6
|
||||||
with:
|
with:
|
||||||
go-version: "stable"
|
go-version: "stable"
|
||||||
- run: go version
|
- run: go version
|
||||||
|
4
.github/workflows/samples-go.yaml
vendored
4
.github/workflows/samples-go.yaml
vendored
@ -28,7 +28,7 @@ jobs:
|
|||||||
- samples/server/others/go-server/no-body-path-params/
|
- samples/server/others/go-server/no-body-path-params/
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-go@v5
|
- uses: actions/setup-go@v6
|
||||||
with:
|
with:
|
||||||
go-version: "stable"
|
go-version: "stable"
|
||||||
- run: go version
|
- run: go version
|
||||||
@ -49,7 +49,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v6
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go-version }}
|
go-version: ${{ matrix.go-version }}
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
|
@ -36,7 +36,7 @@ jobs:
|
|||||||
~/.m2
|
~/.m2
|
||||||
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
|
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
|
||||||
- name: Setup node.js
|
- name: Setup node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v5
|
||||||
- name: Run echo server
|
- name: Run echo server
|
||||||
run: |
|
run: |
|
||||||
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server
|
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server
|
||||||
|
@ -37,7 +37,7 @@ jobs:
|
|||||||
~/.m2
|
~/.m2
|
||||||
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
|
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
|
||||||
- name: Setup node.js
|
- name: Setup node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v5
|
||||||
- name: Run echo server
|
- name: Run echo server
|
||||||
run: |
|
run: |
|
||||||
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server
|
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server
|
||||||
|
@ -43,7 +43,7 @@ jobs:
|
|||||||
~/.m2
|
~/.m2
|
||||||
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
|
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
|
||||||
- name: Setup node.js
|
- name: Setup node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v5
|
||||||
- name: Run echo server
|
- name: Run echo server
|
||||||
run: |
|
run: |
|
||||||
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server
|
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server
|
||||||
|
2
.github/workflows/samples-jaxrs.yaml
vendored
2
.github/workflows/samples-jaxrs.yaml
vendored
@ -42,7 +42,7 @@ jobs:
|
|||||||
- uses: actions/setup-java@v5
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
java-version: 8
|
java-version: 11
|
||||||
- name: Cache maven dependencies
|
- name: Cache maven dependencies
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
env:
|
env:
|
||||||
|
3
.github/workflows/samples-kotlin-client.yaml
vendored
3
.github/workflows/samples-kotlin-client.yaml
vendored
@ -33,6 +33,7 @@ jobs:
|
|||||||
- samples/client/petstore/kotlin-moshi-codegen
|
- samples/client/petstore/kotlin-moshi-codegen
|
||||||
- samples/client/petstore/kotlin-multiplatform
|
- samples/client/petstore/kotlin-multiplatform
|
||||||
- samples/client/petstore/kotlin-multiplatform-kotlinx-datetime
|
- samples/client/petstore/kotlin-multiplatform-kotlinx-datetime
|
||||||
|
- samples/client/petstore/kotlin-multiplatform-allOf-discriminator
|
||||||
- samples/client/petstore/kotlin-nonpublic
|
- samples/client/petstore/kotlin-nonpublic
|
||||||
- samples/client/petstore/kotlin-nullable
|
- samples/client/petstore/kotlin-nullable
|
||||||
- samples/client/petstore/kotlin-retrofit2
|
- samples/client/petstore/kotlin-retrofit2
|
||||||
@ -69,7 +70,7 @@ jobs:
|
|||||||
- samples/client/others/kotlin-jvm-okhttp-parameter-tests
|
- samples/client/others/kotlin-jvm-okhttp-parameter-tests
|
||||||
- samples/client/others/kotlin-jvm-okhttp-path-comments
|
- samples/client/others/kotlin-jvm-okhttp-path-comments
|
||||||
- samples/client/others/kotlin-integer-enum
|
- samples/client/others/kotlin-integer-enum
|
||||||
- samples/client/petstore/kotlin-allOff-discriminator-kotlinx-serialization
|
- samples/client/petstore/kotlin-allOf-discriminator-kotlinx-serialization
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-java@v5
|
- uses: actions/setup-java@v5
|
||||||
|
@ -40,7 +40,7 @@ jobs:
|
|||||||
build-root-directory: ${{ matrix.sample }}
|
build-root-directory: ${{ matrix.sample }}
|
||||||
arguments: wrapper
|
arguments: wrapper
|
||||||
- name: Setup node.js
|
- name: Setup node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v5
|
||||||
- name: Run echo server
|
- name: Run echo server
|
||||||
run: |
|
run: |
|
||||||
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server
|
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server
|
||||||
|
9
.github/workflows/samples-ocaml.yaml
vendored
9
.github/workflows/samples-ocaml.yaml
vendored
@ -4,9 +4,15 @@ on:
|
|||||||
push:
|
push:
|
||||||
paths:
|
paths:
|
||||||
- 'samples/client/petstore/ocaml/**'
|
- 'samples/client/petstore/ocaml/**'
|
||||||
|
- 'samples/client/petstore/ocaml-fake-petstore/**'
|
||||||
|
- 'samples/client/petstore/ocaml-oneOf-primitive/**'
|
||||||
|
- 'samples/client/petstore/ocaml-additional-properties/**'
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- 'samples/client/petstore/ocaml/**'
|
- 'samples/client/petstore/ocaml/**'
|
||||||
|
- 'samples/client/petstore/ocaml-fake-petstore/**'
|
||||||
|
- 'samples/client/petstore/ocaml-oneOf-primitive/**'
|
||||||
|
- 'samples/client/petstore/ocaml-additional-properties/**'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@ -17,6 +23,9 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
sample:
|
sample:
|
||||||
- 'samples/client/petstore/ocaml/'
|
- 'samples/client/petstore/ocaml/'
|
||||||
|
- 'samples/client/petstore/ocaml-fake-petstore/'
|
||||||
|
- 'samples/client/petstore/ocaml-oneOf-primitive/'
|
||||||
|
- 'samples/client/petstore/ocaml-additional-properties/'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- name: Set-up OCaml
|
- name: Set-up OCaml
|
||||||
|
48
.github/workflows/samples-php-server-syntax-check.yaml
vendored
Normal file
48
.github/workflows/samples-php-server-syntax-check.yaml
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
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 {} +
|
2
.github/workflows/samples-postman.yaml
vendored
2
.github/workflows/samples-postman.yaml
vendored
@ -20,7 +20,7 @@ jobs:
|
|||||||
- "3.12"
|
- "3.12"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-python@v5
|
- uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Install
|
- name: Install
|
||||||
|
@ -25,11 +25,11 @@ jobs:
|
|||||||
- "3.13"
|
- "3.13"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-python@v5
|
- uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Setup node.js
|
- name: Setup node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v5
|
||||||
- name: Run echo server
|
- name: Run echo server
|
||||||
run: |
|
run: |
|
||||||
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server
|
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server
|
||||||
|
@ -19,7 +19,7 @@ jobs:
|
|||||||
- samples/server/petstore/python-fastapi/
|
- samples/server/petstore/python-fastapi/
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-python@v5
|
- uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
python-version: '3.9'
|
python-version: '3.9'
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
@ -13,7 +13,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-python@v5
|
- uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
python-version: "3.13"
|
python-version: "3.13"
|
||||||
- name: Install validator
|
- name: Install validator
|
||||||
@ -45,7 +45,7 @@ jobs:
|
|||||||
SWAGGER_BASE_PATH: /v2
|
SWAGGER_BASE_PATH: /v2
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-python@v5
|
- uses: actions/setup-python@v6
|
||||||
id: py
|
id: py
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
|
@ -24,11 +24,11 @@ jobs:
|
|||||||
- "3.12"
|
- "3.12"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-python@v5
|
- uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Setup node.js
|
- name: Setup node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v5
|
||||||
- name: Run echo server
|
- name: Run echo server
|
||||||
run: |
|
run: |
|
||||||
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server
|
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server
|
||||||
|
@ -32,7 +32,7 @@ jobs:
|
|||||||
SWAGGER_BASE_PATH: /v2
|
SWAGGER_BASE_PATH: /v2
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-python@v5
|
- uses: actions/setup-python@v6
|
||||||
id: py
|
id: py
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
|
2
.github/workflows/samples-python-server.yaml
vendored
2
.github/workflows/samples-python-server.yaml
vendored
@ -19,7 +19,7 @@ jobs:
|
|||||||
- samples/server/petstore/python-aiohttp-srclayout/
|
- samples/server/petstore/python-aiohttp-srclayout/
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-python@v5
|
- uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
python-version: '3.9'
|
python-version: '3.9'
|
||||||
- name: Test
|
- name: Test
|
||||||
|
2
.github/workflows/samples-ruby.yaml
vendored
2
.github/workflows/samples-ruby.yaml
vendored
@ -26,7 +26,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- name: Setup node.js
|
- name: Setup node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v5
|
||||||
- name: Run echo server
|
- name: Run echo server
|
||||||
run: |
|
run: |
|
||||||
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server
|
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server
|
||||||
|
72
.github/workflows/samples-rust-client.yaml
vendored
Normal file
72
.github/workflows/samples-rust-client.yaml
vendored
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
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
|
@ -1,16 +1,12 @@
|
|||||||
name: Samples Rust
|
name: Samples Rust Servers
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
paths:
|
paths:
|
||||||
- "samples/client/others/rust/**"
|
|
||||||
- "samples/server/petstore/rust-server/**"
|
- "samples/server/petstore/rust-server/**"
|
||||||
- "samples/client/petstore/rust-server/**"
|
|
||||||
- "samples/server/petstore/rust-axum/**"
|
- "samples/server/petstore/rust-axum/**"
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- "samples/client/others/rust/**"
|
|
||||||
- "samples/client/petstore/rust/**"
|
|
||||||
- "samples/server/petstore/rust-server/**"
|
- "samples/server/petstore/rust-server/**"
|
||||||
- "samples/server/petstore/rust-axum/**"
|
- "samples/server/petstore/rust-axum/**"
|
||||||
|
|
||||||
@ -23,8 +19,6 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
sample:
|
sample:
|
||||||
# these folders contain sub-projects of rust clients, servers
|
# 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/
|
||||||
- samples/server/petstore/rust-server-deprecated/
|
- samples/server/petstore/rust-server-deprecated/
|
||||||
- samples/server/petstore/rust-axum/
|
- samples/server/petstore/rust-axum/
|
||||||
@ -50,19 +44,10 @@ jobs:
|
|||||||
working-directory: ${{ matrix.sample }}
|
working-directory: ${{ matrix.sample }}
|
||||||
run: |
|
run: |
|
||||||
set -e
|
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
|
# Iterate through each example and test various features
|
||||||
for package in $(find . -maxdepth 1 -mindepth 1 -type d)
|
for package in $(find . -maxdepth 1 -mindepth 1 -type d)
|
||||||
do
|
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
|
# Not all versions have a server example
|
||||||
if test -f examples/server/main.rs; then
|
if test -f examples/server/main.rs; then
|
||||||
cargo build --example server --features="server"
|
cargo build --example server --features="server"
|
1
.github/workflows/samples-scala.yaml
vendored
1
.github/workflows/samples-scala.yaml
vendored
@ -24,6 +24,7 @@ jobs:
|
|||||||
- samples/client/petstore/scalaz
|
- samples/client/petstore/scalaz
|
||||||
- samples/client/petstore/scala-pekko
|
- samples/client/petstore/scala-pekko
|
||||||
- samples/client/petstore/scala-http4s
|
- samples/client/petstore/scala-http4s
|
||||||
|
- samples/client/petstore/scala-sttp4-jsoniter
|
||||||
#- samples/client/petstore/scala-sttp
|
#- samples/client/petstore/scala-sttp
|
||||||
#- samples/client/petstore/scala-sttp-circe
|
#- samples/client/petstore/scala-sttp-circe
|
||||||
# servers
|
# servers
|
||||||
|
@ -22,7 +22,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v5
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v5
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v5
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v5
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v5
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
|
|
||||||
|
2
.github/workflows/samples-zapier.yaml
vendored
2
.github/workflows/samples-zapier.yaml
vendored
@ -20,7 +20,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- name: Setup node
|
- name: Setup node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v5
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
working-directory: ${{ matrix.sample }}
|
working-directory: ${{ matrix.sample }}
|
||||||
run: |
|
run: |
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -296,6 +296,9 @@ samples/openapi3/client/petstore/go/privatekey.pem
|
|||||||
|
|
||||||
## OCaml
|
## OCaml
|
||||||
samples/client/petstore/ocaml/_build/
|
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
|
# jetbrain http client
|
||||||
samples/client/jetbrains/adyen/checkout71/http/client/Apis/http-client.private.env.json
|
samples/client/jetbrains/adyen/checkout71/http/client/Apis/http-client.private.env.json
|
||||||
|
219
.travis.yml
219
.travis.yml
@ -1,219 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
21
README.md
21
README.md
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.15.0`):
|
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.16.0`):
|
||||||
[](https://app.travis-ci.com/github/OpenAPITools/openapi-generator/builds)
|
[](https://app.travis-ci.com/github/OpenAPITools/openapi-generator/builds)
|
||||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator)
|
[](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 |
|
| OpenAPI Generator Version | Release Date | Notes |
|
||||||
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------------------------------------- |
|
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------------------------------------- |
|
||||||
| 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.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.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) |
|
| [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) |
|
||||||
| [6.6.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v6.6.0) | 11.05.2023 | 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) |
|
| [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) |
|
| [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 -->
|
<!-- 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):
|
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.14.0/openapi-generator-cli-7.14.0.jar`
|
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.15.0/openapi-generator-cli-7.15.0.jar`
|
||||||
|
|
||||||
For **Mac/Linux** users:
|
For **Mac/Linux** users:
|
||||||
```sh
|
```sh
|
||||||
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
|
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
|
||||||
```
|
```
|
||||||
|
|
||||||
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.
|
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.14.0/openapi-generator-cli-7.14.0.jar
|
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
|
||||||
```
|
```
|
||||||
|
|
||||||
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
|
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"
|
To use a specific version of "openapi-generator-cli"
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
openapi-generator-cli version-manager set 7.14.0
|
openapi-generator-cli version-manager set 7.15.0
|
||||||
```
|
```
|
||||||
|
|
||||||
Or install it as dev-dependency:
|
Or install it as dev-dependency:
|
||||||
@ -482,7 +482,7 @@ pip install openapi-generator-cli
|
|||||||
|
|
||||||
To install a specific version
|
To install a specific version
|
||||||
```
|
```
|
||||||
pip install openapi-generator-cli==7.14.0
|
pip install openapi-generator-cli==7.15.0
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also install with [jdk4py](https://github.com/activeviam/jdk4py) instead of java binary. (python>=3.10 is required)
|
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`)
|
(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 -->
|
<!-- 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.14.0/openapi-generator-cli-7.14.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.15.0/openapi-generator-cli-7.15.0.jar)
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /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`
|
To get a list of **general** options available, please run `java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help generate`
|
||||||
@ -1099,6 +1099,7 @@ Here is a list of template creators:
|
|||||||
* Scala (Akka): @cchafer
|
* Scala (Akka): @cchafer
|
||||||
* Scala (sttp): @chameleon82
|
* Scala (sttp): @chameleon82
|
||||||
* Scala (sttp4): @flsh86
|
* Scala (sttp4): @flsh86
|
||||||
|
* Scala (scala-sttp4-jsoniter): @lbialy
|
||||||
* Scala (Pekko): @mickaelmagniez
|
* Scala (Pekko): @mickaelmagniez
|
||||||
* Scala (http4s): @JennyLeahy
|
* Scala (http4s): @JennyLeahy
|
||||||
* Swift: @tkqubo
|
* Swift: @tkqubo
|
||||||
@ -1264,7 +1265,7 @@ If you want to join the committee, please kindly apply by sending an email to te
|
|||||||
| Nim | |
|
| Nim | |
|
||||||
| NodeJS/Javascript | @CodeNinjai (2017/07) @frol (2017/07) @cliffano (2017/07) |
|
| NodeJS/Javascript | @CodeNinjai (2017/07) @frol (2017/07) @cliffano (2017/07) |
|
||||||
| ObjC | |
|
| ObjC | |
|
||||||
| OCaml | @cgensoul (2019/08) |
|
| OCaml | @cgensoul (2019/08), @sir4ur0n (2025/08) |
|
||||||
| Perl | @wing328 (2017/07) [:heart:](https://www.patreon.com/wing328) @yue9944882 (2019/06) |
|
| 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) |
|
| 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) |
|
| PowerShell | @wing328 (2020/05) |
|
||||||
|
9
bin/configs/go-petstore-withXml.yaml
Normal file
9
bin/configs/go-petstore-withXml.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
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
|
@ -1,9 +1,9 @@
|
|||||||
generatorName: kotlin
|
generatorName: kotlin
|
||||||
outputDir: samples/client/petstore/kotlin-allOff-discriminator-kotlinx-serialization
|
outputDir: samples/client/petstore/kotlin-allOf-discriminator-kotlinx-serialization
|
||||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/polymorphism.yaml
|
inputSpec: modules/openapi-generator/src/test/resources/3_0/kotlin/polymorphism.yaml
|
||||||
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
|
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
artifactId: kotlin-allOff-discriminator
|
artifactId: kotlin-allOf-discriminator
|
||||||
serializableModel: "false"
|
serializableModel: "false"
|
||||||
dateLibrary: java8
|
dateLibrary: java8
|
||||||
enumUnknownDefaultCase: true
|
enumUnknownDefaultCase: true
|
@ -1,9 +1,9 @@
|
|||||||
generatorName: kotlin
|
generatorName: kotlin
|
||||||
outputDir: samples/client/petstore/kotlin-allOff-discriminator
|
outputDir: samples/client/petstore/kotlin-allOf-discriminator
|
||||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/issue_10792.yaml
|
inputSpec: modules/openapi-generator/src/test/resources/3_0/issue_10792.yaml
|
||||||
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
|
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
artifactId: kotlin-allOff-discriminator
|
artifactId: kotlin-allOf-discriminator
|
||||||
serializableModel: "false"
|
serializableModel: "false"
|
||||||
dateLibrary: java8
|
dateLibrary: java8
|
||||||
enumUnknownDefaultCase: true
|
enumUnknownDefaultCase: true
|
@ -0,0 +1,8 @@
|
|||||||
|
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
|
6
bin/configs/ocaml-additional-properties.yaml
Normal file
6
bin/configs/ocaml-additional-properties.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
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
|
6
bin/configs/ocaml-fake-petstore.yaml
Normal file
6
bin/configs/ocaml-fake-petstore.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
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
|
6
bin/configs/ocaml-oneOf-primitive.yaml
Normal file
6
bin/configs/ocaml-oneOf-primitive.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
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
|
@ -13,3 +13,5 @@ additionalProperties:
|
|||||||
nameMappings:
|
nameMappings:
|
||||||
_type: underscore_type
|
_type: underscore_type
|
||||||
type_: type_with_underscore
|
type_: type_with_underscore
|
||||||
|
openapiNormalizer:
|
||||||
|
SIMPLIFY_ONEOF_ANYOF_ENUM: false
|
||||||
|
@ -13,3 +13,5 @@ nameMappings:
|
|||||||
modelNameMappings:
|
modelNameMappings:
|
||||||
# The OpenAPI spec ApiResponse conflicts with the internal ApiResponse
|
# The OpenAPI spec ApiResponse conflicts with the internal ApiResponse
|
||||||
ApiResponse: ModelApiResponse
|
ApiResponse: ModelApiResponse
|
||||||
|
openapiNormalizer:
|
||||||
|
SIMPLIFY_ONEOF_ANYOF_ENUM: false
|
||||||
|
6
bin/configs/scala-sttp4-jsoniter.yaml
Normal file
6
bin/configs/scala-sttp4-jsoniter.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
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"
|
@ -564,6 +564,15 @@ 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
|
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.
|
- `SIMPLIFY_BOOLEAN_ENUM`: when set to `true`, convert boolean enum to just enum.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
@ -96,7 +96,7 @@ mvn integration-test
|
|||||||
### Which Swift generator is still actively maintained?
|
### Which Swift generator is still actively maintained?
|
||||||
|
|
||||||
Please use `swift5` generator because Swift 4.x is deprecated.
|
Please use `swift5` generator because Swift 4.x is deprecated.
|
||||||
There is a new `swift6` generator, that is currently in beta, try it and give us your feedback.
|
There is a new `swift6` generator, that is now stable, try it and give us your feedback.
|
||||||
|
|
||||||
### How do I implement bearer token authentication with URLSession on the Swift 5 API client?
|
### How do I implement bearer token authentication with URLSession on the Swift 5 API client?
|
||||||
|
|
||||||
|
@ -65,10 +65,11 @@ The following generators are available:
|
|||||||
* [scala-pekko](generators/scala-pekko.md)
|
* [scala-pekko](generators/scala-pekko.md)
|
||||||
* [scala-sttp](generators/scala-sttp.md)
|
* [scala-sttp](generators/scala-sttp.md)
|
||||||
* [scala-sttp4 (beta)](generators/scala-sttp4.md)
|
* [scala-sttp4 (beta)](generators/scala-sttp4.md)
|
||||||
|
* [scala-sttp4-jsoniter (beta)](generators/scala-sttp4-jsoniter.md)
|
||||||
* [scalaz](generators/scalaz.md)
|
* [scalaz](generators/scalaz.md)
|
||||||
* [swift-combine](generators/swift-combine.md)
|
* [swift-combine](generators/swift-combine.md)
|
||||||
* [swift5](generators/swift5.md)
|
* [swift5](generators/swift5.md)
|
||||||
* [swift6 (beta)](generators/swift6.md)
|
* [swift6](generators/swift6.md)
|
||||||
* [typescript (experimental)](generators/typescript.md)
|
* [typescript (experimental)](generators/typescript.md)
|
||||||
* [typescript-angular](generators/typescript-angular.md)
|
* [typescript-angular](generators/typescript-angular.md)
|
||||||
* [typescript-aurelia](generators/typescript-aurelia.md)
|
* [typescript-aurelia](generators/typescript-aurelia.md)
|
||||||
|
@ -37,6 +37,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
|pubRepository|Repository in generated pubspec| |null|
|
|pubRepository|Repository in generated pubspec| |null|
|
||||||
|pubVersion|Version in generated pubspec| |1.0.0|
|
|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|
|
|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|
|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
||||||
|sortParamsByRequiredFlag|Sort method arguments 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|
|
|sourceFolder|source folder for generated code| |src|
|
||||||
|
@ -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|
|
|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|
|
|interfaceOnly|Whether to generate only API interface stubs without the server files.| |false|
|
||||||
|invokerPackage|root package for generated code| |org.openapitools.api|
|
|invokerPackage|root package for generated code| |org.openapitools.api|
|
||||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
|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|
|
||||||
|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|
|
|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|
|
|licenseName|The name of the license| |Unlicense|
|
||||||
|licenseUrl|The URL of the license| |http://unlicense.org|
|
|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|
|
|useFeignClientContextId|Whether to generate Feign client with contextId parameter.| |true|
|
||||||
|useFeignClientUrl|Whether to generate Feign client with url parameter.| |true|
|
|useFeignClientUrl|Whether to generate Feign client with url parameter.| |true|
|
||||||
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|
|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| |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|
|
||||||
|useOptional|Use Optional container for optional parameters| |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|
|
|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|
|
|useSealed|Whether to generate sealed model interfaces and classes| |false|
|
||||||
|
@ -209,8 +209,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
|Polymorphism|✗|OAS2,OAS3
|
|Polymorphism|✗|OAS2,OAS3
|
||||||
|Union|✗|OAS3
|
|Union|✗|OAS3
|
||||||
|allOf|✗|OAS2,OAS3
|
|allOf|✗|OAS2,OAS3
|
||||||
|anyOf|✗|OAS3
|
|anyOf|✓|OAS3
|
||||||
|oneOf|✗|OAS3
|
|oneOf|✓|OAS3
|
||||||
|not|✗|OAS3
|
|not|✗|OAS3
|
||||||
|
|
||||||
### Security Feature
|
### Security Feature
|
||||||
|
260
docs/generators/scala-sttp4-jsoniter.md
Normal file
260
docs/generators/scala-sttp4-jsoniter.md
Normal file
@ -0,0 +1,260 @@
|
|||||||
|
---
|
||||||
|
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
|
@ -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|
|
|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|
|
|interfaceOnly|Whether to generate only API interface stubs without the server files.| |false|
|
||||||
|invokerPackage|root package for generated code| |org.openapitools.api|
|
|invokerPackage|root package for generated code| |org.openapitools.api|
|
||||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
|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|
|
||||||
|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|
|
|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|
|
|licenseName|The name of the license| |Unlicense|
|
||||||
|licenseUrl|The URL of the license| |http://unlicense.org|
|
|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|
|
|useFeignClientContextId|Whether to generate Feign client with contextId parameter.| |true|
|
||||||
|useFeignClientUrl|Whether to generate Feign client with url parameter.| |true|
|
|useFeignClientUrl|Whether to generate Feign client with url parameter.| |true|
|
||||||
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|
|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| |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|
|
||||||
|useOptional|Use Optional container for optional parameters| |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|
|
|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|
|
|useSealed|Whether to generate sealed model interfaces and classes| |false|
|
||||||
|
@ -7,7 +7,7 @@ title: Documentation for the swift6 Generator
|
|||||||
| Property | Value | Notes |
|
| Property | Value | Notes |
|
||||||
| -------- | ----- | ----- |
|
| -------- | ----- | ----- |
|
||||||
| generator name | swift6 | pass this to the generate command after -g |
|
| generator name | swift6 | pass this to the generate command after -g |
|
||||||
| generator stability | BETA | |
|
| generator stability | STABLE | |
|
||||||
| generator type | CLIENT | |
|
| generator type | CLIENT | |
|
||||||
| generator language | Swift | |
|
| generator language | Swift | |
|
||||||
| generator default templating engine | mustache | |
|
| generator default templating engine | mustache | |
|
||||||
|
@ -22,7 +22,7 @@ npm install @openapitools/openapi-generator-cli -g
|
|||||||
To install a specific version of the tool, pass the version during installation:
|
To install a specific version of the tool, pass the version during installation:
|
||||||
<!-- RELEASE_VERSION -->
|
<!-- RELEASE_VERSION -->
|
||||||
```bash
|
```bash
|
||||||
openapi-generator-cli version-manager set 7.14.0
|
openapi-generator-cli version-manager set 7.15.0
|
||||||
```
|
```
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
To install the tool as a dev dependency in your current project:
|
To install the tool as a dev dependency in your current project:
|
||||||
@ -119,18 +119,18 @@ docker run --rm \
|
|||||||
<!-- RELEASE_VERSION -->
|
<!-- 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):
|
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.14.0/openapi-generator-cli-7.14.0.jar`
|
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.15.0/openapi-generator-cli-7.15.0.jar`
|
||||||
|
|
||||||
For **Mac/Linux** users:
|
For **Mac/Linux** users:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
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
|
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
|
||||||
```
|
```
|
||||||
|
|
||||||
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.
|
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
|
```powershell
|
||||||
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
|
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
|
||||||
```
|
```
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||||
<version>7.14.0</version>
|
<version>7.15.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<!-- RELEASE_VERSION -->
|
<!-- RELEASE_VERSION -->
|
||||||
<version>7.15.0</version>
|
<version>7.16.0-SNAPSHOT</version>
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<!-- RELEASE_VERSION -->
|
<!-- RELEASE_VERSION -->
|
||||||
<version>7.15.0</version>
|
<version>7.16.0-SNAPSHOT</version>
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
@ -97,7 +97,7 @@ task validateGoodSpec(type: org.openapitools.generator.gradle.plugin.tasks.Valid
|
|||||||
[source,group]
|
[source,group]
|
||||||
----
|
----
|
||||||
plugins {
|
plugins {
|
||||||
id "org.openapi.generator" version "7.14.0"
|
id "org.openapi.generator" version "7.15.0"
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ buildscript {
|
|||||||
// url "https://plugins.gradle.org/m2/"
|
// url "https://plugins.gradle.org/m2/"
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath "org.openapitools:openapi-generator-gradle-plugin:7.14.0"
|
classpath "org.openapitools:openapi-generator-gradle-plugin:7.15.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -759,7 +759,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||||
classpath('org.openapitools:openapi-generator-gradle-plugin:7.14.0') {
|
classpath('org.openapitools:openapi-generator-gradle-plugin:7.15.0') {
|
||||||
exclude group: 'com.google.guava'
|
exclude group: 'com.google.guava'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# RELEASE_VERSION
|
# RELEASE_VERSION
|
||||||
openApiGeneratorVersion=7.15.0
|
openApiGeneratorVersion=7.16.0-SNAPSHOT
|
||||||
# /RELEASE_VERSION
|
# /RELEASE_VERSION
|
||||||
|
|
||||||
# BEGIN placeholders
|
# BEGIN placeholders
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<!-- RELEASE_VERSION -->
|
<!-- RELEASE_VERSION -->
|
||||||
<version>7.15.0</version>
|
<version>7.16.0-SNAPSHOT</version>
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
@ -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:
|
The samples can be tested against other versions of the plugin using the `openApiGeneratorVersion` property. For example:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gradle -PopenApiGeneratorVersion=7.14.0 openApiValidate
|
gradle -PopenApiGeneratorVersion=7.15.0 openApiValidate
|
||||||
```
|
```
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
# RELEASE_VERSION
|
# RELEASE_VERSION
|
||||||
openApiGeneratorVersion=7.15.0
|
openApiGeneratorVersion=7.16.0-SNAPSHOT
|
||||||
# /RELEASE_VERSION
|
# /RELEASE_VERSION
|
||||||
|
@ -12,7 +12,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
|
|||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||||
<!-- RELEASE_VERSION -->
|
<!-- RELEASE_VERSION -->
|
||||||
<version>7.14.0</version>
|
<version>7.15.0</version>
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||||
<!-- RELEASE_VERSION -->
|
<!-- RELEASE_VERSION -->
|
||||||
<version>7.15.0</version>
|
<version>7.16.0-SNAPSHOT</version>
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||||
<!-- RELEASE_VERSION -->
|
<!-- RELEASE_VERSION -->
|
||||||
<version>7.15.0</version>
|
<version>7.16.0-SNAPSHOT</version>
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||||
<!-- RELEASE_VERSION -->
|
<!-- RELEASE_VERSION -->
|
||||||
<version>7.15.0</version>
|
<version>7.16.0-SNAPSHOT</version>
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||||
<!-- RELEASE_VERSION -->
|
<!-- RELEASE_VERSION -->
|
||||||
<version>7.15.0</version>
|
<version>7.16.0-SNAPSHOT</version>
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||||
<!-- RELEASE_VERSION -->
|
<!-- RELEASE_VERSION -->
|
||||||
<version>7.15.0</version>
|
<version>7.16.0-SNAPSHOT</version>
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||||
<!-- RELEASE_VERSION -->
|
<!-- RELEASE_VERSION -->
|
||||||
<version>7.15.0</version>
|
<version>7.16.0-SNAPSHOT</version>
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<!-- RELEASE_VERSION -->
|
<!-- RELEASE_VERSION -->
|
||||||
<version>7.15.0</version>
|
<version>7.16.0-SNAPSHOT</version>
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
@ -321,6 +321,12 @@ public class CodeGenMojo extends AbstractMojo {
|
|||||||
@Parameter(name = "generateAliasAsModel", property = "openapi.generator.maven.plugin.generateAliasAsModel")
|
@Parameter(name = "generateAliasAsModel", property = "openapi.generator.maven.plugin.generateAliasAsModel")
|
||||||
private Boolean 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
|
* A map of language-specific parameters as passed with the -c option to the command line
|
||||||
*/
|
*/
|
||||||
@ -698,6 +704,10 @@ public class CodeGenMojo extends AbstractMojo {
|
|||||||
configurator.setGenerateAliasAsModel(generateAliasAsModel);
|
configurator.setGenerateAliasAsModel(generateAliasAsModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (minimalUpdate != null) {
|
||||||
|
configurator.setEnableMinimalUpdate(minimalUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
if (isNotEmpty(generatorName)) {
|
if (isNotEmpty(generatorName)) {
|
||||||
configurator.setGeneratorName(generatorName);
|
configurator.setGeneratorName(generatorName);
|
||||||
} else {
|
} else {
|
||||||
|
@ -38,6 +38,7 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.StandardOpenOption;
|
import java.nio.file.StandardOpenOption;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -88,6 +89,17 @@ public class CodeGenMojoTest extends BaseTestCase {
|
|||||||
assertEquals("joda", configOptions.get("dateLibrary"));
|
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 {
|
public void testHashGenerationFileContainsExecutionId() throws Exception {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
final Path tempDir = newTempFolder();
|
final Path tempDir = newTempFolder();
|
||||||
@ -136,6 +148,50 @@ public class CodeGenMojoTest extends BaseTestCase {
|
|||||||
assertFalse("src directory should not have been regenerated", Files.exists(generatedDir.resolve("src")));
|
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,
|
* 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.
|
* test that the generated source is regenerated when the hash has changed.
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
<!--
|
||||||
|
~ 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>
|
@ -4,7 +4,7 @@
|
|||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<!-- RELEASE_VERSION -->
|
<!-- RELEASE_VERSION -->
|
||||||
<version>7.15.0</version>
|
<version>7.16.0-SNAPSHOT</version>
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<groupId>org.openapitools</groupId>
|
<groupId>org.openapitools</groupId>
|
||||||
<artifactId>openapi-generator-project</artifactId>
|
<artifactId>openapi-generator-project</artifactId>
|
||||||
<!-- RELEASE_VERSION -->
|
<!-- RELEASE_VERSION -->
|
||||||
<version>7.15.0</version>
|
<version>7.16.0-SNAPSHOT</version>
|
||||||
<!-- /RELEASE_VERSION -->
|
<!-- /RELEASE_VERSION -->
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
@ -88,6 +88,9 @@ public class OpenAPINormalizer {
|
|||||||
// when set to true, boolean enum will be converted to just boolean
|
// when set to true, boolean enum will be converted to just boolean
|
||||||
final String SIMPLIFY_BOOLEAN_ENUM = "SIMPLIFY_BOOLEAN_ENUM";
|
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
|
// 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";
|
final String SET_TAGS_FOR_ALL_OPERATIONS = "SET_TAGS_FOR_ALL_OPERATIONS";
|
||||||
String setTagsForAllOperations;
|
String setTagsForAllOperations;
|
||||||
@ -205,11 +208,12 @@ public class OpenAPINormalizer {
|
|||||||
ruleNames.add(FILTER);
|
ruleNames.add(FILTER);
|
||||||
ruleNames.add(SET_CONTAINER_TO_NULLABLE);
|
ruleNames.add(SET_CONTAINER_TO_NULLABLE);
|
||||||
ruleNames.add(SET_PRIMITIVE_TYPES_TO_NULLABLE);
|
ruleNames.add(SET_PRIMITIVE_TYPES_TO_NULLABLE);
|
||||||
|
ruleNames.add(SIMPLIFY_ONEOF_ANYOF_ENUM);
|
||||||
|
|
||||||
// rules that are default to true
|
// rules that are default to true
|
||||||
rules.put(SIMPLIFY_ONEOF_ANYOF, true);
|
rules.put(SIMPLIFY_ONEOF_ANYOF, true);
|
||||||
rules.put(SIMPLIFY_BOOLEAN_ENUM, true);
|
rules.put(SIMPLIFY_BOOLEAN_ENUM, true);
|
||||||
|
rules.put(SIMPLIFY_ONEOF_ANYOF_ENUM, true);
|
||||||
|
|
||||||
processRules(inputRules);
|
processRules(inputRules);
|
||||||
|
|
||||||
@ -972,6 +976,8 @@ public class OpenAPINormalizer {
|
|||||||
// Remove duplicate oneOf entries
|
// Remove duplicate oneOf entries
|
||||||
ModelUtils.deduplicateOneOfSchema(schema);
|
ModelUtils.deduplicateOneOfSchema(schema);
|
||||||
|
|
||||||
|
schema = processSimplifyOneOfEnum(schema);
|
||||||
|
|
||||||
// simplify first as the schema may no longer be a oneOf after processing the rule below
|
// simplify first as the schema may no longer be a oneOf after processing the rule below
|
||||||
schema = processSimplifyOneOf(schema);
|
schema = processSimplifyOneOf(schema);
|
||||||
|
|
||||||
@ -1000,6 +1006,11 @@ public class OpenAPINormalizer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected Schema normalizeAnyOf(Schema schema, Set<Schema> visitedSchemas) {
|
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++) {
|
for (int i = 0; i < schema.getAnyOf().size(); i++) {
|
||||||
// normalize anyOf sub schemas one by one
|
// normalize anyOf sub schemas one by one
|
||||||
Object item = schema.getAnyOf().get(i);
|
Object item = schema.getAnyOf().get(i);
|
||||||
@ -1275,6 +1286,161 @@ 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`
|
* If the schema is oneOf and the sub-schemas is null, set `nullable: true`
|
||||||
* instead.
|
* instead.
|
||||||
|
@ -47,6 +47,7 @@ import java.util.regex.Pattern;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
|
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.camelize;
|
||||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||||
|
|
||||||
@ -1602,33 +1603,28 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen {
|
|||||||
/**
|
/**
|
||||||
* Provides C# strongly typed declaration for simple arrays of some type and arrays of arrays of some type.
|
* Provides C# strongly typed declaration for simple arrays of some type and arrays of arrays of some type.
|
||||||
*
|
*
|
||||||
* @param arr The input array property
|
* @param items The input array property
|
||||||
* @return The type declaration when the type is an array of arrays.
|
* @return The type declaration when the type is an array of arrays.
|
||||||
*/
|
*/
|
||||||
private String getArrayTypeDeclaration(Schema arr) {
|
private String getTypeDeclarationForArray(Schema<?> items) {
|
||||||
// TODO: collection type here should be fully qualified namespace to avoid model conflicts
|
return getTypeDeclaration(items);
|
||||||
// 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
|
@Override
|
||||||
public String toInstantiationType(Schema p) {
|
public String toInstantiationType(Schema p) {
|
||||||
if (ModelUtils.isArraySchema(p)) {
|
if (ModelUtils.isArraySchema(p)) {
|
||||||
return getArrayTypeDeclaration(p);
|
return getTypeDeclarationForArray(p);
|
||||||
}
|
}
|
||||||
return super.toInstantiationType(p);
|
return super.toInstantiationType(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTypeDeclaration(Schema p) {
|
public String getTypeDeclaration(Schema p) {
|
||||||
if (ModelUtils.isArraySchema(p)) {
|
Schema<?> schema = unaliasSchema(p);
|
||||||
return getArrayTypeDeclaration(p);
|
Schema<?> target = ModelUtils.isGenerateAliasAsModel() ? p : schema;
|
||||||
|
if (ModelUtils.isArraySchema(target)) {
|
||||||
|
Schema<?> items = getSchemaItems(schema);
|
||||||
|
return getSchemaType(target) + "<" + getTypeDeclarationForArray(items) + ">";
|
||||||
} else if (ModelUtils.isMapSchema(p)) {
|
} else if (ModelUtils.isMapSchema(p)) {
|
||||||
// Should we also support maps of maps?
|
// Should we also support maps of maps?
|
||||||
Schema<?> inner = ModelUtils.getAdditionalProperties(p);
|
Schema<?> inner = ModelUtils.getAdditionalProperties(p);
|
||||||
|
@ -800,6 +800,9 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
|||||||
|
|
||||||
if (withXml) {
|
if (withXml) {
|
||||||
goDataTag += " xml:" + "\"" + cp.baseName;
|
goDataTag += " xml:" + "\"" + cp.baseName;
|
||||||
|
if (cp.isXmlWrapped) {
|
||||||
|
goDataTag += ">" + ("".equals(cp.xmlName) ? cp.baseName : cp.xmlName);
|
||||||
|
}
|
||||||
if (cp.isXmlAttribute) {
|
if (cp.isXmlAttribute) {
|
||||||
goDataTag += ",attr";
|
goDataTag += ",attr";
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||||
* Copyright 2018 SmartBear Software
|
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -529,6 +528,21 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
|
|||||||
if (identifier.matches("[a-zA-Z_$][\\w_$]+") && !isReservedWord(identifier)) {
|
if (identifier.matches("[a-zA-Z_$][\\w_$]+") && !isReservedWord(identifier)) {
|
||||||
return 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);
|
return escapeReservedWord(identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1748,7 +1748,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateModelForObject(CodegenModel m, Schema schema) {
|
protected void updateModelForObject(CodegenModel m, Schema schema) {
|
||||||
/**
|
/*
|
||||||
* we have a custom version of this function so we only set isMap to true if
|
* we have a custom version of this function so we only set isMap to true if
|
||||||
* ModelUtils.isMapSchema
|
* ModelUtils.isMapSchema
|
||||||
* In other generators, isMap is true for all type object schemas
|
* In other generators, isMap is true for all type object schemas
|
||||||
|
@ -1058,7 +1058,7 @@ public class CSharpReducedClientCodegen extends AbstractCSharpCodegen {
|
|||||||
@Override
|
@Override
|
||||||
public String toInstantiationType(Schema schema) {
|
public String toInstantiationType(Schema schema) {
|
||||||
if (ModelUtils.isMapSchema(schema)) {
|
if (ModelUtils.isMapSchema(schema)) {
|
||||||
Schema additionalProperties = ModelUtils.getAdditionalProperties(schema);
|
Schema<?> additionalProperties = ModelUtils.getAdditionalProperties(schema);
|
||||||
String inner = getSchemaType(additionalProperties);
|
String inner = getSchemaType(additionalProperties);
|
||||||
if (ModelUtils.isMapSchema(additionalProperties)) {
|
if (ModelUtils.isMapSchema(additionalProperties)) {
|
||||||
inner = toInstantiationType(additionalProperties);
|
inner = toInstantiationType(additionalProperties);
|
||||||
|
@ -69,7 +69,9 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
|
|||||||
|
|
||||||
private static final String DIO_IMPORT = "package:dio/dio.dart";
|
private static final String DIO_IMPORT = "package:dio/dio.dart";
|
||||||
public static final String FINAL_PROPERTIES = "finalProperties";
|
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 FINAL_PROPERTIES_DEFAULT_VALUE = "true";
|
||||||
|
public static final String SKIP_COPY_WITH_DEFAULT_VALUE = "false";
|
||||||
|
|
||||||
private static final String CLIENT_NAME = "clientName";
|
private static final String CLIENT_NAME = "clientName";
|
||||||
|
|
||||||
@ -138,6 +140,11 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
|
|||||||
final CliOption finalProperties = CliOption.newBoolean(FINAL_PROPERTIES, "Whether properties are marked as final when using Json Serializable for serialization");
|
final CliOption finalProperties = CliOption.newBoolean(FINAL_PROPERTIES, "Whether properties are marked as final when using Json Serializable for serialization");
|
||||||
finalProperties.setDefault("true");
|
finalProperties.setDefault("true");
|
||||||
cliOptions.add(finalProperties);
|
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
|
@Override
|
||||||
@ -182,6 +189,13 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
|
|||||||
additionalProperties.put(FINAL_PROPERTIES, Boolean.parseBoolean(additionalProperties.get(FINAL_PROPERTIES).toString()));
|
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)) {
|
if (!additionalProperties.containsKey(CLIENT_NAME)) {
|
||||||
final String name = org.openapitools.codegen.utils.StringUtils.camelize(pubName);
|
final String name = org.openapitools.codegen.utils.StringUtils.camelize(pubName);
|
||||||
additionalProperties.put(CLIENT_NAME, name);
|
additionalProperties.put(CLIENT_NAME, name);
|
||||||
|
@ -966,7 +966,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs) {
|
public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs) {
|
||||||
objs = super.postProcessAllModels(objs);
|
objs = super.postProcessAllModels(objs);
|
||||||
if (getSerializationLibrary() == SERIALIZATION_LIBRARY_TYPE.kotlinx_serialization) {
|
if (getSerializationLibrary() == SERIALIZATION_LIBRARY_TYPE.kotlinx_serialization || getLibrary().equals(MULTIPLATFORM)) {
|
||||||
// The loop removes unneeded variables so commas are handled correctly in the related templates
|
// The loop removes unneeded variables so commas are handled correctly in the related templates
|
||||||
for (Map.Entry<String, ModelsMap> modelsMap : objs.entrySet()) {
|
for (Map.Entry<String, ModelsMap> modelsMap : objs.entrySet()) {
|
||||||
for (ModelMap mo : modelsMap.getValue().getModels()) {
|
for (ModelMap mo : modelsMap.getValue().getModels()) {
|
||||||
@ -976,7 +976,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Remove discriminator property from the base class, it is not needed in the generated code
|
// Remove discriminator property from the base class, it is not needed in the generated code
|
||||||
getAllVarProperties(cm).forEach(list -> list.removeIf(var -> var.name == discriminator.getPropertyName()));
|
getAllVarProperties(cm).forEach(list -> list.removeIf(var -> var.name.equals(discriminator.getPropertyName())));
|
||||||
|
|
||||||
for (CodegenDiscriminator.MappedModel mappedModel : discriminator.getMappedModels()) {
|
for (CodegenDiscriminator.MappedModel mappedModel : discriminator.getMappedModels()) {
|
||||||
// Add the mapping name to additionalProperties.disciminatorValue
|
// Add the mapping name to additionalProperties.disciminatorValue
|
||||||
@ -989,7 +989,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
|||||||
}
|
}
|
||||||
additionalProperties.discriminatorValue = mappedModel.getMappingName();
|
additionalProperties.discriminatorValue = mappedModel.getMappingName();
|
||||||
// Remove the discriminator property from the derived class, it is not needed in the generated code
|
// 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 == discriminator.getPropertyName()));
|
getAllVarProperties(mappedModel.getModel()).forEach(list -> list.removeIf(prop -> prop.name.equals(discriminator.getPropertyName())));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ import com.google.common.collect.ImmutableMap;
|
|||||||
import com.samskivert.mustache.Mustache;
|
import com.samskivert.mustache.Mustache;
|
||||||
import com.samskivert.mustache.Mustache.Lambda;
|
import com.samskivert.mustache.Mustache.Lambda;
|
||||||
import com.samskivert.mustache.Template;
|
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.OpenAPI;
|
||||||
import io.swagger.v3.oas.models.Operation;
|
import io.swagger.v3.oas.models.Operation;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -425,6 +424,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
|||||||
importMapping.put("JsonProperty", "com.fasterxml.jackson.annotation.JsonProperty");
|
importMapping.put("JsonProperty", "com.fasterxml.jackson.annotation.JsonProperty");
|
||||||
importMapping.put("JsonSubTypes", "com.fasterxml.jackson.annotation.JsonSubTypes");
|
importMapping.put("JsonSubTypes", "com.fasterxml.jackson.annotation.JsonSubTypes");
|
||||||
importMapping.put("JsonTypeInfo", "com.fasterxml.jackson.annotation.JsonTypeInfo");
|
importMapping.put("JsonTypeInfo", "com.fasterxml.jackson.annotation.JsonTypeInfo");
|
||||||
|
importMapping.put("JsonIgnoreProperties", "com.fasterxml.jackson.annotation.JsonIgnoreProperties");
|
||||||
// import JsonCreator if JsonProperty is imported
|
// import JsonCreator if JsonProperty is imported
|
||||||
// used later in recursive import in postProcessingModels
|
// used later in recursive import in postProcessingModels
|
||||||
importMapping.put("com.fasterxml.jackson.annotation.JsonProperty", "com.fasterxml.jackson.annotation.JsonCreator");
|
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")) {
|
if (model.discriminator != null && additionalProperties.containsKey("jackson")) {
|
||||||
model.imports.addAll(Arrays.asList("JsonSubTypes", "JsonTypeInfo"));
|
model.imports.addAll(Arrays.asList("JsonSubTypes", "JsonTypeInfo", "JsonIgnoreProperties"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,8 +51,6 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
|
|
||||||
static final String X_MODEL_MODULE = "x-model-module";
|
static final String X_MODEL_MODULE = "x-model-module";
|
||||||
|
|
||||||
public static final String CO_HTTP = "cohttp";
|
|
||||||
|
|
||||||
@Setter protected String packageName = "openapi";
|
@Setter protected String packageName = "openapi";
|
||||||
@Setter protected String packageVersion = "1.0.0";
|
@Setter protected String packageVersion = "1.0.0";
|
||||||
protected String apiDocPath = "docs/";
|
protected String apiDocPath = "docs/";
|
||||||
@ -97,12 +95,15 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
.excludeSchemaSupportFeatures(
|
.excludeSchemaSupportFeatures(
|
||||||
SchemaSupportFeature.Polymorphism
|
SchemaSupportFeature.Polymorphism
|
||||||
)
|
)
|
||||||
|
.includeSchemaSupportFeatures(
|
||||||
|
SchemaSupportFeature.oneOf,
|
||||||
|
SchemaSupportFeature.anyOf
|
||||||
|
)
|
||||||
.includeClientModificationFeatures(
|
.includeClientModificationFeatures(
|
||||||
ClientModificationFeature.BasePath
|
ClientModificationFeature.BasePath
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
outputFolder = "generated-code/ocaml";
|
outputFolder = "generated-code/ocaml";
|
||||||
modelTemplateFiles.put("model.mustache", ".ml");
|
modelTemplateFiles.put("model.mustache", ".ml");
|
||||||
|
|
||||||
@ -133,6 +134,7 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
supportingFiles.add(new SupportingFile("dune.mustache", "", "dune"));
|
supportingFiles.add(new SupportingFile("dune.mustache", "", "dune"));
|
||||||
supportingFiles.add(new SupportingFile("dune-project.mustache", "", "dune-project"));
|
supportingFiles.add(new SupportingFile("dune-project.mustache", "", "dune-project"));
|
||||||
supportingFiles.add(new SupportingFile("readme.mustache", "", "README.md"));
|
supportingFiles.add(new SupportingFile("readme.mustache", "", "README.md"));
|
||||||
|
supportingFiles.add(new SupportingFile("ocamlformat.mustache", "", ".ocamlformat"));
|
||||||
|
|
||||||
defaultIncludes = new HashSet<>(
|
defaultIncludes = new HashSet<>(
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
@ -171,6 +173,7 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
typeMapping.put("short", "int");
|
typeMapping.put("short", "int");
|
||||||
typeMapping.put("char", "char");
|
typeMapping.put("char", "char");
|
||||||
typeMapping.put("float", "float");
|
typeMapping.put("float", "float");
|
||||||
|
typeMapping.put("decimal", "string");
|
||||||
typeMapping.put("double", "float");
|
typeMapping.put("double", "float");
|
||||||
typeMapping.put("integer", "int32");
|
typeMapping.put("integer", "int32");
|
||||||
typeMapping.put("number", "float");
|
typeMapping.put("number", "float");
|
||||||
@ -179,6 +182,7 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
typeMapping.put("any", "Yojson.Safe.t");
|
typeMapping.put("any", "Yojson.Safe.t");
|
||||||
typeMapping.put("file", "string");
|
typeMapping.put("file", "string");
|
||||||
typeMapping.put("ByteArray", "string");
|
typeMapping.put("ByteArray", "string");
|
||||||
|
typeMapping.put("AnyType", "Yojson.Safe.t");
|
||||||
// lib
|
// lib
|
||||||
typeMapping.put("string", "string");
|
typeMapping.put("string", "string");
|
||||||
typeMapping.put("UUID", "string");
|
typeMapping.put("UUID", "string");
|
||||||
@ -186,15 +190,6 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
typeMapping.put("set", "`Set");
|
typeMapping.put("set", "`Set");
|
||||||
typeMapping.put("password", "string");
|
typeMapping.put("password", "string");
|
||||||
typeMapping.put("DateTime", "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
|
@Override
|
||||||
@ -202,13 +197,12 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
List<String> toRemove = new ArrayList<>();
|
List<String> toRemove = new ArrayList<>();
|
||||||
|
|
||||||
for (Map.Entry<String, ModelsMap> modelEntry : superobjs.entrySet()) {
|
for (Map.Entry<String, ModelsMap> modelEntry : superobjs.entrySet()) {
|
||||||
// process enum in models
|
|
||||||
List<ModelMap> models = modelEntry.getValue().getModels();
|
List<ModelMap> models = modelEntry.getValue().getModels();
|
||||||
for (ModelMap mo : models) {
|
for (ModelMap mo : models) {
|
||||||
CodegenModel cm = mo.getModel();
|
CodegenModel cm = mo.getModel();
|
||||||
|
|
||||||
// for enum model
|
// for enum model
|
||||||
if (Boolean.TRUE.equals(cm.isEnum) && cm.allowableValues != null) {
|
if (cm.isEnum && cm.allowableValues != null) {
|
||||||
toRemove.add(modelEntry.getKey());
|
toRemove.add(modelEntry.getKey());
|
||||||
} else {
|
} else {
|
||||||
enrichPropertiesWithEnumDefaultValues(cm.getAllVars());
|
enrichPropertiesWithEnumDefaultValues(cm.getAllVars());
|
||||||
@ -219,6 +213,15 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
enrichPropertiesWithEnumDefaultValues(cm.getVars());
|
enrichPropertiesWithEnumDefaultValues(cm.getVars());
|
||||||
enrichPropertiesWithEnumDefaultValues(cm.getParentVars());
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,8 +245,7 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
@Override
|
@Override
|
||||||
protected void updateDataTypeWithEnumForMap(CodegenProperty property) {
|
protected void updateDataTypeWithEnumForMap(CodegenProperty property) {
|
||||||
CodegenProperty baseItem = property.items;
|
CodegenProperty baseItem = property.items;
|
||||||
while (baseItem != null && (Boolean.TRUE.equals(baseItem.isMap)
|
while (baseItem != null && (baseItem.isMap || baseItem.isArray)) {
|
||||||
|| Boolean.TRUE.equals(baseItem.isArray))) {
|
|
||||||
baseItem = baseItem.items;
|
baseItem = baseItem.items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,8 +262,7 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
@Override
|
@Override
|
||||||
protected void updateDataTypeWithEnumForArray(CodegenProperty property) {
|
protected void updateDataTypeWithEnumForArray(CodegenProperty property) {
|
||||||
CodegenProperty baseItem = property.items;
|
CodegenProperty baseItem = property.items;
|
||||||
while (baseItem != null && (Boolean.TRUE.equals(baseItem.isMap)
|
while (baseItem != null && (baseItem.isMap || baseItem.isArray)) {
|
||||||
|| Boolean.TRUE.equals(baseItem.isArray))) {
|
|
||||||
baseItem = baseItem.items;
|
baseItem = baseItem.items;
|
||||||
}
|
}
|
||||||
if (baseItem != null) {
|
if (baseItem != null) {
|
||||||
@ -312,19 +313,17 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
|
|
||||||
collectEnumSchemas(parentName, sName, schema);
|
collectEnumSchemas(parentName, sName, schema);
|
||||||
|
|
||||||
if (schema.getProperties() != null) {
|
|
||||||
String pName = parentName != null ? parentName + "_" + sName : sName;
|
String pName = parentName != null ? parentName + "_" + sName : sName;
|
||||||
|
if (schema.getProperties() != null) {
|
||||||
collectEnumSchemas(pName, schema.getProperties());
|
collectEnumSchemas(pName, schema.getProperties());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (schema.getAdditionalProperties() != null && schema.getAdditionalProperties() instanceof Schema) {
|
if (schema.getAdditionalProperties() != null && schema.getAdditionalProperties() instanceof Schema) {
|
||||||
String pName = parentName != null ? parentName + "_" + sName : sName;
|
|
||||||
collectEnumSchemas(pName, (Schema) schema.getAdditionalProperties());
|
collectEnumSchemas(pName, (Schema) schema.getAdditionalProperties());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ModelUtils.isArraySchema(schema)) {
|
if (ModelUtils.isArraySchema(schema)) {
|
||||||
if (ModelUtils.getSchemaItems(schema) != null) {
|
if (ModelUtils.getSchemaItems(schema) != null) {
|
||||||
String pName = parentName != null ? parentName + "_" + sName : sName;
|
|
||||||
collectEnumSchemas(pName, ModelUtils.getSchemaItems(schema));
|
collectEnumSchemas(pName, ModelUtils.getSchemaItems(schema));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -677,7 +676,7 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
public String toEnumValueName(String name) {
|
public String toEnumValueName(String name) {
|
||||||
if (reservedWords.contains(name)) {
|
if (reservedWords.contains(name)) {
|
||||||
return escapeReservedWord(name);
|
return escapeReservedWord(name);
|
||||||
} else if (((CharSequence) name).chars().anyMatch(character -> specialCharReplacements.keySet().contains(String.valueOf((char) character)))) {
|
} else if (name.chars().anyMatch(character -> specialCharReplacements.containsKey(String.valueOf((char) character)))) {
|
||||||
return escape(name, specialCharReplacements, Collections.singletonList("_"), null);
|
return escape(name, specialCharReplacements, Collections.singletonList("_"), null);
|
||||||
} else {
|
} else {
|
||||||
return name;
|
return name;
|
||||||
@ -723,8 +722,6 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
List<CodegenOperation> operations = objectMap.getOperation();
|
List<CodegenOperation> operations = objectMap.getOperation();
|
||||||
|
|
||||||
for (CodegenOperation operation : operations) {
|
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) {
|
for (CodegenParameter param : operation.bodyParams) {
|
||||||
if (param.isModel && param.dataType.endsWith(".t")) {
|
if (param.isModel && param.dataType.endsWith(".t")) {
|
||||||
param.vendorExtensions.put(X_MODEL_MODULE, param.dataType.substring(0, param.dataType.lastIndexOf('.')));
|
param.vendorExtensions.put(X_MODEL_MODULE, param.dataType.substring(0, param.dataType.lastIndexOf('.')));
|
||||||
|
@ -546,25 +546,35 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
* @param allowableValues allowable values
|
* @param allowableValues allowable values
|
||||||
*/
|
*/
|
||||||
public void addUnspecifiedToAllowableValues(Map<String, Object> allowableValues) {
|
public void addUnspecifiedToAllowableValues(Map<String, Object> allowableValues) {
|
||||||
|
|
||||||
|
final String UNSPECIFIED = "UNSPECIFIED";
|
||||||
|
|
||||||
if (startEnumsWithUnspecified) {
|
if (startEnumsWithUnspecified) {
|
||||||
if (allowableValues.containsKey("enumVars")) {
|
if (allowableValues.containsKey("enumVars")) {
|
||||||
List<Map<String, Object>> enumVars = (List<Map<String, Object>>) allowableValues.get("enumVars");
|
List<Map<String, Object>> enumVars = (List<Map<String, Object>>) allowableValues.get("enumVars");
|
||||||
|
boolean unspecifiedPresent = enumVars.stream()
|
||||||
HashMap<String, Object> unspecified = new HashMap<String, Object>();
|
.anyMatch(e -> {
|
||||||
unspecified.put("name", "UNSPECIFIED");
|
return UNSPECIFIED.equals(e.get("name"));
|
||||||
unspecified.put("isString", "false");
|
});
|
||||||
unspecified.put("value", "\"UNSPECIFIED\"");
|
if (!unspecifiedPresent) {
|
||||||
enumVars.add(0, unspecified);
|
HashMap<String, Object> unspecifiedEnum = new HashMap<String, Object>();
|
||||||
|
unspecifiedEnum.put("name", UNSPECIFIED);
|
||||||
|
unspecifiedEnum.put("isString", "false");
|
||||||
|
unspecifiedEnum.put("value", "\"" + UNSPECIFIED + "\"");
|
||||||
|
enumVars.add(0, unspecifiedEnum);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allowableValues.containsKey("values")) {
|
if (allowableValues.containsKey("values")) {
|
||||||
List<String> values = (List<String>) allowableValues.get("values");
|
List<String> values = (List<String>) allowableValues.get("values");
|
||||||
|
if (!values.contains(UNSPECIFIED)) {
|
||||||
List<String> modifiableValues = new ArrayList<>(values);
|
List<String> modifiableValues = new ArrayList<>(values);
|
||||||
modifiableValues.add(0, "UNSPECIFIED");
|
modifiableValues.add(0, UNSPECIFIED);
|
||||||
allowableValues.put("values", modifiableValues);
|
allowableValues.put("values", modifiableValues);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates enum vars and puts index to them
|
* Iterates enum vars and puts index to them
|
||||||
|
@ -450,7 +450,15 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
CodegenOperation op = super.fromOperation(path, httpMethod, operation, servers);
|
CodegenOperation op = super.fromOperation(path, httpMethod, operation, servers);
|
||||||
|
|
||||||
String underscoredOperationId = underscore(op.operationId);
|
String underscoredOperationId = underscore(op.operationId);
|
||||||
ArrayList<MethodOperation> pathMethods = pathMethodOpMap.get(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);
|
||||||
|
}
|
||||||
|
ArrayList<MethodOperation> pathMethods = pathMethodOpMap.get(axumPath);
|
||||||
|
|
||||||
// Prevent multiple declarations of the same operation
|
// Prevent multiple declarations of the same operation
|
||||||
if (pathMethods != null && pathMethods.stream().anyMatch(pathMethod ->
|
if (pathMethods != null && pathMethods.stream().anyMatch(pathMethod ->
|
||||||
@ -463,14 +471,6 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
|
|
||||||
if (!op.isCallbackRequest) {
|
if (!op.isCallbackRequest) {
|
||||||
// group route by path
|
// 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
|
pathMethodOpMap
|
||||||
.computeIfAbsent(axumPath, (key) -> new ArrayList<>())
|
.computeIfAbsent(axumPath, (key) -> new ArrayList<>())
|
||||||
.add(new MethodOperation(
|
.add(new MethodOperation(
|
||||||
|
@ -307,6 +307,69 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
|
|||||||
mdl.getComposedSchemas().setOneOf(newOneOfs);
|
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;
|
return mdl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -708,9 +771,9 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we use a file parameter, we need to include the imports and crates for it
|
// If we use a file body parameter, we need to include the imports and crates for it
|
||||||
// But they should be added only once per file
|
// But they should be added only once per file
|
||||||
for (var param: operation.allParams) {
|
for (var param: operation.bodyParams) {
|
||||||
if (param.isFile && supportAsync && !useAsyncFileStream) {
|
if (param.isFile && supportAsync && !useAsyncFileStream) {
|
||||||
useAsyncFileStream = true;
|
useAsyncFileStream = true;
|
||||||
additionalProperties.put("useAsyncFileStream", Boolean.TRUE);
|
additionalProperties.put("useAsyncFileStream", Boolean.TRUE);
|
||||||
|
@ -0,0 +1,730 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -188,6 +188,12 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
updateOption(CodegenConstants.API_PACKAGE, apiPackage);
|
updateOption(CodegenConstants.API_PACKAGE, apiPackage);
|
||||||
updateOption(CodegenConstants.MODEL_PACKAGE, modelPackage);
|
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
|
apiTestTemplateFiles.clear(); // TODO: add test template
|
||||||
|
|
||||||
// spring uses the jackson lib
|
// spring uses the jackson lib
|
||||||
@ -365,9 +371,6 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
|
|
||||||
convertPropertyToTypeAndWriteBack(REQUEST_MAPPING_OPTION, RequestMappingMode::valueOf, this::setRequestMappingMode);
|
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
|
// Please refrain from updating values of Config Options after super.ProcessOpts() is called
|
||||||
super.processOpts();
|
super.processOpts();
|
||||||
|
|
||||||
@ -1036,6 +1039,12 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
codegenOperation.imports.addAll(provideArgsClassSet);
|
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 (reactive) {
|
||||||
if (DocumentationProvider.SPRINGFOX.equals(getDocumentationProvider())) {
|
if (DocumentationProvider.SPRINGFOX.equals(getDocumentationProvider())) {
|
||||||
codegenOperation.imports.add("ApiIgnore");
|
codegenOperation.imports.add("ApiIgnore");
|
||||||
|
@ -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("# 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("# Please support his work directly via https://paypal.com/paypalme/4brunu \uD83D\uDE4F #");
|
||||||
System.out.println("# #");
|
System.out.println("# #");
|
||||||
System.out.println("# There is a new swift6 generator, that is currently in beta. #");
|
System.out.println("# There is a new swift6 generator, that is now stable. #");
|
||||||
System.out.println("# Try it and give us your feedback. #");
|
System.out.println("# Try it and give us your feedback. #");
|
||||||
System.out.println("# https://openapi-generator.tech/docs/generators/swift6 #");
|
System.out.println("# https://openapi-generator.tech/docs/generators/swift6 #");
|
||||||
System.out.println("# #");
|
System.out.println("# #");
|
||||||
|
@ -142,7 +142,7 @@ public class Swift6ClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
this.useOneOfInterfaces = true;
|
this.useOneOfInterfaces = true;
|
||||||
|
|
||||||
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||||
.stability(Stability.BETA)
|
.stability(Stability.STABLE)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
outputFolder = "generated-code" + File.separator + "swift";
|
outputFolder = "generated-code" + File.separator + "swift";
|
||||||
|
@ -559,7 +559,9 @@ public class ModelUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// additionalProperties explicitly set to false
|
// additionalProperties explicitly set to false
|
||||||
if (schema.getAdditionalProperties() instanceof Boolean && Boolean.FALSE.equals(schema.getAdditionalProperties())) {
|
if ((schema.getAdditionalProperties() instanceof Boolean && Boolean.FALSE.equals(schema.getAdditionalProperties())) ||
|
||||||
|
(schema.getAdditionalProperties() instanceof Schema && Boolean.FALSE.equals(((Schema) schema.getAdditionalProperties()).getBooleanSchemaValue()))
|
||||||
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -808,7 +810,13 @@ public class ModelUtils {
|
|||||||
(null != schema.getProperties() && !schema.getProperties().isEmpty()) &&
|
(null != schema.getProperties() && !schema.getProperties().isEmpty()) &&
|
||||||
// no additionalProperties is set
|
// no additionalProperties is set
|
||||||
(schema.getAdditionalProperties() == null ||
|
(schema.getAdditionalProperties() == null ||
|
||||||
(schema.getAdditionalProperties() instanceof Boolean && !(Boolean) schema.getAdditionalProperties()));
|
// 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())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasValidation(Schema sc) {
|
public static boolean hasValidation(Schema sc) {
|
||||||
@ -1565,6 +1573,7 @@ public class ModelUtils {
|
|||||||
List<String> refedWithoutDiscriminator = new ArrayList<>();
|
List<String> refedWithoutDiscriminator = new ArrayList<>();
|
||||||
|
|
||||||
if (interfaces != null && !interfaces.isEmpty()) {
|
if (interfaces != null && !interfaces.isEmpty()) {
|
||||||
|
List<String> parentNameCandidates = new ArrayList<>(interfaces.size());
|
||||||
for (Schema schema : interfaces) {
|
for (Schema schema : interfaces) {
|
||||||
// get the actual schema
|
// get the actual schema
|
||||||
if (StringUtils.isNotEmpty(schema.get$ref())) {
|
if (StringUtils.isNotEmpty(schema.get$ref())) {
|
||||||
@ -1572,10 +1581,10 @@ public class ModelUtils {
|
|||||||
Schema s = allSchemas.get(parentName);
|
Schema s = allSchemas.get(parentName);
|
||||||
if (s == null) {
|
if (s == null) {
|
||||||
LOGGER.error("Failed to obtain schema from {}", parentName);
|
LOGGER.error("Failed to obtain schema from {}", parentName);
|
||||||
return "UNKNOWN_PARENT_NAME";
|
parentNameCandidates.add("UNKNOWN_PARENT_NAME");
|
||||||
} else if (hasOrInheritsDiscriminator(s, allSchemas, new ArrayList<Schema>())) {
|
} else if (hasOrInheritsDiscriminator(s, allSchemas, new ArrayList<Schema>())) {
|
||||||
// discriminator.propertyName is used or x-parent is used
|
// discriminator.propertyName is used or x-parent is used
|
||||||
return parentName;
|
parentNameCandidates.add(parentName);
|
||||||
} else {
|
} else {
|
||||||
// not a parent since discriminator.propertyName or x-parent is not set
|
// not a parent since discriminator.propertyName or x-parent is not set
|
||||||
hasAmbiguousParents = true;
|
hasAmbiguousParents = true;
|
||||||
@ -1592,6 +1601,12 @@ 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) {
|
if (refedWithoutDiscriminator.size() == 1 && nullSchemaChildrenCount == 1) {
|
||||||
// One schema is a $ref and the other is the 'null' type, so the parent is obvious.
|
// 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.
|
// In this particular case there is no need to specify a discriminator.
|
||||||
@ -1926,7 +1941,7 @@ public class ModelUtils {
|
|||||||
if (multipleOf != null) target.setMultipleOf(multipleOf);
|
if (multipleOf != null) target.setMultipleOf(multipleOf);
|
||||||
if (minimum != null) {
|
if (minimum != null) {
|
||||||
if (isIntegerSchema(schema)) {
|
if (isIntegerSchema(schema)) {
|
||||||
target.setMinimum(String.valueOf(minimum.longValue()));
|
target.setMinimum(String.valueOf(minimum.toBigInteger()));
|
||||||
} else {
|
} else {
|
||||||
target.setMinimum(String.valueOf(minimum));
|
target.setMinimum(String.valueOf(minimum));
|
||||||
}
|
}
|
||||||
@ -1934,7 +1949,7 @@ public class ModelUtils {
|
|||||||
}
|
}
|
||||||
if (maximum != null) {
|
if (maximum != null) {
|
||||||
if (isIntegerSchema(schema)) {
|
if (isIntegerSchema(schema)) {
|
||||||
target.setMaximum(String.valueOf(maximum.longValue()));
|
target.setMaximum(String.valueOf(maximum.toBigInteger()));
|
||||||
} else {
|
} else {
|
||||||
target.setMaximum(String.valueOf(maximum));
|
target.setMaximum(String.valueOf(maximum));
|
||||||
}
|
}
|
||||||
@ -2164,6 +2179,22 @@ 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.
|
* 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
Loading…
x
Reference in New Issue
Block a user