mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-06 12:36:09 +00:00
Compare commits
28 Commits
elonmallin
...
csharp-net
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f702631649 | ||
|
|
178f4fbad8 | ||
|
|
bae20c1887 | ||
|
|
d9920a5b81 | ||
|
|
37451fa569 | ||
|
|
e47e7041f7 | ||
|
|
69fcfeff38 | ||
|
|
dd4143b75e | ||
|
|
a460b7ea87 | ||
|
|
61fde48501 | ||
|
|
6be4d2e082 | ||
|
|
2ca958642b | ||
|
|
2c25443260 | ||
|
|
d1b148a7d3 | ||
|
|
8860d967c0 | ||
|
|
322afeacd4 | ||
|
|
c8b3da7388 | ||
|
|
91ac75ff05 | ||
|
|
6da264b0f8 | ||
|
|
53289263d9 | ||
|
|
e2a62ace74 | ||
|
|
c9f7af752f | ||
|
|
ec3c484ce9 | ||
|
|
7e529926a6 | ||
|
|
2f655f1a9c | ||
|
|
5693eee4e0 | ||
|
|
f83e4ffb9b | ||
|
|
c377fdf62d |
@@ -57,54 +57,43 @@ commands: # a reusable command with parameters
|
||||
- run: docker ps -a
|
||||
- run: sleep 30
|
||||
- run: cat /etc/hosts
|
||||
# Test
|
||||
- run: ./mvnw --no-snapshot-updates --quiet clean install -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
||||
- run: export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=128m"
|
||||
- run:
|
||||
name: "Setup custom environment variables"
|
||||
command: echo 'export CIRCLE_NODE_INDEX="<<parameters.nodeNo>>"' >> $BASH_ENV
|
||||
- run: ./CI/circle_parallel.sh
|
||||
# Save dependency cache
|
||||
- save_cache:
|
||||
key: source-v2-{{ .Branch }}-{{ .Revision }}
|
||||
paths:
|
||||
# This is a broad list of cache paths to include many possible development environments
|
||||
# You can probably delete some of these entries
|
||||
- vendor/bundle
|
||||
- ~/.nvm
|
||||
- ~/.pyenv
|
||||
- ~/virtualenvs
|
||||
- ~/.m2
|
||||
- ~/.ivy2
|
||||
- ~/.sbt
|
||||
- ~/.bundle
|
||||
- ~/.go_workspace
|
||||
- ~/.gradle
|
||||
- ~/.cache/bower
|
||||
- ".git"
|
||||
- ~/.stack
|
||||
- /home/circleci/OpenAPITools/openapi-generator/samples/client/petstore/haskell-http-client/.stack-work
|
||||
- ~/R
|
||||
# save "default" cache using the key "source-v2-"
|
||||
- save_cache:
|
||||
key: source-v2-
|
||||
paths:
|
||||
# This is a broad list of cache paths to include many possible development environments
|
||||
# You can probably delete some of these entries
|
||||
- vendor/bundle
|
||||
- ~/.nvm
|
||||
- ~/.pyenv
|
||||
- ~/virtualenvs
|
||||
- ~/.m2
|
||||
- ~/.ivy2
|
||||
- ~/.sbt
|
||||
- ~/.bundle
|
||||
- ~/.go_workspace
|
||||
- ~/.gradle
|
||||
- ~/.cache/bower
|
||||
- ".git"
|
||||
- ~/.stack
|
||||
- /home/circleci/OpenAPITools/openapi-generator/samples/client/petstore/haskell-http-client/.stack-work
|
||||
- ~/R
|
||||
#- save_cache:
|
||||
# key: source-v2-{{ .Branch }}-{{ .Revision }}
|
||||
# paths:
|
||||
# # This is a broad list of cache paths to include many possible development environments
|
||||
# # You can probably delete some of these entries
|
||||
# - ~/.m2
|
||||
# - ~/.ivy2
|
||||
# - ~/.sbt
|
||||
# - ~/.bundle
|
||||
# - ~/.go_workspace
|
||||
# - ~/.gradle
|
||||
# - ".git"
|
||||
# - ~/.stack
|
||||
# - ~/R
|
||||
## save "default" cache using the key "source-v2-"
|
||||
#- save_cache:
|
||||
# key: source-v2-
|
||||
# paths:
|
||||
# # This is a broad list of cache paths to include many possible development environments
|
||||
# # You can probably delete some of these entries
|
||||
# - vendor/bundle
|
||||
# - ~/.m2
|
||||
# - ~/.ivy2
|
||||
# - ~/.sbt
|
||||
# - ~/.bundle
|
||||
# - ~/.go_workspace
|
||||
# - ~/.gradle
|
||||
# - ~/.cache/bower
|
||||
# - ".git"
|
||||
# - ~/.stack
|
||||
# - ~/R
|
||||
# Teardown
|
||||
# If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each
|
||||
# Save test results
|
||||
|
||||
3
.github/workflows/docker.yaml
vendored
3
.github/workflows/docker.yaml
vendored
@@ -1,6 +1,7 @@
|
||||
name: Docker tests
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
paths:
|
||||
- Dockerfile
|
||||
@@ -27,7 +28,7 @@ jobs:
|
||||
shell: bash
|
||||
run: |
|
||||
sed -i 's/ -it / /g' run-in-docker.sh
|
||||
./run-in-docker.sh mvn clean install
|
||||
./run-in-docker.sh mvn -B clean install
|
||||
|
||||
- name: Build Dockerfile
|
||||
shell: bash
|
||||
|
||||
4
.github/workflows/samples-dotnet.yaml
vendored
4
.github/workflows/samples-dotnet.yaml
vendored
@@ -1,4 +1,4 @@
|
||||
name: Samples C# .Net 7
|
||||
name: Samples C# .Net 8
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -45,7 +45,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-dotnet@v3.2.0
|
||||
with:
|
||||
dotnet-version: '7.0.x'
|
||||
dotnet-version: '8.0.x'
|
||||
- name: Build
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: dotnet build Org.OpenAPITools.sln
|
||||
|
||||
18
.github/workflows/samples-dotnet6-client.yaml
vendored
18
.github/workflows/samples-dotnet6-client.yaml
vendored
@@ -16,9 +16,9 @@ on:
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net47/**
|
||||
# build C# API client (.net framework 4.8)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net48/**
|
||||
# build C# API client (.net 5.0)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net5.0/**
|
||||
# build C# API client (.net 5.0 with ConditionalSerialization)
|
||||
# build C# API client (.net 7.0)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net7.0/**
|
||||
# build C# API client (.net 7.0 with ConditionalSerialization)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/**
|
||||
# build C# API client (property, parameter name mappings)
|
||||
- samples/client/petstore/csharp-restsharp-name-parameter-mappings/**
|
||||
@@ -37,9 +37,9 @@ on:
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net47/**
|
||||
# build C# API client (.net framework 4.8)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net48/**
|
||||
# build C# API client (.net 5.0)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net5.0/**
|
||||
# build C# API client (.net 5.0 with ConditionalSerialization)
|
||||
# build C# API client (.net 7.0)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net7.0/**
|
||||
# build C# API client (.net 7.0 with ConditionalSerialization)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/**
|
||||
# build C# API client (property, parameter name mappings)
|
||||
- samples/client/petstore/csharp-restsharp-name-parameter-mappings/**
|
||||
@@ -65,9 +65,9 @@ jobs:
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net47/
|
||||
# build C# API client (.net framework 4.8)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net48/
|
||||
# build C# API client (.net 5.0)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net5.0/
|
||||
# build C# API client (.net 5.0 with ConditionalSerialization)
|
||||
# build C# API client (.net 7.0)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net7.0/
|
||||
# build C# API client (.net 7.0 with ConditionalSerialization)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/
|
||||
# build C# API client (property, parameter name mappings)
|
||||
- samples/client/petstore/csharp-restsharp-name-parameter-mappings
|
||||
|
||||
81
.github/workflows/samples-dotnet7-client.yaml
vendored
Normal file
81
.github/workflows/samples-dotnet7-client.yaml
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
name: Samples C# .Net 7
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
# build C# API client (multiple frameworks)
|
||||
- samples/client/petstore/csharp/OpenAPIClientCoreAndNet47/**
|
||||
# build C# API client (httpclient)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-httpclient/**
|
||||
# build C# API client (generichost)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/**
|
||||
# build C# API client (netcore)
|
||||
- samples/client/petstore/csharp/OpenAPIClient/**
|
||||
- samples/client/petstore/csharp/OpenAPIClientCore/**
|
||||
# build C# API client (.net framework 4.7)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net47/**
|
||||
# build C# API client (.net framework 4.8)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net48/**
|
||||
# build C# API client (.net 7.0)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net7.0/**
|
||||
# build C# API client (.net 7.0 with ConditionalSerialization)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/**
|
||||
# build C# API client (property, parameter name mappings)
|
||||
- samples/client/petstore/csharp-restsharp-name-parameter-mappings/**
|
||||
pull_request:
|
||||
paths:
|
||||
# build C# API client (multiple frameworks)
|
||||
- samples/client/petstore/csharp/OpenAPIClientCoreAndNet47/**
|
||||
# build C# API client (httpclient)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-httpclient/**
|
||||
# build C# API client (generichost)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/**
|
||||
# build C# API client (netcore)
|
||||
- samples/client/petstore/csharp/OpenAPIClient/**
|
||||
- samples/client/petstore/csharp/OpenAPIClientCore/**
|
||||
# build C# API client (.net framework 4.7)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net47/**
|
||||
# build C# API client (.net framework 4.8)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net48/**
|
||||
# build C# API client (.net 7.0)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net7.0/**
|
||||
# build C# API client (.net 7.0 with ConditionalSerialization)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/**
|
||||
# build C# API client (property, parameter name mappings)
|
||||
- samples/client/petstore/csharp-restsharp-name-parameter-mappings/**
|
||||
jobs:
|
||||
build:
|
||||
name: Build .Net clients
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
sample:
|
||||
# clients
|
||||
# build C# API client (multiple frameworks)
|
||||
- samples/client/petstore/csharp/OpenAPIClientCoreAndNet47/
|
||||
# build C# API client (httpclient)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-httpclient/
|
||||
# build C# API client (generichost)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/
|
||||
# build C# API client (netcore)
|
||||
- samples/client/petstore/csharp/OpenAPIClient/
|
||||
- samples/client/petstore/csharp/OpenAPIClientCore/
|
||||
# build C# API client (.net framework 4.7)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net47/
|
||||
# build C# API client (.net framework 4.8)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net48/
|
||||
# build C# API client (.net 7.0)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-net7.0/
|
||||
# build C# API client (.net 7.0 with ConditionalSerialization)
|
||||
- samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/
|
||||
# build C# API client (property, parameter name mappings)
|
||||
- samples/client/petstore/csharp-restsharp-name-parameter-mappings
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-dotnet@v3.2.0
|
||||
with:
|
||||
dotnet-version: '7.0.x'
|
||||
- name: Build
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: dotnet build Org.OpenAPITools.sln
|
||||
@@ -19,6 +19,7 @@ jobs:
|
||||
- samples/client/echo_api/java/apache-httpclient
|
||||
- samples/client/echo_api/java/native
|
||||
- samples/client/echo_api/java/feign-gson
|
||||
- samples/client/echo_api/java/resttemplate
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-java@v3
|
||||
|
||||
@@ -6,11 +6,13 @@ on:
|
||||
- samples/client/echo_api/java/apache-httpclient/**
|
||||
- samples/client/echo_api/java/feign-gson/**
|
||||
- samples/client/echo_api/java/okhttp-gson/**
|
||||
- samples/client/echo_api/java/resttemplate/**
|
||||
pull_request:
|
||||
paths:
|
||||
- samples/client/echo_api/java/apache-httpclient/**
|
||||
- samples/client/echo_api/java/feign-gson/**
|
||||
- samples/client/echo_api/java/okhttp-gson/**
|
||||
- samples/client/echo_api/java/resttemplate/**
|
||||
jobs:
|
||||
build:
|
||||
name: Build Java Client JDK8
|
||||
@@ -23,6 +25,7 @@ jobs:
|
||||
- samples/client/echo_api/java/apache-httpclient
|
||||
- samples/client/echo_api/java/feign-gson
|
||||
- samples/client/echo_api/java/okhttp-gson
|
||||
- samples/client/echo_api/java/resttemplate
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-java@v3
|
||||
|
||||
@@ -3,19 +3,19 @@
|
||||
##
|
||||
## You can build _just_ this part with:
|
||||
## docker --target builder -t container-name:builder -f .hub.cli.dockerfile .
|
||||
FROM maven:3.6.3-jdk-11-openj9 as builder
|
||||
FROM maven:3-eclipse-temurin-17 as builder
|
||||
|
||||
ENV GEN_DIR /opt/openapi-generator
|
||||
WORKDIR ${GEN_DIR}
|
||||
COPY . ${GEN_DIR}
|
||||
|
||||
# Pre-compile openapi-generator-cli
|
||||
RUN mvn -am -pl "modules/openapi-generator-cli" package
|
||||
RUN mvn -B -am -pl "modules/openapi-generator-cli" package
|
||||
|
||||
## The final (release) image
|
||||
## The resulting container here only needs the target jar
|
||||
## and ca-certificates (to be able to query HTTPS hosted specs)
|
||||
FROM openjdk:11.0.8-jre-slim-buster
|
||||
FROM eclipse-temurin:17-jre
|
||||
|
||||
ENV GEN_DIR /opt/openapi-generator
|
||||
|
||||
|
||||
@@ -3,18 +3,18 @@
|
||||
##
|
||||
## You can build _just_ this part with:
|
||||
## docker --target builder -t container-name:builder -f .hub.online.dockerfile .
|
||||
FROM maven:3.6.3-jdk-11-openj9 as builder
|
||||
FROM maven:3-eclipse-temurin-17 as builder
|
||||
|
||||
ENV GEN_DIR /opt/openapi-generator
|
||||
WORKDIR ${GEN_DIR}
|
||||
COPY . ${GEN_DIR}
|
||||
|
||||
# Pre-compile openapi-generator-online
|
||||
RUN mvn -am -pl "modules/openapi-generator-online" package
|
||||
RUN mvn -B -am -pl "modules/openapi-generator-online" package
|
||||
|
||||
## The final (release) image
|
||||
## The resulting container here only needs the target jar
|
||||
FROM openjdk:11.0.8-jre-slim-buster
|
||||
FROM eclipse-temurin:17-jre
|
||||
|
||||
ENV GEN_DIR /opt/openapi-generator
|
||||
ENV TARGET_DIR /generator
|
||||
|
||||
@@ -10,10 +10,13 @@ set -e
|
||||
export NODE_ENV=test
|
||||
|
||||
if [ "$NODE_INDEX" = "1" ]; then
|
||||
echo "Running node $NODE_INDEX to test 'samples.circleci' defined in pom.xml ..."
|
||||
echo "Running node $NODE_INDEX ..."
|
||||
java -version
|
||||
|
||||
./mvnw --no-snapshot-updates --quiet verify -Psamples.circleci -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
||||
(cd samples/client/petstore/ruby && mvn integration-test)
|
||||
(cd samples/client/petstore/ruby-faraday && mvn integration-test)
|
||||
(cd samples/client/petstore/ruby-httpx && mvn integration-test)
|
||||
(cd samples/client/petstore/ruby-autoload && mvn integration-test)
|
||||
|
||||
elif [ "$NODE_INDEX" = "2" ]; then
|
||||
echo "Running node $NODE_INDEX to test Go"
|
||||
@@ -33,20 +36,14 @@ elif [ "$NODE_INDEX" = "2" ]; then
|
||||
export PATH="/usr/local/go1.18/go/bin:$PATH"
|
||||
go version
|
||||
|
||||
# run integration tests
|
||||
./mvnw --no-snapshot-updates --quiet verify -Psamples.misc -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
||||
# run go integration tests
|
||||
(cd samples/client/petstore/go && mvn integration-test)
|
||||
(cd samples/openapi3/client/petstore/go && mvn integration-test)
|
||||
(cd samples/openapi3/client/petstore/go-petstore-generateMarshalJSON-false && mvn integration-test)
|
||||
|
||||
elif [ "$NODE_INDEX" = "3" ]; then
|
||||
|
||||
echo "Running node $NODE_INDEX to test 'samples.circleci.node3' defined in pom.xml ..."
|
||||
#wget https://www.python.org/ftp/python/3.8.9/Python-3.8.9.tgz
|
||||
#tar -xf Python-3.8.9.tgz
|
||||
#cd Python-3.8.9
|
||||
#./configure --enable-optimizations
|
||||
#sudo make altinstall
|
||||
pyenv install --list
|
||||
pyenv install 3.7.12
|
||||
#pyenv install 2.7.14 #python2 no longer supported
|
||||
pyenv global 3.7.12
|
||||
echo "Running node $NODE_INDEX ... "
|
||||
|
||||
# Install node@stable (for angular 6)
|
||||
set +e
|
||||
@@ -63,23 +60,71 @@ elif [ "$NODE_INDEX" = "3" ]; then
|
||||
echo 'export NVM_DIR="/opt/circleci/.nvm"' >> $BASH_ENV
|
||||
echo "[ -s \"$NVM_DIR/nvm.sh\" ] && . \"$NVM_DIR/nvm.sh\"" >> $BASH_ENV
|
||||
|
||||
./mvnw --no-snapshot-updates --quiet verify -Psamples.circleci.node3 -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
||||
(cd samples/client/others/typescript-angular && mvn integration-test)
|
||||
(cd samples/client/petstore/typescript-angular-v12-provided-in-root && mvn integration-test)
|
||||
(cd samples/client/petstore/typescript-angular-v13-provided-in-root && mvn integration-test)
|
||||
(cd samples/client/petstore/typescript-angular-v14-provided-in-root && mvn integration-test)
|
||||
(cd samples/client/petstore/typescript-angular-v15-provided-in-root && mvn integration-test)
|
||||
(cd samples/client/petstore/typescript-angular-v16-provided-in-root && mvn integration-test)
|
||||
(cd samples/openapi3/client/petstore/typescript/builds/default && mvn integration-test)
|
||||
(cd samples/openapi3/client/petstore/typescript/tests/default && mvn integration-test)
|
||||
(cd samples/openapi3/client/petstore/typescript/builds/jquery && mvn integration-test)
|
||||
(cd samples/openapi3/client/petstore/typescript/tests/jquery && mvn integration-test)
|
||||
(cd samples/openapi3/client/petstore/typescript/builds/object_params && mvn integration-test)
|
||||
(cd samples/openapi3/client/petstore/typescript/tests/object_params && mvn integration-test)
|
||||
(cd samples/openapi3/client/petstore/typescript/builds/inversify && mvn integration-test)
|
||||
(cd samples/openapi3/client/petstore/typescript/tests/inversify && mvn integration-test)
|
||||
#(cd samples/openapi3/client/petstore/typescript/tests/deno && mvn integration-test)
|
||||
(cd samples/openapi3/client/petstore/typescript/builds/browser && mvn integration-test)
|
||||
(cd samples/openapi3/client/petstore/typescript/tests/browser && mvn integration-test)
|
||||
(cd samples/client/petstore/typescript-fetch/builds/default && mvn integration-test)
|
||||
(cd samples/client/petstore/typescript-fetch/builds/es6-target && mvn integration-test)
|
||||
(cd samples/client/petstore/typescript-fetch/builds/with-npm-version && mvn integration-test)
|
||||
(cd samples/client/petstore/typescript-fetch/tests/default && mvn integration-test)
|
||||
(cd samples/client/petstore/typescript-node/npm && mvn integration-test)
|
||||
(cd samples/client/petstore/typescript-rxjs/builds/with-npm-version && mvn integration-test)
|
||||
(cd samples/client/petstore/typescript-axios/builds/with-npm-version && mvn integration-test)
|
||||
(cd samples/client/petstore/typescript-axios/tests/default && mvn integration-test)
|
||||
(cd samples/client/petstore/javascript-flowtyped && mvn integration-test)
|
||||
(cd samples/client/petstore/javascript-es6 && mvn integration-test)
|
||||
(cd samples/client/petstore/javascript-promise-es6 && mvn integration-test)
|
||||
|
||||
elif [ "$NODE_INDEX" = "4" ]; then
|
||||
echo "Running node $NODE_INDEX to test 'samples.circleci.node4' defined in pom.xml ..."
|
||||
echo "Running node $NODE_INDEX ..."
|
||||
|
||||
#mvn --no-snapshot-updates --quiet verify -Psamples.circleci.node4 -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
||||
#(cd samples/openapi3/client/petstore/python && make test)
|
||||
# comment out due to ModuleNotFoundError: No module named 'urllib3.request'
|
||||
#(cd samples/openapi3/client/petstore/python-prior && make test)
|
||||
#(cd samples/openapi3/client/3_0_3_unit_test/python && make test)
|
||||
#wget https://www.python.org/ftp/python/3.8.9/Python-3.8.9.tgz
|
||||
#tar -xf Python-3.8.9.tgz
|
||||
#cd Python-3.8.9
|
||||
#./configure --enable-optimizations
|
||||
#sudo make altinstall
|
||||
pyenv install --list
|
||||
pyenv install 3.7.12
|
||||
#pyenv install 2.7.14 #python2 no longer supported
|
||||
pyenv global 3.7.12
|
||||
|
||||
(cd samples/openapi3/client/petstore/python && mvn integration-test)
|
||||
(cd samples/openapi3/client/petstore/python-pydantic-v1 && mvn integration-test)
|
||||
(cd samples/openapi3/client/petstore/python-aiohttp && mvn integration-test)
|
||||
(cd samples/openapi3/client/petstore/python-pydantic-v1-aiohttp && mvn integration-test)
|
||||
|
||||
else
|
||||
echo "Running node $NODE_INDEX to test 'samples.circleci.others' defined in pom.xml ..."
|
||||
echo "Running node $NODE_INDEX ..."
|
||||
java -version
|
||||
|
||||
./mvnw --no-snapshot-updates --quiet verify -Psamples.circleci.others -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
||||
./mvnw --no-snapshot-updates --quiet javadoc:javadoc -Psamples.circleci -Dorg.slf4j.simpleLogger.defaultLogLevel=error
|
||||
(cd samples/client/petstore/scala-akka && mvn integration-test)
|
||||
(cd samples/client/petstore/scala-sttp && mvn integration-test)
|
||||
(cd samples/client/petstore/scala-sttp4 && mvn integration-test)
|
||||
(cd samples/client/petstore/clojure && mvn integration-test)
|
||||
(cd samples/client/petstore/java/jersey2-java8 && mvn integration-test)
|
||||
(cd samples/openapi3/client/petstore/java/jersey2-java8 && mvn integration-test)
|
||||
(cd samples/client/petstore/java/jersey3 && mvn integration-test)
|
||||
(cd samples/client/others/java/okhttp-gson-streaming && mvn integration-test)
|
||||
(cd samples/client/petstore/java/okhttp-gson && mvn integration-test)
|
||||
(cd samples/client/petstore/java/okhttp-gson-3.1 && mvn integration-test)
|
||||
(cd samples/client/petstore/java/resteasy && mvn integration-test)
|
||||
(cd samples/client/petstore/java-micronaut-client && mvn integration-test)
|
||||
(cd samples/client/petstore/java/apache-httpclient && mvn integration-test)
|
||||
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM maven:3.6.3-jdk-11-openj9
|
||||
FROM maven:3-eclipse-temurin-17
|
||||
|
||||
ENV GEN_DIR /opt/openapi-generator
|
||||
WORKDIR ${GEN_DIR}
|
||||
@@ -20,7 +20,7 @@ COPY ./modules/openapi-generator ${GEN_DIR}/modules/openapi-generator
|
||||
COPY ./pom.xml ${GEN_DIR}
|
||||
|
||||
# Pre-compile openapi-generator-cli
|
||||
RUN mvn -am -pl "modules/openapi-generator-cli" package
|
||||
RUN mvn -B -am -pl "modules/openapi-generator-cli" package
|
||||
|
||||
# This exists at the end of the file to benefit from cached layers when modifying docker-entrypoint.sh.
|
||||
COPY docker-entrypoint.sh /usr/local/bin/
|
||||
|
||||
12
README.md
12
README.md
@@ -15,7 +15,7 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.1.0`):
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.2.0`):
|
||||
[](https://app.travis-ci.com/github/OpenAPITools/openapi-generator/builds)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator)
|
||||
@@ -120,8 +120,8 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
|
||||
|
||||
| OpenAPI Generator Version | Release Date | Notes |
|
||||
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------------------------------------- |
|
||||
| 7.1.0 (upcoming patch release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.1.0-SNAPSHOT/) | 18.10.2023 | Minor release with breaking changes (with fallback) |
|
||||
| [7.0.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.0.1) (latest stable release) | 18.09.2023 | Patch release (enhancements, bug fixes, etc) |
|
||||
| 7.2.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.2.0-SNAPSHOT/) | 15.12.2023 | Minor release with breaking changes (with fallback) |
|
||||
| [7.1.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.1.0) (latest stable release) | 13.11.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) |
|
||||
| [4.3.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.3.1) | 06.05.2020 | Patch release (enhancements, bug fixes, etc) |
|
||||
@@ -184,16 +184,16 @@ See the different versions of the [openapi-generator-cli](https://search.maven.o
|
||||
<!-- RELEASE_VERSION -->
|
||||
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 11 runtime at a minimum):
|
||||
|
||||
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.0.1/openapi-generator-cli-7.0.1.jar`
|
||||
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.1.0/openapi-generator-cli-7.1.0.jar`
|
||||
|
||||
For **Mac/Linux** users:
|
||||
```sh
|
||||
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.0.1/openapi-generator-cli-7.0.1.jar -O openapi-generator-cli.jar
|
||||
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.1.0/openapi-generator-cli-7.1.0.jar -O openapi-generator-cli.jar
|
||||
```
|
||||
|
||||
For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
|
||||
```
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.0.1/openapi-generator-cli-7.0.1.jar
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.1.0/openapi-generator-cli-7.1.0.jar
|
||||
```
|
||||
|
||||
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
|
||||
|
||||
@@ -56,8 +56,8 @@ test_script:
|
||||
- dotnet test samples\client\petstore\csharp\OpenAPIClient-net47\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
# test C# API client (.net framework 4.8)
|
||||
- dotnet test samples\client\petstore\csharp\OpenAPIClient-net48\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
# test C# API client (.net 5.0)
|
||||
- dotnet test samples\client\petstore\csharp\OpenAPIClient-net5.0\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
# test C# API client (.net 7.0)
|
||||
- dotnet test samples\client\petstore\csharp\OpenAPIClient-net7.0\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
# test C# API Client using conditional-serialization
|
||||
- dotnet test samples\client\petstore\csharp\OpenAPIClient-ConditionalSerialization\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
|
||||
|
||||
@@ -9,3 +9,4 @@ additionalProperties:
|
||||
useCompareNetObjects: true
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
nullableReferenceTypes: true
|
||||
equatable: true
|
||||
|
||||
@@ -9,3 +9,4 @@ additionalProperties:
|
||||
useCompareNetObjects: true
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
nullableReferenceTypes: true
|
||||
equatable: true
|
||||
|
||||
@@ -10,3 +10,4 @@ additionalProperties:
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
useSourceGeneration: true
|
||||
packageName: UseSourceGeneration
|
||||
equatable: true
|
||||
|
||||
@@ -9,3 +9,4 @@ additionalProperties:
|
||||
useCompareNetObjects: true
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
nullableReferenceTypes: true
|
||||
equatable: true
|
||||
|
||||
@@ -9,3 +9,4 @@ additionalProperties:
|
||||
useCompareNetObjects: true
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
nullableReferenceTypes: true
|
||||
equatable: true
|
||||
|
||||
@@ -9,3 +9,4 @@ additionalProperties:
|
||||
useCompareNetObjects: true
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
nullableReferenceTypes: false
|
||||
equatable: true
|
||||
|
||||
@@ -9,3 +9,4 @@ additionalProperties:
|
||||
useCompareNetObjects: true
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
targetFramework: netstandard2.0
|
||||
equatable: true
|
||||
|
||||
@@ -10,3 +10,4 @@ additionalProperties:
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
useOneOfDiscriminatorLookup: true
|
||||
targetFramework: netstandard2.0
|
||||
equatable: true
|
||||
|
||||
@@ -7,3 +7,4 @@ additionalProperties:
|
||||
targetFramework: net6.0
|
||||
setCompareNetObjects: "true"
|
||||
hideGenerationTimestamp: "true"
|
||||
equatable: true
|
||||
|
||||
@@ -6,3 +6,4 @@ additionalProperties:
|
||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
||||
targetFramework: netstandard2.1;net47
|
||||
useCompareNetObjects: "true"
|
||||
equatable: true
|
||||
|
||||
@@ -10,3 +10,4 @@ additionalProperties:
|
||||
useOneOfDiscriminatorLookup: true
|
||||
targetFramework: net47
|
||||
skipOneOfAnyOfGetter: true
|
||||
equatable: true
|
||||
|
||||
@@ -9,3 +9,4 @@ additionalProperties:
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
useOneOfDiscriminatorLookup: true
|
||||
targetFramework: net48
|
||||
equatable: true
|
||||
|
||||
@@ -16,3 +16,4 @@ additionalProperties:
|
||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
||||
hideGenerationTimestamp: "true"
|
||||
targetFramework: net6.0
|
||||
equatable: true
|
||||
|
||||
@@ -6,3 +6,4 @@ additionalProperties:
|
||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
||||
targetFramework: net7.0
|
||||
useCompareNetObjects: "true"
|
||||
equatable: true
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# for .net standard
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/OpenAPIClient-net5.0
|
||||
outputDir: samples/client/petstore/csharp/OpenAPIClient-net7.0
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
additionalProperties:
|
||||
@@ -9,3 +9,4 @@ additionalProperties:
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
useOneOfDiscriminatorLookup: true
|
||||
targetFramework: net7.0
|
||||
equatable: true
|
||||
|
||||
11
bin/configs/csharp-restsharp-net8.0.yaml
Normal file
11
bin/configs/csharp-restsharp-net8.0.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
generatorName: csharp
|
||||
outputDir: samples/client/petstore/csharp/OpenAPIClient-net8.0
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
additionalProperties:
|
||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
||||
useCompareNetObjects: true
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
useOneOfDiscriminatorLookup: true
|
||||
targetFramework: net8.0
|
||||
equatable: true
|
||||
@@ -6,5 +6,6 @@ additionalProperties:
|
||||
packageGuid: '{321C8C3F-0156-40C1-AE42-D59761FB9B6C}'
|
||||
targetFramework: netstandard2.0
|
||||
useCompareNetObjects: "true"
|
||||
equatable: true
|
||||
globalProperties:
|
||||
skipFormModel: "false"
|
||||
|
||||
@@ -10,3 +10,4 @@ additionalProperties:
|
||||
useOneOfDiscriminatorLookup: true
|
||||
targetFramework: netstandard2.0
|
||||
conditionalSerialization: true
|
||||
equatable: true
|
||||
|
||||
@@ -9,3 +9,4 @@ additionalProperties:
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
useOneOfDiscriminatorLookup: true
|
||||
targetFramework: netstandard2.0
|
||||
equatable: true
|
||||
|
||||
@@ -6,3 +6,4 @@ templateDir: modules/openapi-generator/src/main/resources/csharp
|
||||
library: unityWebRequest
|
||||
additionalProperties:
|
||||
targetFramework: netstandard2.0
|
||||
equatable: true
|
||||
|
||||
@@ -14,3 +14,6 @@ additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
||||
useOneOfDiscriminatorLookup: "true"
|
||||
disallowAdditionalPropertiesIfNotPresent: false
|
||||
enumNameMappings:
|
||||
s: LOWER_CASE_S
|
||||
S: UPPER_CASE_S
|
||||
|
||||
10
bin/configs/java-resttemplate-echo-api.yaml
Normal file
10
bin/configs/java-resttemplate-echo-api.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
generatorName: java
|
||||
outputDir: samples/client/echo_api/java/resttemplate
|
||||
library: resttemplate
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/echo_api.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/Java
|
||||
additionalProperties:
|
||||
artifactId: echo-api-resttemplate
|
||||
hideGenerationTimestamp: "true"
|
||||
java8: true
|
||||
containerDefaultToNull: true
|
||||
@@ -4,7 +4,7 @@ set -euo pipefail
|
||||
|
||||
# GEN_DIR allows to share the entrypoint between Dockerfile and run-in-docker.sh (backward compatible)
|
||||
GEN_DIR=${GEN_DIR:-/opt/openapi-generator}
|
||||
JAVA_OPTS=${JAVA_OPTS:-"-Xmx1024M -DloggerPath=conf/log4j.properties"}
|
||||
JAVA_OPTS=${JAVA_OPTS:-"-DloggerPath=conf/log4j.properties"}
|
||||
|
||||
cli="${GEN_DIR}/modules/openapi-generator-cli"
|
||||
codegen="${cli}/target/openapi-generator-cli.jar"
|
||||
|
||||
@@ -421,7 +421,13 @@ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generat
|
||||
```
|
||||
will rename the `Tag` schema to `Label` instead.
|
||||
|
||||
Not all generators support thess features yet. Please give it a try to confirm the behaviour and open an issue (ticket) to let us know which generators you would like to have this feature enabled and we'll prioritize accordingly. We also welcome PRs to add these features to generators. Related PRs for reference: #16209, #16234 (modelNameMappings), #16194, #16206 (nameMappings, parameterNameMappings).
|
||||
To map enum names, use `enumNameMappings` option, e.g.
|
||||
```sh
|
||||
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o /tmp/java/ --enum-name-mappings sold=UNAVAILABLE
|
||||
```
|
||||
will rename SOLD to UNAVAILABLE instead.
|
||||
|
||||
Not all generators support thess features yet. Please give it a try to confirm the behaviour and open an issue (ticket) to let us know which generators you would like to have this feature enabled and we'll prioritize accordingly. We also welcome PRs to add these features to generators. Related PRs for reference: #16209, #16234 (modelNameMappings), #16194, #16206 (nameMappings, parameterNameMappings), #17108 (enumNameMappings).
|
||||
|
||||
NOTE: some generators use `baseName` (original name obtained direclty from OpenAPI spec, e.g. `shipping-date`) mustache tag in the templates so the mapping feature won't work.
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|dateFormat|The default Date format (only `generichost` library supports this option).| |yyyy'-'MM'-'dd|
|
||||
|dateTimeFormat|The default DateTime format (only `generichost` library supports this option).| |yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK|
|
||||
|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|
|
||||
|equatable|Overrides Equals and GetHashCode methods.| |true|
|
||||
|equatable|Overrides Equals and GetHashCode methods.| |false|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||
|interfacePrefix|Prefix interfaces with a community standard or widely accepted prefix.| |I|
|
||||
|library|HTTP library template (sub-template) to use|<dl><dt>**generichost**</dt><dd>HttpClient with Generic Host dependency injection (https://docs.microsoft.com/en-us/dotnet/core/extensions/generic-host) (Experimental. Subject to breaking changes without notice.)</dd><dt>**httpclient**</dt><dd>HttpClient (https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient) (Experimental. Subject to breaking changes without notice.)</dd><dt>**unityWebRequest**</dt><dd>UnityWebRequest (...) (Experimental. Subject to breaking changes without notice.)</dd><dt>**restsharp**</dt><dd>RestSharp (https://github.com/restsharp/RestSharp)</dd></dl>|restsharp|
|
||||
@@ -45,7 +45,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|releaseNote|Release note, default to 'Minor update'.| |Minor update|
|
||||
|returnICollection|Return ICollection<T> instead of the concrete type.| |false|
|
||||
|sourceFolder|source folder for generated code| |src|
|
||||
|targetFramework|The target .NET framework version. To target multiple frameworks, use `;` as the separator, e.g. `netstandard2.1;netcoreapp3.1`|<dl><dt>**netstandard1.3**</dt><dd>.NET Standard 1.3</dd><dt>**netstandard1.4**</dt><dd>.NET Standard 1.4</dd><dt>**netstandard1.5**</dt><dd>.NET Standard 1.5</dd><dt>**netstandard1.6**</dt><dd>.NET Standard 1.6</dd><dt>**netstandard2.0**</dt><dd>.NET Standard 2.0</dd><dt>**netstandard2.1**</dt><dd>.NET Standard 2.1</dd><dt>**net47**</dt><dd>.NET Framework 4.7</dd><dt>**net48**</dt><dd>.NET Framework 4.8</dd><dt>**net6.0**</dt><dd>.NET 6.0 (End of Support 12 November 2024)</dd><dt>**net7.0**</dt><dd>.NET 7.0</dd></dl>|net7.0|
|
||||
|targetFramework|The target .NET framework version. To target multiple frameworks, use `;` as the separator, e.g. `netstandard2.1;netcoreapp3.1`|<dl><dt>**netstandard1.3**</dt><dd>.NET Standard 1.3</dd><dt>**netstandard1.4**</dt><dd>.NET Standard 1.4</dd><dt>**netstandard1.5**</dt><dd>.NET Standard 1.5</dd><dt>**netstandard1.6**</dt><dd>.NET Standard 1.6</dd><dt>**netstandard2.0**</dt><dd>.NET Standard 2.0</dd><dt>**netstandard2.1**</dt><dd>.NET Standard 2.1</dd><dt>**net47**</dt><dd>.NET Framework 4.7</dd><dt>**net48**</dt><dd>.NET Framework 4.8</dd><dt>**net6.0**</dt><dd>.NET 6.0 (End of Support 12 November 2024)</dd><dt>**net7.0**</dt><dd>.NET 7.0</dd><dt>**net8.0**</dt><dd>.NET 8.0</dd></dl>|net8.0|
|
||||
|useCollection|Deserialize array types to Collection<T> instead of List<T>.| |false|
|
||||
|useDateTimeOffset|Use DateTimeOffset to model date-time properties| |false|
|
||||
|useOneOfDiscriminatorLookup|Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and only one match in oneOf's schemas) will be skipped.| |false|
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM openjdk:11.0-jre-buster
|
||||
FROM amazoncorretto:17.0.8-alpine3.18
|
||||
|
||||
ADD target/openapi-generator-cli.jar /opt/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.1.0-SNAPSHOT</version>
|
||||
<version>7.2.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -89,6 +89,9 @@ public class ConfigHelp extends OpenApiGeneratorCommand {
|
||||
@Option(name = {"--model-name-mappings"}, title = "model name mappings", description = "displays the model name mappings (none)")
|
||||
private Boolean modelNameMappings;
|
||||
|
||||
@Option(name = {"--enum-name-mappings"}, title = "enum name mappings", description = "displays the enum name mappings (none)")
|
||||
private Boolean enumNameMappings;
|
||||
|
||||
@Option(name = {"--openapi-normalizer"}, title = "openapi normalizer rules", description = "displays the OpenAPI normalizer rules (none)")
|
||||
private Boolean openapiNormalizer;
|
||||
|
||||
@@ -542,6 +545,18 @@ public class ConfigHelp extends OpenApiGeneratorCommand {
|
||||
sb.append(newline);
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(enumNameMappings)) {
|
||||
sb.append(newline).append("ENUM NAME MAPPING").append(newline).append(newline);
|
||||
Map<String, String> map = config.enumNameMapping()
|
||||
.entrySet()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> {
|
||||
throw new IllegalStateException(String.format(Locale.ROOT, "Duplicated options! %s and %s", a, b));
|
||||
}, TreeMap::new));
|
||||
writePlainTextFromMap(sb, map, optIndent, optNestedIndent, "enum name", "Mapped to");
|
||||
sb.append(newline);
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(openapiNormalizer)) {
|
||||
sb.append(newline).append("OPENAPI NORMALIZER RULES").append(newline).append(newline);
|
||||
Map<String, String> map = config.openapiNormalizer()
|
||||
|
||||
@@ -209,6 +209,13 @@ public class Generate extends OpenApiGeneratorCommand {
|
||||
+ " You can also have multiple occurrences of this option.")
|
||||
private List<String> modelNameMappings = new ArrayList<>();
|
||||
|
||||
@Option(
|
||||
name = {"--enum-name-mappings"},
|
||||
title = "enum name mappings",
|
||||
description = "specifies mappings between the enum name and the new name in the format of enum_name=AnotherName,enum_name2=OtherName2."
|
||||
+ " You can also have multiple occurrences of this option.")
|
||||
private List<String> enumNameMappings = new ArrayList<>();
|
||||
|
||||
@Option(
|
||||
name = {"--openapi-normalizer"},
|
||||
title = "OpenAPI normalizer rules",
|
||||
@@ -492,6 +499,7 @@ public class Generate extends OpenApiGeneratorCommand {
|
||||
applyNameMappingsKvpList(nameMappings, configurator);
|
||||
applyParameterNameMappingsKvpList(parameterNameMappings, configurator);
|
||||
applyModelNameMappingsKvpList(modelNameMappings, configurator);
|
||||
applyEnumNameMappingsKvpList(enumNameMappings, configurator);
|
||||
applyOpenAPINormalizerKvpList(openapiNormalizer, configurator);
|
||||
applyTypeMappingsKvpList(typeMappings, configurator);
|
||||
applyAdditionalPropertiesKvpList(additionalProperties, configurator);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.1.0-SNAPSHOT</version>
|
||||
<version>7.2.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -56,6 +56,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
private final Map<String, String> nameMappings;
|
||||
private final Map<String, String> parameterNameMappings;
|
||||
private final Map<String, String> modelNameMappings;
|
||||
private final Map<String, String> enumNameMappings;
|
||||
private final Map<String, String> openapiNormalizer;
|
||||
private final Set<String> languageSpecificPrimitives;
|
||||
private final Map<String, String> reservedWordsMappings;
|
||||
@@ -295,6 +296,15 @@ public final class GeneratorSettings implements Serializable {
|
||||
return modelNameMappings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets enum name mappings between an enum name and the new name.
|
||||
*
|
||||
* @return the enum name mappings
|
||||
*/
|
||||
public Map<String, String> getEnumNameMappings() {
|
||||
return enumNameMappings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets OpenAPI normalizer rules
|
||||
*
|
||||
@@ -425,6 +435,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
nameMappings = Collections.unmodifiableMap(builder.nameMappings);
|
||||
parameterNameMappings = Collections.unmodifiableMap(builder.parameterNameMappings);
|
||||
modelNameMappings = Collections.unmodifiableMap(builder.modelNameMappings);
|
||||
enumNameMappings = Collections.unmodifiableMap(builder.enumNameMappings);
|
||||
openapiNormalizer = Collections.unmodifiableMap(builder.openapiNormalizer);
|
||||
languageSpecificPrimitives = Collections.unmodifiableSet(builder.languageSpecificPrimitives);
|
||||
reservedWordsMappings = Collections.unmodifiableMap(builder.reservedWordsMappings);
|
||||
@@ -502,6 +513,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
nameMappings = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
parameterNameMappings = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
modelNameMappings = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
enumNameMappings = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
openapiNormalizer = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
languageSpecificPrimitives = Collections.unmodifiableSet(new HashSet<>(0));
|
||||
reservedWordsMappings = Collections.unmodifiableMap(new HashMap<>(0));
|
||||
@@ -572,6 +584,9 @@ public final class GeneratorSettings implements Serializable {
|
||||
if (copy.getModelNameMappings() != null) {
|
||||
builder.modelNameMappings.putAll(copy.getModelNameMappings());
|
||||
}
|
||||
if (copy.getEnumNameMappings() != null) {
|
||||
builder.enumNameMappings.putAll(copy.getEnumNameMappings());
|
||||
}
|
||||
if (copy.getOpenAPINormalizer() != null) {
|
||||
builder.openapiNormalizer.putAll(copy.getOpenAPINormalizer());
|
||||
}
|
||||
@@ -620,6 +635,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
private Map<String, String> nameMappings;
|
||||
private Map<String, String> parameterNameMappings;
|
||||
private Map<String, String> modelNameMappings;
|
||||
private Map<String, String> enumNameMappings;
|
||||
private Map<String, String> openapiNormalizer;
|
||||
private Set<String> languageSpecificPrimitives;
|
||||
private Map<String, String> reservedWordsMappings;
|
||||
@@ -644,6 +660,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
nameMappings = new HashMap<>();
|
||||
parameterNameMappings = new HashMap<>();
|
||||
modelNameMappings = new HashMap<>();
|
||||
enumNameMappings = new HashMap<>();
|
||||
openapiNormalizer = new HashMap<>();
|
||||
languageSpecificPrimitives = new HashSet<>();
|
||||
reservedWordsMappings = new HashMap<>();
|
||||
@@ -1043,6 +1060,32 @@ public final class GeneratorSettings implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code enumNameMappings} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param enumNameMappings the {@code enumNameMappings} to set
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withEnumNameMappings(Map<String, String> enumNameMappings) {
|
||||
this.enumNameMappings = enumNameMappings;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a single {@code enumNameMappings} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
* @param key A key for the name mapping
|
||||
* @param value The value of name mapping
|
||||
* @return a reference to this Builder
|
||||
*/
|
||||
public Builder withEnumNameMapping(String key, String value) {
|
||||
if (this.enumNameMappings == null) {
|
||||
this.enumNameMappings = new HashMap<>();
|
||||
}
|
||||
this.enumNameMappings.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@code openapiNormalizer} and returns a reference to this Builder so that the methods can be chained together.
|
||||
*
|
||||
@@ -1259,6 +1302,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
Objects.equals(getNameMappings(), that.getNameMappings()) &&
|
||||
Objects.equals(getParameterNameMappings(), that.getParameterNameMappings()) &&
|
||||
Objects.equals(getModelNameMappings(), that.getModelNameMappings()) &&
|
||||
Objects.equals(getEnumNameMappings(), that.getEnumNameMappings()) &&
|
||||
Objects.equals(getOpenAPINormalizer(), that.getOpenAPINormalizer()) &&
|
||||
Objects.equals(getLanguageSpecificPrimitives(), that.getLanguageSpecificPrimitives()) &&
|
||||
Objects.equals(getReservedWordsMappings(), that.getReservedWordsMappings()) &&
|
||||
@@ -1294,6 +1338,7 @@ public final class GeneratorSettings implements Serializable {
|
||||
getNameMappings(),
|
||||
getParameterNameMappings(),
|
||||
getModelNameMappings(),
|
||||
getEnumNameMappings(),
|
||||
getOpenAPINormalizer(),
|
||||
getLanguageSpecificPrimitives(),
|
||||
getReservedWordsMappings(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=7.1.0-SNAPSHOT
|
||||
openApiGeneratorVersion=7.2.0-SNAPSHOT
|
||||
# /RELEASE_VERSION
|
||||
|
||||
# BEGIN placeholders
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.1.0-SNAPSHOT</version>
|
||||
<version>7.2.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=7.1.0-SNAPSHOT
|
||||
openApiGeneratorVersion=7.2.0-SNAPSHOT
|
||||
# /RELEASE_VERSION
|
||||
|
||||
@@ -182,6 +182,11 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
|
||||
*/
|
||||
val modelNameMappings = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* Specifies mappings between an enum name and the new name
|
||||
*/
|
||||
val enumNameMappings = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* Specifies mappings (rules) in OpenAPI normalizer
|
||||
*/
|
||||
|
||||
@@ -293,6 +293,13 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
|
||||
@Input
|
||||
val modelNameMappings = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* Specifies mappings between the enum name and the new name
|
||||
*/
|
||||
@Optional
|
||||
@Input
|
||||
val enumNameMappings = project.objects.mapProperty<String, String>()
|
||||
|
||||
/**
|
||||
* Specifies mappings (rules) in OpenAPI normalizer
|
||||
*/
|
||||
@@ -852,6 +859,12 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
|
||||
}
|
||||
}
|
||||
|
||||
if (enumNameMappings.isPresent) {
|
||||
enumNameMappings.get().forEach { entry ->
|
||||
configurator.addEnumNameMapping(entry.key, entry.value)
|
||||
}
|
||||
}
|
||||
|
||||
if (openapiNormalizer.isPresent) {
|
||||
openapiNormalizer.get().forEach { entry ->
|
||||
configurator.addOpenAPINormalizer(entry.key, entry.value)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.1.0-SNAPSHOT</version>
|
||||
<version>7.2.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.1.0-SNAPSHOT</version>
|
||||
<version>7.2.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.1.0-SNAPSHOT</version>
|
||||
<version>7.2.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.1.0-SNAPSHOT</version>
|
||||
<version>7.2.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.1.0-SNAPSHOT</version>
|
||||
<version>7.2.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.1.0-SNAPSHOT</version>
|
||||
<version>7.2.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.1.0-SNAPSHOT</version>
|
||||
<version>7.2.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -350,6 +350,12 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
@Parameter(name = "modelNameMappings", property = "openapi.generator.maven.plugin.modelNameMappings")
|
||||
private List<String> modelNameMappings;
|
||||
|
||||
/**
|
||||
* A map of enum names and the new names
|
||||
*/
|
||||
@Parameter(name = "enumNameMappings", property = "openapi.generator.maven.plugin.enumNameMappings")
|
||||
private List<String> enumNameMappings;
|
||||
|
||||
/**
|
||||
* A set of rules for OpenAPI normalizer
|
||||
*/
|
||||
@@ -834,6 +840,11 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
applyModelNameMappingsKvpList(modelNameMappings, configurator);
|
||||
}
|
||||
|
||||
// Apply Enum Name Mappings
|
||||
if (enumNameMappings != null && (configOptions == null || !configOptions.containsKey("enum-name-mappings"))) {
|
||||
applyEnumNameMappingsKvpList(enumNameMappings, configurator);
|
||||
}
|
||||
|
||||
// Apply OpenAPI normalizer rules
|
||||
if (openapiNormalizer != null && (configOptions == null || !configOptions.containsKey("openapi-normalizer"))) {
|
||||
applyOpenAPINormalizerKvpList(openapiNormalizer, configurator);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM openjdk:11
|
||||
FROM amazoncorretto:17.0.8-alpine3.18
|
||||
|
||||
WORKDIR /generator
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.1.0-SNAPSHOT</version>
|
||||
<version>7.2.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.1.0-SNAPSHOT</version>
|
||||
<version>7.2.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -155,6 +155,8 @@ public interface CodegenConfig {
|
||||
|
||||
Map<String, String> modelNameMapping();
|
||||
|
||||
Map<String, String> enumNameMapping();
|
||||
|
||||
Map<String, String> openapiNormalizer();
|
||||
|
||||
Map<String, String> apiTemplateFiles();
|
||||
|
||||
@@ -173,6 +173,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
protected Map<String, String> parameterNameMapping = new HashMap<>();
|
||||
// a map to store the mapping between model name and the name provided by the user
|
||||
protected Map<String, String> modelNameMapping = new HashMap<>();
|
||||
// a map to store the mapping between enum name and the name provided by the user
|
||||
protected Map<String, String> enumNameMapping = new HashMap<>();
|
||||
// a map to store the rules in OpenAPI Normalizer
|
||||
protected Map<String, String> openapiNormalizer = new HashMap<>();
|
||||
protected String modelPackage = "", apiPackage = "", fileSuffix;
|
||||
@@ -1244,6 +1246,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return modelNameMapping;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> enumNameMapping() {
|
||||
return enumNameMapping;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> openapiNormalizer() {
|
||||
return openapiNormalizer;
|
||||
@@ -4159,6 +4166,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (original.getExtensions() != null) {
|
||||
property.getVendorExtensions().putAll(original.getExtensions());
|
||||
}
|
||||
if (original.getDeprecated() != null) {
|
||||
property.deprecated = p.getDeprecated();
|
||||
}
|
||||
}
|
||||
|
||||
// set the default value
|
||||
@@ -4649,18 +4659,19 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
bodyParameterName = (String) op.vendorExtensions.get("x-codegen-request-body-name");
|
||||
}
|
||||
bodyParam = fromRequestBody(requestBody, imports, bodyParameterName);
|
||||
bodyParam.description = escapeText(requestBody.getDescription());
|
||||
postProcessParameter(bodyParam);
|
||||
|
||||
bodyParams.add(bodyParam);
|
||||
if (bodyParam != null) {
|
||||
bodyParam.description = escapeText(requestBody.getDescription());
|
||||
postProcessParameter(bodyParam);
|
||||
bodyParams.add(bodyParam);
|
||||
if (prependFormOrBodyParameters) {
|
||||
allParams.add(bodyParam);
|
||||
}
|
||||
|
||||
if (prependFormOrBodyParameters) {
|
||||
allParams.add(bodyParam);
|
||||
}
|
||||
|
||||
// add example
|
||||
if (schemas != null && !isSkipOperationExample()) {
|
||||
op.requestBodyExamples = new ExampleGenerator(schemas, this.openAPI).generate(null, new ArrayList<>(getConsumesInfo(this.openAPI, operation)), bodyParam.baseType);
|
||||
// add example
|
||||
if (schemas != null && !isSkipOperationExample()) {
|
||||
op.requestBodyExamples = new ExampleGenerator(schemas, this.openAPI).generate(null, new ArrayList<>(getConsumesInfo(this.openAPI, operation)), bodyParam.baseType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7589,6 +7600,10 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
String name = null;
|
||||
LOGGER.debug("Request body = {}", body);
|
||||
Schema schema = ModelUtils.getSchemaFromRequestBody(body);
|
||||
if (schema == null) {
|
||||
LOGGER.error("Schema cannot be null in the request body: {}", body);
|
||||
return null;
|
||||
}
|
||||
Schema original = null;
|
||||
// check if it's allOf (only 1 sub schema) with or without default/nullable/etc set in the top level
|
||||
if (ModelUtils.isAllOf(schema) && schema.getAllOf().size() == 1 &&
|
||||
@@ -7682,6 +7697,10 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (original.getExtensions() != null) {
|
||||
codegenParameter.vendorExtensions.putAll(original.getExtensions());
|
||||
}
|
||||
|
||||
if (original.getDeprecated() != null) {
|
||||
codegenParameter.isDeprecated = original.getDeprecated();
|
||||
}
|
||||
}
|
||||
|
||||
return codegenParameter;
|
||||
|
||||
@@ -74,6 +74,7 @@ public class CodegenConfigurator {
|
||||
private Map<String, String> nameMappings = new HashMap<>();
|
||||
private Map<String, String> parameterNameMappings = new HashMap<>();
|
||||
private Map<String, String> modelNameMappings = new HashMap<>();
|
||||
private Map<String, String> enumNameMappings = new HashMap<>();
|
||||
private Map<String, String> openapiNormalizer = new HashMap<>();
|
||||
private Set<String> languageSpecificPrimitives = new HashSet<>();
|
||||
private Map<String, String> reservedWordsMappings = new HashMap<>();
|
||||
@@ -136,6 +137,9 @@ public class CodegenConfigurator {
|
||||
if(generatorSettings.getModelNameMappings() != null) {
|
||||
configurator.modelNameMappings.putAll(generatorSettings.getModelNameMappings());
|
||||
}
|
||||
if(generatorSettings.getEnumNameMappings() != null) {
|
||||
configurator.enumNameMappings.putAll(generatorSettings.getEnumNameMappings());
|
||||
}
|
||||
if(generatorSettings.getOpenAPINormalizer() != null) {
|
||||
configurator.openapiNormalizer.putAll(generatorSettings.getOpenAPINormalizer());
|
||||
}
|
||||
@@ -244,6 +248,12 @@ public class CodegenConfigurator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator addEnumNameMapping(String key, String value) {
|
||||
this.enumNameMappings.put(key, value);
|
||||
generatorSettingsBuilder.withEnumNameMapping(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator addOpenAPINormalizer(String key, String value) {
|
||||
this.openapiNormalizer.put(key, value);
|
||||
generatorSettingsBuilder.withOpenAPINormalizer(key, value);
|
||||
@@ -440,6 +450,12 @@ public class CodegenConfigurator {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setEnumNameMappings(Map<String, String> enumNameMappings) {
|
||||
this.enumNameMappings = enumNameMappings;
|
||||
generatorSettingsBuilder.withEnumNameMappings(enumNameMappings);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setOpenAPINormalizer(Map<String, String> openapiNormalizer) {
|
||||
this.openapiNormalizer = openapiNormalizer;
|
||||
generatorSettingsBuilder.withOpenAPINormalizer(openapiNormalizer);
|
||||
@@ -728,6 +744,7 @@ public class CodegenConfigurator {
|
||||
config.nameMapping().putAll(generatorSettings.getNameMappings());
|
||||
config.parameterNameMapping().putAll(generatorSettings.getParameterNameMappings());
|
||||
config.modelNameMapping().putAll(generatorSettings.getModelNameMappings());
|
||||
config.enumNameMapping().putAll(generatorSettings.getEnumNameMappings());
|
||||
config.openapiNormalizer().putAll(generatorSettings.getOpenAPINormalizer());
|
||||
config.languageSpecificPrimitives().addAll(generatorSettings.getLanguageSpecificPrimitives());
|
||||
config.reservedWordsMappings().putAll(generatorSettings.getReservedWordsMappings());
|
||||
|
||||
@@ -159,6 +159,19 @@ public final class CodegenConfiguratorUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyEnumNameMappingsKvpList(List<String> enumNameMappings, CodegenConfigurator configurator) {
|
||||
for (String propString : enumNameMappings) {
|
||||
applyEnumNameMappingsKvp(propString, configurator);
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyEnumNameMappingsKvp(String enumNameMappings, CodegenConfigurator configurator) {
|
||||
final Map<String, String> map = createMapFromKeyValuePairs(enumNameMappings);
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
configurator.addEnumNameMapping(entry.getKey().trim(), entry.getValue().trim());
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyOpenAPINormalizerKvpList(List<String> openapiNormalizer, CodegenConfigurator configurator) {
|
||||
for (String propString : openapiNormalizer) {
|
||||
applyOpenAPINormalizerKvp(propString, configurator);
|
||||
|
||||
@@ -418,11 +418,14 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
@Override
|
||||
protected ImmutableMap.Builder<String, Lambda> addMustacheLambdas() {
|
||||
CopyLambda copyLambda = new CopyLambda();
|
||||
|
||||
return super.addMustacheLambdas()
|
||||
.put("camelcase_param", new CamelCaseLambda().generator(this).escapeAsParamName(true))
|
||||
.put("required", new RequiredParameterLambda())
|
||||
.put("optional", new OptionalParameterLambda().generator(this))
|
||||
.put("joinWithComma", new JoinWithCommaLambda())
|
||||
.put("joinWithAmpersand", new JoinWithCommaLambda(true, " ", " && "))
|
||||
.put("joinLinesWithComma", new JoinWithCommaLambda(false, "\n", ",\n"))
|
||||
.put("joinConditions", new JoinWithCommaLambda(true, " ", " && "))
|
||||
.put("trimLineBreaks", new TrimLineBreaksLambda())
|
||||
@@ -430,9 +433,13 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
.put("trimTrailing", new TrimTrailingWhiteSpaceLambda(false))
|
||||
.put("first", new FirstLambda(" "))
|
||||
.put("firstDot", new FirstLambda("\\."))
|
||||
.put("indent1", new IndentedLambda(4, " ", false, true))
|
||||
.put("indent3", new IndentedLambda(12, " ", false, true))
|
||||
.put("indent4", new IndentedLambda(16, " ", false, true))
|
||||
.put("uniqueLinesWithNewLine", new UniqueLambda("\n", true));
|
||||
.put("copy", copyLambda)
|
||||
.put("paste", new PasteLambda(copyLambda, true, true, true, false))
|
||||
.put("pasteOnce", new PasteLambda(copyLambda, true, true, true, true))
|
||||
.put("pasteLine", new PasteLambda(copyLambda, true, true, false, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1689,6 +1689,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
@Override
|
||||
public String toEnumVarName(String value, String datatype) {
|
||||
if (enumNameMapping.containsKey(value)) {
|
||||
return enumNameMapping.get(value);
|
||||
}
|
||||
|
||||
if (value.length() == 0) {
|
||||
return "EMPTY";
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
protected static final String NET_48_OR_LATER = "net48OrLater";
|
||||
protected static final String NET_60_OR_LATER = "net60OrLater";
|
||||
protected static final String NET_70_OR_LATER = "net70OrLater";
|
||||
protected static final String NET_80_OR_LATER = "net80OrLater";
|
||||
|
||||
@SuppressWarnings("hiding")
|
||||
private final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class);
|
||||
@@ -91,7 +92,8 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
FrameworkStrategy.NETFRAMEWORK_4_7,
|
||||
FrameworkStrategy.NETFRAMEWORK_4_8,
|
||||
FrameworkStrategy.NET_6_0,
|
||||
FrameworkStrategy.NET_7_0
|
||||
FrameworkStrategy.NET_7_0,
|
||||
FrameworkStrategy.NET_8_0
|
||||
);
|
||||
private static FrameworkStrategy latestFramework = frameworkStrategies.get(frameworkStrategies.size() - 1);
|
||||
protected final Map<String, String> frameworks;
|
||||
@@ -114,7 +116,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
protected boolean supportsFileParameters = Boolean.TRUE;
|
||||
|
||||
protected boolean validatable = Boolean.TRUE;
|
||||
protected boolean equatable = Boolean.TRUE;
|
||||
protected boolean equatable = Boolean.FALSE;
|
||||
// By default, generated code is considered public
|
||||
protected boolean nonPublicApi = Boolean.FALSE;
|
||||
|
||||
@@ -454,14 +456,13 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
Collections.sort(codegenModel.readWriteVars, propertyComparatorByName);
|
||||
Collections.sort(codegenModel.parentVars, propertyComparatorByName);
|
||||
|
||||
Comparator<CodegenProperty> comparator = propertyComparatorByNullable.thenComparing(propertyComparatorByDefaultValue);
|
||||
Collections.sort(codegenModel.vars, comparator);
|
||||
Collections.sort(codegenModel.allVars, comparator);
|
||||
Collections.sort(codegenModel.requiredVars, comparator);
|
||||
Collections.sort(codegenModel.optionalVars, comparator);
|
||||
Collections.sort(codegenModel.readOnlyVars, comparator);
|
||||
Collections.sort(codegenModel.readWriteVars, comparator);
|
||||
Collections.sort(codegenModel.parentVars, comparator);
|
||||
Collections.sort(codegenModel.vars, propertyComparatorByNotNullableRequiredNoDefault);
|
||||
Collections.sort(codegenModel.allVars, propertyComparatorByNotNullableRequiredNoDefault);
|
||||
Collections.sort(codegenModel.requiredVars, propertyComparatorByNotNullableRequiredNoDefault);
|
||||
Collections.sort(codegenModel.optionalVars, propertyComparatorByNotNullableRequiredNoDefault);
|
||||
Collections.sort(codegenModel.readOnlyVars, propertyComparatorByNotNullableRequiredNoDefault);
|
||||
Collections.sort(codegenModel.readWriteVars, propertyComparatorByNotNullableRequiredNoDefault);
|
||||
Collections.sort(codegenModel.parentVars, propertyComparatorByNotNullableRequiredNoDefault);
|
||||
}
|
||||
|
||||
return codegenModel;
|
||||
@@ -474,24 +475,12 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
}
|
||||
};
|
||||
|
||||
public static Comparator<CodegenProperty> propertyComparatorByDefaultValue = new Comparator<CodegenProperty>() {
|
||||
public static Comparator<CodegenProperty> propertyComparatorByNotNullableRequiredNoDefault = new Comparator<CodegenProperty>() {
|
||||
@Override
|
||||
public int compare(CodegenProperty one, CodegenProperty another) {
|
||||
if ((one.defaultValue == null) == (another.defaultValue == null))
|
||||
if (one.isNullable == another.isNullable && one.required == another.required && (one.defaultValue == null) == (another.defaultValue == null))
|
||||
return 0;
|
||||
else if (one.defaultValue == null)
|
||||
return -1;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
public static Comparator<CodegenProperty> propertyComparatorByNullable = new Comparator<CodegenProperty>() {
|
||||
@Override
|
||||
public int compare(CodegenProperty one, CodegenProperty another) {
|
||||
if (one.isNullable == another.isNullable)
|
||||
return 0;
|
||||
else if (Boolean.FALSE.equals(one.isNullable))
|
||||
else if (!one.isNullable && one.required && one.defaultValue == null)
|
||||
return -1;
|
||||
else
|
||||
return 1;
|
||||
@@ -1341,6 +1330,8 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
};
|
||||
static FrameworkStrategy NET_7_0 = new FrameworkStrategy("net7.0", ".NET 7.0", "net7.0", Boolean.FALSE) {
|
||||
};
|
||||
static FrameworkStrategy NET_8_0 = new FrameworkStrategy("net8.0", ".NET 8.0", "net8.0", Boolean.FALSE) {
|
||||
};
|
||||
protected String name;
|
||||
protected String description;
|
||||
protected String testTargetFramework;
|
||||
@@ -1464,6 +1455,17 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
properties.put(NET_48_OR_LATER, true);
|
||||
properties.put(NET_60_OR_LATER, true);
|
||||
properties.put(NET_70_OR_LATER, true);
|
||||
} else if (strategies.stream().anyMatch(p -> "net8.0".equals(p.name))) {
|
||||
properties.put(NET_STANDARD_14_OR_LATER, true);
|
||||
properties.put(NET_STANDARD_15_OR_LATER, true);
|
||||
properties.put(NET_STANDARD_16_OR_LATER, true);
|
||||
properties.put(NET_STANDARD_20_OR_LATER, true);
|
||||
properties.put(NET_STANDARD_21_OR_LATER, true);
|
||||
properties.put(NET_47_OR_LATER, true);
|
||||
properties.put(NET_48_OR_LATER, true);
|
||||
properties.put(NET_60_OR_LATER, true);
|
||||
properties.put(NET_70_OR_LATER, true);
|
||||
properties.put(NET_80_OR_LATER, true);
|
||||
} else {
|
||||
throw new RuntimeException("Unhanlded case");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.templating.mustache;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import com.samskivert.mustache.Template.Fragment;
|
||||
|
||||
/**
|
||||
* Saves template text to be used later.
|
||||
*
|
||||
* Register:
|
||||
* <pre>
|
||||
* additionalProperties.put("copy", new CopyLambda());
|
||||
* </pre>
|
||||
*
|
||||
* Use:
|
||||
* <pre>
|
||||
* {{#copy}}{{name}}{{/copy}}
|
||||
* </pre>
|
||||
*/
|
||||
public class CopyLambda implements Mustache.Lambda {
|
||||
public String savedContent;
|
||||
|
||||
public CopyLambda() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Fragment fragment, Writer writer) throws IOException {
|
||||
savedContent = fragment.execute().stripTrailing();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* 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.templating.mustache;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import com.samskivert.mustache.Template.Fragment;
|
||||
|
||||
/**
|
||||
* Writes text that was previously saved.
|
||||
*
|
||||
* Register:
|
||||
* <pre>
|
||||
* additionalProperties.put("paste", new PasteLambda(copyLambda, true, true, true, false));
|
||||
* </pre>
|
||||
*
|
||||
* Use:
|
||||
* <pre>
|
||||
* {{#paste}}{{/paste}}
|
||||
* </pre>
|
||||
*/
|
||||
public class PasteLambda implements Mustache.Lambda {
|
||||
private final CopyLambda copyLambda;
|
||||
private final Boolean stripLeading;
|
||||
private final Boolean stripTrailing;
|
||||
private final Boolean endWithLineBreak;
|
||||
private final Boolean clear;
|
||||
|
||||
public PasteLambda(CopyLambda copyLambda, Boolean stripLeading, Boolean stripTrailing, Boolean endWithLineBreak, boolean clear) {
|
||||
this.copyLambda = copyLambda;
|
||||
this.stripLeading = stripLeading;
|
||||
this.stripTrailing = stripTrailing;
|
||||
this.endWithLineBreak = endWithLineBreak;
|
||||
this.clear = clear;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Fragment fragment, Writer writer) throws IOException {
|
||||
String content = this.copyLambda.savedContent;
|
||||
|
||||
if (content == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.stripTrailing){
|
||||
content = content.stripTrailing();
|
||||
}
|
||||
if (this.stripLeading) {
|
||||
content = content.stripLeading();
|
||||
}
|
||||
if (this.endWithLineBreak && !content.endsWith("\n")){
|
||||
content = content + "\n";
|
||||
}
|
||||
writer.write(content);
|
||||
|
||||
if (this.clear) {
|
||||
this.copyLambda.savedContent = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1848,7 +1848,7 @@ public class ModelUtils {
|
||||
* @return true if allOf is not empty
|
||||
*/
|
||||
public static boolean hasAllOf(Schema schema) {
|
||||
if (schema.getAllOf() != null && !schema.getAllOf().isEmpty()) {
|
||||
if (schema != null && schema.getAllOf() != null && !schema.getAllOf().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@ import java.util.Objects;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
||||
//import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Abstract class for oneOf,anyOf schemas defined in OpenAPI spec
|
||||
*/
|
||||
|
||||
@@ -13,34 +13,9 @@ import {{import}};
|
||||
{{#serializableModel}}
|
||||
import java.io.Serializable;
|
||||
{{/serializableModel}}
|
||||
{{#jackson}}
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
{{#withXml}}
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.*;
|
||||
{{/withXml}}
|
||||
{{#vendorExtensions.x-has-readonly-properties}}
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
{{/vendorExtensions.x-has-readonly-properties}}
|
||||
{{/jackson}}
|
||||
{{#withXml}}
|
||||
import {{javaxPackage}}.xml.bind.annotation.*;
|
||||
{{/withXml}}
|
||||
{{#jsonb}}
|
||||
import java.lang.reflect.Type;
|
||||
import {{javaxPackage}}.json.bind.annotation.JsonbTypeDeserializer;
|
||||
import {{javaxPackage}}.json.bind.annotation.JsonbTypeSerializer;
|
||||
import {{javaxPackage}}.json.bind.serializer.DeserializationContext;
|
||||
import {{javaxPackage}}.json.bind.serializer.JsonbDeserializer;
|
||||
import {{javaxPackage}}.json.bind.serializer.JsonbSerializer;
|
||||
import {{javaxPackage}}.json.bind.serializer.SerializationContext;
|
||||
import {{javaxPackage}}.json.stream.JsonGenerator;
|
||||
import {{javaxPackage}}.json.stream.JsonParser;
|
||||
import {{javaxPackage}}.json.bind.annotation.JsonbProperty;
|
||||
{{#vendorExtensions.x-has-readonly-properties}}
|
||||
import {{javaxPackage}}.json.bind.annotation.JsonbCreator;
|
||||
{{/vendorExtensions.x-has-readonly-properties}}
|
||||
{{/jsonb}}
|
||||
{{#parcelableModel}}
|
||||
import android.os.Parcelable;
|
||||
import android.os.Parcel;
|
||||
|
||||
@@ -1,26 +1,14 @@
|
||||
{{#jackson}}
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
{{/jackson}}
|
||||
{{#gson}}
|
||||
import java.io.IOException;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
{{/gson}}
|
||||
|
||||
/**
|
||||
* {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}}
|
||||
*/
|
||||
{{#gson}}
|
||||
@JsonAdapter({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.Adapter.class)
|
||||
{{/gson}}
|
||||
{{#jsonb}}
|
||||
@JsonbTypeSerializer({{datatypeWithEnum}}.Serializer.class)
|
||||
@JsonbTypeDeserializer({{datatypeWithEnum}}.Deserializer.class)
|
||||
{{/jsonb}}
|
||||
{{>additionalEnumTypeAnnotations}}public enum {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} {
|
||||
{{#allowableValues}}{{#enumVars}}
|
||||
{{#enumDescription}}
|
||||
@@ -40,9 +28,6 @@ import com.google.gson.stream.JsonWriter;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
{{#jackson}}
|
||||
@JsonValue
|
||||
{{/jackson}}
|
||||
public {{{dataType}}} getValue() {
|
||||
return value;
|
||||
}
|
||||
@@ -52,9 +37,6 @@ import com.google.gson.stream.JsonWriter;
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
{{#jackson}}
|
||||
@JsonCreator
|
||||
{{/jackson}}
|
||||
public static {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue({{{dataType}}} value) {
|
||||
for ({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
|
||||
if (b.value.{{^isString}}equals{{/isString}}{{#isString}}{{#useEnumCaseInsensitive}}equalsIgnoreCase{{/useEnumCaseInsensitive}}{{^useEnumCaseInsensitive}}equals{{/useEnumCaseInsensitive}}{{/isString}}(value)) {
|
||||
@@ -63,7 +45,6 @@ import com.google.gson.stream.JsonWriter;
|
||||
}
|
||||
{{#isNullable}}return null;{{/isNullable}}{{^isNullable}}{{#enumUnknownDefaultCase}}{{#allowableValues}}{{#enumVars}}{{#-last}}return {{{name}}};{{/-last}}{{/enumVars}}{{/allowableValues}}{{/enumUnknownDefaultCase}}{{^enumUnknownDefaultCase}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/enumUnknownDefaultCase}}{{/isNullable}}
|
||||
}
|
||||
{{#gson}}
|
||||
|
||||
public static class Adapter extends TypeAdapter<{{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}> {
|
||||
@Override
|
||||
@@ -82,28 +63,6 @@ import com.google.gson.stream.JsonWriter;
|
||||
{{^isNumber}}{{{dataType}}}{{/isNumber}}{{#isNumber}}String{{/isNumber}} value = jsonElement.{{#isNumber}}getAsString(){{/isNumber}}{{#isInteger}}getAsInt(){{/isInteger}}{{^isNumber}}{{^isInteger}}getAs{{{dataType}}}(){{/isInteger}}{{/isNumber}};
|
||||
{{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.fromValue({{#isNumber}}new BigDecimal({{/isNumber}}value{{#isNumber}}){{/isNumber}});
|
||||
}
|
||||
{{/gson}}
|
||||
{{#jsonb}}
|
||||
|
||||
public static final class Deserializer implements JsonbDeserializer<{{datatypeWithEnum}}> {
|
||||
@Override
|
||||
public {{datatypeWithEnum}} deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
|
||||
for ({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
|
||||
if (String.valueOf(b.value).equals(parser.getString())) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
{{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + parser.getString() + "'");{{/useNullForUnknownEnumValue}}
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Serializer implements JsonbSerializer<{{datatypeWithEnum}}> {
|
||||
@Override
|
||||
public void serialize({{datatypeWithEnum}} obj, JsonGenerator generator, SerializationContext ctx) {
|
||||
generator.write(obj.value);
|
||||
}
|
||||
}
|
||||
{{/jsonb}}
|
||||
{{#supportUrlQuery}}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
/**
|
||||
* {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}}
|
||||
*/
|
||||
{{#gson}}
|
||||
@JsonAdapter({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}.Adapter.class)
|
||||
{{/gson}}
|
||||
{{#jsonb}}
|
||||
@JsonbTypeSerializer({{datatypeWithEnum}}.Serializer.class)
|
||||
@JsonbTypeDeserializer({{datatypeWithEnum}}.Deserializer.class)
|
||||
{{/jsonb}}
|
||||
{{#withXml}}
|
||||
@XmlType(name="{{datatypeWithEnum}}")
|
||||
@XmlEnum({{dataType}}.class)
|
||||
@@ -34,9 +28,6 @@
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
{{#jackson}}
|
||||
@JsonValue
|
||||
{{/jackson}}
|
||||
public {{{dataType}}} getValue() {
|
||||
return value;
|
||||
}
|
||||
@@ -46,9 +37,6 @@
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
{{#jackson}}
|
||||
@JsonCreator
|
||||
{{/jackson}}
|
||||
public static {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue({{{dataType}}} value) {
|
||||
for ({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
|
||||
if (b.value.{{^isString}}equals{{/isString}}{{#isString}}{{#useEnumCaseInsensitive}}equalsIgnoreCase{{/useEnumCaseInsensitive}}{{^useEnumCaseInsensitive}}equals{{/useEnumCaseInsensitive}}{{/isString}}(value)) {
|
||||
@@ -57,7 +45,6 @@
|
||||
}
|
||||
{{#isNullable}}return null;{{/isNullable}}{{^isNullable}}{{#enumUnknownDefaultCase}}{{#allowableValues}}{{#enumVars}}{{#-last}}return {{{name}}};{{/-last}}{{/enumVars}}{{/allowableValues}}{{/enumUnknownDefaultCase}}{{^enumUnknownDefaultCase}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/enumUnknownDefaultCase}}{{/isNullable}}
|
||||
}
|
||||
{{#gson}}
|
||||
|
||||
public static class Adapter extends TypeAdapter<{{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}> {
|
||||
@Override
|
||||
@@ -76,25 +63,4 @@
|
||||
{{^isNumber}}{{{dataType}}}{{/isNumber}}{{#isNumber}}String{{/isNumber}} value = jsonElement.{{#isNumber}}getAsString(){{/isNumber}}{{#isInteger}}getAsInt(){{/isInteger}}{{^isNumber}}{{^isInteger}}getAs{{{dataType}}}(){{/isInteger}}{{/isNumber}};
|
||||
{{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.fromValue({{#isNumber}}new BigDecimal({{/isNumber}}value{{#isNumber}}){{/isNumber}});
|
||||
}
|
||||
{{/gson}}
|
||||
{{#jsonb}}
|
||||
public static final class Deserializer implements JsonbDeserializer<{{datatypeWithEnum}}> {
|
||||
@Override
|
||||
public {{datatypeWithEnum}} deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
|
||||
for ({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
|
||||
if (String.valueOf(b.value).equals(parser.getString())) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
{{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + parser.getString() + "'");{{/useNullForUnknownEnumValue}}
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Serializer implements JsonbSerializer<{{datatypeWithEnum}}> {
|
||||
@Override
|
||||
public void serialize({{datatypeWithEnum}} obj, JsonGenerator generator, SerializationContext ctx) {
|
||||
generator.write(obj.value);
|
||||
}
|
||||
}
|
||||
{{/jsonb}}
|
||||
}
|
||||
|
||||
@@ -37,16 +37,6 @@ import {{invokerPackage}}.JSON;
|
||||
@Schema(description = "{{{.}}}")
|
||||
{{/description}}
|
||||
{{/swagger2AnnotationLibrary}}
|
||||
{{#jackson}}
|
||||
@JsonPropertyOrder({
|
||||
{{#vars}}
|
||||
{{classname}}.JSON_PROPERTY_{{nameInSnakeCase}}{{^-last}},{{/-last}}
|
||||
{{/vars}}
|
||||
})
|
||||
{{#isClassnameSanitized}}
|
||||
@JsonTypeName("{{name}}")
|
||||
{{/isClassnameSanitized}}
|
||||
{{/jackson}}
|
||||
{{>additionalModelTypeAnnotations}}{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}}
|
||||
{{#vendorExtensions.x-class-extra-annotation}}
|
||||
{{{vendorExtensions.x-class-extra-annotation}}}
|
||||
@@ -67,12 +57,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{/mostInnerItems}}
|
||||
{{/isContainer}}
|
||||
{{/isEnum}}
|
||||
{{#gson}}
|
||||
public static final String SERIALIZED_NAME_{{nameInSnakeCase}} = "{{baseName}}";
|
||||
{{/gson}}
|
||||
{{#jackson}}
|
||||
public static final String JSON_PROPERTY_{{nameInSnakeCase}} = "{{baseName}}";
|
||||
{{/jackson}}
|
||||
{{#withXml}}
|
||||
{{#isXmlAttribute}}
|
||||
@XmlAttribute(name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}")
|
||||
@@ -94,26 +79,14 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{/isContainer}}
|
||||
{{/isXmlAttribute}}
|
||||
{{/withXml}}
|
||||
{{#gson}}
|
||||
{{#deprecated}}
|
||||
@Deprecated
|
||||
{{/deprecated}}
|
||||
@SerializedName(SERIALIZED_NAME_{{nameInSnakeCase}})
|
||||
{{/gson}}
|
||||
{{#vendorExtensions.x-field-extra-annotation}}
|
||||
{{{vendorExtensions.x-field-extra-annotation}}}
|
||||
{{/vendorExtensions.x-field-extra-annotation}}
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{#isContainer}}
|
||||
private JsonNullable<{{{datatypeWithEnum}}}> {{name}} = JsonNullable.<{{{datatypeWithEnum}}}>undefined();
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
private JsonNullable<{{{datatypeWithEnum}}}> {{name}} = JsonNullable.<{{{datatypeWithEnum}}}>{{#defaultValue}}of({{{.}}}){{/defaultValue}}{{^defaultValue}}undefined(){{/defaultValue}};
|
||||
{{/isContainer}}
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{^vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{#isDiscriminator}}protected{{/isDiscriminator}}{{^isDiscriminator}}private{{/isDiscriminator}} {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
|
||||
{{/vars}}
|
||||
public {{classname}}() {
|
||||
@@ -122,21 +95,18 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
super();
|
||||
{{/parcelableModel}}
|
||||
{{/parent}}
|
||||
{{#gson}}
|
||||
{{#discriminator}}
|
||||
{{^discriminator.isEnum}}
|
||||
this.{{{discriminatorName}}} = this.getClass().getSimpleName();
|
||||
{{/discriminator.isEnum}}
|
||||
{{/discriminator}}
|
||||
{{/gson}}
|
||||
}
|
||||
{{#vendorExtensions.x-has-readonly-properties}}
|
||||
{{^withXml}}
|
||||
|
||||
{{#jsonb}}@JsonbCreator{{/jsonb}}{{#jackson}}@JsonCreator{{/jackson}}
|
||||
public {{classname}}(
|
||||
{{#readOnlyVars}}
|
||||
{{#jsonb}}@JsonbProperty("{{baseName}}"){{/jsonb}}{{#jackson}}@JsonProperty(JSON_PROPERTY_{{nameInSnakeCase}}){{/jackson}} {{{datatypeWithEnum}}} {{name}}{{^-last}}, {{/-last}}
|
||||
{{{datatypeWithEnum}}} {{name}}{{^-last}}, {{/-last}}
|
||||
{{/readOnlyVars}}
|
||||
) {
|
||||
this();
|
||||
@@ -153,54 +123,27 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
@Deprecated
|
||||
{{/deprecated}}
|
||||
public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{name}});{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{^vendorExtensions.x-is-jackson-optional-nullable}}this.{{name}} = {{name}};{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
this.{{name}} = {{name}};
|
||||
return this;
|
||||
}
|
||||
{{#isArray}}
|
||||
|
||||
public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
if (this.{{name}} == null || !this.{{name}}.isPresent()) {
|
||||
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}ArrayList{{/uniqueItems}}<>(){{/defaultValue}});
|
||||
}
|
||||
try {
|
||||
this.{{name}}.get().add({{name}}Item);
|
||||
} catch (java.util.NoSuchElementException e) {
|
||||
// this can never happen, as we make sure above that the value is present
|
||||
}
|
||||
return this;
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{^vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
if (this.{{name}} == null) {
|
||||
this.{{name}} = {{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}ArrayList{{/uniqueItems}}<>(){{/defaultValue}};
|
||||
}
|
||||
this.{{name}}.add({{name}}Item);
|
||||
return this;
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
}
|
||||
{{/isArray}}
|
||||
{{#isMap}}
|
||||
|
||||
public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
if (this.{{name}} == null || !this.{{name}}.isPresent()) {
|
||||
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}{{^defaultValue}}new HashMap<>(){{/defaultValue}});
|
||||
}
|
||||
try {
|
||||
this.{{name}}.get().put(key, {{name}}Item);
|
||||
} catch (java.util.NoSuchElementException e) {
|
||||
// this can never happen, as we make sure above that the value is present
|
||||
}
|
||||
return this;
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{^vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
if (this.{{name}} == null) {
|
||||
this.{{name}} = {{{defaultValue}}}{{^defaultValue}}new HashMap<>(){{/defaultValue}};
|
||||
}
|
||||
this.{{name}}.put(key, {{name}}Item);
|
||||
return this;
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
}
|
||||
{{/isMap}}
|
||||
|
||||
@@ -237,9 +180,6 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{^required}}
|
||||
@{{javaxPackage}}.annotation.Nullable
|
||||
{{/required}}
|
||||
{{#jsonb}}
|
||||
@JsonbProperty("{{baseName}}")
|
||||
{{/jsonb}}
|
||||
{{#useBeanValidation}}
|
||||
{{>beanValidation}}
|
||||
{{/useBeanValidation}}
|
||||
@@ -252,47 +192,15 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{#vendorExtensions.x-extra-annotation}}
|
||||
{{{vendorExtensions.x-extra-annotation}}}
|
||||
{{/vendorExtensions.x-extra-annotation}}
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{!unannotated, Jackson would pick this up automatically and add it *in addition* to the _JsonNullable getter field}}
|
||||
@JsonIgnore
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{^vendorExtensions.x-is-jackson-optional-nullable}}{{#jackson}}{{> jackson_annotations}}{{/jackson}}{{/vendorExtensions.x-is-jackson-optional-nullable}} public {{{datatypeWithEnum}}} {{getter}}() {
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{#isReadOnly}}{{! A readonly attribute doesn't have setter => jackson will set null directly if explicitly returned by API, so make sure we have an empty JsonNullable}}
|
||||
if ({{name}} == null) {
|
||||
{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>{{#defaultValue}}of({{{.}}}){{/defaultValue}}{{^defaultValue}}undefined(){{/defaultValue}};
|
||||
}
|
||||
{{/isReadOnly}}
|
||||
return {{name}}.orElse(null);
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{^vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
return {{name}};
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
}
|
||||
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{> jackson_annotations}}
|
||||
public JsonNullable<{{{datatypeWithEnum}}}> {{getter}}_JsonNullable() {
|
||||
public {{{datatypeWithEnum}}} {{getter}}() {
|
||||
return {{name}};
|
||||
}
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
@JsonProperty(JSON_PROPERTY_{{nameInSnakeCase}})
|
||||
{{#isReadOnly}}private{{/isReadOnly}}{{^isReadOnly}}public{{/isReadOnly}} void {{setter}}_JsonNullable(JsonNullable<{{{datatypeWithEnum}}}> {{name}}) {
|
||||
{{! For getters/setters that have name differing from attribute name, we must include setter (albeit private) for jackson to be able to set the attribute}}
|
||||
this.{{name}} = {{name}};
|
||||
}
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
|
||||
{{^isReadOnly}}
|
||||
{{#vendorExtensions.x-setter-extra-annotation}} {{{vendorExtensions.x-setter-extra-annotation}}}
|
||||
{{/vendorExtensions.x-setter-extra-annotation}}{{#jackson}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{> jackson_annotations}}{{/vendorExtensions.x-is-jackson-optional-nullable}}{{/jackson}}{{#deprecated}} @Deprecated
|
||||
{{/vendorExtensions.x-setter-extra-annotation}}{{#deprecated}} @Deprecated
|
||||
{{/deprecated}} public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
|
||||
{{#vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{name}});
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
{{^vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
this.{{name}} = {{name}};
|
||||
{{/vendorExtensions.x-is-jackson-optional-nullable}}
|
||||
}
|
||||
{{/isReadOnly}}
|
||||
|
||||
@@ -312,7 +220,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
return false;
|
||||
}{{#hasVars}}
|
||||
{{classname}} {{classVarName}} = ({{classname}}) o;
|
||||
return {{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}equalsNullable(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{#isByteArray}}Arrays{{/isByteArray}}{{^isByteArray}}Objects{{/isByteArray}}.equals(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}} &&
|
||||
return {{#vars}}{{#isByteArray}}Arrays{{/isByteArray}}{{^isByteArray}}Objects{{/isByteArray}}.equals(this.{{name}}, {{classVarName}}.{{name}}){{^-last}} &&
|
||||
{{/-last}}{{/vars}}{{#isAdditionalPropertiesTrue}}&&
|
||||
Objects.equals(this.additionalProperties, {{classVarName}}.additionalProperties){{/isAdditionalPropertiesTrue}}{{#parent}} &&
|
||||
super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}}
|
||||
@@ -330,7 +238,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
return HashCodeBuilder.reflectionHashCode(this);
|
||||
{{/useReflectionEqualsHashCode}}
|
||||
{{^useReflectionEqualsHashCode}}
|
||||
return Objects.hash({{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}hashCodeNullable({{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{^isByteArray}}{{name}}{{/isByteArray}}{{#isByteArray}}Arrays.hashCode({{name}}){{/isByteArray}}{{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}}, {{/-last}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}{{#isAdditionalPropertiesTrue}}{{#hasVars}}, {{/hasVars}}{{^hasVars}}{{#parent}}, {{/parent}}{{/hasVars}}additionalProperties{{/isAdditionalPropertiesTrue}});
|
||||
return Objects.hash({{#vars}}{{^isByteArray}}{{name}}{{/isByteArray}}{{#isByteArray}}Arrays.hashCode({{name}}){{/isByteArray}}{{^-last}}, {{/-last}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}{{#isAdditionalPropertiesTrue}}{{#hasVars}}, {{/hasVars}}{{^hasVars}}{{#parent}}, {{/parent}}{{/hasVars}}additionalProperties{{/isAdditionalPropertiesTrue}});
|
||||
{{/useReflectionEqualsHashCode}}
|
||||
}{{#vendorExtensions.x-jackson-optional-nullable-helpers}}
|
||||
|
||||
@@ -362,7 +270,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private{{#jsonb}} static{{/jsonb}} String toIndentedString(Object o) {
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{{#isNullable}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}}{{/isNullable}}
|
||||
{{#lambda.first}}{{#isNullable}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} {{/isNullable}}{{^required}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} {{/required}}{{/lambda.first}}
|
||||
@@ -38,7 +38,7 @@
|
||||
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
|
||||
|
||||
{{#allVars}}
|
||||
{{#isInnerEnum}}{{^isMap}}{{classname}}.{{/isMap}}{{/isInnerEnum}}{{{datatypeWithEnum}}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = default;
|
||||
Option<{{#isInnerEnum}}{{^isMap}}{{classname}}.{{/isMap}}{{/isInnerEnum}}{{{datatypeWithEnum}}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}}> {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = default;
|
||||
{{#-last}}
|
||||
|
||||
{{/-last}}
|
||||
@@ -167,39 +167,39 @@
|
||||
{{^isMap}}
|
||||
{{^isEnum}}
|
||||
{{^isUuid}}
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = utf8JsonReader.GetString();
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}utf8JsonReader.GetString(){{^isNullable}}{{nrt!}}{{/isNullable}});
|
||||
{{/isUuid}}
|
||||
{{/isEnum}}
|
||||
{{/isMap}}
|
||||
{{/isString}}
|
||||
{{#isBoolean}}
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = utf8JsonReader.GetBoolean();
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}utf8JsonReader.GetBoolean());
|
||||
{{/isBoolean}}
|
||||
{{#isNumeric}}
|
||||
{{^isEnum}}
|
||||
{{#isDouble}}
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = utf8JsonReader.GetDouble();
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}utf8JsonReader.GetDouble());
|
||||
{{/isDouble}}
|
||||
{{#isDecimal}}
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = utf8JsonReader.GetDecimal();
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}utf8JsonReader.GetDecimal());
|
||||
{{/isDecimal}}
|
||||
{{#isFloat}}
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = (float)utf8JsonReader.GetDouble();
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}(float)utf8JsonReader.GetDouble());
|
||||
{{/isFloat}}
|
||||
{{#isLong}}
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = utf8JsonReader.Get{{#vendorExtensions.x-unsigned}}U{{/vendorExtensions.x-unsigned}}Int64();
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}utf8JsonReader.Get{{#vendorExtensions.x-unsigned}}U{{/vendorExtensions.x-unsigned}}Int64());
|
||||
{{/isLong}}
|
||||
{{^isLong}}
|
||||
{{^isFloat}}
|
||||
{{^isDecimal}}
|
||||
{{^isDouble}}
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = utf8JsonReader.Get{{#vendorExtensions.x-unsigned}}U{{/vendorExtensions.x-unsigned}}Int32();
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}utf8JsonReader.Get{{#vendorExtensions.x-unsigned}}U{{/vendorExtensions.x-unsigned}}Int32());
|
||||
{{/isDouble}}
|
||||
{{/isDecimal}}
|
||||
{{/isFloat}}
|
||||
@@ -208,36 +208,34 @@
|
||||
{{/isNumeric}}
|
||||
{{#isDate}}
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = JsonSerializer.Deserialize<DateTime{{#isNullable}}?{{/isNullable}}>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}JsonSerializer.Deserialize<DateTime{{#isNullable}}?{{/isNullable}}>(ref utf8JsonReader, jsonSerializerOptions));
|
||||
{{/isDate}}
|
||||
{{#isDateTime}}
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = JsonSerializer.Deserialize<DateTime{{#isNullable}}?{{/isNullable}}>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}JsonSerializer.Deserialize<DateTime{{#isNullable}}?{{/isNullable}}>(ref utf8JsonReader, jsonSerializerOptions));
|
||||
{{/isDateTime}}
|
||||
{{#isEnum}}
|
||||
{{^isMap}}
|
||||
{{#isNumeric}}
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = ({{#isInnerEnum}}{{classname}}.{{/isInnerEnum}}{{{datatypeWithEnum}}})utf8JsonReader.Get{{#vendorExtensions.x-unsigned}}U{{/vendorExtensions.x-unsigned}}Int32();
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}({{#isInnerEnum}}{{classname}}.{{/isInnerEnum}}{{{datatypeWithEnum}}})utf8JsonReader.Get{{#vendorExtensions.x-unsigned}}U{{/vendorExtensions.x-unsigned}}Int32());
|
||||
{{/isNumeric}}
|
||||
{{^isNumeric}}
|
||||
string{{nrt?}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue = utf8JsonReader.GetString();
|
||||
{{^isInnerEnum}}
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue == null
|
||||
? null
|
||||
: {{{datatypeWithEnum}}}ValueConverter.FromStringOrDefault({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue);
|
||||
if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue != null)
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}{{{datatypeWithEnum}}}ValueConverter.FromStringOrDefault({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue));
|
||||
{{/isInnerEnum}}
|
||||
{{#isInnerEnum}}
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue == null
|
||||
? null
|
||||
: {{classname}}.{{{datatypeWithEnum}}}FromStringOrDefault({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue);
|
||||
if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue != null)
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}{{classname}}.{{{datatypeWithEnum}}}FromStringOrDefault({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue));
|
||||
{{/isInnerEnum}}
|
||||
{{/isNumeric}}
|
||||
{{/isMap}}
|
||||
{{/isEnum}}
|
||||
{{#isUuid}}
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = utf8JsonReader.GetGuid();
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}utf8JsonReader.GetGuid());
|
||||
{{/isUuid}}
|
||||
{{^isUuid}}
|
||||
{{^isEnum}}
|
||||
@@ -247,7 +245,7 @@
|
||||
{{^isDate}}
|
||||
{{^isDateTime}}
|
||||
if (utf8JsonReader.TokenType != JsonTokenType.Null)
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = JsonSerializer.Deserialize<{{{datatypeWithEnum}}}>(ref utf8JsonReader, jsonSerializerOptions);
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} = {{>OptionProperty}}JsonSerializer.Deserialize<{{{datatypeWithEnum}}}>(ref utf8JsonReader, jsonSerializerOptions){{^isNullable}}{{nrt!}}{{/isNullable}});
|
||||
{{/isDateTime}}
|
||||
{{/isDate}}
|
||||
{{/isNumeric}}
|
||||
@@ -263,10 +261,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
{{#allVars}}
|
||||
{{#required}}
|
||||
if (!{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}.IsSet)
|
||||
throw new ArgumentException("Property is required for class {{classname}}.", nameof({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}));
|
||||
|
||||
{{/required}}
|
||||
{{/allVars}}
|
||||
{{#allVars}}
|
||||
{{^isNullable}}
|
||||
if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} == null)
|
||||
throw new ArgumentNullException(nameof({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}), "Property is required for class {{classname}}.");
|
||||
if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}.IsSet && {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}.Value == null)
|
||||
throw new ArgumentNullException(nameof({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}), "Property is not nullable for class {{classname}}.");
|
||||
|
||||
{{/isNullable}}
|
||||
{{/allVars}}
|
||||
@@ -275,7 +280,7 @@
|
||||
{{#model.hasDiscriminatorWithNonEmptyMapping}}
|
||||
{{#mappedModels}}
|
||||
if ({{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}} != null)
|
||||
return new {{classname}}({{#lambda.joinWithComma}}{{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{#model.composedSchemas.anyOf}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/allVars}}{{/lambda.joinWithComma}});
|
||||
return new {{classname}}({{#lambda.joinWithComma}}{{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{#model.composedSchemas.anyOf}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#required}}.Value{{nrt!}}{{^isNullable}}{{#vendorExtensions.x-is-value-type}}.Value{{/vendorExtensions.x-is-value-type}}{{/isNullable}}{{/required}} {{/allVars}}{{/lambda.joinWithComma}});
|
||||
|
||||
{{#-last}}
|
||||
throw new JsonException();
|
||||
@@ -284,13 +289,23 @@
|
||||
{{/model.hasDiscriminatorWithNonEmptyMapping}}
|
||||
{{/model.discriminator}}
|
||||
{{^composedSchemas.oneOf}}
|
||||
return new {{classname}}({{#lambda.joinWithComma}}{{#model.composedSchemas.anyOf}}{{#lambda.camelcase_param}}{{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/allVars}}{{/lambda.joinWithComma}});
|
||||
{{^required}}
|
||||
{{#model.composedSchemas.anyOf}}
|
||||
Option<{{baseType}}{{>NullConditionalProperty}}> {{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}}ParsedValue = {{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}} == null
|
||||
? default
|
||||
: new Option<{{baseType}}{{>NullConditionalProperty}}>({{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}});
|
||||
{{/model.composedSchemas.anyOf}}
|
||||
{{#-last}}
|
||||
|
||||
{{/-last}}
|
||||
{{/required}}
|
||||
return new {{classname}}({{#lambda.joinWithComma}}{{#model.composedSchemas.anyOf}}{{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}}ParsedValue{{#required}}.Value{{^isNullable}}{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{nrt!}}{{/vendorExtensions.x-is-value-type}}{{/isNullable}}{{/required}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#required}}.Value{{nrt!}}{{^isNullable}}{{#vendorExtensions.x-is-value-type}}.Value{{nrt!}}{{/vendorExtensions.x-is-value-type}}{{/isNullable}}{{/required}} {{/allVars}}{{/lambda.joinWithComma}});
|
||||
{{/composedSchemas.oneOf}}
|
||||
{{^model.discriminator}}
|
||||
{{#composedSchemas}}
|
||||
{{#oneOf}}
|
||||
if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} != null)
|
||||
return new {{classname}}({{#lambda.joinWithComma}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{#model.composedSchemas.anyOf}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/allVars}}{{/lambda.joinWithComma}});
|
||||
return new {{classname}}({{#lambda.joinWithComma}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{#model.composedSchemas.anyOf}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#required}}ParsedValue{{/required}} {{/allVars}}{{/lambda.joinWithComma}});
|
||||
|
||||
{{#-last}}
|
||||
throw new JsonException();
|
||||
@@ -328,10 +343,10 @@
|
||||
{{^model.discriminator}}
|
||||
{{#composedSchemas}}
|
||||
{{#anyOf}}
|
||||
if ({{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}}.{{datatypeWithEnum}} != null)
|
||||
if ({{#lambda.joinWithAmpersand}}{{^required}}{{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}}.{{datatypeWithEnum}}Option.IsSet {{/required}}{{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}}.{{datatypeWithEnum}}{{^required}}Option.Value{{/required}} != null{{/lambda.joinWithAmpersand}})
|
||||
{
|
||||
{{datatypeWithEnum}}JsonConverter {{datatypeWithEnum}}JsonConverter = ({{datatypeWithEnum}}JsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert({{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}}.{{datatypeWithEnum}}.GetType()));
|
||||
{{datatypeWithEnum}}JsonConverter.WriteProperties(ref writer, {{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}}.{{datatypeWithEnum}}, jsonSerializerOptions);
|
||||
{{datatypeWithEnum}}JsonConverter {{datatypeWithEnum}}JsonConverter = ({{datatypeWithEnum}}JsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert({{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}}.{{datatypeWithEnum}}{{^required}}Option.Value{{/required}}.GetType()));
|
||||
{{datatypeWithEnum}}JsonConverter.WriteProperties(ref writer, {{#lambda.camelcase_param}}{{model.classname}}{{/lambda.camelcase_param}}.{{datatypeWithEnum}}{{^required}}Option.Value{{/required}}, jsonSerializerOptions);
|
||||
}
|
||||
|
||||
{{/anyOf}}
|
||||
@@ -354,78 +369,76 @@
|
||||
{{#lambda.trimTrailingWithNewLine}}
|
||||
{{#lambda.trimLineBreaks}}
|
||||
{{#allVars}}
|
||||
{{^isNullable}}
|
||||
{{#vendorExtensions.x-is-reference-type}}
|
||||
if ({{^required}}{{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}Option.IsSet && {{/required}}{{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}} == null)
|
||||
throw new ArgumentNullException(nameof({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}), "Property is required for class {{classname}}.");
|
||||
|
||||
{{/vendorExtensions.x-is-reference-type}}
|
||||
{{/isNullable}}
|
||||
{{/allVars}}
|
||||
{{#allVars}}
|
||||
{{#isString}}
|
||||
{{^isMap}}
|
||||
{{^isEnum}}
|
||||
{{^isUuid}}
|
||||
{{#lambda.copy}}
|
||||
writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}});
|
||||
{{/lambda.copy}}
|
||||
{{#lambda.indent3}}
|
||||
{{>WriteProperty}}
|
||||
{{/lambda.indent3}}
|
||||
{{/isUuid}}
|
||||
{{/isEnum}}
|
||||
{{/isMap}}
|
||||
{{/isString}}
|
||||
{{#isBoolean}}
|
||||
{{#isNullable}}
|
||||
|
||||
if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}} != null)
|
||||
writer.WriteBoolean("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}.Value);
|
||||
else
|
||||
writer.WriteNull("{{baseName}}");
|
||||
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
writer.WriteBoolean("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}});
|
||||
{{/isNullable}}
|
||||
{{#lambda.copy}}
|
||||
writer.WriteBoolean("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}{{#required}}{{#isNullable}}.Value{{/isNullable}}{{/required}});
|
||||
{{/lambda.copy}}
|
||||
{{#lambda.indent3}}
|
||||
{{>WriteProperty}}
|
||||
{{/lambda.indent3}}
|
||||
{{/isBoolean}}
|
||||
{{^isEnum}}
|
||||
{{#isNumeric}}
|
||||
{{#isNullable}}
|
||||
|
||||
if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}} != null)
|
||||
writer.WriteNumber("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}.Value);
|
||||
else
|
||||
writer.WriteNull("{{baseName}}");
|
||||
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
writer.WriteNumber("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}});
|
||||
{{/isNullable}}
|
||||
{{#lambda.copy}}
|
||||
writer.WriteNumber("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}{{#required}}{{#isNullable}}.Value{{/isNullable}}{{/required}});
|
||||
{{/lambda.copy}}
|
||||
{{#lambda.indent3}}
|
||||
{{>WriteProperty}}
|
||||
{{/lambda.indent3}}
|
||||
{{/isNumeric}}
|
||||
{{/isEnum}}
|
||||
{{#isDate}}
|
||||
{{#isNullable}}
|
||||
|
||||
if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}} != null)
|
||||
writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}.Value.ToString({{name}}Format));
|
||||
else
|
||||
writer.WriteNull("{{baseName}}");
|
||||
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}.ToString({{name}}Format));
|
||||
{{/isNullable}}
|
||||
{{#lambda.copy}}
|
||||
writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}{{#required}}{{#isNullable}}.Value{{/isNullable}}{{/required}}.ToString({{name}}Format));
|
||||
{{/lambda.copy}}
|
||||
{{#lambda.indent3}}
|
||||
{{>WriteProperty}}
|
||||
{{/lambda.indent3}}
|
||||
{{/isDate}}
|
||||
{{#isDateTime}}
|
||||
{{#isNullable}}
|
||||
|
||||
if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}} != null)
|
||||
writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}.Value.ToString({{name}}Format));
|
||||
else
|
||||
writer.WriteNull("{{baseName}}");
|
||||
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}.ToString({{name}}Format));
|
||||
{{/isNullable}}
|
||||
{{#lambda.copy}}
|
||||
writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}{{#required}}{{#isNullable}}.Value{{/isNullable}}{{/required}}.ToString({{name}}Format));
|
||||
{{/lambda.copy}}
|
||||
{{#lambda.indent3}}
|
||||
{{>WriteProperty}}
|
||||
{{/lambda.indent3}}
|
||||
{{/isDateTime}}
|
||||
{{#isEnum}}
|
||||
{{#isNumeric}}
|
||||
writer.WriteNumber("{{baseName}}", {{#isInnerEnum}}{{classname}}.{{/isInnerEnum}}{{{datatypeWithEnum}}}ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}));
|
||||
{{#lambda.copy}}
|
||||
writer.WriteNumber("{{baseName}}", {{#isInnerEnum}}{{classname}}.{{/isInnerEnum}}{{{datatypeWithEnum}}}ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}{{#required}}{{#isNullable}}.Value{{/isNullable}}{{/required}}));
|
||||
{{/lambda.copy}}
|
||||
{{#lambda.indent3}}
|
||||
{{>WriteProperty}}
|
||||
{{/lambda.indent3}}
|
||||
{{/isNumeric}}
|
||||
{{^isMap}}
|
||||
{{^isNumeric}}
|
||||
{{#isInnerEnum}}
|
||||
|
||||
var {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue = {{classname}}.{{{datatypeWithEnum}}}ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}});
|
||||
var {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue = {{classname}}.{{{datatypeWithEnum}}}ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}{{#required}}{{#isNullable}}{{nrt!}}.Value{{/isNullable}}{{/required}});
|
||||
if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue != null)
|
||||
writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue);
|
||||
else
|
||||
@@ -433,18 +446,21 @@
|
||||
|
||||
{{/isInnerEnum}}
|
||||
{{^isInnerEnum}}
|
||||
{{#lambda.copy}}
|
||||
{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue
|
||||
{{/lambda.copy}}
|
||||
{{#required}}
|
||||
{{#isNullable}}
|
||||
|
||||
if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}} == null)
|
||||
writer.WriteNull("{{baseName}}");
|
||||
else
|
||||
{
|
||||
var {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue = {{{datatypeWithEnum}}}ValueConverter.ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{#isNullable}}.Value{{/isNullable}});
|
||||
var {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue = {{{datatypeWithEnum}}}ValueConverter.ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}.Value);
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
{{#-first}}
|
||||
{{#isString}}
|
||||
if ({{#lambda.camelcase_param}}{{nameInCamelCase}}{{/lambda.camelcase_param}}RawValue != null){{! we cant use name here because enumVar also has a name property, so use the camel case variant only as a work around }}
|
||||
if ({{#lambda.pasteLine}}{{/lambda.pasteLine}} != null){{! we cant use name here because enumVar also has a name property, so use the paste lambda instead }}
|
||||
writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{nameInCamelCase}}{{/lambda.camelcase_param}}RawValue);
|
||||
else
|
||||
writer.WriteNull("{{baseName}}");
|
||||
@@ -456,44 +472,53 @@
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
}
|
||||
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
var {{#lambda.camelcase_param}}{{nameInCamelCase}}{{/lambda.camelcase_param}}RawValue = {{{datatypeWithEnum}}}ValueConverter.ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{#isNullable}}.Value{{/isNullable}});
|
||||
var {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue = {{{datatypeWithEnum}}}ValueConverter.ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}});
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
{{#-first}}
|
||||
{{#isString}}
|
||||
|
||||
if ({{#lambda.camelcase_param}}{{nameInCamelCase}}{{/lambda.camelcase_param}}RawValue != null)
|
||||
writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{nameInCamelCase}}{{/lambda.camelcase_param}}RawValue);
|
||||
else
|
||||
writer.WriteNull("{{baseName}}");
|
||||
|
||||
writer.WriteString("{{baseName}}", {{#lambda.pasteLine}}{{/lambda.pasteLine}});
|
||||
{{/isString}}
|
||||
{{^isString}}
|
||||
writer.WriteNumber("{{baseName}}", {{#lambda.camelcase_param}}{{nameInCamelCase}}{{/lambda.camelcase_param}}RawValue);
|
||||
writer.WriteNumber("{{baseName}}", {{#lambda.camelcase_param}}{{#lambda.pasteLine}}{{/lambda.pasteLine}}{{/lambda.camelcase_param}}RawValue);
|
||||
{{/isString}}
|
||||
{{/-first}}
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
{{/isNullable}}
|
||||
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}Option.IsSet)
|
||||
{{#isNullable}}
|
||||
if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}Option{{nrt!}}.Value != null)
|
||||
{
|
||||
var {{#lambda.pasteLine}}{{/lambda.pasteLine}} = {{{datatypeWithEnum}}}ValueConverter.ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}Option.Value{{nrt!}}.Value);
|
||||
writer.{{#lambda.first}}{{#allowableValues}}{{#enumVars}}{{#isString}}WriteString {{/isString}}{{^isString}}WriteNumber {{/isString}}{{/enumVars}}{{/allowableValues}}{{/lambda.first}}("{{baseName}}", {{#lambda.pasteLine}}{{/lambda.pasteLine}});
|
||||
}
|
||||
else
|
||||
writer.WriteNull("{{baseName}}");
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
{
|
||||
var {{#lambda.pasteLine}}{{/lambda.pasteLine}} = {{{datatypeWithEnum}}}ValueConverter.ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{nrt!}}.Value);
|
||||
writer.{{#lambda.first}}{{#allowableValues}}{{#enumVars}}{{#isString}}WriteString {{/isString}}{{^isString}}WriteNumber {{/isString}}{{/enumVars}}{{/allowableValues}}{{/lambda.first}}("{{baseName}}", {{#lambda.pasteLine}}{{/lambda.pasteLine}});
|
||||
}
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{/isInnerEnum}}
|
||||
{{/isNumeric}}
|
||||
{{/isMap}}
|
||||
{{/isEnum}}
|
||||
{{#isUuid}}
|
||||
{{^isNullable}}
|
||||
writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}});
|
||||
{{/isNullable}}
|
||||
{{#isNullable}}
|
||||
|
||||
if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}} == null)
|
||||
writer.WriteNull("{{baseName}}");
|
||||
else
|
||||
writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}.Value);
|
||||
|
||||
{{/isNullable}}
|
||||
{{#lambda.copy}}
|
||||
writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}{{#required}}{{#isNullable}}.Value{{/isNullable}}{{/required}});
|
||||
{{/lambda.copy}}
|
||||
{{#lambda.indent3}}
|
||||
{{>WriteProperty}}
|
||||
{{/lambda.indent3}}
|
||||
{{/isUuid}}
|
||||
{{^isUuid}}
|
||||
{{^isEnum}}
|
||||
@@ -502,8 +527,39 @@
|
||||
{{^isNumeric}}
|
||||
{{^isDate}}
|
||||
{{^isDateTime}}
|
||||
{{#required}}
|
||||
{{#isNullable}}
|
||||
if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}} != null)
|
||||
{
|
||||
writer.WritePropertyName("{{baseName}}");
|
||||
JsonSerializer.Serialize(writer, {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}, jsonSerializerOptions);
|
||||
}
|
||||
else
|
||||
writer.WriteNull("{{baseName}}");
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
writer.WritePropertyName("{{baseName}}");
|
||||
JsonSerializer.Serialize(writer, {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}, jsonSerializerOptions);
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}Option.IsSet)
|
||||
{{#isNullable}}
|
||||
if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}Option.Value != null)
|
||||
{
|
||||
writer.WritePropertyName("{{baseName}}");
|
||||
JsonSerializer.Serialize(writer, {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}, jsonSerializerOptions);
|
||||
}
|
||||
else
|
||||
writer.WriteNull("{{baseName}}");
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
{
|
||||
writer.WritePropertyName("{{baseName}}");
|
||||
JsonSerializer.Serialize(writer, {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}, jsonSerializerOptions);
|
||||
}
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{/isDateTime}}
|
||||
{{/isDate}}
|
||||
{{/isNumeric}}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{{#parentModel.composedSchemas.anyOf}}{{#lambda.camelcase_param}}{{parent}}{{/lambda.camelcase_param}}.{{#lambda.titlecase}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.titlecase}} {{/parentModel.composedSchemas.anyOf}}{{#allVars}}{{#isInherited}}{{^isNew}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{/isNew}}{{#isNew}}{{#isEnum}}{{#isInnerEnum}}{{classname}}.{{/isInnerEnum}}{{{datatypeWithEnum}}}ToJsonValue({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}){{/isEnum}}{{^isEnum}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}.ToString(){{/isEnum}}{{/isNew}} {{/isInherited}}{{/allVars}}
|
||||
{{#parentModel.composedSchemas.anyOf}}{{#lambda.camelcase_param}}{{parent}}{{/lambda.camelcase_param}}.{{#lambda.titlecase}}{{baseType}}{{#isArray}}{{{dataFormat}}}{{/isArray}}{{/lambda.titlecase}} {{/parentModel.composedSchemas.anyOf}}{{#allVars}}{{#isInherited}}{{^isNew}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{/isNew}}{{#isNew}}{{#isEnum}}{{#isInnerEnum}}{{classname}}.{{/isInnerEnum}}{{{datatypeWithEnum}}}ToJsonValue({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{^required}}.Value{{/required}}){{/isEnum}}{{^isEnum}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}.ToString(){{/isEnum}}{{/isNew}} {{/isInherited}}{{/allVars}}
|
||||
@@ -1 +1 @@
|
||||
{{#model.allVars}}{{{datatypeWithEnum}}}{{>NullConditionalProperty}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#defaultValue}} = {{^isDateTime}}{{#isString}}{{^isEnum}}@{{/isEnum}}{{/isString}}{{{defaultValue}}}{{/isDateTime}}{{#isDateTime}}default{{/isDateTime}}{{/defaultValue}}{{^defaultValue}}{{#isNullable}} = default{{/isNullable}}{{/defaultValue}} {{/model.allVars}}
|
||||
{{#model.allVars}}{{^required}}Option<{{/required}}{{{datatypeWithEnum}}}{{>NullConditionalProperty}}{{^required}}>{{/required}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{#defaultValue}} = {{^required}}default{{/required}}{{#required}}{{^isDateTime}}{{#isString}}{{^isEnum}}@{{/isEnum}}{{/isString}}{{{.}}}{{/isDateTime}}{{#isDateTime}}default{{/isDateTime}}{{/required}}{{/defaultValue}}{{^defaultValue}}{{#lambda.first}}{{#isNullable}} = default {{/isNullable}}{{^required}} = default {{/required}}{{/lambda.first}}{{/defaultValue}} {{/model.allVars}}
|
||||
@@ -31,5 +31,17 @@ namespace {{packageName}}.{{clientPackage}}
|
||||
IsSet = true;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implicitly converts this option to the contained type
|
||||
/// </summary>
|
||||
/// <param name="option"></param>
|
||||
public static implicit operator TType(Option<TType> option) => option.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Implicitly converts the provided value to an Option
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public static implicit operator Option<TType>(TType value) => new Option<TType>(value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
new Option<{{#isInnerEnum}}{{^isMap}}{{classname}}.{{/isMap}}{{/isInnerEnum}}{{{datatypeWithEnum}}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}}>(
|
||||
@@ -0,0 +1,7 @@
|
||||
// {{{name}}} ({{{dataType}}}) pattern
|
||||
Regex regex{{{name}}} = new Regex(@"{{{vendorExtensions.x-regex}}}"{{#vendorExtensions.x-modifiers}}{{#-first}}, {{/-first}}RegexOptions.{{{.}}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}});
|
||||
{{#lambda.copy}}this.{{{name}}}{{#useGenericHost}}{{^required}}Option.Value{{/required}}{{/useGenericHost}} != null && {{/lambda.copy}}
|
||||
if ({{#lambda.first}}{{^required}}{{#lambda.pasteLine}}{{/lambda.pasteLine}} {{/required}}{{#isNullable}}{{#lambda.pasteLine}}{{/lambda.pasteLine}}{{/isNullable}}{{/lambda.first}}!regex{{{name}}}.Match(this.{{{name}}}{{#useGenericHost}}{{^required}}Option.Value{{/required}}{{/useGenericHost}}{{#isUuid}}.ToString(){{#lambda.first}}{{^required}}{{nrt!}} {{/required}}{{#isNullable}}! {{/isNullable}}{{/lambda.first}}{{/isUuid}}).Success)
|
||||
{
|
||||
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must match a pattern of " + regex{{{name}}}, new [] { "{{{name}}}" });
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{{#required}}
|
||||
{{>WritePropertyHelper}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}Option.IsSet)
|
||||
{{#lambda.indent1}}
|
||||
{{>WritePropertyHelper}}
|
||||
{{/lambda.indent1}}
|
||||
{{/required}}
|
||||
@@ -0,0 +1,9 @@
|
||||
{{#isNullable}}
|
||||
if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{^required}}Option.Value{{/required}} != null)
|
||||
{{#lambda.pasteLine}}{{/lambda.pasteLine}}
|
||||
else
|
||||
writer.WriteNull("{{baseName}}");
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
{{#lambda.pasteLine}}{{/lambda.pasteLine}}
|
||||
{{/isNullable}}
|
||||
@@ -26,8 +26,8 @@ using OpenAPIClientUtils = {{packageName}}.Client.ClientUtils;
|
||||
{{#useGenericHost}}
|
||||
{{#useSourceGeneration}}
|
||||
using System.Text.Json.Serialization.Metadata;
|
||||
using {{packageName}}.{{clientPackage}};
|
||||
{{/useSourceGeneration}}
|
||||
using {{packageName}}.{{clientPackage}};
|
||||
{{/useGenericHost}}
|
||||
{{#models}}
|
||||
{{#lambda.trimTrailingWithNewLine}}
|
||||
|
||||
@@ -15,19 +15,19 @@
|
||||
{{#allVars}}
|
||||
/// <param name="{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}">{{description}}{{^description}}{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}{{/description}}{{#defaultValue}} (default to {{.}}){{/defaultValue}}</param>
|
||||
{{/allVars}}
|
||||
{{#model.vendorExtensions.x-model-is-mutatable}}{{>visibility}}{{/model.vendorExtensions.x-model-is-mutatable}}{{^model.vendorExtensions.x-model-is-mutatable}}internal{{/model.vendorExtensions.x-model-is-mutatable}} {{classname}}({{#lambda.joinWithComma}}{{{dataType}}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} {{#model.composedSchemas.anyOf}}{{{dataType}}}{{>NullConditionalProperty}} {{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}} {{/model.composedSchemas.anyOf}}{{>ModelSignature}}{{/lambda.joinWithComma}}){{#parent}} : base({{#lambda.joinWithComma}}{{#parentModel.composedSchemas.oneOf}}{{#lambda.camelcase_param}}{{parent}}{{/lambda.camelcase_param}}.{{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}} {{/parentModel.composedSchemas.oneOf}}{{>ModelBaseSignature}}{{/lambda.joinWithComma}}){{/parent}}
|
||||
{{#model.vendorExtensions.x-model-is-mutatable}}{{>visibility}}{{/model.vendorExtensions.x-model-is-mutatable}}{{^model.vendorExtensions.x-model-is-mutatable}}internal{{/model.vendorExtensions.x-model-is-mutatable}} {{classname}}({{#lambda.joinWithComma}}{{{dataType}}} {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}} {{#model.composedSchemas.anyOf}}{{^required}}Option<{{/required}}{{{dataType}}}{{>NullConditionalProperty}}{{^required}}>{{/required}} {{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}} {{/model.composedSchemas.anyOf}}{{>ModelSignature}}{{/lambda.joinWithComma}}){{#parent}} : base({{#lambda.joinWithComma}}{{#parentModel.composedSchemas.oneOf}}{{#lambda.camelcase_param}}{{parent}}{{/lambda.camelcase_param}}.{{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}} {{/parentModel.composedSchemas.oneOf}}{{>ModelBaseSignature}}{{/lambda.joinWithComma}}){{/parent}}
|
||||
{
|
||||
{{#composedSchemas.anyOf}}
|
||||
{{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}} = {{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}};
|
||||
{{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}}{{^required}}Option{{/required}} = {{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}};
|
||||
{{/composedSchemas.anyOf}}
|
||||
{{name}} = {{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}};
|
||||
{{#allVars}}
|
||||
{{^isInherited}}
|
||||
{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
||||
{{name}}{{^required}}Option{{/required}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
||||
{{/isInherited}}
|
||||
{{#isInherited}}
|
||||
{{#isNew}}
|
||||
{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
||||
{{name}}{{^required}}Option{{/required}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
||||
{{/isNew}}
|
||||
{{/isInherited}}
|
||||
{{/allVars}}
|
||||
@@ -49,18 +49,18 @@
|
||||
{{^composedSchemas.anyOf}}
|
||||
[JsonConstructor]
|
||||
{{/composedSchemas.anyOf}}
|
||||
{{#model.vendorExtensions.x-model-is-mutatable}}{{>visibility}}{{/model.vendorExtensions.x-model-is-mutatable}}{{^model.vendorExtensions.x-model-is-mutatable}}internal{{/model.vendorExtensions.x-model-is-mutatable}} {{classname}}({{#lambda.joinWithComma}}{{#composedSchemas.anyOf}}{{{name}}}{{>NullConditionalProperty}} {{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}} {{/composedSchemas.anyOf}}{{>ModelSignature}}{{/lambda.joinWithComma}}){{#parent}} : base({{#lambda.joinWithComma}}{{>ModelBaseSignature}}{{/lambda.joinWithComma}}){{/parent}}
|
||||
{{#model.vendorExtensions.x-model-is-mutatable}}{{>visibility}}{{/model.vendorExtensions.x-model-is-mutatable}}{{^model.vendorExtensions.x-model-is-mutatable}}internal{{/model.vendorExtensions.x-model-is-mutatable}} {{classname}}({{#lambda.joinWithComma}}{{#composedSchemas.anyOf}}{{^required}}Option<{{/required}}{{{name}}}{{>NullConditionalProperty}}{{^required}}>{{/required}} {{#lambda.camelcase_param}}{{baseType}}{{/lambda.camelcase_param}} {{/composedSchemas.anyOf}}{{>ModelSignature}}{{/lambda.joinWithComma}}){{#parent}} : base({{#lambda.joinWithComma}}{{>ModelBaseSignature}}{{/lambda.joinWithComma}}){{/parent}}
|
||||
{
|
||||
{{#composedSchemas.anyOf}}
|
||||
{{#lambda.titlecase}}{{name}}{{/lambda.titlecase}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
||||
{{#lambda.titlecase}}{{name}}{{/lambda.titlecase}}{{^required}}Option{{/required}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
||||
{{/composedSchemas.anyOf}}
|
||||
{{#allVars}}
|
||||
{{^isInherited}}
|
||||
{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
||||
{{name}}{{^required}}Option{{/required}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
||||
{{/isInherited}}
|
||||
{{#isInherited}}
|
||||
{{#isNew}}
|
||||
{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
||||
{{name}}{{^required}}Option{{/required}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
|
||||
{{/isNew}}
|
||||
{{/isInherited}}
|
||||
{{/allVars}}
|
||||
@@ -84,6 +84,15 @@
|
||||
{{/complexType}}
|
||||
{{/isEnum}}
|
||||
{{#isEnum}}
|
||||
{{^required}}
|
||||
/// <summary>
|
||||
/// Used to track the state of {{{name}}}
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public {{#isNew}}new {{/isNew}}Option<{{{datatypeWithEnum}}}{{>NullConditionalProperty}}> {{name}}Option { get; {{^isReadOnly}}private set; {{/isReadOnly}}}
|
||||
|
||||
{{/required}}
|
||||
/// <summary>
|
||||
/// {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}}
|
||||
/// </summary>
|
||||
@@ -97,12 +106,21 @@
|
||||
{{#deprecated}}
|
||||
[Obsolete]
|
||||
{{/deprecated}}
|
||||
public {{#isNew}}new {{/isNew}}{{{datatypeWithEnum}}}{{>NullConditionalProperty}} {{name}} { get; {{^isReadOnly}}set; {{/isReadOnly}}}
|
||||
public {{#isNew}}new {{/isNew}}{{{datatypeWithEnum}}}{{#lambda.first}}{{#isNullable}}{{>NullConditionalProperty}} {{/isNullable}}{{^required}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} {{/required}}{{/lambda.first}} {{name}} {{#required}}{ get; {{^isReadOnly}}set; {{/isReadOnly}}}{{/required}}{{^required}}{ get { return this.{{name}}Option; } {{^isReadOnly}}set { this.{{name}}Option = new{{^net70OrLater}} Option<{{{datatypeWithEnum}}}{{>NullConditionalProperty}}>{{/net70OrLater}}(value); } {{/isReadOnly}}}{{/required}}
|
||||
|
||||
{{/isEnum}}
|
||||
{{/vars}}
|
||||
{{#composedSchemas.anyOf}}
|
||||
{{^vendorExtensions.x-duplicated-data-type}}
|
||||
{{^required}}
|
||||
/// <summary>
|
||||
/// Used to track the state of {{{name}}}
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public {{#isNew}}new {{/isNew}}Option<{{{datatypeWithEnum}}}{{>NullConditionalProperty}}> {{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}}Option { get; {{^isReadOnly}}private set; {{/isReadOnly}}}
|
||||
|
||||
{{/required}}
|
||||
/// <summary>
|
||||
/// {{description}}{{^description}}Gets or Sets {{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}}{{/description}}
|
||||
/// </summary>{{#description}}
|
||||
@@ -113,7 +131,7 @@
|
||||
{{#deprecated}}
|
||||
[Obsolete]
|
||||
{{/deprecated}}
|
||||
public {{{dataType}}}{{>NullConditionalProperty}} {{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}} { get; {{^isReadOnly}}set; {{/isReadOnly}}}
|
||||
public {{{datatypeWithEnum}}}{{#lambda.first}}{{#isNullable}}{{>NullConditionalProperty}} {{/isNullable}}{{^required}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} {{/required}}{{/lambda.first}} {{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}} {{#required}}{ get; {{^isReadOnly}}set; {{/isReadOnly}}}{{/required}}{{^required}}{ get { return this.{{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}}Option; } {{^isReadOnly}}set { this.{{#lambda.titlecase}}{{baseType}}{{/lambda.titlecase}}Option = new{{^net70OrLater}} Option<{{{datatypeWithEnum}}}{{>NullConditionalProperty}}>{{/net70OrLater}}(value); } {{/isReadOnly}}}{{/required}}
|
||||
|
||||
{{/vendorExtensions.x-duplicated-data-type}}
|
||||
{{/composedSchemas.anyOf}}
|
||||
@@ -137,6 +155,15 @@
|
||||
{{^isEnum}}
|
||||
{{#isInherited}}
|
||||
{{#isNew}}
|
||||
{{^required}}
|
||||
/// <summary>
|
||||
/// Used to track the state of {{{name}}}
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public new Option<{{{datatypeWithEnum}}}{{>NullConditionalProperty}}> {{name}}Option { get; {{^isReadOnly}}private set; {{/isReadOnly}}}
|
||||
|
||||
{{/required}}
|
||||
/// <summary>
|
||||
/// {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}}
|
||||
/// </summary>{{#description}}
|
||||
@@ -148,11 +175,20 @@
|
||||
{{#deprecated}}
|
||||
[Obsolete]
|
||||
{{/deprecated}}
|
||||
public new {{{datatypeWithEnum}}}{{>NullConditionalProperty}} {{name}} { get; {{^isReadOnly}}set; {{/isReadOnly}}}
|
||||
public new {{{datatypeWithEnum}}}{{#lambda.first}}{{#isNullable}}{{>NullConditionalProperty}} {{/isNullable}}{{^required}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} {{/required}}{{/lambda.first}} {{name}} {{#required}}{ get; {{^isReadOnly}}set; {{/isReadOnly}}}{{/required}}{{^required}}{ get { return this.{{name}}Option } {{^isReadOnly}}set { this.{{name}}Option = new{{^net70OrLater}} Option<{{{datatypeWithEnum}}}{{>NullConditionalProperty}}>{{/net70OrLater}}(value); } {{/isReadOnly}}}{{/required}}
|
||||
|
||||
{{/isNew}}
|
||||
{{/isInherited}}
|
||||
{{^isInherited}}
|
||||
{{^required}}
|
||||
/// <summary>
|
||||
/// Used to track the state of {{{name}}}
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public Option<{{{datatypeWithEnum}}}{{>NullConditionalProperty}}> {{name}}Option { get; {{^isReadOnly}}private set; {{/isReadOnly}}}
|
||||
|
||||
{{/required}}
|
||||
/// <summary>
|
||||
/// {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}}
|
||||
/// </summary>{{#description}}
|
||||
@@ -164,7 +200,7 @@
|
||||
{{#deprecated}}
|
||||
[Obsolete]
|
||||
{{/deprecated}}
|
||||
public {{{datatypeWithEnum}}}{{>NullConditionalProperty}} {{name}} { get; {{^isReadOnly}}set; {{/isReadOnly}}}
|
||||
public {{{datatypeWithEnum}}}{{#lambda.first}}{{#isNullable}}{{>NullConditionalProperty}} {{/isNullable}}{{^required}}{{nrt?}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} {{/required}}{{/lambda.first}} {{name}} {{#required}}{ get; {{^isReadOnly}}set; {{/isReadOnly}}}{{/required}}{{^required}}{ get { return this. {{name}}Option; } {{^isReadOnly}}set { this.{{name}}Option = new{{^net70OrLater}} Option<{{{datatypeWithEnum}}}{{>NullConditionalProperty}}>{{/net70OrLater}}(value); } {{/isReadOnly}}}{{/required}}
|
||||
|
||||
{{/isInherited}}
|
||||
{{/isEnum}}
|
||||
@@ -274,16 +310,24 @@
|
||||
int hashCode = 41;
|
||||
{{/parent}}
|
||||
{{#readOnlyVars}}
|
||||
{{#required}}
|
||||
{{^isNullable}}
|
||||
hashCode = (hashCode * 59) + {{name}}.GetHashCode();
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{/readOnlyVars}}
|
||||
{{#readOnlyVars}}
|
||||
{{#isNullable}}
|
||||
{{#lambda.copy}}
|
||||
|
||||
if ({{name}} != null)
|
||||
hashCode = (hashCode * 59) + {{name}}.GetHashCode();
|
||||
{{/lambda.copy}}
|
||||
{{#isNullable}}
|
||||
{{#lambda.pasteOnce}}{{/lambda.pasteOnce}}
|
||||
{{/isNullable}}
|
||||
{{^required}}
|
||||
{{#lambda.pasteOnce}}{{/lambda.pasteOnce}}
|
||||
{{/required}}
|
||||
{{/readOnlyVars}}
|
||||
{{#isAdditionalPropertiesTrue}}
|
||||
{{^parentModel}}
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
{{#isString}}
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
{{/isString}}
|
||||
public static {{>EnumValueDataType}}{{>NullConditionalProperty}} {{datatypeWithEnum}}ToJsonValue({{datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}{{>NullConditionalProperty}} value)
|
||||
public static {{>EnumValueDataType}}{{#nrt}}{{#isString}}{{#isNullable}}{{nrt?}} {{^nrt}}{{#vendorExtensions.x-is-value-type}}? {{/vendorExtensions.x-is-value-type}}{{/nrt}}{{/isNullable}}{{/isString}}{{/nrt}} {{datatypeWithEnum}}ToJsonValue({{datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}{{#isString}}{{>NullConditionalProperty}}{{/isString}} value)
|
||||
{
|
||||
{{^isString}}
|
||||
return ({{>EnumValueDataType}}) value;
|
||||
@@ -83,8 +83,8 @@
|
||||
{{#isNullable}}
|
||||
if (value == null)
|
||||
return null;
|
||||
{{/isNullable}}
|
||||
|
||||
{{/isNullable}}
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
if (value == {{datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}.{{name}})
|
||||
|
||||
@@ -35,10 +35,10 @@
|
||||
<PackageReference Include="RestSharp" Version="110.2.0" />
|
||||
{{/useRestSharp}}
|
||||
{{#useGenericHost}}
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="{{#lambda.first}}{{#netStandard}}5.0.0 {{/netStandard}}{{#net47}}7.0.0 {{/net47}}{{#net48}}7.0.0 {{/net48}}{{#net6.0}}6.0.0 {{/net6.0}}{{#net70OrLater}}7.0.0{{/net70OrLater}}{{/lambda.first}}" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="{{#lambda.first}}{{#netStandard}}5.0.0 {{/netStandard}}{{#net47}}7.0.0 {{/net47}}{{#net48}}7.0.0 {{/net48}}{{#net6.0}}6.0.1 {{/net6.0}}{{#net70OrLater}}7.0.1 {{/net70OrLater}}{{/lambda.first}}" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="{{#lambda.first}}{{#netStandard}}5.0.0 {{/netStandard}}{{#net47}}7.0.0 {{/net47}}{{#net48}}7.0.0 {{/net48}}{{#net6.0}}6.0.0 {{/net6.0}}{{#net7.0}}7.0.0 {{/net7.0}}{{#net8.0}}8.0.0 {{/net8.0}}{{/lambda.first}}" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="{{#lambda.first}}{{#netStandard}}5.0.0 {{/netStandard}}{{#net47}}7.0.0 {{/net47}}{{#net48}}7.0.0 {{/net48}}{{#net6.0}}6.0.1 {{/net6.0}}{{#net7.0}}7.0.1 {{/net7.0}}{{#net8.0}}8.0.0 {{/net8.0}}{{/lambda.first}}" />
|
||||
{{#supportsRetry}}
|
||||
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="{{#lambda.first}}{{#netStandard}}5.0.1 {{/netStandard}}{{#net47}}7.0.0 {{/net47}}{{#net48}}7.0.0 {{/net48}}{{#net6.0}}6.0.19 {{/net6.0}}{{#net70OrLater}}7.0.11 {{/net70OrLater}}{{/lambda.first}}" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="{{#lambda.first}}{{#netStandard}}5.0.1 {{/netStandard}}{{#net47}}7.0.0 {{/net47}}{{#net48}}7.0.0 {{/net48}}{{#net6.0}}6.0.19 {{/net6.0}}{{#net7.0}}7.0.11 {{/net7.0}}{{#net8.0}}8.0.0 {{/net8.0}}{{/lambda.first}}" />
|
||||
{{/supportsRetry}}
|
||||
{{/useGenericHost}}
|
||||
{{^useGenericHost}}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="{{^netStandard}}17.7.2{{/netStandard}}{{#netStandard}}15.9.2{{/netStandard}}" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="{{^netStandard}}17.8.0{{/netStandard}}{{#netStandard}}15.9.2{{/netStandard}}" />
|
||||
<PackageReference Include="xunit" Version="{{^netStandard}}2.6.1{{/netStandard}}{{#netStandard}}2.4.2{{/netStandard}}" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="{{^netStandard}}2.5.3{{/netStandard}}{{#netStandard}}2.4.5{{/netStandard}}" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
{{/minLength}}
|
||||
{{#maximum}}
|
||||
// {{{name}}} ({{{dataType}}}) maximum
|
||||
if (this.{{{name}}} > ({{{dataType}}}){{maximum}})
|
||||
if ({{#useGenericHost}}{{^required}}this.{{{name}}}Option.IsSet && {{/required}}{{/useGenericHost}}this.{{{name}}}{{#useGenericHost}}{{^required}}Option.Value{{/required}}{{/useGenericHost}} > ({{{dataType}}}){{maximum}})
|
||||
{
|
||||
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must be a value less than or equal to {{maximum}}.", new [] { "{{{name}}}" });
|
||||
}
|
||||
@@ -86,7 +86,7 @@
|
||||
{{/maximum}}
|
||||
{{#minimum}}
|
||||
// {{{name}}} ({{{dataType}}}) minimum
|
||||
if (this.{{{name}}} < ({{{dataType}}}){{minimum}})
|
||||
if ({{#useGenericHost}}{{^required}}this.{{{name}}}Option.IsSet && {{/required}}{{/useGenericHost}}this.{{{name}}}{{#useGenericHost}}{{^required}}Option.Value{{/required}}{{/useGenericHost}} < ({{{dataType}}}){{minimum}})
|
||||
{
|
||||
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must be a value greater than or equal to {{minimum}}.", new [] { "{{{name}}}" });
|
||||
}
|
||||
@@ -96,7 +96,7 @@
|
||||
{{^isByteArray}}
|
||||
{{#vendorExtensions.x-is-value-type}}
|
||||
{{#isNullable}}
|
||||
if (this.{{{name}}} != null){
|
||||
if (this.{{{name}}}{{#useGenericHost}}{{^required}}Option.Value{{/required}}{{/useGenericHost}} != null){
|
||||
{{#lambda.trimTrailingWithNewLine}}
|
||||
{{#lambda.indent4}}
|
||||
{{>ValidateRegex}}
|
||||
@@ -116,7 +116,7 @@
|
||||
{{/isNullable}}
|
||||
{{/vendorExtensions.x-is-value-type}}
|
||||
{{^vendorExtensions.x-is-value-type}}
|
||||
if (this.{{{name}}} != null) {
|
||||
if (this.{{{name}}}{{#useGenericHost}}{{^required}}Option.Value{{/required}}{{/useGenericHost}} != null) {
|
||||
{{#lambda.trimTrailingWithNewLine}}
|
||||
{{#lambda.indent4}}
|
||||
{{>ValidateRegex}}
|
||||
|
||||
@@ -169,7 +169,7 @@ func (c *{{classname}}Controller) {{nickname}}(w http.ResponseWriter, r *http.Re
|
||||
}
|
||||
{{/isInteger}}
|
||||
{{#isDateTime}}
|
||||
{{paramName}}Param, err := time.Parse(time.RFC3339, {{#routers}}{{#mux}}params["{{baseName}}"]{{/mux}}{{#chi}}chi.URLParam(r, "{{baseName}}"){{/chi}}{{/routers}})
|
||||
{{paramName}}Param, err := parseTime({{#routers}}{{#mux}}params["{{baseName}}"]{{/mux}}{{#chi}}chi.URLParam(r, "{{baseName}}"){{/chi}}{{/routers}})
|
||||
if err != nil {
|
||||
c.errorHandler(w, r, &ParsingError{Err: err}, nil)
|
||||
return
|
||||
@@ -180,8 +180,13 @@ func (c *{{classname}}Controller) {{nickname}}(w http.ResponseWriter, r *http.Re
|
||||
{{^isDouble}}
|
||||
{{^isLong}}
|
||||
{{^isInteger}}
|
||||
{{^isDateTime}}
|
||||
{{^isEnumOrRef}}
|
||||
{{paramName}}Param := {{#routers}}{{#mux}}params["{{baseName}}"]{{/mux}}{{#chi}}chi.URLParam(r, "{{baseName}}"){{/chi}}{{/routers}}
|
||||
if {{paramName}}Param == "" {
|
||||
c.errorHandler(w, r, &RequiredError{"{{baseName}}"}, nil)
|
||||
return
|
||||
}
|
||||
{{/isEnumOrRef}}
|
||||
{{#isEnumOrRef}}
|
||||
{{paramName}}Param, err := New{{dataType}}FromValue({{#routers}}{{#mux}}params["{{baseName}}"]{{/mux}}{{#chi}}chi.URLParam(r, "{{baseName}}"){{/chi}}{{/routers}})
|
||||
@@ -190,6 +195,7 @@ func (c *{{classname}}Controller) {{nickname}}(w http.ResponseWriter, r *http.Re
|
||||
return
|
||||
}
|
||||
{{/isEnumOrRef}}
|
||||
{{/isDateTime}}
|
||||
{{/isInteger}}
|
||||
{{/isLong}}
|
||||
{{/isDouble}}
|
||||
|
||||
@@ -16,6 +16,18 @@ from {{packageName}}.exceptions import ApiException, UnauthorizedException, Forb
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
SUPPORTED_SOCKS_PROXIES = {"socks5", "socks5h", "socks4", "socks4a"}
|
||||
|
||||
|
||||
def is_socks_proxy_url(url):
|
||||
if url is None:
|
||||
return False
|
||||
split_section = url.split("://")
|
||||
if len(split_section) < 2:
|
||||
return False
|
||||
else:
|
||||
return split_section[0].lower() in SUPPORTED_SOCKS_PROXIES
|
||||
|
||||
|
||||
class RESTResponse(io.IOBase):
|
||||
|
||||
@@ -71,17 +83,29 @@ class RESTClientObject:
|
||||
|
||||
# https pool manager
|
||||
if configuration.proxy:
|
||||
self.pool_manager = urllib3.ProxyManager(
|
||||
num_pools=pools_size,
|
||||
maxsize=maxsize,
|
||||
cert_reqs=cert_reqs,
|
||||
ca_certs=configuration.ssl_ca_cert,
|
||||
cert_file=configuration.cert_file,
|
||||
key_file=configuration.key_file,
|
||||
proxy_url=configuration.proxy,
|
||||
proxy_headers=configuration.proxy_headers,
|
||||
**addition_pool_args
|
||||
)
|
||||
if is_socks_proxy_url(configuration.proxy):
|
||||
from urllib3.contrib.socks import SOCKSProxyManager
|
||||
self.pool_manager = SOCKSProxyManager(
|
||||
cert_reqs=cert_reqs,
|
||||
ca_certs=configuration.ssl_ca_cert,
|
||||
cert_file=configuration.cert_file,
|
||||
key_file=configuration.key_file,
|
||||
proxy_url=configuration.proxy,
|
||||
headers=configuration.proxy_headers,
|
||||
**addition_pool_args
|
||||
)
|
||||
else:
|
||||
self.pool_manager = urllib3.ProxyManager(
|
||||
num_pools=pools_size,
|
||||
maxsize=maxsize,
|
||||
cert_reqs=cert_reqs,
|
||||
ca_certs=configuration.ssl_ca_cert,
|
||||
cert_file=configuration.cert_file,
|
||||
key_file=configuration.key_file,
|
||||
proxy_url=configuration.proxy,
|
||||
proxy_headers=configuration.proxy_headers,
|
||||
**addition_pool_args
|
||||
)
|
||||
else:
|
||||
self.pool_manager = urllib3.PoolManager(
|
||||
num_pools=pools_size,
|
||||
|
||||
@@ -289,7 +289,7 @@ class ApiClient:
|
||||
|
||||
def response_deserialize(
|
||||
self,
|
||||
response_data=None,
|
||||
response_data: rest.RESTResponse = None,
|
||||
response_types_map=None
|
||||
) -> ApiResponse:
|
||||
"""Deserializes response into an object.
|
||||
@@ -304,39 +304,29 @@ class ApiClient:
|
||||
# if not found, look for '1XX', '2XX', etc.
|
||||
response_type = response_types_map.get(str(response_data.status)[0] + "XX", None)
|
||||
|
||||
if not 200 <= response_data.status <= 299:
|
||||
if response_data.status == 400:
|
||||
raise BadRequestException(http_resp=response_data)
|
||||
|
||||
if response_data.status == 401:
|
||||
raise UnauthorizedException(http_resp=response_data)
|
||||
|
||||
if response_data.status == 403:
|
||||
raise ForbiddenException(http_resp=response_data)
|
||||
|
||||
if response_data.status == 404:
|
||||
raise NotFoundException(http_resp=response_data)
|
||||
|
||||
if 500 <= response_data.status <= 599:
|
||||
raise ServiceException(http_resp=response_data)
|
||||
raise ApiException(http_resp=response_data)
|
||||
|
||||
# deserialize response data
|
||||
|
||||
if response_type == "bytearray":
|
||||
return_data = response_data.data
|
||||
elif response_type is None:
|
||||
return_data = None
|
||||
elif response_type == "file":
|
||||
return_data = self.__deserialize_file(response_data)
|
||||
else:
|
||||
match = None
|
||||
content_type = response_data.getheader('content-type')
|
||||
if content_type is not None:
|
||||
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type)
|
||||
encoding = match.group(1) if match else "utf-8"
|
||||
response_text = response_data.data.decode(encoding)
|
||||
return_data = self.deserialize(response_text, response_type)
|
||||
response_text = None
|
||||
return_data = None
|
||||
try:
|
||||
if response_type == "bytearray":
|
||||
return_data = response_data.data
|
||||
elif response_type == "file":
|
||||
return_data = self.__deserialize_file(response_data)
|
||||
elif response_type is not None:
|
||||
match = None
|
||||
content_type = response_data.getheader('content-type')
|
||||
if content_type is not None:
|
||||
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type)
|
||||
encoding = match.group(1) if match else "utf-8"
|
||||
response_text = response_data.data.decode(encoding)
|
||||
return_data = self.deserialize(response_text, response_type)
|
||||
finally:
|
||||
if not 200 <= response_data.status <= 299:
|
||||
raise ApiException.from_response(
|
||||
http_resp=response_data,
|
||||
body=response_text,
|
||||
data=return_data,
|
||||
)
|
||||
|
||||
return ApiResponse(
|
||||
status_code = response_data.status,
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
# coding: utf-8
|
||||
|
||||
{{>partial_header}}
|
||||
from typing import Any, Optional
|
||||
|
||||
from typing_extensions import Self
|
||||
|
||||
class OpenApiException(Exception):
|
||||
"""The base exception class for all OpenAPIExceptions"""
|
||||
@@ -91,17 +94,56 @@ class ApiKeyError(OpenApiException, KeyError):
|
||||
|
||||
class ApiException(OpenApiException):
|
||||
|
||||
def __init__(self, status=None, reason=None, http_resp=None) -> None:
|
||||
def __init__(
|
||||
self,
|
||||
status=None,
|
||||
reason=None,
|
||||
http_resp=None,
|
||||
*,
|
||||
body: Optional[str] = None,
|
||||
data: Optional[Any] = None,
|
||||
) -> None:
|
||||
self.status = status
|
||||
self.reason = reason
|
||||
self.body = body
|
||||
self.data = data
|
||||
self.headers = None
|
||||
|
||||
if http_resp:
|
||||
self.status = http_resp.status
|
||||
self.reason = http_resp.reason
|
||||
self.body = http_resp.data.decode('utf-8')
|
||||
if self.status is None:
|
||||
self.status = http_resp.status
|
||||
if self.reason is None:
|
||||
self.reason = http_resp.reason
|
||||
if self.body is None:
|
||||
try:
|
||||
self.body = http_resp.data.decode('utf-8')
|
||||
except Exception:
|
||||
pass
|
||||
self.headers = http_resp.getheaders()
|
||||
else:
|
||||
self.status = status
|
||||
self.reason = reason
|
||||
self.body = None
|
||||
self.headers = None
|
||||
|
||||
@classmethod
|
||||
def from_response(
|
||||
cls,
|
||||
*,
|
||||
http_resp,
|
||||
body: Optional[str],
|
||||
data: Optional[Any],
|
||||
) -> Self:
|
||||
if http_resp.status == 400:
|
||||
raise BadRequestException(http_resp=http_resp, body=body, data=data)
|
||||
|
||||
if http_resp.status == 401:
|
||||
raise UnauthorizedException(http_resp=http_resp, body=body, data=data)
|
||||
|
||||
if http_resp.status == 403:
|
||||
raise ForbiddenException(http_resp=http_resp, body=body, data=data)
|
||||
|
||||
if http_resp.status == 404:
|
||||
raise NotFoundException(http_resp=http_resp, body=body, data=data)
|
||||
|
||||
if 500 <= http_resp.status <= 599:
|
||||
raise ServiceException(http_resp=http_resp, body=body, data=data)
|
||||
raise ApiException(http_resp=http_resp, body=body, data=data)
|
||||
|
||||
def __str__(self):
|
||||
"""Custom error messages for exception"""
|
||||
@@ -111,38 +153,30 @@ class ApiException(OpenApiException):
|
||||
error_message += "HTTP response headers: {0}\n".format(
|
||||
self.headers)
|
||||
|
||||
if self.body:
|
||||
error_message += "HTTP response body: {0}\n".format(self.body)
|
||||
if self.data or self.body:
|
||||
error_message += "HTTP response body: {0}\n".format(self.data or self.body)
|
||||
|
||||
return error_message
|
||||
|
||||
class BadRequestException(ApiException):
|
||||
|
||||
def __init__(self, status=None, reason=None, http_resp=None) -> None:
|
||||
super(BadRequestException, self).__init__(status, reason, http_resp)
|
||||
class BadRequestException(ApiException):
|
||||
pass
|
||||
|
||||
|
||||
class NotFoundException(ApiException):
|
||||
|
||||
def __init__(self, status=None, reason=None, http_resp=None) -> None:
|
||||
super(NotFoundException, self).__init__(status, reason, http_resp)
|
||||
pass
|
||||
|
||||
|
||||
class UnauthorizedException(ApiException):
|
||||
|
||||
def __init__(self, status=None, reason=None, http_resp=None) -> None:
|
||||
super(UnauthorizedException, self).__init__(status, reason, http_resp)
|
||||
pass
|
||||
|
||||
|
||||
class ForbiddenException(ApiException):
|
||||
|
||||
def __init__(self, status=None, reason=None, http_resp=None) -> None:
|
||||
super(ForbiddenException, self).__init__(status, reason, http_resp)
|
||||
pass
|
||||
|
||||
|
||||
class ServiceException(ApiException):
|
||||
|
||||
def __init__(self, status=None, reason=None, http_resp=None) -> None:
|
||||
super(ServiceException, self).__init__(status, reason, http_resp)
|
||||
pass
|
||||
|
||||
|
||||
def render_path(path_to_item):
|
||||
|
||||
@@ -38,7 +38,8 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
|
||||
any_of_schemas: List[str] = Literal[{{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ANY_OF_SCHEMAS]
|
||||
|
||||
model_config = {
|
||||
"validate_assignment": True
|
||||
"validate_assignment": True,
|
||||
"protected_namespaces": (),
|
||||
}
|
||||
{{#discriminator}}
|
||||
|
||||
|
||||
@@ -82,7 +82,8 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
|
||||
|
||||
model_config = {
|
||||
"populate_by_name": True,
|
||||
"validate_assignment": True
|
||||
"validate_assignment": True,
|
||||
"protected_namespaces": (),
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -34,7 +34,8 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
|
||||
one_of_schemas: List[str] = Literal[{{#oneOf}}"{{.}}"{{^-last}}, {{/-last}}{{/oneOf}}]
|
||||
|
||||
model_config = {
|
||||
"validate_assignment": True
|
||||
"validate_assignment": True,
|
||||
"protected_namespaces": (),
|
||||
}
|
||||
|
||||
{{#discriminator}}
|
||||
|
||||
@@ -44,6 +44,9 @@
|
||||
)
|
||||
|
||||
_response_types_map: Dict[str, Optional[str]] = {
|
||||
{{#returnType}}{{#responses}}{{^isWildcard}}'{{code}}': {{#dataType}}"{{.}}"{{/dataType}}{{^dataType}}None{{/dataType}}{{/isWildcard}}{{^-last}},{{/-last}}
|
||||
{{/responses}}{{/returnType}}
|
||||
{{#responses}}
|
||||
{{^isWildcard}}
|
||||
'{{code}}': {{#dataType}}"{{.}}"{{/dataType}}{{^dataType}}None{{/dataType}},
|
||||
{{/isWildcard}}
|
||||
{{/responses}}
|
||||
}
|
||||
@@ -11,8 +11,20 @@ import urllib3
|
||||
|
||||
from {{packageName}}.exceptions import ApiException, ApiValueError
|
||||
|
||||
SUPPORTED_SOCKS_PROXIES = {"socks5", "socks5h", "socks4", "socks4a"}
|
||||
RESTResponseType = urllib3.HTTPResponse
|
||||
|
||||
|
||||
def is_socks_proxy_url(url):
|
||||
if url is None:
|
||||
return False
|
||||
split_section = url.split("://")
|
||||
if len(split_section) < 2:
|
||||
return False
|
||||
else:
|
||||
return split_section[0].lower() in SUPPORTED_SOCKS_PROXIES
|
||||
|
||||
|
||||
class RESTResponse(io.IOBase):
|
||||
|
||||
def __init__(self, resp) -> None:
|
||||
@@ -67,15 +79,27 @@ class RESTClientObject:
|
||||
|
||||
# https pool manager
|
||||
if configuration.proxy:
|
||||
self.pool_manager = urllib3.ProxyManager(
|
||||
cert_reqs=cert_reqs,
|
||||
ca_certs=configuration.ssl_ca_cert,
|
||||
cert_file=configuration.cert_file,
|
||||
key_file=configuration.key_file,
|
||||
proxy_url=configuration.proxy,
|
||||
proxy_headers=configuration.proxy_headers,
|
||||
**addition_pool_args
|
||||
)
|
||||
if is_socks_proxy_url(configuration.proxy):
|
||||
from urllib3.contrib.socks import SOCKSProxyManager
|
||||
self.pool_manager = SOCKSProxyManager(
|
||||
cert_reqs=cert_reqs,
|
||||
ca_certs=configuration.ssl_ca_cert,
|
||||
cert_file=configuration.cert_file,
|
||||
key_file=configuration.key_file,
|
||||
proxy_url=configuration.proxy,
|
||||
headers=configuration.proxy_headers,
|
||||
**addition_pool_args
|
||||
)
|
||||
else:
|
||||
self.pool_manager = urllib3.ProxyManager(
|
||||
cert_reqs=cert_reqs,
|
||||
ca_certs=configuration.ssl_ca_cert,
|
||||
cert_file=configuration.cert_file,
|
||||
key_file=configuration.key_file,
|
||||
proxy_url=configuration.proxy,
|
||||
proxy_headers=configuration.proxy_headers,
|
||||
**addition_pool_args
|
||||
)
|
||||
else:
|
||||
self.pool_manager = urllib3.PoolManager(
|
||||
cert_reqs=cert_reqs,
|
||||
@@ -198,6 +222,15 @@ class RESTClientObject:
|
||||
headers=headers,
|
||||
preload_content=False
|
||||
)
|
||||
elif headers['Content-Type'] == 'text/plain' and isinstance(body, bool):
|
||||
request_body = "true" if body else "false"
|
||||
r = self.pool_manager.request(
|
||||
method,
|
||||
url,
|
||||
body=request_body,
|
||||
preload_content=False,
|
||||
timeout=timeout,
|
||||
headers=headers)
|
||||
else:
|
||||
# Cannot generate the request from given parameters
|
||||
msg = """Cannot prepare a request message for provided
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
{{^withSeparateModelsAndApi}}
|
||||
import type { Configuration } from './configuration';
|
||||
import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
|
||||
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
|
||||
import globalAxios from 'axios';
|
||||
{{#withNodeImports}}
|
||||
// URLSearchParams not necessarily used
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user