Compare commits

..

1 Commits

Author SHA1 Message Date
William Cheng
78f82ddc5a test publish 2023-02-02 18:19:26 +08:00
2453 changed files with 18165 additions and 48822 deletions

View File

@@ -40,7 +40,7 @@ jobs:
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('samples/**/pubspec.yaml') }}
- uses: dart-lang/setup-dart@v1
with:
sdk: 2.15.0
sdk: 2.14.0
- name: Run tests
uses: ./.github/actions/run-samples
with:

View File

@@ -1,38 +0,0 @@
name: Python Client (Echo API)
on:
push:
paths:
- samples/client/echo_api/python-nextgen/**
pull_request:
paths:
- samples/client/echo_api/python-nextgen/**
jobs:
build:
name: Test Python client
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sample:
# clients
- samples/client/echo_api/python-nextgen
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.7'
- name: Setup node.js
uses: actions/setup-node@v3
- name: Run echo server
run: |
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server
(cd http-echo-server && npm install && npm start &)
- name: Install
working-directory: ${{ matrix.sample }}
run: |
pip install -r requirements.txt
pip install -r test-requirements.txt
- name: Test
working-directory: ${{ matrix.sample }}
run: python -m pytest

View File

@@ -150,7 +150,7 @@ script:
- docker buildx version
# run integration tests defined in maven pom.xml
# WARN: Travis will timeout after 10 minutes of no stdout/stderr activity, which is problematic with mvn --quiet.
- mvn -e --no-snapshot-updates --quiet --batch-mode --show-version clean install -Dorg.slf4j.simpleLogger.defaultLogLevel=error
#- mvn -e --no-snapshot-updates --quiet --batch-mode --show-version clean install -Dorg.slf4j.simpleLogger.defaultLogLevel=error
#- mvn -e --no-snapshot-updates --quiet --batch-mode --show-version verify -Psamples -Dorg.slf4j.simpleLogger.defaultLogLevel=error
after_success:
# push to maven repo
@@ -216,14 +216,12 @@ after_success:
fi;
fi;
# publish latest website, variables below are secure environment variables which are unavailable to PRs from forks.
#- if [ "$TRAVIS_BRANCH" = "master" ] && [ -z $TRAVIS_TAG ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
# cd website;
# git config --global user.name "${GH_NAME}";
# git config --global user.email "${GH_EMAIL}";
# echo "machine github.com login ${GH_NAME} password ${GH_TOKEN}" > ~/.netrc;
# yarn install;
# GIT_USER="${GH_NAME}" yarn run publish-gh-pages;
# fi;
- cd website;
git config --global user.name "${GH_NAME}";
git config --global user.email "${GH_EMAIL}";
echo "machine github.com login ${GH_NAME} password ${GH_TOKEN}" > ~/.netrc;
yarn install;
GIT_USER="${GH_NAME}" yarn run publish-gh-pages;
env:
- DOCKER_GENERATOR_IMAGE_NAME=openapitools/openapi-generator-online DOCKER_CODEGEN_CLI_IMAGE_NAME=openapitools/openapi-generator-cli NODE_ENV=test CC=gcc-5 CXX=g++-5

View File

@@ -35,11 +35,11 @@ elif [ "$NODE_INDEX" = "2" ]; then
#sudo apt-get -y build-dep libcurl4-gnutls-dev
#sudo apt-get -y install libcurl4-gnutls-dev
# Install golang version 1.18
# Install golang version 1.14
go version
sudo mkdir /usr/local/go1.18
wget -c https://dl.google.com/go/go1.18.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local/go1.18
export PATH="/usr/local/go1.18/go/bin:$PATH"
sudo mkdir /usr/local/go1.14
wget -c https://dl.google.com/go/go1.14.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local/go1.14
export PATH="/usr/local/go1.14/go/bin:$PATH"
go version
# run integration tests

View File

@@ -20,6 +20,7 @@
[![Integration Test2](https://circleci.com/gh/OpenAPITools/openapi-generator.svg?style=shield)](https://circleci.com/gh/OpenAPITools/openapi-generator)
[![Windows Test](https://ci.appveyor.com/api/projects/status/github/openapitools/openapi-generator?branch=master&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/openapi-generator)
[![Bitrise](https://img.shields.io/bitrise/4a2b10a819d12b67/master?label=bitrise%3A%20Swift+4,5&token=859FMDR8QHwabCzwvZK6vQ)](https://app.bitrise.io/app/4a2b10a819d12b67)
[![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/openapitools/openapi-generator/Check%20Supported%20Java%20Versions/master?label=Check%20Supported%20Java%20Versions&logo=github&logoColor=green)](https://github.com/OpenAPITools/openapi-generator/actions?query=workflow%3A%22Check+Supported+Java+Versions%22)
[7.0.x](https://github.com/OpenAPITools/openapi-generator/tree/7.0.x) (`7.0.x`):
[![Build Status](https://img.shields.io/travis/OpenAPITools/openapi-generator/7.0.x.svg?label=Integration%20Test)](https://travis-ci.com/OpenAPITools/openapi-generator)
@@ -76,13 +77,13 @@ If you find OpenAPI Generator useful for work, please consider asking your compa
## Overview
OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an [OpenAPI Spec](https://github.com/OAI/OpenAPI-Specification) (both 2.0 and 3.0 are supported). Currently, the following languages/frameworks are supported:
| | Languages/Frameworks |
| -------------------------------- |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.1, .NET Core 3.1, .NET 5.0. Libraries: RestSharp, GenericHost, HttpClient), **C++** (Arduino, cpp-restsdk, Qt5, Tizen, Unreal Engine 4), **Clojure**, **Crystal**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Apache HttpClient 4.x, Apache HttpClient 5.x, Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client, MicroProfile Rest Client, Helidon), **Jetbrains HTTP Client**, **Julia**, **k6**, **Kotlin**, **Lua**, **Nim**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types, Apollo GraphQL DataStore), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (hyper, reqwest, rust-server), **Scala** (akka, http4s, scalaz, sttp, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x, 5.x), **Typescript** (AngularJS, Angular (2.x - 13.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs) |
| **Server stubs** | **Ada**, **C#** (ASP.NET Core, Azure Functions), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin, Echo), **Haskell** (Servant, Yesod), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/), [Apache Camel](https://camel.apache.org/), [Helidon](https://helidon.io/)), **Julia**, **Kotlin** (Spring Boot, Ktor, Vertx), **PHP** (Laravel, Lumen, [Mezzio (fka Zend Expressive)](https://github.com/mezzio/mezzio), Slim, Silex, [Symfony](https://symfony.com/)), **Python** (FastAPI, Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** ([rust-server](https://openapi-generator.tech/docs/generators/rust-server/)), **Scala** (Akka, [Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra) |
| **API documentation generators** | **HTML**, **Confluence Wiki**, **Asciidoc**, **Markdown**, **PlantUML** |
| **Configuration files** | [**Apache2**](https://httpd.apache.org/) |
| **Others** | **GraphQL**, **JMeter**, **Ktorm**, **MySQL Schema**, **Protocol Buffer**, **WSDL** |
| | Languages/Frameworks |
| -------------------------------- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.1, .NET Core 3.1, .NET 5.0. Libraries: RestSharp, GenericHost, HttpClient), **C++** (Arduino, cpp-restsdk, Qt5, Tizen, Unreal Engine 4), **Clojure**, **Crystal**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Apache HttpClient, Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client, MicroProfile Rest Client, Helidon), **Jetbrains HTTP Client**, **Julia**, **k6**, **Kotlin**, **Lua**, **Nim**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types, Apollo GraphQL DataStore), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (hyper, reqwest, rust-server), **Scala** (akka, http4s, scalaz, sttp, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x, 5.x), **Typescript** (AngularJS, Angular (2.x - 13.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs) |
| **Server stubs** | **Ada**, **C#** (ASP.NET Core, Azure Functions), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin, Echo), **Haskell** (Servant, Yesod), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/), [Apache Camel](https://camel.apache.org/), [Helidon](https://helidon.io/)), **Julia**, **Kotlin** (Spring Boot, Ktor, Vertx), **PHP** (Laravel, Lumen, [Mezzio (fka Zend Expressive)](https://github.com/mezzio/mezzio), Slim, Silex, [Symfony](https://symfony.com/)), **Python** (FastAPI, Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** ([rust-server](https://openapi-generator.tech/docs/generators/rust-server/)), **Scala** (Akka, [Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra) |
| **API documentation generators** | **HTML**, **Confluence Wiki**, **Asciidoc**, **Markdown**, **PlantUML** |
| **Configuration files** | [**Apache2**](https://httpd.apache.org/) |
| **Others** | **GraphQL**, **JMeter**, **Ktorm**, **MySQL Schema**, **Protocol Buffer**, **WSDL** |
## Table of contents
@@ -121,7 +122,7 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
| OpenAPI Generator Version | Release Date | Notes |
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------------------------------------- |
| 7.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.0.0-SNAPSHOT/) | Feb/Mar 2023 | Major release with breaking changes (no fallback) |
| 6.4.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/6.4.0-SNAPSHOT/) | 05.12.2022 | Minor release with breaking changes (with fallback) |
| 6.4.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/6.3.0-SNAPSHOT/) | 05.12.2022 | Minor release with breaking changes (with fallback) |
| [6.3.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v6.3.0) (latest stable release) | 01.02.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) |
@@ -130,8 +131,6 @@ OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0
For old releases, please refer to the [**Release**](https://github.com/OpenAPITools/openapi-generator/releases) page.
For decomissioned generators/libraries/frameworks, please refer to [the "Decommission" label](https://github.com/OpenAPITools/openapi-generator/issues?q=label%3ADecommission+is%3Amerged+) in the pull request page.
## [1.2 - Artifacts on Maven Central](#table-of-contents)
You can find our released artifacts on maven central:
@@ -886,8 +885,6 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- 2022-10-26 - [Quarkus Insights #106: Quarkiverse Extension Spotlight: OpenApi Generator](https://www.youtube.com/watch?v=_s_if69t2iQ) by [Quarkusio](https://www.youtube.com/c/Quarkusio)
- 2022-11-28 - [The REST API implementation flow](https://tmsvr.com/openapi-code-generation-for-rest-apis/) by [Imre Tömösvári](https://tmsvr.com/author/imre/)
- 2022-12-13 - [API-First with Spring WebFlux and OpenAPI Generator](https://boottechnologies-ci.medium.com/api-first-with-spring-webflux-and-openapi-generator-38b7804c4ed4) by [Eric Anicet](https://boottechnologies-ci.medium.com/)
- 2023-01-06 - [Major Improvements with Helidon and OpenAPI](https://medium.com/helidon/major-improvements-with-helidon-and-openapi-f76a0951508e) by [Tim Quinn](https://medium.com/@tquinno600)
- 2023-02-02 - [Replacing Postman with the Jetbrains HTTP Client](https://lengrand.fr/replacing-postman-in-seconds-with-the-jetbrains-http-client/) by [julien Lengrand-Lambert](https://github.com/jlengrand)
## [6 - About Us](#table-of-contents)
@@ -957,7 +954,7 @@ Here is a list of template creators:
* Java (Google APIs Client Library): @charlescapps
* Java (Rest-assured): @viclovsky
* Java (Java 11 Native HTTP client): @bbdouglas
* Java (Apache HttpClient 5.x): @harrywhite4 @andrevegas
* Java (Apache HttpClient): @harrywhite4
* Java (Helidon): @spericas @tjquinno @tvallin
* Javascript/NodeJS: @jfiala
* JavaScript (Apollo DataSource): @erithmetic
@@ -1137,7 +1134,7 @@ If you want to join the committee, please kindly apply by sending an email to te
| Perl | @wing328 (2017/07) [:heart:](https://www.patreon.com/wing328) @yue9944882 (2019/06) |
| PHP | @jebentier (2017/07), @dkarlovi (2017/07), @mandrean (2017/08), @jfastnacht (2017/09), [@ybelenko](https://github.com/ybelenko) (2018/07), @renepardon (2018/12) |
| PowerShell | @wing328 (2020/05) |
| Python | @spacether (2019/11) [:heart:][spacether sponsorship] @krjakbrjak (2023/02) |
| Python | @spacether (2019/11) [:heart:][spacether sponsorship] |
| R | @Ramanth (2019/07) @saigiridhar21 (2019/07) |
| Ruby | @cliffano (2017/07) @zlx (2017/09) @autopp (2019/02) |
| Rust | @frol (2017/07) @farcaller (2017/08) @richardwhiuk (2019/07) @paladinzh (2020/05) @jacob-pro (2022/10) |

View File

@@ -15,4 +15,3 @@ additionalProperties:
camelUseDefaultValidationErrorProcessor: true
camelRestClientRequestValidation: true
camelSecurityDefinitions: true
implicitHeaders: true

View File

@@ -1,11 +0,0 @@
generatorName: jaxrs-spec
outputDir: samples/server/petstore/jaxrs-spec-jakarta
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/spec
additionalProperties:
artifactId: jaxrs-spec-petstore-server-jakarta
serializableModel: "true"
hideGenerationTimestamp: "true"
implicitHeadersRegex: (api_key|enum_header_string)
generateBuilders: "true"
useJakartaEe: "true"

View File

@@ -5,4 +5,3 @@ templateDir: modules/openapi-generator/src/main/resources/python-nextgen
library: asyncio
additionalProperties:
packageName: petstore_api
floatStrictType: false

View File

@@ -1,7 +0,0 @@
generatorName: python-nextgen
outputDir: samples/client/echo_api/python-nextgen
inputSpec: modules/openapi-generator/src/test/resources/3_0/echo_api.yaml
templateDir: modules/openapi-generator/src/main/resources/python-nextgen
additionalProperties:
hideGenerationTimestamp: "true"
allowStringInDateTimeParameters: true

View File

@@ -11,7 +11,7 @@ title: Documentation for the dart-dio Generator
| generator type | CLIENT | |
| generator language | Dart | |
| generator default templating engine | mustache | |
| helpTxt | Generates a Dart Dio client library. | |
| helpTxt | Generates a Dart Dio client library with null-safety. | |
## CONFIG OPTIONS
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.

View File

@@ -0,0 +1,214 @@
---
title: Config Options for go-experimental
sidebar_label: go-experimental
---
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|disallowAdditionalPropertiesIfNotPresent|Specify the behavior when the 'additionalProperties' keyword is not present in the OAS document. If false: the 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications. If true: when the 'additionalProperties' keyword is not present in a schema, the value of 'additionalProperties' is set to false, i.e. no additional properties are allowed. Note: this mode is not compliant with the JSON schema specification. This is the original openapi-generator behavior.This setting is currently ignored for OAS 2.0 documents: 1) When the 'additionalProperties' keyword is not present in a 2.0 schema, additional properties are NOT allowed. 2) Boolean values of the 'additionalProperties' keyword are ignored. It's as if additional properties are NOT allowed.Note: the root cause are issues #1369 and #1371, which must be resolved in the swagger-parser project.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>when the 'additionalProperties' keyword is not present in a schema, the value of 'additionalProperties' is automatically set to false, i.e. no additional properties are allowed. Note: this mode is not compliant with the JSON schema specification. This is the original openapi-generator behavior.</dd></dl>|true|
|enumClassPrefix|Prefix enum with class name| |false|
|generateInterfaces|Generate interfaces for api classes| |false|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|isGoSubmodule|whether the generated Go module is a submodule| |false|
|packageName|Go package name (convention: lowercase).| |openapi|
|packageVersion|Go package version.| |1.0.0|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|structPrefix|whether to prefix struct with the class name. e.g. DeletePetOpts =&gt; PetApiDeletePetOpts| |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|
|skipReadonlyPropertiesInInt|Skip default values to the readOnly properties in the model init function./ /false/
|withAWSV4Signature|whether to include AWS v4 signature support| |false|
|withGoCodegenComment|whether to include Go codegen comment to disable Go Lint and collapse by default in GitHub PRs and diffs| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
## IMPORT MAPPING
| Type/Alias | Imports |
| ---------- | ------- |
## INSTANTIATION TYPES
| Type/Alias | Instantiated By |
| ---------- | --------------- |
## LANGUAGE PRIMITIVES
<ul class="column-ul">
<li>bool</li>
<li>byte</li>
<li>complex128</li>
<li>complex64</li>
<li>float32</li>
<li>float64</li>
<li>int</li>
<li>int32</li>
<li>int64</li>
<li>interface{}</li>
<li>map[string]interface{}</li>
<li>rune</li>
<li>string</li>
<li>uint</li>
<li>uint32</li>
<li>uint64</li>
</ul>
## RESERVED WORDS
<ul class="column-ul">
<li>bool</li>
<li>break</li>
<li>byte</li>
<li>case</li>
<li>chan</li>
<li>complex128</li>
<li>complex64</li>
<li>const</li>
<li>continue</li>
<li>default</li>
<li>defer</li>
<li>else</li>
<li>error</li>
<li>fallthrough</li>
<li>float32</li>
<li>float64</li>
<li>for</li>
<li>func</li>
<li>go</li>
<li>goto</li>
<li>if</li>
<li>import</li>
<li>int</li>
<li>int16</li>
<li>int32</li>
<li>int64</li>
<li>int8</li>
<li>interface</li>
<li>map</li>
<li>nil</li>
<li>package</li>
<li>range</li>
<li>return</li>
<li>rune</li>
<li>select</li>
<li>string</li>
<li>struct</li>
<li>switch</li>
<li>type</li>
<li>uint</li>
<li>uint16</li>
<li>uint32</li>
<li>uint64</li>
<li>uint8</li>
<li>uintptr</li>
<li>var</li>
</ul>
## FEATURE SET
### Client Modification Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|BasePath|✓|ToolingExtension
|Authorizations|✗|ToolingExtension
|UserAgent|✓|ToolingExtension
|MockServer|✗|ToolingExtension
### Data Type Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Custom|✗|OAS2,OAS3
|Int32|✓|OAS2,OAS3
|Int64|✓|OAS2,OAS3
|Float|✓|OAS2,OAS3
|Double|✓|OAS2,OAS3
|Decimal|✓|ToolingExtension
|String|✓|OAS2,OAS3
|Byte|✓|OAS2,OAS3
|Binary|✓|OAS2,OAS3
|Boolean|✓|OAS2,OAS3
|Date|✓|OAS2,OAS3
|DateTime|✓|OAS2,OAS3
|Password|✓|OAS2,OAS3
|File|✓|OAS2
|Array|✓|OAS2,OAS3
|Maps|✓|ToolingExtension
|CollectionFormat|✓|OAS2
|CollectionFormatMulti|✓|OAS2
|Enum|✓|OAS2,OAS3
|ArrayOfEnum|✓|ToolingExtension
|ArrayOfModel|✓|ToolingExtension
|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
|ArrayOfCollectionOfModel|✓|ToolingExtension
|ArrayOfCollectionOfEnum|✓|ToolingExtension
|MapOfEnum|✓|ToolingExtension
|MapOfModel|✓|ToolingExtension
|MapOfCollectionOfPrimitives|✓|ToolingExtension
|MapOfCollectionOfModel|✓|ToolingExtension
|MapOfCollectionOfEnum|✓|ToolingExtension
### Documentation Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Readme|✓|ToolingExtension
|Model|✓|ToolingExtension
|Api|✓|ToolingExtension
### Global Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Host|✓|OAS2,OAS3
|BasePath|✓|OAS2,OAS3
|Info|✓|OAS2,OAS3
|Schemes|✗|OAS2,OAS3
|PartialSchemes|✓|OAS2,OAS3
|Consumes|✓|OAS2
|Produces|✓|OAS2
|ExternalDocumentation|✓|OAS2,OAS3
|Examples|✓|OAS2,OAS3
|XMLStructureDefinitions|✗|OAS2,OAS3
|MultiServer|✗|OAS3
|ParameterizedServer|✓|OAS3
|ParameterStyling|✗|OAS3
|Callbacks|✗|OAS3
|LinkObjects|✗|OAS3
### Parameter Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Path|✓|OAS2,OAS3
|Query|✓|OAS2,OAS3
|Header|✓|OAS2,OAS3
|Body|✓|OAS2
|FormUnencoded|✓|OAS2
|FormMultipart|✓|OAS2
|Cookie|✓|OAS3
### Schema Support Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|Simple|✓|OAS2,OAS3
|Composite|✓|OAS2,OAS3
|Polymorphism|✗|OAS2,OAS3
|Union|✗|OAS3
### Security Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|BasicAuth|✓|OAS2,OAS3
|ApiKey|✓|OAS2,OAS3
|OpenIDConnect|✗|OAS3
|BearerToken|✗|OAS3
|OAuth2_Implicit|✓|OAS2,OAS3
|OAuth2_Password|✗|OAS2,OAS3
|OAuth2_ClientCredentials|✗|OAS2,OAS3
|OAuth2_AuthorizationCode|✗|OAS2,OAS3
### Wire Format Feature
| Name | Supported | Defined By |
| ---- | --------- | ---------- |
|JSON|✓|OAS2,OAS3
|XML|✓|OAS2,OAS3
|PROTOBUF|✗|ToolingExtension
|Custom|✗|OAS2,OAS3

View File

@@ -57,11 +57,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|implicitHeadersRegex|Skip header parameters that matches given regex in the generated API methods using @ApiImplicitParams annotation. Note: this parameter is ignored when implicitHeaders=true| |null|
|invokerPackage|root package for generated code| |org.openapitools.client|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey3' or other HTTP libraries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x</dd><dt>**jersey3**</dt><dd>HTTP client: Jersey client 3.x. JSON processing: Jackson 2.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 10.x. JSON processing: Jackson 2.9.x. or Gson 2.x</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.10.x. Only for Java 8</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+</dd><dt>**microprofile**</dt><dd>HTTP client: Microprofile client 1.x. JSON processing: JSON-B or Jackson 2.9.x</dd><dt>**apache-httpclient**</dt><dd>HTTP client: Apache httpclient 5.x</dd></dl>|okhttp-gson|
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey3' or other HTTP libraries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x</dd><dt>**jersey3**</dt><dd>HTTP client: Jersey client 3.x. JSON processing: Jackson 2.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 10.x. JSON processing: Jackson 2.9.x. or Gson 2.x</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.10.x. Only for Java 8</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+</dd><dt>**microprofile**</dt><dd>HTTP client: Microprofile client 1.x. JSON processing: JSON-B</dd><dt>**apache-httpclient**</dt><dd>HTTP client: Apache httpclient 4.x</dd></dl>|okhttp-gson|
|licenseName|The name of the license| |Unlicense|
|licenseUrl|The URL of the license| |http://unlicense.org|
|microprofileFramework|Framework for microprofile. Possible values &quot;kumuluzee&quot;| |null|
|microprofileMutiny|Whether to use async types for microprofile (currently only Smallrye Mutiny is supported).| |null|
|microprofileRestClientVersion|Version of MicroProfile Rest Client API.| |null|
|modelPackage|package for generated models| |org.openapitools.client.model|
|openApiNullable|Enable OpenAPI Jackson Nullable library| |true|

View File

@@ -19,9 +19,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|allowStringInDateTimeParameters|Allow string as input to datetime/date parameters for backward compartibility.| |false|
|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|
|floatStrictType|Use strict type for float, i.e. StrictFloat or confloat(strict=true, ...)| |true|
|generateSourceCodeOnly|Specifies that only a library source code is to be generated.| |false|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|library|library template (sub-template) to use: asyncio, tornado (deprecated), urllib3| |urllib3|

View File

@@ -642,7 +642,7 @@ openapi-generator-cli generate -i petstore.yaml -g typescript-fetch -o out \
The `batch` command allows you to move all CLI arguments supported by the `generate` command into a YAML or JSON file.
*NOTE*: This command supports an additional `!include` property which may point to another "shared" file, the base path to which can be
modified by `--includes-base-dir`. Starting with 5.0.0, the `!batch` command supports multiple `!include` properties, either sequential or nested under other keys. In order to support multiple `!include` properties in a JSON file, the property name can have a suffix, e.g. `!include1`, `!include2`, etc. The suffix have no meaning other than providing unique property names.
modified by `--includes-base-dir`. Starting with 5.0.0, the `!batch` command supports multiple `!include` properties, either sequential or nested. In order to support multiple `!include` properties in a JSON file, the property name can have a suffix, e.g. `!include1`, `!include2`, etc. The suffix have no meaning other than providing unique property names.
```text
openapi-generator-cli help batch
@@ -697,11 +697,6 @@ additionalProperties:
x-ext-name: "Your Name"
EOF
# create nested "shared" config
cat > shared/nested.yaml <<EOF
useCompareNetObjects: "true"
EOF
# create "standard" configs
cat > kotlin.yaml <<EOF
'!include': 'shared/common.yaml'
@@ -719,7 +714,7 @@ outputDir: out/csharp-netcore
generatorName: csharp-netcore
additionalProperties:
packageGuid: "{321C8C3F-0156-40C1-AE42-D59761FB9B6C}"
'!include': 'shared/nested.yaml'
useCompareNetObjects: "true"
EOF
# Generate them

View File

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

View File

@@ -32,7 +32,6 @@ import java.util.stream.Stream;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.config.CodegenConfigurator;
import org.openapitools.codegen.config.MergedSpecBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,13 +57,6 @@ public class Generate extends OpenApiGeneratorCommand {
description = "location of the OpenAPI spec, as URL or file (required if not loaded via config using -c)")
private String spec;
@Option(name = "--input-spec-root-directory", title = "Folder with spec(s)",
description = "Local root folder with spec file(s)")
private String inputSpecRootDirectory;
@Option(name = "--merged-spec-filename", title = "Name of resulted merged specs file (used along with --input-spec-root-directory option)")
private String mergedFileName;
@Option(name = {"-t", "--template-dir"}, title = "template directory",
description = "folder containing the template files")
private String templateDir;
@@ -291,12 +283,6 @@ public class Generate extends OpenApiGeneratorCommand {
@Override
public void execute() {
if (StringUtils.isNotBlank(inputSpecRootDirectory)) {
spec = new MergedSpecBuilder(inputSpecRootDirectory, StringUtils.isBlank(mergedFileName) ? "_merged_spec" : mergedFileName)
.buildMergedSpec();
System.out.println("Merge input spec would be used - " + spec);
}
if (logToStderr != null) {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
Stream.of(Logger.ROOT_LOGGER_NAME, "io.swagger", "org.openapitools")

View File

@@ -52,10 +52,6 @@ public class OptionUtilsTest {
doTupleListTest("a=1,=,c=3", asList(Pair.of("a", "1"), Pair.of("c", "3")));
doTupleListTest("", emptyPairList());
doTupleListTest(null, emptyPairList());
doTupleListTest("a=1,b=2,c=\"3,4,5\"",
asList(Pair.of("a", "1"), Pair.of("b", "2"),
Pair.of("c", "\"3,4,5\"")));
}
private static void doTupleListTest(String input, List<Pair<String, String>> expectedResults) {

View File

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

View File

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

View File

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

View File

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

View File

@@ -39,7 +39,6 @@ import org.openapitools.codegen.CodegenConstants
import org.openapitools.codegen.DefaultGenerator
import org.openapitools.codegen.config.CodegenConfigurator
import org.openapitools.codegen.config.GlobalSettings
import org.openapitools.codegen.config.MergedSpecBuilder
/**
* A task which generates the desired code.
@@ -97,21 +96,6 @@ open class GenerateTask : DefaultTask() {
@PathSensitive(PathSensitivity.RELATIVE)
val inputSpec = project.objects.property<String>()
/**
* Local root folder with spec files
*/
@Optional
@get:InputFile
@PathSensitive(PathSensitivity.RELATIVE)
val inputSpecRootDirectory = project.objects.property<String>();
/**
* Name of the file that will contains all merged specs
*/
@Input
@Optional
val mergedFileName = project.objects.property<String>();
/**
* The remote Open API 2.0/3.x specification URL location.
*/
@@ -543,11 +527,6 @@ open class GenerateTask : DefaultTask() {
@Suppress("unused")
@TaskAction
fun doWork() {
inputSpecRootDirectory.ifNotEmpty { inputSpecRootDirectoryValue -> {
inputSpec.set(MergedSpecBuilder(inputSpecRootDirectoryValue, mergedFileName.get()).buildMergedSpec())
logger.info("Merge input spec would be used - {}", inputSpec.get())
}}
cleanupOutput.ifNotEmpty { cleanup ->
if (cleanup) {
project.delete(outputDir)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -20,7 +20,7 @@
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>6.4.0</version>
<version>6.4.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
@@ -125,6 +125,8 @@
<properties>
<swagger-annotations-version>1.5.8</swagger-annotations-version>
<spring-boot-starter-web.version>2.2.1.RELEASE</spring-boot-starter-web.version>
<springfox-version>2.8.0</springfox-version>
</properties>
</project>

View File

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

View File

@@ -59,7 +59,6 @@ import org.openapitools.codegen.DefaultGenerator;
import org.openapitools.codegen.auth.AuthParser;
import org.openapitools.codegen.config.CodegenConfigurator;
import org.openapitools.codegen.config.GlobalSettings;
import org.openapitools.codegen.config.MergedSpecBuilder;
import org.sonatype.plexus.build.incremental.BuildContext;
import org.sonatype.plexus.build.incremental.DefaultBuildContext;
import org.slf4j.Logger;
@@ -105,18 +104,6 @@ public class CodeGenMojo extends AbstractMojo {
@Parameter(name = "inputSpec", property = "openapi.generator.maven.plugin.inputSpec", required = true)
private String inputSpec;
/**
* Local root folder with spec files
*/
@Parameter(name = "inputSpecRootDirectory", property = "openapi.generator.maven.plugin.inputSpecRootDirectory")
private String inputSpecRootDirectory;
/**
* Name of the file that will contains all merged specs
*/
@Parameter(name = "mergedFileName", property = "openapi.generator.maven.plugin.mergedFileName", defaultValue = "_merged_spec")
private String mergedFileName;
/**
* Git host, e.g. gitlab.com.
*/
@@ -481,12 +468,6 @@ public class CodeGenMojo extends AbstractMojo {
@Override
public void execute() throws MojoExecutionException {
if (StringUtils.isNotBlank(inputSpecRootDirectory)) {
inputSpec = new MergedSpecBuilder(inputSpecRootDirectory, mergedFileName)
.buildMergedSpec();
LOGGER.info("Merge input spec would be used - {}", inputSpec);
}
File inputSpecFile = new File(inputSpec);
if (output == null) {

View File

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

View File

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

View File

@@ -3946,7 +3946,7 @@ public class DefaultCodegen implements CodegenConfig {
if (!ModelUtils.isArraySchema(p) && !ModelUtils.isMapSchema(p) && !isFreeFormObject(p) && !isAnyTypeWithNothingElseSet) {
/* schemas that are not Array, not ModelUtils.isMapSchema, not isFreeFormObject, not AnyType with nothing else set
* so primitive schemas int, str, number, referenced schemas, AnyType schemas with properties, enums, or composition
* so primitive schemas int, str, number, referenced schemas, AnyType schemas with properties, enums, or composition
*/
String type = getSchemaType(p);
setNonArrayMapProperty(property, type);
@@ -5303,6 +5303,14 @@ public class DefaultCodegen implements CodegenConfig {
}
}
// sort auth methods to maintain the same order
Collections.sort(codegenSecurities, new Comparator<CodegenSecurity>() {
@Override
public int compare(CodegenSecurity one, CodegenSecurity another) {
return ObjectUtils.compare(one.name, another.name);
}
});
return codegenSecurities;
}
@@ -6714,9 +6722,6 @@ public class DefaultCodegen implements CodegenConfig {
// Set 'required' flag defined in the schema element
if (!codegenParameter.required && schema.getRequired() != null) {
codegenParameter.required = schema.getRequired().contains(entry.getKey());
} else if (!codegenParameter.required) {
// Set 'required' flag for properties declared inside the allOf
codegenParameter.required = allRequired.stream().anyMatch(r -> r.equals(codegenParameter.paramName));
}
parameters.add(codegenParameter);

View File

@@ -727,17 +727,14 @@ public class DefaultGenerator implements Generator {
outputFolder += File.separator + support.getFolder();
}
File of = new File(outputFolder);
String outputFilename = new File(support.getDestinationFilename()).isAbsolute() // split
? support.getDestinationFilename()
: outputFolder + File.separator + support.getDestinationFilename().replace('/', File.separatorChar);
if (!of.isDirectory()) {
// check that its not a dryrun and the files in the directory aren't ignored before we make the directory
if (!dryRun && ignoreProcessor.allowsFile(new File(outputFilename)) && !of.mkdirs()) {
if (!dryRun && !of.mkdirs()) {
once(LOGGER).debug("Output directory {} not created. It {}.", outputFolder, of.exists() ? "already exists." : "may not have appropriate permissions.");
}
}
String outputFilename = new File(support.getDestinationFilename()).isAbsolute() // split
? support.getDestinationFilename()
: outputFolder + File.separator + support.getDestinationFilename().replace('/', File.separatorChar);
boolean shouldGenerate = true;
if (supportingFilesToGenerate != null && !supportingFilesToGenerate.isEmpty()) {

View File

@@ -23,7 +23,6 @@ import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.v3.core.util.Json;
import io.swagger.v3.oas.models.*;
import io.swagger.v3.oas.models.PathItem.HttpMethod;
import io.swagger.v3.oas.models.callbacks.Callback;
import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.oas.models.parameters.Parameter;
@@ -108,63 +107,52 @@ public class InlineModelResolver {
for (Map.Entry<String, PathItem> pathsEntry : paths.entrySet()) {
PathItem path = pathsEntry.getValue();
Map<HttpMethod, Operation> operationsMap = new LinkedHashMap<>(path.readOperationsMap());
List<Operation> operations = new ArrayList<>(path.readOperations());
// use path name (e.g. /foo/bar) and HTTP verb to come up with a name
// in case operationId is not defined later in other methods
String pathname = pathsEntry.getKey();
String name = pathname;
if (path.getDelete() != null) {
name = pathname + "_delete";
} else if (path.getGet() != null) {
name = pathname + "_get";
} else if (path.getHead() != null) {
name = pathname + "_head";
} else if (path.getOptions() != null) {
name = pathname + "_options";
} else if (path.getPatch() != null) {
name = pathname + "_patch";
} else if (path.getPost() != null) {
name = pathname + "_post";
} else if (path.getPut() != null) {
name = pathname + "_put";
} else if (path.getTrace() != null) {
name = pathname + "_trace";
} else {
// no HTTP verb defined?
//throw new RuntimeException("No HTTP verb found/detected in the inline model resolver");
}
// Include callback operation as well
for (Map.Entry<HttpMethod, Operation> operationEntry : new LinkedHashMap<>(path.readOperationsMap()).entrySet()) {
Operation operation = operationEntry.getValue();
for (Operation operation : path.readOperations()) {
Map<String, Callback> callbacks = operation.getCallbacks();
if (callbacks != null) {
for (Map.Entry<String, Callback> callbackEntry : callbacks.entrySet()) {
Callback callback = callbackEntry.getValue();
for (Map.Entry<String, PathItem> pathItemEntry : callback.entrySet()) {
PathItem pathItem = pathItemEntry.getValue();
operationsMap.putAll(pathItem.readOperationsMap());
}
}
operations.addAll(callbacks.values().stream()
.flatMap(callback -> callback.values().stream())
.flatMap(pathItem -> pathItem.readOperations().stream())
.collect(Collectors.toList()));
}
}
for (Map.Entry<HttpMethod, Operation> operationEntry : operationsMap.entrySet()) {
Operation operation = operationEntry.getValue();
String inlineSchemaName = this.getInlineSchemaName(operationEntry.getKey(), pathname);
flattenRequestBody(inlineSchemaName, operation);
flattenParameters(inlineSchemaName, operation);
flattenResponses(inlineSchemaName, operation);
for (Operation operation : operations) {
flattenRequestBody(name, operation);
flattenParameters(name, operation);
flattenResponses(name, operation);
}
}
}
private String getInlineSchemaName(HttpMethod httpVerb, String pathname) {
String name = pathname;
if (httpVerb.equals(HttpMethod.DELETE)) {
name += "_delete";
} else if (httpVerb.equals(HttpMethod.GET)) {
name += "_get";
} else if (httpVerb.equals(HttpMethod.HEAD)) {
name += "_head";
} else if (httpVerb.equals(HttpMethod.OPTIONS)) {
name += "_options";
} else if (httpVerb.equals(HttpMethod.PATCH)) {
name += "_patch";
} else if (httpVerb.equals(HttpMethod.POST)) {
name += "_post";
} else if (httpVerb.equals(HttpMethod.PUT)) {
name += "_put";
} else if (httpVerb.equals(HttpMethod.TRACE)) {
name += "_trace";
} else {
// no HTTP verb defined?
// throw new RuntimeException("No HTTP verb found/detected in the inline model
// resolver");
}
return name;
}
/**
* Return false if model can be represented by primitives e.g. string, object
* without properties, array or map of other model (model contanier), etc.

View File

@@ -1,151 +0,0 @@
package org.openapitools.codegen.config;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.google.common.collect.ImmutableMap;
import io.swagger.parser.OpenAPIParser;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.parser.core.models.ParseOptions;
public class MergedSpecBuilder {
private static final Logger LOGGER = LoggerFactory.getLogger(MergedSpecBuilder.class);
private final String inputSpecRootDirectory;
private final String mergeFileName;
public MergedSpecBuilder(final String rootDirectory, final String mergeFileName) {
this.inputSpecRootDirectory = rootDirectory;
this.mergeFileName = mergeFileName;
}
public String buildMergedSpec() {
deleteMergedFileFromPreviousRun();
List<String> specRelatedPaths = getAllSpecFilesInDirectory();
if (specRelatedPaths.isEmpty()) {
throw new RuntimeException("Spec directory doesn't contains any specification");
}
LOGGER.info("In spec root directory {} found specs {}", inputSpecRootDirectory, specRelatedPaths);
String openapiVersion = null;
boolean isJson = false;
ParseOptions options = new ParseOptions();
options.setResolve(true);
List<SpecWithPaths> allPaths = new ArrayList<>();
for (String specRelatedPath : specRelatedPaths) {
String specPath = inputSpecRootDirectory + File.separator + specRelatedPath;
try {
LOGGER.info("Reading spec: {}", specPath);
OpenAPI result = new OpenAPIParser()
.readLocation(specPath, new ArrayList<>(), options)
.getOpenAPI();
if (openapiVersion == null) {
openapiVersion = result.getOpenapi();
if (specRelatedPath.toLowerCase(Locale.ROOT).endsWith(".json")) {
isJson = true;
}
}
allPaths.add(new SpecWithPaths(specRelatedPath, result.getPaths().keySet()));
} catch (Exception e) {
LOGGER.error("Failed to read file: {}. It would be ignored", specPath);
}
}
Map<String, Object> mergedSpec = generatedMergedSpec(openapiVersion, allPaths);
String mergedFilename = this.mergeFileName + (isJson ? ".json" : ".yaml");
Path mergedFilePath = Paths.get(inputSpecRootDirectory, mergedFilename);
try {
ObjectMapper objectMapper = isJson ? new ObjectMapper() : new ObjectMapper(new YAMLFactory());
Files.write(mergedFilePath, objectMapper.writeValueAsBytes(mergedSpec), StandardOpenOption.CREATE, StandardOpenOption.WRITE);
} catch (IOException e) {
throw new RuntimeException(e);
}
return mergedFilePath.toString();
}
private static Map<String, Object> generatedMergedSpec(String openapiVersion, List<SpecWithPaths> allPaths) {
Map<String, Object> spec = generateHeader(openapiVersion);
Map<String, Object> paths = new HashMap<>();
spec.put("paths", paths);
for(SpecWithPaths specWithPaths : allPaths) {
for (String path : specWithPaths.paths) {
String specRelatedPath = "./" + specWithPaths.specRelatedPath + "#/paths/" + path.replace("/", "~1");
paths.put(path, ImmutableMap.of(
"$ref", specRelatedPath
));
}
}
return spec;
}
private static Map<String, Object> generateHeader(String openapiVersion) {
Map<String, Object> map = new HashMap<>();
map.put("openapi", openapiVersion);
map.put("info", ImmutableMap.of(
"title", "merged spec",
"description", "merged spec",
"version", "1.0.0"
));
map.put("servers", Collections.singleton(
ImmutableMap.of("url", "http://localhost:8080")
));
return map;
}
private List<String> getAllSpecFilesInDirectory() {
Path rootDirectory = new File(inputSpecRootDirectory).toPath();
try {
return Files.walk(rootDirectory)
.filter(path -> !Files.isDirectory(path))
.map(path -> rootDirectory.relativize(path).toString())
.collect(Collectors.toList());
} catch (IOException e) {
throw new RuntimeException("Exception while listing files in spec root directory: " + inputSpecRootDirectory, e);
}
}
private void deleteMergedFileFromPreviousRun() {
try {
Files.deleteIfExists(Paths.get(inputSpecRootDirectory + File.separator + mergeFileName + ".json"));
} catch (IOException e) { }
try {
Files.deleteIfExists(Paths.get(inputSpecRootDirectory + File.separator + mergeFileName + ".yaml"));
} catch (IOException e) { }
}
private static class SpecWithPaths {
private final String specRelatedPath;
private final Set<String> paths;
private SpecWithPaths(final String specRelatedPath, final Set<String> paths) {
this.specRelatedPath = specRelatedPath;
this.paths = paths;
}
}
}

View File

@@ -25,6 +25,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;

View File

@@ -979,7 +979,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
* Return null if there's no default value.
* Any non-null value will cause {{#defaultValue} check to pass.
*
* @param cp Codegen property
* @param cp Codegen property
* @param schema Property schema
* @return string presentation of the default value of the property
*/
@@ -1004,7 +1004,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
String defaultValue = "";
if (cp.items.getIsEnumOrRef()) { // inline or ref enum
if (cp.items.isEnum) { // enum
List<String> defaultValues = new ArrayList<>();
for (String _value : _values) {
defaultValues.add(cp.items.datatypeWithEnum + "." + toEnumVarName(_value, cp.items.dataType));
@@ -1013,20 +1013,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
} else {
if (cp.items.isString) { // array item is string
defaultValue = String.format(Locale.ROOT, "\"%s\"", StringUtils.join(_values, "\", \""));
} else if (cp.items.isNumeric) {
defaultValue = _values.stream()
.map(v -> {
if ("BigInteger".equals(cp.items.dataType)) {
return "new BigInteger(\"" + v + "\")";
} else if ("BigDecimal".equals(cp.items.dataType)) {
return "new BigDecimal(\"" + v + "\")";
} else if (cp.items.isFloat) {
return v + "f";
} else {
return v;
}
})
.collect(Collectors.joining(", "));
} else { // array item is non-string, e.g. integer
defaultValue = StringUtils.join(_values, ", ");
}
@@ -1052,7 +1038,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
if (ModelUtils.isArraySchema(schema)) {
if (schema.getDefault() == null) {
if (cp.isNullable || containerDefaultToNull) { // nullable or containerDefaultToNull set to true
return null;
return "null";
} else {
if (ModelUtils.isSet(schema)) {
return String.format(Locale.ROOT, "new %s<>()",
@@ -1075,7 +1061,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
}
if (cp.isNullable || containerDefaultToNull) { // nullable or containerDefaultToNull set to true
return null;
return "null";
}
if (getAdditionalProperties(schema) == null) {
@@ -1177,11 +1163,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
if (defaultValue instanceof ArrayNode) {
ArrayNode array = (ArrayNode) defaultValue;
return StreamSupport.stream(array.spliterator(), false)
.map(JsonNode::toString)
// remove wrapper quotes
.map(item -> StringUtils.removeStart(item, "\""))
.map(item -> StringUtils.removeEnd(item, "\""))
.collect(Collectors.joining(","));
.map(JsonNode::toString)
// remove wrapper quotes
.map(item -> StringUtils.removeStart(item, "\""))
.map(item -> StringUtils.removeEnd(item, "\""))
.collect(Collectors.joining(","));
}
}
// escape quotes
@@ -1556,10 +1542,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
OperationMap operations = objs.getOperations();
List<CodegenOperation> operationList = operations.getOperation();
for (CodegenOperation op : operationList) {
// check if the operation has form parameters
if (op.getHasFormParams()) {
additionalProperties.put("hasFormParamsInSpec", true);
}
Collection<String> operationImports = new ConcurrentSkipListSet<>();
for (CodegenParameter p : op.allParams) {
if (importMapping.containsKey(p.dataType)) {
@@ -1570,7 +1552,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
handleImplicitHeaders(op);
}
return objs;
}
@@ -2250,9 +2231,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
/**
* Search for property by {@link CodegenProperty#name}
*
* @param name name to search for
* @param properties list of properties
* @param name - name to search for
* @param properties - list of properties
* @return either found property or {@link Optional#empty()} if nothing has been found
*/
protected Optional<CodegenProperty> findByName(String name, List<CodegenProperty> properties) {
@@ -2261,8 +2241,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
}
return properties.stream()
.filter(p -> p.name.equals(name))
.findFirst();
.filter(p -> p.name.equals(name))
.findFirst();
}
/**
@@ -2304,7 +2284,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
}
}
}
@Override
public List<VendorExtension> getSupportedVendorExtensions() {
List<VendorExtension> extensions = super.getSupportedVendorExtensions();
@@ -2330,7 +2309,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
}
return addImports;
}
public static void addImports(List<Map<String, String>> imports, CodegenModel cm, Map<String, String> imports2Classnames) {
for (Map.Entry<String, String> entry : imports2Classnames.entrySet()) {
cm.imports.add(entry.getKey());

View File

@@ -47,7 +47,9 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.openapitools.codegen.utils.StringUtils.underscore;
@@ -107,14 +109,14 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
serializationLibrary.setDefault(SERIALIZATION_LIBRARY_DEFAULT);
cliOptions.add(serializationLibrary);
// Date Library Option
final CliOption dateOption = CliOption.newString(DATE_LIBRARY, "Specify Date library");
dateOption.setDefault(DATE_LIBRARY_DEFAULT);
final CliOption finalProperties = CliOption.newBoolean(FINAL_PROPERTIES, "Whether properties are marked as final when using Json Serializable for serialization");
finalProperties.setDefault("true");
cliOptions.add(finalProperties);
// Date Library Option
final CliOption dateOption = CliOption.newString(DATE_LIBRARY, "Specify Date library");
dateOption.setDefault(DATE_LIBRARY_DEFAULT);
final Map<String, String> dateOptions = new HashMap<>();
dateOptions.put(DATE_LIBRARY_CORE, "[DEFAULT] Dart core library (DateTime)");
dateOptions.put(DATE_LIBRARY_TIME_MACHINE, "Time Machine is date and time library for Flutter, Web, and Server with support for timezones, calendars, cultures, formatting and parsing.");
@@ -145,7 +147,7 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
@Override
public String getHelp() {
return "Generates a Dart Dio client library.";
return "Generates a Dart Dio client library with null-safety.";
}
@Override
@@ -670,6 +672,7 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
}
}
resultImports.addAll(rewriteImports(op.imports, false));
if (SERIALIZATION_LIBRARY_BUILT_VALUE.equals(library) && (op.getHasFormParams() || op.getHasQueryParams())) {
resultImports.add("package:" + pubName + "/" + sourceFolder + "/api_util.dart");
}

View File

@@ -387,29 +387,10 @@ public class GoClientCodegen extends AbstractGoCodegen {
}
}
/**
* Determines if at least one of the allOf pieces of a schema are of type string
*
* @param p
* @return
*/
private boolean isAllOfStringSchema(Schema schema) {
if (schema.getAllOf() != null) {
Iterator<Schema> it = schema.getAllOf().iterator();
while (it.hasNext()) {
Schema childSchema = ModelUtils.getReferencedSchema(this.openAPI, it.next());
if (ModelUtils.isStringSchema(childSchema)) {
return true;
}
}
}
return false;
}
@Override
public String toDefaultValue(Schema p) {
p = ModelUtils.getReferencedSchema(this.openAPI, p);
if (ModelUtils.isStringSchema(p) || isAllOfStringSchema(p)) {
if (ModelUtils.isStringSchema(p)) {
Object defaultObj = p.getDefault();
if (defaultObj != null) {
if (defaultObj instanceof java.lang.String) {

View File

@@ -65,7 +65,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen
public static final String USE_REFLECTION_EQUALS_HASHCODE = "useReflectionEqualsHashCode";
public static final String CASE_INSENSITIVE_RESPONSE_HEADERS = "caseInsensitiveResponseHeaders";
public static final String MICROPROFILE_FRAMEWORK = "microprofileFramework";
public static final String MICROPROFILE_MUTINY = "microprofileMutiny";
public static final String USE_ABSTRACTION_FOR_FILES = "useAbstractionForFiles";
public static final String DYNAMIC_OPERATIONS = "dynamicOperations";
public static final String SUPPORT_STREAMING = "supportStreaming";
@@ -108,7 +107,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen
protected boolean doNotUseRx = true;
protected boolean usePlayWS = false;
protected String microprofileFramework = MICROPROFILE_DEFAULT;
protected boolean microprofileMutiny = false;
protected String configKey = null;
protected boolean asyncNative = false;
@@ -201,7 +199,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen
cliOptions.add(CliOption.newBoolean(USE_REFLECTION_EQUALS_HASHCODE, "Use org.apache.commons.lang3.builder for equals and hashCode in the models. WARNING: This will fail under a security manager, unless the appropriate permissions are set up correctly and also there's potential performance impact."));
cliOptions.add(CliOption.newBoolean(CASE_INSENSITIVE_RESPONSE_HEADERS, "Make API response's headers case-insensitive. Available on " + OKHTTP_GSON + ", " + JERSEY2 + " libraries"));
cliOptions.add(CliOption.newString(MICROPROFILE_FRAMEWORK, "Framework for microprofile. Possible values \"kumuluzee\""));
cliOptions.add(CliOption.newString(MICROPROFILE_MUTINY, "Whether to use async types for microprofile (currently only Smallrye Mutiny is supported)."));
cliOptions.add(CliOption.newBoolean(USE_ABSTRACTION_FOR_FILES, "Use alternative types instead of java.io.File to allow passing bytes without a file on disk. Available on resttemplate, webclient, libraries"));
cliOptions.add(CliOption.newBoolean(DYNAMIC_OPERATIONS, "Generate operations dynamically at runtime from an OAS", this.dynamicOperations));
cliOptions.add(CliOption.newBoolean(SUPPORT_STREAMING, "Support streaming endpoint (beta)", this.supportStreaming));
@@ -227,8 +224,8 @@ public class JavaClientCodegen extends AbstractJavaCodegen
supportedLibraries.put(GOOGLE_API_CLIENT, "HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x");
supportedLibraries.put(REST_ASSURED, "HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.10.x. Only for Java 8");
supportedLibraries.put(NATIVE, "HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+");
supportedLibraries.put(MICROPROFILE, "HTTP client: Microprofile client 1.x. JSON processing: JSON-B or Jackson 2.9.x");
supportedLibraries.put(APACHE, "HTTP client: Apache httpclient 5.x");
supportedLibraries.put(MICROPROFILE, "HTTP client: Microprofile client 1.x. JSON processing: JSON-B");
supportedLibraries.put(APACHE, "HTTP client: Apache httpclient 4.x");
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
libraryOption.setEnum(supportedLibraries);
@@ -339,10 +336,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen
}
additionalProperties.put(MICROPROFILE_FRAMEWORK, microprofileFramework);
if (additionalProperties.containsKey(MICROPROFILE_MUTINY)) {
this.setMicroprofileMutiny(convertPropertyToBooleanAndWriteBack(MICROPROFILE_MUTINY));
}
if (!additionalProperties.containsKey(MICROPROFILE_REST_CLIENT_VERSION)) {
additionalProperties.put(MICROPROFILE_REST_CLIENT_VERSION, MICROPROFILE_REST_CLIENT_DEFAULT_VERSION);
} else {
@@ -653,12 +646,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("api_exception.mustache", apiExceptionFolder, "ApiException.java"));
supportingFiles.add(new SupportingFile("api_exception_mapper.mustache", apiExceptionFolder, "ApiExceptionMapper.java"));
if (getSerializationLibrary() == null) {
LOGGER.info("No serializationLibrary configured, using '{}' as fallback", SERIALIZATION_LIBRARY_JSONB);
setSerializationLibrary(SERIALIZATION_LIBRARY_JSONB);
} else if (getSerializationLibrary().equals(SERIALIZATION_LIBRARY_GSON)) {
forceSerializationLibrary(SERIALIZATION_LIBRARY_JSONB);
}
serializationLibrary = "none";
if (microprofileFramework.equals(MICROPROFILE_KUMULUZEE)) {
supportingFiles.add(new SupportingFile("kumuluzee.pom.mustache", "", "pom.xml"));
@@ -983,7 +971,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
}
// TODO: inverse logic. Do not add the imports unconditionally in the first place.
if (!AnnotationLibrary.SWAGGER1.equals(getAnnotationLibrary())) {
if (! AnnotationLibrary.SWAGGER1.equals(getAnnotationLibrary())) {
// Remove io.swagger.annotations.* imports
codegenModel.imports.remove("ApiModel");
codegenModel.imports.remove("ApiModelProperty");
@@ -1135,10 +1123,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen
this.microprofileFramework = microprofileFramework;
}
public void setMicroprofileMutiny(boolean microprofileMutiny) {
this.microprofileMutiny = microprofileMutiny;
}
public void setConfigKey(String configKey) {
this.configKey = configKey;
}

View File

@@ -46,16 +46,13 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
public static final String PACKAGE_URL = "packageUrl";
public static final String DEFAULT_LIBRARY = "urllib3";
public static final String RECURSION_LIMIT = "recursionLimit";
public static final String ALLOW_STRING_IN_DATETIME_PARAMETERS = "allowStringInDateTimeParameters";
public static final String FLOAT_STRICT_TYPE = "floatStrictType";
public static final String PYTHON_ATTR_NONE_IF_UNSET = "pythonAttrNoneIfUnset";
protected String packageUrl;
protected String apiDocPath = "docs" + File.separator;
protected String modelDocPath = "docs" + File.separator;
protected boolean hasModelsToImport = Boolean.FALSE;
protected boolean useOneOfDiscriminatorLookup = false; // use oneOf discriminator's mapping for model lookup
protected boolean allowStringInDateTimeParameters = false; // use StrictStr instead of datetime in parameters
protected boolean floatStrictType = true;
protected Map<Character, String> regexModifiers;
@@ -167,10 +164,6 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
cliOptions.add(new CliOption(CodegenConstants.SOURCECODEONLY_GENERATION, CodegenConstants.SOURCECODEONLY_GENERATION_DESC)
.defaultValue(Boolean.FALSE.toString()));
cliOptions.add(new CliOption(RECURSION_LIMIT, "Set the recursion limit. If not set, use the system default value."));
cliOptions.add(new CliOption(ALLOW_STRING_IN_DATETIME_PARAMETERS, "Allow string as input to datetime/date parameters for backward compartibility.")
.defaultValue(Boolean.FALSE.toString()));
cliOptions.add(new CliOption(FLOAT_STRICT_TYPE, "Use strict type for float, i.e. StrictFloat or confloat(strict=true, ...)")
.defaultValue(Boolean.TRUE.toString()));
supportedLibraries.put("urllib3", "urllib3-based client");
supportedLibraries.put("asyncio", "asyncio-based client");
@@ -266,14 +259,6 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
additionalProperties.put(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, useOneOfDiscriminatorLookup);
}
if (additionalProperties.containsKey(ALLOW_STRING_IN_DATETIME_PARAMETERS)) {
setAllowStringInDateTimeParameters(convertPropertyToBooleanAndWriteBack(ALLOW_STRING_IN_DATETIME_PARAMETERS));
}
if (additionalProperties.containsKey(FLOAT_STRICT_TYPE)) {
setFloatStrictType(convertPropertyToBooleanAndWriteBack(FLOAT_STRICT_TYPE));
}
String modelPath = packagePath() + File.separatorChar + modelPackage.replace('.', File.separatorChar);
String apiPath = packagePath() + File.separatorChar + apiPackage.replace('.', File.separatorChar);
@@ -403,23 +388,8 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
}
if (cp.isArray) {
if (cp.maxItems != null || cp.minItems != null) {
String maxOrMinItems = "";
if (cp.maxItems != null) {
maxOrMinItems += String.format(Locale.ROOT, ", max_items=%d", cp.maxItems);
}
if (cp.minItems != null) {
maxOrMinItems += String.format(Locale.ROOT, ", min_items=%d", cp.minItems);
}
pydanticImports.add("conlist");
return String.format(Locale.ROOT, "conlist(%s%s)",
getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports),
maxOrMinItems);
} else {
typingImports.add("List");
return String.format(Locale.ROOT, "List[%s]", getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports));
}
typingImports.add("List");
return String.format(Locale.ROOT, "List[%s]", getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports));
} else if (cp.isMap) {
typingImports.add("Dict");
return String.format(Locale.ROOT, "Dict[str, %s]", getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports));
@@ -454,6 +424,7 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
if (cp.hasValidation) {
List<String> fieldCustomization = new ArrayList<>();
// e.g. confloat(ge=10, le=100, strict=True)
fieldCustomization.add("strict=True");
if (cp.getMaximum() != null) {
if (cp.getExclusiveMaximum()) {
fieldCustomization.add("gt=" + cp.getMaximum());
@@ -472,20 +443,12 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
fieldCustomization.add("multiple_of=" + cp.getMultipleOf());
}
if (floatStrictType) {
fieldCustomization.add("strict=True");
}
pydanticImports.add("confloat");
return String.format(Locale.ROOT, "%s(%s)", "confloat",
StringUtils.join(fieldCustomization, ", "));
} else {
if (floatStrictType) {
pydanticImports.add("StrictFloat");
return "StrictFloat";
} else {
return "float";
}
pydanticImports.add("StrictFloat");
return "StrictFloat";
}
} else if (cp.isInteger || cp.isLong || cp.isShort || cp.isUnboundedInteger) {
if (cp.hasValidation) {
@@ -579,14 +542,7 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
if (cp.isDateTime) {
datetimeImports.add("datetime");
}
if (allowStringInDateTimeParameters) {
pydanticImports.add("StrictStr");
typingImports.add("Union");
return String.format(Locale.ROOT, "Union[%s, StrictStr]", cp.dataType);
} else {
return cp.dataType;
}
return cp.dataType;
} else if (cp.isUuid) {
return cp.dataType;
} else if (cp.isFreeFormObject) { // type: object
@@ -653,22 +609,8 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
return String.format(Locale.ROOT, "%sEnum", cp.nameInCamelCase);
} else*/
if (cp.isArray) {
if (cp.maxItems != null || cp.minItems != null) {
String maxOrMinItems = "";
if (cp.maxItems != null) {
maxOrMinItems += String.format(Locale.ROOT, ", max_items=%d", cp.maxItems);
}
if (cp.minItems != null) {
maxOrMinItems += String.format(Locale.ROOT, ", min_items=%d", cp.minItems);
}
pydanticImports.add("conlist");
return String.format(Locale.ROOT, "conlist(%s%s)",
getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports),
maxOrMinItems);
} else {
typingImports.add("List");
return String.format(Locale.ROOT, "List[%s]", getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports));
}
typingImports.add("List");
return String.format(Locale.ROOT, "List[%s]", getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports));
} else if (cp.isMap) {
typingImports.add("Dict");
return String.format(Locale.ROOT, "Dict[str, %s]", getPydanticType(cp.items, typingImports, pydanticImports, datetimeImports, modelImports));
@@ -703,6 +645,7 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
if (cp.hasValidation) {
List<String> fieldCustomization = new ArrayList<>();
// e.g. confloat(ge=10, le=100, strict=True)
fieldCustomization.add("strict=True");
if (cp.getMaximum() != null) {
if (cp.getExclusiveMaximum()) {
fieldCustomization.add("lt=" + cp.getMaximum());
@@ -721,20 +664,12 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
fieldCustomization.add("multiple_of=" + cp.getMultipleOf());
}
if (floatStrictType) {
fieldCustomization.add("strict=True");
}
pydanticImports.add("confloat");
return String.format(Locale.ROOT, "%s(%s)", "confloat",
StringUtils.join(fieldCustomization, ", "));
} else {
if (floatStrictType) {
pydanticImports.add("StrictFloat");
return "StrictFloat";
} else {
return "float";
}
pydanticImports.add("StrictFloat");
return "StrictFloat";
}
} else if (cp.isInteger || cp.isLong || cp.isShort || cp.isUnboundedInteger) {
if (cp.hasValidation) {
@@ -1039,7 +974,7 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
codegenProperties = model.vars;
}
//loop through properties/schemas to set up typing, pydantic
//loop through properties/schemas to setup typing, pydantic
for (CodegenProperty cp : codegenProperties) {
String typing = getPydanticType(cp, typingImports, pydanticImports, datetimeImports, modelImports);
List<String> fields = new ArrayList<>();
@@ -1085,12 +1020,7 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
if (cp.defaultValue == null) {
fieldCustomization = "None";
} else {
if (cp.isArray || cp.isMap) {
// TODO handle default value for array/map
fieldCustomization = "None";
} else {
fieldCustomization = cp.defaultValue;
}
fieldCustomization = cp.defaultValue;
}
} else { // required field
fieldCustomization = firstField;
@@ -1106,9 +1036,9 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
// setup x-py-name for each oneOf/anyOf schema
if (!model.oneOf.isEmpty()) { // oneOf
cp.vendorExtensions.put("x-py-name", String.format(Locale.ROOT, "oneof_schema_%d_validator", property_count++));
cp.vendorExtensions.put("x-py-name", String.format(Locale.ROOT, "__oneof_schema_%d", property_count++));
} else if (!model.anyOf.isEmpty()) { // anyOf
cp.vendorExtensions.put("x-py-name", String.format(Locale.ROOT, "anyof_schema_%d_validator", property_count++));
cp.vendorExtensions.put("x-py-name", String.format(Locale.ROOT, "__anyof_schema_%d", property_count++));
}
}
@@ -1381,12 +1311,4 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
}
return "var_" + name;
}
public void setAllowStringInDateTimeParameters(boolean allowStringInDateTimeParameters) {
this.allowStringInDateTimeParameters = allowStringInDateTimeParameters;
}
public void setFloatStrictType(boolean floatStrictType) {
this.floatStrictType = floatStrictType;
}
}

View File

@@ -44,7 +44,6 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
import io.swagger.v3.oas.models.tags.Tag;
import org.apache.commons.lang3.tuple.Pair;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants;
@@ -803,13 +802,7 @@ public class SpringCodegen extends AbstractJavaCodegen
handleImplicitHeaders(operation);
}
// The tag for the controller is the first tag of the first operation
final CodegenOperation firstOperation = ops.get(0);
final Tag firstTag = firstOperation.tags.get(0);
final String firstTagName = firstTag.getName();
// But use a sensible tag name if there is none
objs.put("tagName", "default".equals(firstTagName) ? firstOperation.baseName : firstTagName);
objs.put("tagDescription", firstTag.getDescription());
objs.put("tagDescription", ops.get(0).tags.get(0).getDescription());
}
return objs;

View File

@@ -10,7 +10,7 @@ import java.util.Locale;
public enum StringHelpers implements Helper<Object> {
/**
* Indicates whether the string starts with the given value.
* Indicates the string starts with the defined value.
* For example:
*
* <pre>
@@ -39,6 +39,8 @@ public enum StringHelpers implements Helper<Object> {
* <pre>
* {{startsWith a b yes='y' no='n'}}
* </pre>
*
* If value is "handlebars.java", the output will be "Handlebars.java".
*/
startsWith {
@Override
@@ -55,60 +57,6 @@ public enum StringHelpers implements Helper<Object> {
return result ? options.fn() : options.inverse();
}
return result
? options.hash("yes", true)
: options.hash("no", false);
}
},
/**
* Indicates whether the string ends with the given value.
* For example:
*
* <pre>
* {{endsWith a b ["insensitive"]}}
* </pre>
*
* <pre>
* {{endsWith a text='b' [insensitive=true]}}
* </pre>
*
* Render 'yes' or 'no':
* <pre>
* {{#endsWith a b}}
* yes
* {{else}}
* no
* {{/endsWith}}
* </pre>
*
* Render 'true' or 'false':
* <pre>
* {{endsWith a b}}
* </pre>
*
* Render 'y' or 'n':
* <pre>
* {{endsWith a b yes='y' no='n'}}
* </pre>
*/
endsWith {
@Override
public Object apply(Object value, Options options) throws IOException {
String match = options.param(0, options.hash("text", ""));
if (match.length() < 1) {
return false;
}
boolean caseInsensitive = options.hash("insensitive", false);
boolean result = caseInsensitive
? value.toString().toLowerCase(Locale.ROOT).endsWith(match.toLowerCase(Locale.ROOT))
: value.toString().endsWith(match);
if (options.tagType == TagType.SECTION) {
return result ? options.fn() : options.inverse();
}
return result
? options.hash("yes", true)
: options.hash("no", false);

View File

@@ -51,8 +51,7 @@ public class OptionUtils {
List<String> results = new ArrayList<String>();
if(input != null && !input.isEmpty()) {
String[] tokens = input.split(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)", -1);
for (String value : tokens) {
for (String value : input.split(",")) {
if(isNotEmpty(value))
results.add(value);
}

View File

@@ -192,7 +192,6 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
public ApiClient setBasePath(String basePath) {
this.basePath = basePath;
this.serverIndex = null;
return this;
}

View File

@@ -13,28 +13,29 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JavaType;
import org.apache.hc.client5.http.cookie.BasicCookieStore;
import org.apache.hc.client5.http.cookie.Cookie;
import org.apache.hc.client5.http.entity.UrlEncodedFormEntity;
import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.client5.http.impl.cookie.BasicClientCookie;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.http.NameValuePair;
import org.apache.hc.core5.http.ParseException;
import org.apache.hc.core5.http.io.entity.ByteArrayEntity;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.io.entity.FileEntity;
import org.apache.hc.core5.http.io.entity.StringEntity;
import org.apache.hc.core5.http.io.support.ClassicRequestBuilder;
import org.apache.hc.core5.http.message.BasicNameValuePair;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.ParseException;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.FileEntity;
import org.apache.http.entity.StringEntity;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.cookie.BasicClientCookie;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.apache.http.cookie.Cookie;
import java.util.Collection;
import java.util.Collections;
@@ -57,7 +58,6 @@ import java.io.InputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.nio.charset.UnsupportedCharsetException;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.nio.file.Paths;
@@ -735,7 +735,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
private ContentType getContentType(String headerValue) throws ApiException {
try {
return ContentType.parse(headerValue);
} catch (UnsupportedCharsetException e) {
} catch (ParseException e) {
throw new ApiException("Could not parse content type " + headerValue);
}
}
@@ -816,7 +816,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
* @throws IOException IO exception
*/
@SuppressWarnings("unchecked")
public <T> T deserialize(CloseableHttpResponse response, TypeReference<T> valueType) throws ApiException, IOException, ParseException {
public <T> T deserialize(HttpResponse response, TypeReference<T> valueType) throws ApiException, IOException {
if (valueType == null) {
return null;
}
@@ -846,14 +846,14 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
} else {
throw new ApiException(
"Deserialization for content type '" + mimeType + "' not supported for type '" + valueType + "'",
response.getCode(),
response.getStatusLine().getStatusCode(),
responseHeaders,
EntityUtils.toString(entity)
);
}
}
private File downloadFileFromResponse(CloseableHttpResponse response) throws IOException {
private File downloadFileFromResponse(HttpResponse response) throws IOException {
Header contentDispositionHeader = response.getFirstHeader("Content-Disposition");
String contentDisposition = contentDispositionHeader == null ? null : contentDispositionHeader.getValue();
File file = prepareDownloadFile(contentDisposition);
@@ -978,13 +978,13 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
return cookie;
}
protected <T> T processResponse(CloseableHttpResponse response, TypeReference<T> returnType) throws ApiException, IOException, ParseException {
statusCode = response.getCode();
protected <T> T processResponse(CloseableHttpResponse response, TypeReference<T> returnType) throws ApiException, IOException {
statusCode = response.getStatusLine().getStatusCode();
if (statusCode == HttpStatus.SC_NO_CONTENT) {
return null;
}
responseHeaders = transformResponseHeaders(response.getHeaders());
responseHeaders = transformResponseHeaders(response.getAllHeaders());
if (isSuccessfulStatus(statusCode)) {
return this.deserialize(response, returnType);
} else {
@@ -1034,9 +1034,14 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
final String url = buildUrl(path, queryParams, collectionQueryParams, urlQueryDeepObject);
ClassicRequestBuilder builder = ClassicRequestBuilder.create(method);
RequestBuilder builder = RequestBuilder.create(method);
builder.setUri(url);
RequestConfig config = RequestConfig.custom()
.setConnectionRequestTimeout(connectionTimeout)
.build();
builder.setConfig(config);
if (accept != null) {
builder.addHeader("Accept", accept);
}
@@ -1077,7 +1082,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
try (CloseableHttpResponse response = httpClient.execute(builder.build(), context)) {
return processResponse(response, returnType);
} catch (IOException | ParseException e) {
} catch (IOException e) {
throw new ApiException(e);
}
}

View File

@@ -120,7 +120,7 @@ ext {
jackson_databind_nullable_version = "0.2.4"
{{/openApiNullable}}
jakarta_annotation_version = "1.3.5"
httpclient_version = "5.1.3"
httpclient_version = "4.5.13"
jodatime_version = "2.9.9"
junit_version = "4.13.2"
}
@@ -128,7 +128,8 @@ ext {
dependencies {
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
implementation "com.google.code.findbugs:jsr305:3.0.2"
implementation "org.apache.httpcomponents.client5:httpclient5:$httpclient_version"
implementation "org.apache.httpcomponents:httpclient:$httpclient_version"
implementation "org.apache.httpcomponents:httpmime:$httpclient_version"
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"

View File

@@ -232,8 +232,13 @@
<!-- HTTP client: apache client -->
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient-version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>${httpclient-version}</version>
</dependency>
@@ -332,7 +337,7 @@
{{#swagger1AnnotationLibrary}}
<swagger-annotations-version>1.6.6</swagger-annotations-version>
{{/swagger1AnnotationLibrary}}
<httpclient-version>5.1.3</httpclient-version>
<httpclient-version>4.5.13</httpclient-version>
<jackson-version>2.14.1</jackson-version>
<jackson-databind-version>2.14.1</jackson-databind-version>
{{#openApiNullable}}

View File

@@ -449,10 +449,9 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
if (auth instanceof ApiKeyAuth) {
String name = authEntry.getKey();
// respect x-auth-id-alias property
name = authenticationLookup.getOrDefault(name, name);
String secret = secrets.get(name);
if (secret != null) {
((ApiKeyAuth) auth).setApiKey(secret);
name = authenticationLookup.containsKey(name) ? authenticationLookup.get(name) : name;
if (secrets.containsKey(name)) {
((ApiKeyAuth) auth).setApiKey(secrets.get(name));
}
}
}
@@ -1068,6 +1067,11 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
return file;
}
String contentType = null;
List<Object> contentTypes = response.getHeaders().get("Content-Type");
if (contentTypes != null && !contentTypes.isEmpty())
contentType = String.valueOf(contentTypes.get(0));
// read the entity stream multiple times
response.bufferEntity();
@@ -1169,11 +1173,14 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
boolean isBodyNullable)
throws ApiException {
// Not using `.target(targetURL).path(path)` below,
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
String targetURL;
List<ServerConfiguration> serverConfigurations;
if (serverIndex != null && (serverConfigurations = operationServers.get(operation)) != null) {
int index = operationServerIndex.getOrDefault(operation, serverIndex).intValue();
Map<String, String> variables = operationServerVariables.getOrDefault(operation, serverVariables);
if (serverIndex != null && operationServers.containsKey(operation)) {
Integer index = operationServerIndex.containsKey(operation) ? operationServerIndex.get(operation) : serverIndex;
Map<String, String> variables = operationServerVariables.containsKey(operation) ?
operationServerVariables.get(operation) : serverVariables;
List<ServerConfiguration> serverConfigurations = operationServers.get(operation);
if (index < 0 || index >= serverConfigurations.size()) {
throw new ArrayIndexOutOfBoundsException(
String.format(
@@ -1184,8 +1191,6 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
} else {
targetURL = this.basePath + path;
}
// Not using `.target(targetURL).path(path)` below,
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
WebTarget target = httpClient.target(targetURL);
if (queryParams != null) {
@@ -1196,10 +1201,11 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
}
}
Invocation.Builder invocationBuilder = target.request();
Invocation.Builder invocationBuilder;
if (accept != null) {
invocationBuilder = invocationBuilder.accept(accept);
invocationBuilder = target.request().accept(accept);
} else {
invocationBuilder = target.request();
}
for (Entry<String, String> entry : cookieParams.entrySet()) {

View File

@@ -27,23 +27,23 @@ public class JSON implements ContextResolver<ObjectMapper> {
private ObjectMapper mapper;
public JSON() {
mapper = JsonMapper.builder()
.serializationInclusion(JsonInclude.Include.NON_NULL)
.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true)
.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true)
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING)
.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING)
.defaultDateFormat(new RFC3339DateFormat())
.addModule(new JavaTimeModule())
{{#joda}}
.addModule(new JodaModule())
{{/joda}}
{{#openApiNullable}}
.addModule(new JsonNullableModule())
{{/openApiNullable}}
.build();
mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
JsonMapper.builder().configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
mapper.setDateFormat(new RFC3339DateFormat());
mapper.registerModule(new JavaTimeModule());
{{#joda}}
mapper.registerModule(new JodaModule());
{{/joda}}
{{#openApiNullable}}
JsonNullableModule jnm = new JsonNullableModule();
mapper.registerModule(jnm);
{{/openApiNullable}}
}
/**

View File

@@ -82,7 +82,12 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{/isContainer}}
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{#isContainer}}
private {{{datatypeWithEnum}}} {{name}}{{#required}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{/required}}{{^required}} = null{{/required}};
{{/isContainer}}
{{^isContainer}}
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
{{/isContainer}}
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{/vars}}
@@ -131,7 +136,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
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}});
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}});
}
try {
this.{{name}}.get().add({{name}}Item);
@@ -142,11 +147,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{^required}}
{{#defaultValue}}
if (this.{{name}} == null) {
this.{{name}} = {{{defaultValue}}};
}
{{/defaultValue}}
{{/required}}
this.{{name}}.add({{name}}Item);
return this;
@@ -158,7 +161,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
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}});
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}});
}
try {
this.{{name}}.get().put(key, {{name}}Item);
@@ -169,11 +172,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{^required}}
{{#defaultValue}}
if (this.{{name}} == null) {
this.{{name}} = {{{defaultValue}}};
}
{{/defaultValue}}
{{/required}}
this.{{name}}.put(key, {{name}}Item);
return this;

View File

@@ -449,10 +449,9 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
if (auth instanceof ApiKeyAuth) {
String name = authEntry.getKey();
// respect x-auth-id-alias property
name = authenticationLookup.getOrDefault(name, name);
String secret = secrets.get(name);
if (secret != null) {
((ApiKeyAuth) auth).setApiKey(secret);
name = authenticationLookup.containsKey(name) ? authenticationLookup.get(name) : name;
if (secrets.containsKey(name)) {
((ApiKeyAuth) auth).setApiKey(secrets.get(name));
}
}
}
@@ -1068,6 +1067,11 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
return file;
}
String contentType = null;
List<Object> contentTypes = response.getHeaders().get("Content-Type");
if (contentTypes != null && !contentTypes.isEmpty())
contentType = String.valueOf(contentTypes.get(0));
// read the entity stream multiple times
response.bufferEntity();
@@ -1169,11 +1173,14 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
boolean isBodyNullable)
throws ApiException {
// Not using `.target(targetURL).path(path)` below,
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
String targetURL;
List<ServerConfiguration> serverConfigurations;
if (serverIndex != null && (serverConfigurations = operationServers.get(operation)) != null) {
int index = operationServerIndex.getOrDefault(operation, serverIndex).intValue();
Map<String, String> variables = operationServerVariables.getOrDefault(operation, serverVariables);
if (serverIndex != null && operationServers.containsKey(operation)) {
Integer index = operationServerIndex.containsKey(operation) ? operationServerIndex.get(operation) : serverIndex;
Map<String, String> variables = operationServerVariables.containsKey(operation) ?
operationServerVariables.get(operation) : serverVariables;
List<ServerConfiguration> serverConfigurations = operationServers.get(operation);
if (index < 0 || index >= serverConfigurations.size()) {
throw new ArrayIndexOutOfBoundsException(
String.format(
@@ -1184,8 +1191,6 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
} else {
targetURL = this.basePath + path;
}
// Not using `.target(targetURL).path(path)` below,
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
WebTarget target = httpClient.target(targetURL);
if (queryParams != null) {
@@ -1196,10 +1201,11 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
}
}
Invocation.Builder invocationBuilder = target.request();
Invocation.Builder invocationBuilder;
if (accept != null) {
invocationBuilder = invocationBuilder.accept(accept);
invocationBuilder = target.request().accept(accept);
} else {
invocationBuilder = target.request();
}
for (Entry<String, String> entry : cookieParams.entrySet()) {

View File

@@ -27,23 +27,23 @@ public class JSON implements ContextResolver<ObjectMapper> {
private ObjectMapper mapper;
public JSON() {
mapper = JsonMapper.builder()
.serializationInclusion(JsonInclude.Include.NON_NULL)
.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true)
.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true)
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING)
.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING)
.defaultDateFormat(new RFC3339DateFormat())
.addModule(new JavaTimeModule())
{{#joda}}
.addModule(new JodaModule())
{{/joda}}
{{#openApiNullable}}
.addModule(new JsonNullableModule())
{{/openApiNullable}}
.build();
mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
JsonMapper.builder().configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
mapper.setDateFormat(new RFC3339DateFormat());
mapper.registerModule(new JavaTimeModule());
{{#joda}}
mapper.registerModule(new JodaModule());
{{/joda}}
{{#openApiNullable}}
JsonNullableModule jnm = new JsonNullableModule();
mapper.registerModule(jnm);
{{/openApiNullable}}
}
/**

View File

@@ -82,7 +82,12 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{/isContainer}}
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{#isContainer}}
private {{{datatypeWithEnum}}} {{name}}{{#required}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{/required}}{{^required}} = null{{/required}};
{{/isContainer}}
{{^isContainer}}
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
{{/isContainer}}
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{/vars}}
@@ -131,7 +136,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
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}});
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}});
}
try {
this.{{name}}.get().add({{name}}Item);
@@ -142,11 +147,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{^required}}
{{#defaultValue}}
if (this.{{name}} == null) {
this.{{name}} = {{{defaultValue}}};
}
{{/defaultValue}}
{{/required}}
this.{{name}}.add({{name}}Item);
return this;
@@ -158,7 +161,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
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}});
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}});
}
try {
this.{{name}}.get().put(key, {{name}}Item);
@@ -169,11 +172,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{^required}}
{{#defaultValue}}
if (this.{{name}} == null) {
this.{{name}} = {{{defaultValue}}};
}
{{/defaultValue}}
{{/required}}
this.{{name}}.put(key, {{name}}Item);
return this;

View File

@@ -15,9 +15,6 @@ import {{rootJavaEEPackage}}.ws.rs.core.MediaType;
{{^disableMultipart}}
import org.apache.cxf.jaxrs.ext.multipart.*;
{{/disableMultipart}}
{{#microprofileMutiny}}
import io.smallrye.mutiny.Uni;
{{/microprofileMutiny}}
{{#useBeanValidation}}
import {{javaxPackage}}.validation.constraints.*;
@@ -69,7 +66,7 @@ public interface {{classname}} {
{{#hasProduces}}
@Produces({ {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} })
{{/hasProduces}}
{{^vendorExtensions.x-java-is-response-void}}{{#microprofileMutiny}}Uni<{{{returnType}}}>{{/microprofileMutiny}}{{^microprofileMutiny}}{{{returnType}}}{{/microprofileMutiny}}{{/vendorExtensions.x-java-is-response-void}}{{#vendorExtensions.x-java-is-response-void}}{{#microprofileMutiny}}Uni<Void>{{/microprofileMutiny}}{{^microprofileMutiny}}void{{/microprofileMutiny}}{{/vendorExtensions.x-java-is-response-void}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException, ProcessingException;
public {{{returnType}}}{{^returnType}}void{{/returnType}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException, ProcessingException;
{{/operation}}
}
{{/operations}}

View File

@@ -72,7 +72,7 @@ public class {{classname}}Test {
{{#allParams}}
{{^isFile}}{{{dataType}}} {{paramName}} = null;{{/isFile}}{{#isFile}}org.apache.cxf.jaxrs.ext.multipart.Attachment {{paramName}} = null;{{/isFile}}
{{/allParams}}
//{{^vendorExtensions.x-java-is-response-void}}{{#microprofileMutiny}}Uni<{{{returnType}}}>{{/microprofileMutiny}}{{^microprofileMutiny}}{{{returnType}}}{{/microprofileMutiny}} response = {{/vendorExtensions.x-java-is-response-void}}api.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
//{{#returnType}}{{{.}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
//{{#returnType}}assertNotNull(response);{{/returnType}}

View File

@@ -3,10 +3,8 @@
@XmlEnum({{dataType}}.class)
{{/withXml}}
{{^withXml}}
{{#jsonb}}
@JsonbTypeSerializer({{datatypeWithEnum}}.Serializer.class)
@JsonbTypeDeserializer({{datatypeWithEnum}}.Deserializer.class)
{{/jsonb}}
{{/withXml}}
{{>additionalEnumTypeAnnotations}}public enum {{datatypeWithEnum}} {
@@ -26,9 +24,6 @@
value = v;
}
{{#jackson}}
@JsonValue
{{/jackson}}
public {{dataType}} value() {
return value;
}
@@ -49,7 +44,6 @@
}
{{/withXml}}
{{^withXml}}
{{#jsonb}}
public static final class Deserializer implements JsonbDeserializer<{{datatypeWithEnum}}> {
@Override
public {{datatypeWithEnum}} deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
@@ -68,17 +62,5 @@
generator.write(obj.value);
}
}
{{/jsonb}}
{{#jackson}}
@JsonCreator
public static {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue({{{dataType}}} value) {
for ({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
if (b.value.equals(value)) {
return b;
}
}
{{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}}
}
{{/jackson}}
{{/withXml}}
}

View File

@@ -156,13 +156,6 @@
<version>${jakarta.annotation.version}</version>
<scope>provided</scope>
</dependency>
{{#microprofileMutiny}}
<dependency>
<groupId>io.smallrye.reactive</groupId>
<artifactId>mutiny</artifactId>
<version>${mutiny.version}</version>
</dependency>
{{/microprofileMutiny}}
</dependencies>
<repositories>
<repository>
@@ -203,8 +196,5 @@
<maven.failsafe.plugin.version>2.6</maven.failsafe.plugin.version>
<build.helper.maven.plugin.version>1.9.1</build.helper.maven.plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
{{#microprofileMutiny}}
<mutiny.version>1.2.0</mutiny.version>
{{/microprofileMutiny}}
</properties>
</project>

View File

@@ -0,0 +1,4 @@
{{#useGenericResponse}}Response{{/useGenericResponse}}{{! non-generic response:
}}{{^useGenericResponse}}{{!
}}{{{returnType}}}{{!
}}{{/useGenericResponse}}

View File

@@ -195,166 +195,4 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
}
{{/anyOf}}
{{#supportUrlQuery}}
/**
* Convert the instance into URL query string.
*
* @return URL query string
*/
public String toUrlQueryString() {
return toUrlQueryString(null);
}
/**
* Convert the instance into URL query string.
*
* @param prefix prefix of the query string
* @return URL query string
*/
public String toUrlQueryString(String prefix) {
String suffix = "";
String containerSuffix = "";
String containerPrefix = "";
if (prefix == null) {
// style=form, explode=true, e.g. /pet?name=cat&type=manx
prefix = "";
} else {
// deepObject style e.g. /pet?id[name]=cat&id[type]=manx
prefix = prefix + "[";
suffix = "]";
containerSuffix = "]";
containerPrefix = "[";
}
StringJoiner joiner = new StringJoiner("&");
{{#composedSchemas.oneOf}}
if (getActualInstance() instanceof {{{dataType}}}) {
{{#isArray}}
{{#items.isPrimitiveType}}
{{#uniqueItems}}
if (getActualInstance() != null) {
int i = 0;
for ({{items.dataType}} _item : ({{{dataType}}})getActualInstance()) {
joiner.add(String.format("%s{{baseName}}%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf(_item), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
i++;
}
{{/uniqueItems}}
{{^uniqueItems}}
if (getActualInstance() != null) {
for (int i = 0; i < (({{{dataType}}})getActualInstance()).size(); i++) {
joiner.add(String.format("%s{{baseName}}%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf(getActualInstance().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
}
{{/uniqueItems}}
{{/items.isPrimitiveType}}
{{^items.isPrimitiveType}}
{{#items.isModel}}
{{#uniqueItems}}
if (getActualInstance() != null) {
int i = 0;
for ({{items.dataType}} _item : ({{{dataType}}})getActualInstance()) {
if (_item != null) {
joiner.add(_item.toUrlQueryString(String.format("%s{{baseName}}%s%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix))));
}
}
i++;
}
{{/uniqueItems}}
{{^uniqueItems}}
if (getActualInstance() != null) {
for (int i = 0; i < (({{{dataType}}})getActualInstance()).size(); i++) {
if ((({{{dataType}}})getActualInstance()).get(i) != null) {
joiner.add((({{{items.dataType}}})getActualInstance()).get(i).toUrlQueryString(String.format("%s{{baseName}}%s%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix))));
}
}
}
{{/uniqueItems}}
{{/items.isModel}}
{{^items.isModel}}
{{#uniqueItems}}
if (getActualInstance() != null) {
int i = 0;
for ({{items.dataType}} _item : ({{{dataType}}})getActualInstance()) {
if (_item != null) {
joiner.add(String.format("%s{{baseName}}%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf(_item), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
i++;
}
}
{{/uniqueItems}}
{{^uniqueItems}}
if (getActualInstance() != null) {
for (int i = 0; i < (({{{dataType}}})getActualInstance()).size(); i++) {
if (getActualInstance().get(i) != null) {
joiner.add(String.format("%s{{baseName}}%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf((({{{dataType}}})getActualInstance()).get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
}
}
{{/uniqueItems}}
{{/items.isModel}}
{{/items.isPrimitiveType}}
{{/isArray}}
{{^isArray}}
{{#isMap}}
{{#items.isPrimitiveType}}
if (getActualInstance() != null) {
for (String _key : (({{{dataType}}})getActualInstance()).keySet()) {
joiner.add(String.format("%s{{baseName}}%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix),
getActualInstance().get(_key), URLEncoder.encode(String.valueOf((({{{dataType}}})getActualInstance()).get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
}
{{/items.isPrimitiveType}}
{{^items.isPrimitiveType}}
if (getActualInstance() != null) {
for (String _key : (({{{dataType}}})getActualInstance()).keySet()) {
if ((({{{dataType}}})getActualInstance()).get(_key) != null) {
joiner.add((({{{items.dataType}}})getActualInstance()).get(_key).toUrlQueryString(String.format("%s{{baseName}}%s%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix))));
}
}
}
{{/items.isPrimitiveType}}
{{/isMap}}
{{^isMap}}
{{#isPrimitiveType}}
if (getActualInstance() != null) {
joiner.add(String.format("%s{{{baseName}}}%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getActualInstance()), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
{{/isPrimitiveType}}
{{^isPrimitiveType}}
{{#isModel}}
if (getActualInstance() != null) {
joiner.add((({{{dataType}}})getActualInstance()).toUrlQueryString(prefix + "{{{baseName}}}" + suffix));
}
{{/isModel}}
{{^isModel}}
if (getActualInstance() != null) {
joiner.add(String.format("%s{{{baseName}}}%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getActualInstance()), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
{{/isModel}}
{{/isPrimitiveType}}
{{/isMap}}
{{/isArray}}
return joiner.toString();
}
{{/composedSchemas.oneOf}}
return null;
}
{{/supportUrlQuery}}
}

View File

@@ -13,23 +13,8 @@ import {{import}};
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
{{#hasFormParamsInSpec}}
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
{{/hasFormParamsInSpec}}
import java.io.InputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.net.http.HttpRequest;
import java.nio.channels.Channels;
import java.nio.channels.Pipe;
import java.io.InputStream;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
@@ -440,85 +425,7 @@ public class {{classname}} {
{{/isString}}
{{/bodyParam}}
{{^bodyParam}}
{{#hasFormParams}}
{{#isMultipart}}
MultipartEntityBuilder multiPartBuilder = MultipartEntityBuilder.create();
boolean hasFiles = false;
{{#formParams}}
{{#isArray}}
for (int i=0; i < {{paramName}}.size(); i++) {
multiPartBuilder.addTextBody("{{{baseName}}}", {{paramName}}.get(i).toString());
}
{{/isArray}}
{{^isArray}}
{{#isFile}}
multiPartBuilder.addBinaryBody("{{{baseName}}}", {{paramName}});
hasFiles = true;
{{/isFile}}
{{^isFile}}
multiPartBuilder.addTextBody("{{{baseName}}}", {{paramName}}.toString());
{{/isFile}}
{{/isArray}}
{{/formParams}}
HttpEntity entity = multiPartBuilder.build();
HttpRequest.BodyPublisher formDataPublisher;
if (hasFiles) {
Pipe pipe;
try {
pipe = Pipe.open();
} catch (IOException e) {
throw new RuntimeException(e);
}
new Thread(() -> {
try (OutputStream outputStream = Channels.newOutputStream(pipe.sink())) {
entity.writeTo(outputStream);
} catch (IOException e) {
e.printStackTrace();
}
}).start();
formDataPublisher = HttpRequest.BodyPublishers.ofInputStream(() -> Channels.newInputStream(pipe.source()));
} else {
ByteArrayOutputStream formOutputStream = new ByteArrayOutputStream();
try {
entity.writeTo(formOutputStream);
} catch (IOException e) {
throw new RuntimeException(e);
}
formDataPublisher = HttpRequest.BodyPublishers
.ofInputStream(() -> new ByteArrayInputStream(formOutputStream.toByteArray()));
}
localVarRequestBuilder
.header("Content-Type", entity.getContentType().getValue())
.method("{{httpMethod}}", formDataPublisher);
{{/isMultipart}}
{{^isMultipart}}
List<NameValuePair> formValues = new ArrayList<>();
{{#formParams}}
{{#isArray}}
for (int i=0; i < {{paramName}}.size(); i++) {
formValues.add(new BasicNameValuePair("{{{baseName}}}", {{paramName}}.get(i).toString()));
}
{{/isArray}}
{{^isArray}}
formValues.add(new BasicNameValuePair("{{{baseName}}}", {{paramName}}.toString()));
{{/isArray}}
{{/formParams}}
HttpEntity entity = new UrlEncodedFormEntity(formValues, java.nio.charset.StandardCharsets.UTF_8);
ByteArrayOutputStream formOutputStream = new ByteArrayOutputStream();
try {
entity.writeTo(formOutputStream);
} catch (IOException e) {
throw new RuntimeException(e);
}
localVarRequestBuilder
.header("Content-Type", entity.getContentType().getValue())
.method("{{httpMethod}}", HttpRequest.BodyPublishers
.ofInputStream(() -> new ByteArrayInputStream(formOutputStream.toByteArray())));
{{/isMultipart}}
{{/hasFormParams}}
{{^hasFormParams}}
localVarRequestBuilder.method("{{httpMethod}}", HttpRequest.BodyPublishers.noBody());
{{/hasFormParams}}
{{/bodyParam}}
if (memberVarReadTimeout != null) {
localVarRequestBuilder.timeout(memberVarReadTimeout);

View File

@@ -1,6 +1,5 @@
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'com.diffplug.spotless'
group = '{{groupId}}'
version = '{{artifactVersion}}'
@@ -9,9 +8,6 @@ buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.11.0'
}
}
repositories {
@@ -72,9 +68,6 @@ ext {
jackson_version = "2.14.1"
jakarta_annotation_version = "1.3.5"
junit_version = "4.13.2"
{{#hasFormParamsInSpec}}
httpmime_version = "4.5.13"
{{/hasFormParamsInSpec}}
}
dependencies {
@@ -88,31 +81,5 @@ dependencies {
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
implementation "org.openapitools:jackson-databind-nullable:0.2.1"
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
{{#hasFormParamsInSpec}}
implementation "org.apache.httpcomponents:httpmime:$httpmime_version"
{{/hasFormParamsInSpec}}
testImplementation "junit:junit:$junit_version"
}
// Use spotless plugin to automatically format code, remove unused import, etc
// To apply changes directly to the file, run `gradlew spotlessApply`
// Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle
spotless {
// comment out below to run spotless as part of the `check` task
enforceCheck false
format 'misc', {
// define the files (e.g. '*.gradle', '*.md') to apply `misc` to
target '.gitignore'
// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces() // Takes an integer argument if you don't like 4
endWithNewline()
}
java {
// don't need to set target, it is inferred from java
// apply a specific flavor of google-java-format
googleJavaFormat('1.8').aosp().reflowLongStrings()
removeUnusedImports()
importOrder()
}
}

View File

@@ -320,8 +320,8 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
for ({{items.dataType}} _item : ({{{dataType}}})getActualInstance()) {
if (_item != null) {
joiner.add(String.format("%s{{baseName}}%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf(_item), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)),
URLEncoder.encode(String.valueOf(_item), StandardCharsets.UTF_8).replaceAll("\\+", "%20"));
}
i++;
}

View File

@@ -82,7 +82,12 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{/isContainer}}
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{#isContainer}}
private {{{datatypeWithEnum}}} {{name}}{{#required}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{/required}}{{^required}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{^defaultValue}} = null{{/defaultValue}}{{/required}};
{{/isContainer}}
{{^isContainer}}
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
{{/isContainer}}
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{/vars}}
@@ -131,7 +136,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
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}});
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}});
}
try {
this.{{name}}.get().add({{name}}Item);
@@ -156,7 +161,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
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}});
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}});
}
try {
this.{{name}}.get().put(key, {{name}}Item);
@@ -167,11 +172,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{^required}}
{{#defaultValue}}
if (this.{{name}} == null) {
this.{{name}} = {{{defaultValue}}};
}
{{/defaultValue}}
{{/required}}
this.{{name}}.put(key, {{name}}Item);
return this;
@@ -436,8 +439,8 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
for ({{items.dataType}} _item : {{getter}}()) {
if (_item != null) {
joiner.add(String.format("%s{{baseName}}%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf(_item), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)),
URLEncoder.encode(String.valueOf(_item), StandardCharsets.UTF_8).replaceAll("\\+", "%20"));
}
i++;
}

View File

@@ -134,46 +134,6 @@
</execution>
</executions>
</plugin>
<!-- Use spotless plugin to automatically format code, remove unused import, etc
To apply changes directly to the file, run `mvn spotless:apply`
Ref: https://github.com/diffplug/spotless/tree/main/plugin-maven
-->
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>${spotless.version}</version>
<configuration>
<formats>
<!-- you can define as many formats as you want, each is independent -->
<format>
<!-- define the files to apply to -->
<includes>
<include>.gitignore</include>
</includes>
<!-- define the steps to apply to those files -->
<trimTrailingWhitespace/>
<endWithNewline/>
<indent>
<spaces>true</spaces> <!-- or <tabs>true</tabs> -->
<spacesPerTab>4</spacesPerTab> <!-- optional, default is 4 -->
</indent>
</format>
</formats>
<!-- define a language-specific format -->
<java>
<!-- no need to specify files, inferred automatically, but you can if you want -->
<!-- apply a specific flavor of google-java-format and reflow long strings -->
<googleJavaFormat>
<version>1.8</version>
<style>AOSP</style>
<reflowLongStrings>true</reflowLongStrings>
</googleJavaFormat>
<removeUnusedImports/>
<importOrder/>
</java>
</configuration>
</plugin>
</plugins>
</build>
@@ -248,13 +208,6 @@
<version>${jakarta-annotation-version}</version>
<scope>provided</scope>
</dependency>
{{#hasFormParamsInSpec}}
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>${httpmime-version}</version>
</dependency>
{{/hasFormParamsInSpec}}
<!-- test dependencies -->
<dependency>
@@ -280,10 +233,6 @@
{{^useJakartaEe}}
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
{{/useJakartaEe}}
{{#hasFormParamsInSpec}}
<httpmime-version>4.5.13</httpmime-version>
{{/hasFormParamsInSpec}}
<junit-version>4.13.2</junit-version>
<spotless.version>2.27.2</spotless.version>
</properties>
</project>

View File

@@ -291,7 +291,6 @@ public class ApiClient {
*/
public ApiClient setBasePath(String basePath) {
this.basePath = basePath;
this.serverIndex = null;
return this;
}

View File

@@ -101,7 +101,12 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{/isContainer}}
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{#isContainer}}
private {{{datatypeWithEnum}}} {{name}}{{#required}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{/required}}{{^required}} = null{{/required}};
{{/isContainer}}
{{^isContainer}}
{{#isDiscriminator}}protected{{/isDiscriminator}}{{^isDiscriminator}}private{{/isDiscriminator}} {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
{{/isContainer}}
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{/vars}}
@@ -148,7 +153,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
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}});
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}});
}
try {
this.{{name}}.get().add({{name}}Item);
@@ -159,11 +164,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{^required}}
{{#defaultValue}}
if (this.{{name}} == null) {
this.{{name}} = {{{defaultValue}}};
}
{{/defaultValue}}
{{/required}}
this.{{name}}.add({{name}}Item);
return this;
@@ -175,7 +178,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
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}});
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}});
}
try {
this.{{name}}.get().put(key, {{name}}Item);
@@ -186,11 +189,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{^required}}
{{#defaultValue}}
if (this.{{name}} == null) {
this.{{name}} = {{{defaultValue}}};
}
{{/defaultValue}}
{{/required}}
this.{{name}}.put(key, {{name}}Item);
return this;

View File

@@ -15,9 +15,7 @@
{{/vars}}
})
{{#isClassnameSanitized}}
{{^hasDiscriminatorWithNonEmptyMapping}}
@JsonTypeName("{{name}}")
{{/hasDiscriminatorWithNonEmptyMapping}}
{{/isClassnameSanitized}}
{{/jackson}}
{{>additionalModelTypeAnnotations}}{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}}
@@ -86,7 +84,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{#isContainer}}
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
private {{{datatypeWithEnum}}} {{name}}{{#required}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{/required}}{{^required}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{^defaultValue}} = null{{/defaultValue}}{{/required}};
{{/isContainer}}
{{^isContainer}}
{{#isDiscriminator}}protected{{/isDiscriminator}}{{^isDiscriminator}}private{{/isDiscriminator}} {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
@@ -136,7 +134,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
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}});
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}{{^defaultValue}}null{{/defaultValue}});
}
try {
this.{{name}}.get().add({{name}}Item);
@@ -147,11 +145,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{^required}}
{{#defaultValue}}
if (this.{{name}} == null) {
this.{{name}} = {{{defaultValue}}};
}
{{/defaultValue}}
{{/required}}
this.{{name}}.add({{name}}Item);
return this;
@@ -163,7 +159,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
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}});
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}});
}
try {
this.{{name}}.get().put(key, {{name}}Item);
@@ -174,11 +170,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{^required}}
{{#defaultValue}}
if (this.{{name}} == null) {
this.{{name}} = {{{defaultValue}}};
}
{{/defaultValue}}
{{/required}}
this.{{name}}.put(key, {{name}}Item);
return this;
@@ -444,8 +438,8 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
if (_item != null) {
try {
joiner.add(String.format("%s{{baseName}}%s%s=%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
URLEncoder.encode(String.valueOf(_item), "UTF-8").replaceAll("\\+", "%20")));
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)),
URLEncoder.encode(String.valueOf(_item), "UTF-8").replaceAll("\\+", "%20"));
} catch (UnsupportedEncodingException e) {
// Should never happen, UTF-8 is always supported
throw new RuntimeException(e);

View File

@@ -18,8 +18,12 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}} {{#vendorExtens
{{#vendorExtensions.x-field-extra-annotation}}
{{{vendorExtensions.x-field-extra-annotation}}}
{{/vendorExtensions.x-field-extra-annotation}}
{{#isContainer}}
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
{{/isContainer}}
{{^isContainer}}
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
{{/vars}}
{{/isContainer}}{{/vars}}
{{#vars}}
/**
@@ -53,7 +57,7 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}} {{#vendorExtens
public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
{{^required}}
if (this.{{name}} == null) {
this.{{name}} = {{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}ArrayList{{/uniqueItems}}<>(){{/defaultValue}};
this.{{name}} = {{{defaultValue}}};
}
{{/required}}
this.{{name}}.add({{name}}Item);
@@ -66,7 +70,7 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}} {{#vendorExtens
public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
{{^required}}
if (this.{{name}} == null) {
this.{{name}} = {{{defaultValue}}}{{^defaultValue}}new HashMap<>(){{/defaultValue}};
this.{{name}} = {{{defaultValue}}};
}
{{/required}}
this.{{name}}.put(key, {{name}}Item);

View File

@@ -51,7 +51,12 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}}{{#vendorExtensi
{{#vendorExtensions.x-field-extra-annotation}}
{{{vendorExtensions.x-field-extra-annotation}}}
{{/vendorExtensions.x-field-extra-annotation}}
{{#isContainer}}
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
{{/isContainer}}
{{^isContainer}}
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
{{/isContainer}}
{{/vars}}
{{#vars}}
/**

View File

@@ -47,7 +47,12 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}}{{#vendorExtensi
{{/isContainer}}
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{^vendorExtensions.x-is-jackson-optional-nullable}}
{{#isContainer}}
private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}};
{{/isContainer}}
{{^isContainer}}
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
{{/isContainer}}
{{/vendorExtensions.x-is-jackson-optional-nullable}}
{{/vars}}
{{#vars}}
@@ -151,7 +156,7 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}}{{#vendorExtensi
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}});
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}});
}
this.{{name}}.get().add({{name}}Item);
return this;
@@ -167,7 +172,7 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}}{{#vendorExtensi
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}});
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}});
}
this.{{name}}.get().put(key, {{name}}Item);
return this;

View File

@@ -36,7 +36,12 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}} {{#vendorExtens
{{#vendorExtensions.x-field-extra-annotation}}
{{{vendorExtensions.x-field-extra-annotation}}}
{{/vendorExtensions.x-field-extra-annotation}}
{{#isContainer}}
private {{{datatypeWithEnum}}} {{name}}{{#required}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{/required}}{{^required}} = null{{/required}};
{{/isContainer}}
{{^isContainer}}
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
{{/isContainer}}
{{/vars}}
{{#vars}}
@@ -49,7 +54,7 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}} {{#vendorExtens
public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
{{^required}}
if (this.{{name}} == null) {
this.{{name}} = {{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}ArrayList{{/uniqueItems}}<>(){{/defaultValue}};
this.{{name}} = {{{defaultValue}}};
}
{{/required}}
this.{{name}}.add({{name}}Item);
@@ -61,7 +66,7 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}} {{#vendorExtens
public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
{{^required}}
if (this.{{name}} == null) {
this.{{name}} = {{{defaultValue}}}{{^defaultValue}}new HashMap<>(){{/defaultValue}};
this.{{name}} = {{{defaultValue}}};
}
{{/required}}
this.{{name}}.put(key, {{name}}Item);

View File

@@ -31,7 +31,12 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}} {{#vendorExtens
{{#vendorExtensions.x-field-extra-annotation}}
{{{vendorExtensions.x-field-extra-annotation}}}
{{/vendorExtensions.x-field-extra-annotation}}
{{#isContainer}}
private {{#useBeanValidation}}@Valid {{/useBeanValidation}}{{{datatypeWithEnum}}} {{name}}{{#required}}{{^isNullable}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{/isNullable}}{{#isNullable}} = null{{/isNullable}}{{/required}}{{^required}} = null{{/required}};
{{/isContainer}}
{{^isContainer}}
private {{#useBeanValidation}}@Valid {{/useBeanValidation}}{{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};
{{/isContainer}}
{{/vars}}
{{#generateBuilders}}
{{^additionalProperties}}
@@ -83,7 +88,7 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}} {{#vendorExtens
{{#isArray}}
public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) {
if (this.{{name}} == null) {
this.{{name}} = {{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}ArrayList{{/uniqueItems}}<>(){{/defaultValue}};
this.{{name}} = {{{defaultValue}}};
}
this.{{name}}.add({{name}}Item);
@@ -101,7 +106,7 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}} {{#vendorExtens
{{#isMap}}
public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
if (this.{{name}} == null) {
this.{{name}} = {{{defaultValue}}}{{^defaultValue}}new HashMap<>(){{/defaultValue}};
this.{{name}} = {{{defaultValue}}};
}
this.{{name}}.put(key, {{name}}Item);

View File

@@ -89,20 +89,11 @@
<artifactId>joda-time</artifactId>
<version>${joda-version}</version>
</dependency>
{{#useJakartaEe}}
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>${javax.annotation-api-version}</version>
</dependency>
{{/useJakartaEe}}
{{^useJakartaEe}}
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>${javax.annotation-api-version}</version>
</dependency>
{{/useJakartaEe}}
{{#useSwaggerAnnotations}}
<dependency>
<groupId>io.swagger</groupId>
@@ -163,25 +154,10 @@
<jackson-version>2.9.9</jackson-version>
<junit-version>4.13.2</junit-version>
<joda-version>2.10.13</joda-version>
{{#useJakartaEe}}
<javax.annotation-api-version>2.1.1</javax.annotation-api-version>
{{/useJakartaEe}}
{{^useJakartaEe}}
<javax.annotation-api-version>1.3.2</javax.annotation-api-version>
{{/useJakartaEe}}
{{#useBeanValidation}}
{{#useJakartaEe}}
<beanvalidation-version>3.0.2</beanvalidation-version>
{{/useJakartaEe}}
{{^useJakartaEe}}
<beanvalidation-version>2.0.2</beanvalidation-version>
{{/useJakartaEe}}
{{/useBeanValidation}}
{{#useJakartaEe}}
<jakarta.ws.rs-version>3.1.0</jakarta.ws.rs-version>
{{/useJakartaEe}}
{{^useJakartaEe}}
<jakarta.ws.rs-version>2.1.6</jakarta.ws.rs-version>
{{/useJakartaEe}}
</properties>
</project>

View File

@@ -79,10 +79,10 @@ import {{javaxPackage}}.annotation.Generated;
@Controller
{{/useSpringController}}
{{#swagger2AnnotationLibrary}}
@Tag(name = "{{{tagName}}}", description = {{#tagDescription}}"{{{.}}}"{{/tagDescription}}{{^tagDescription}}"the {{{tagName}}} API"{{/tagDescription}})
@Tag(name = "{{{baseName}}}", description = {{#tagDescription}}"{{{.}}}"{{/tagDescription}}{{^tagDescription}}"the {{{baseName}}} API"{{/tagDescription}})
{{/swagger2AnnotationLibrary}}
{{#swagger1AnnotationLibrary}}
@Api(value = "{{{tagName}}}", description = {{#tagDescription}}"{{{.}}}"{{/tagDescription}}{{^tagDescription}}"the {{{tagName}}} API"{{/tagDescription}})
@Api(value = "{{{baseName}}}", description = {{#tagDescription}}"{{{.}}}"{{/tagDescription}}{{^tagDescription}}"the {{{baseName}}} API"{{/tagDescription}})
{{/swagger1AnnotationLibrary}}
{{#operations}}
{{#virtualService}}

View File

@@ -1 +0,0 @@
{{! RequestBody required param is responsible for optional and nullability }}{{>beanValidationCore}}

View File

@@ -1 +1 @@
{{#isBodyParam}}{{>paramDoc}}{{#useBeanValidation}} @Valid{{>beanValidationBodyParams}}{{/useBeanValidation}} @RequestBody{{^required}}(required = false){{/required}} {{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isArray}}Mono<{{{dataType}}}>{{/isArray}}{{#isArray}}Flux<{{{baseType}}}>{{/isArray}}{{/reactive}} {{paramName}}{{/isBodyParam}}
{{#isBodyParam}}{{>paramDoc}}{{#useBeanValidation}} @Valid{{/useBeanValidation}} @RequestBody{{^required}}(required = false){{/required}} {{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isArray}}Mono<{{{dataType}}}>{{/isArray}}{{#isArray}}Flux<{{{baseType}}}>{{/isArray}}{{/reactive}} {{paramName}}{{/isBodyParam}}

View File

@@ -15,9 +15,7 @@
{{/discriminator}}
{{#jackson}}
{{#isClassnameSanitized}}
{{^hasDiscriminatorWithNonEmptyMapping}}
@JsonTypeName("{{name}}")
{{/hasDiscriminatorWithNonEmptyMapping}}
{{/isClassnameSanitized}}
{{/jackson}}
{{#withXml}}
@@ -98,7 +96,7 @@ public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{^parent}}
{{#openApiNullable}}
{{^required}}
if (this.{{name}} == null{{#isNullable}} || !this.{{name}}.isPresent(){{/isNullable}}) {
this.{{name}} = {{#isNullable}}JsonNullable.of({{/isNullable}}{{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}ArrayList{{/uniqueItems}}<>(){{/defaultValue}}{{#isNullable}}){{/isNullable}};
this.{{name}} = {{#isNullable}}JsonNullable.of({{{defaultValue}}}){{/isNullable}}{{^isNullable}}{{{defaultValue}}}{{/isNullable}};
}
{{/required}}
this.{{name}}{{#isNullable}}.get(){{/isNullable}}.add({{name}}Item);
@@ -117,7 +115,7 @@ public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{^parent}}
public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
{{^required}}
if (this.{{name}} == null) {
this.{{name}} = {{{defaultValue}}}{{^defaultValue}}new HashMap<>(){{/defaultValue}};
this.{{name}} = {{{defaultValue}}};
}
{{/required}}
this.{{name}}.put(key, {{name}}Item);

View File

@@ -80,7 +80,7 @@ class {{classname}} {{#parent}}{{^parentModel}}{{#vendorExtensions.x-is-array}}e
}
// validate the required field `{{{baseName}}}` (array)
for (const item of data['{{{baseName}}}']) {
{{{items.dataType}}}.validateJSON(item);
{{{items.dataType}}}.validateJsonObject(item);
};
{{/isRequired}}
{{^isRequired}}
@@ -91,7 +91,7 @@ class {{classname}} {{#parent}}{{^parentModel}}{{#vendorExtensions.x-is-array}}e
}
// validate the optional field `{{{baseName}}}` (array)
for (const item of data['{{{baseName}}}']) {
{{{items.dataType}}}.validateJSON(item);
{{{items.dataType}}}.validateJsonObject(item);
};
}
{{/isRequired}}

View File

@@ -531,15 +531,6 @@ namespace {{packageName}}.Client
return await ToApiResponse<T>(response, responseData, req.RequestUri);
}
catch (OperationCanceledException original)
{
if (timeoutTokenSource != null && timeoutTokenSource.IsCancellationRequested)
{
throw new TaskCanceledException($"[{req.Method}] {req.RequestUri} was timeout.",
new TimeoutException(original.Message, original));
}
throw;
}
finally
{
if (timeoutTokenSource != null)

View File

@@ -6,7 +6,6 @@
"yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffK",
"yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fK",
"yyyy'-'MM'-'dd'T'HH':'mm':'ssK",
"yyyy'-'MM'-'dd",
"yyyyMMddTHHmmss.fffffffK",
"yyyyMMddTHHmmss.ffffffK",
"yyyyMMddTHHmmss.fffffK",
@@ -14,5 +13,4 @@
"yyyyMMddTHHmmss.fffK",
"yyyyMMddTHHmmss.ffK",
"yyyyMMddTHHmmss.fK",
"yyyyMMddTHHmmssK",
"yyyyMMdd"
"yyyyMMddTHHmmssK",

View File

@@ -12,10 +12,7 @@ namespace {{packageName}}.{{clientPackage}}
/// </summary>
{{>visibility}} class DateTimeJsonConverter : JsonConverter<DateTime>
{
/// <summary>
/// The formats used to deserialize the date
/// </summary>
public static string[] Formats { get; } = {
public static readonly string[] FORMATS = {
{{>DateTimeFormats}}
};
@@ -32,7 +29,7 @@ namespace {{packageName}}.{{clientPackage}}
string value = reader.GetString(){{nrt!}};
foreach(string format in Formats)
foreach(string format in FORMATS)
if (DateTime.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out DateTime result))
return result;
@@ -46,6 +43,6 @@ namespace {{packageName}}.{{clientPackage}}
/// <param name="dateTimeValue"></param>
/// <param name="options"></param>
public override void Write(Utf8JsonWriter writer, DateTime dateTimeValue, JsonSerializerOptions options) =>
writer.WriteStringValue(dateTimeValue.ToString(Formats[0], CultureInfo.InvariantCulture));
writer.WriteStringValue(dateTimeValue.ToString(FORMATS[0], CultureInfo.InvariantCulture));
}
}

View File

@@ -12,10 +12,7 @@ namespace {{packageName}}.{{clientPackage}}
/// </summary>
{{>visibility}} class DateTimeNullableJsonConverter : JsonConverter<DateTime?>
{
/// <summary>
/// The formats used to deserialize the date
/// </summary>
public static string[] Formats { get; } = {
public static readonly string[] FORMATS = {
{{>DateTimeFormats}}
};
@@ -32,7 +29,7 @@ namespace {{packageName}}.{{clientPackage}}
string value = reader.GetString(){{nrt!}};
foreach(string format in Formats)
foreach(string format in FORMATS)
if (DateTime.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal, out DateTime result))
return result;
@@ -50,7 +47,7 @@ namespace {{packageName}}.{{clientPackage}}
if (dateTimeValue == null)
writer.WriteNullValue();
else
writer.WriteStringValue(dateTimeValue.Value.ToString(Formats[0], CultureInfo.InvariantCulture));
writer.WriteStringValue(dateTimeValue.Value.ToString(FORMATS[0], CultureInfo.InvariantCulture));
}
}
}

View File

@@ -3,22 +3,6 @@
/// </summary>
{{>visibility}} class {{classname}}JsonConverter : JsonConverter<{{classname}}>
{
{{#allVars}}
{{#isDateTime}}
/// <summary>
/// The format to use to serialize {{name}}
/// </summary>
public static string {{name}}Format { get; set; } = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK";
{{/isDateTime}}
{{#isDate}}
/// <summary>
/// The format to use to serialize {{name}}
/// </summary>
public static string {{name}}Format { get; set; } = "yyyy-MM-dd";
{{/isDate}}
{{/allVars}}
/// <summary>
/// A Json reader.
/// </summary>
@@ -224,26 +208,12 @@
{{/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}}
writer.WritePropertyName("{{baseName}}");
JsonSerializer.Serialize(writer, {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}, jsonSerializerOptions);
{{/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}}
writer.WritePropertyName("{{baseName}}");
JsonSerializer.Serialize(writer, {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}, jsonSerializerOptions);
{{/isDateTime}}
{{#isEnum}}
{{#isNumeric}}

View File

@@ -271,8 +271,8 @@ namespace {{packageName}}.{{apiPackage}}
{
{{^servers}}
uriBuilder.Host = HttpClient.BaseAddress{{nrt!}}.Host;
uriBuilder.Port = HttpClient.BaseAddress.Port;
uriBuilder.Scheme = HttpClient.BaseAddress.Scheme;
uriBuilder.Port = HttpClient.BaseAddress{{nrt!}}.Port;
uriBuilder.Scheme = ClientUtils.SCHEME;
uriBuilder.Path = ClientUtils.CONTEXT_PATH + "{{path}}";
{{/servers}}

View File

@@ -533,15 +533,6 @@ namespace {{packageName}}.Client
return await ToApiResponse<T>(response, responseData, req.RequestUri);
}
catch (OperationCanceledException original)
{
if (timeoutTokenSource != null && timeoutTokenSource.IsCancellationRequested)
{
throw new TaskCanceledException($"[{req.Method}] {req.RequestUri} was timeout.",
new TimeoutException(original.Message, original));
}
throw;
}
finally
{
if (timeoutTokenSource != null)

View File

@@ -19,11 +19,8 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
## Requirements
* Dart 2.15.0+ or Flutter 2.8.0+
* Dio 5.0.0+ (https://pub.dev/packages/dio)
{{#useJsonSerializable}}
* JSON Serializable 6.1.5+ (https://pub.dev/packages/json_serializable)
{{/useJsonSerializable}}
* Dart 2.12.0 or later OR Flutter 1.26.0 or later
* Dio 4.0.0+
{{#useDateLibTimeMachine}}
* timemachine option currently **DOES NOT** support sound null-safety and may not work
{{/useDateLibTimeMachine}}

View File

@@ -8,5 +8,3 @@ analyzer:
exclude:
- test/*.dart{{#useJsonSerializable}}
- lib/src/model/*.g.dart{{/useJsonSerializable}}
errors:
deprecated_member_use_from_same_package: ignore

View File

@@ -99,10 +99,9 @@ class {{classname}} {
_path,{{#hasQueryParams}}
queryParameters: _queryParameters,{{/hasQueryParams}}
),
type: DioErrorType.unknown,
type: DioErrorType.other,
error: error,
stackTrace: stackTrace,
);
)..stackTrace = stackTrace;
}{{/hasBodyOrFormParams}}
final _response = await _dio.request<Object>(
@@ -124,10 +123,9 @@ class {{classname}} {
throw DioError(
requestOptions: _response.requestOptions,
response: _response,
type: DioErrorType.unknown,
type: DioErrorType.other,
error: error,
stackTrace: stackTrace,
);
)..stackTrace = stackTrace;
}
return Response<{{{returnType}}}>(

View File

@@ -25,8 +25,8 @@ class {{clientName}} {
this.dio = dio ??
Dio(BaseOptions(
baseUrl: basePathOverride ?? basePath,
connectTimeout: const Duration(milliseconds: 5000),
receiveTimeout: const Duration(milliseconds: 3000),
connectTimeout: 5000,
receiveTimeout: 3000,
)) {
if (interceptors == null) {
this.dio.interceptors.addAll([

View File

@@ -4,10 +4,15 @@ description: {{pubDescription}}
homepage: {{pubHomepage}}
environment:
sdk: '>=2.15.0 <3.0.0'
{{#useBuiltValue}}
sdk: '>=2.12.0 <3.0.0'
{{/useBuiltValue}}
{{#useJsonSerializable}}
sdk: '>=2.14.0 <3.0.0'
{{/useJsonSerializable}}
dependencies:
dio: '^5.0.0'
dio: '>=4.0.1 <5.0.0'
{{#useBuiltValue}}
one_of: '>=1.5.0 <2.0.0'
one_of_serializer: '>=1.5.0 <2.0.0'

View File

@@ -6,8 +6,5 @@
/// * [{{{name}}}] {{#description}}- {{{.}}}{{/description}}
{{/allVars}}
{{/hasVars}}
{{#isDeprecated}}
@Deprecated('{{{classname}}} has been deprecated')
{{/isDeprecated}}
@BuiltValue({{#vendorExtensions.x-is-parent}}instantiable: false{{/vendorExtensions.x-is-parent}})
abstract class {{classname}} {{^allOf}}{{^vendorExtensions.x-is-parent}}implements {{/vendorExtensions.x-is-parent}}{{/allOf}}{{#allOf}}{{#-first}}implements {{/-first}}{{/allOf}}{{#allOf}}{{{.}}}{{^-last}}, {{/-last}}{{/allOf}}{{^vendorExtensions.x-is-parent}}{{#allOf}}{{#-first}}, {{/-first}}{{/allOf}}{{/vendorExtensions.x-is-parent}}{{^vendorExtensions.x-is-parent}}Built<{{classname}}, {{classname}}Builder>{{/vendorExtensions.x-is-parent}}

View File

@@ -3,9 +3,6 @@
{{#description}}
/// {{{.}}}
{{/description}}
{{#isDeprecated}}
@Deprecated('{{{name}}} has been deprecated')
{{/isDeprecated}}
@BuiltValueField(wireName: r'{{baseName}}')
{{>serialization/built_value/variable_type}}{{^isNullable}}{{^required}}?{{/required}}{{/isNullable}} get {{name}};
{{#allowableValues}}

View File

@@ -59,15 +59,14 @@ class _${{classname}}Serializer implements PrimitiveSerializer<{{classname}}> {
{{#anyOf}}
{{#-first}}
final anyOf = object.anyOf;
{{#vendorExtensions.x-self-and-ancestor-only-props}}
final result = _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
final serialized = serializers.serialize(anyOf, specifiedType: FullType(AnyOf, anyOf.valueTypes.map((type) => FullType(type)).toList()));
result.addAll((serialized is Map ? serialized.entries.map((e) => <dynamic>[e.key, e.value]).expand<dynamic>((e) => e) : serialized) as Iterable<Object?>);
final result = {{^vendorExtensions.x-has-self-and-ancestor-only-props}}<Object?>[]{{/vendorExtensions.x-has-self-and-ancestor-only-props}}{{#vendorExtensions.x-has-self-and-ancestor-only-props}}_serializeProperties(serializers, object, specifiedType: specifiedType).toList(){{/vendorExtensions.x-has-self-and-ancestor-only-props}};
for (var _valueEntry in anyOf.values.entries) {
final _typeIndex = _valueEntry.key;
final _type = anyOf.types[_typeIndex];
final _value = _valueEntry.value;
result.addAll(serializers.serialize(_value, specifiedType: FullType(_type)) as Iterable<Object?>);
}
return result;
{{/vendorExtensions.x-self-and-ancestor-only-props}}
{{^vendorExtensions.x-self-and-ancestor-only-props}}
return serializers.serialize(anyOf, specifiedType: FullType(AnyOf, anyOf.valueTypes.map((type) => FullType(type)).toList()))!;
{{/vendorExtensions.x-self-and-ancestor-only-props}}
{{/-first}}
{{/anyOf}}
{{^oneOf}}

View File

@@ -4,9 +4,6 @@ import 'package:built_value/serializer.dart';
part '{{classFilename}}.g.dart';
{{#isDeprecated}}
@Deprecated('{{{classname}}} has been deprecated')
{{/isDeprecated}}
class {{classname}} extends EnumClass {
{{#allowableValues}}

View File

@@ -1,6 +1,3 @@
{{#isDeprecated}}
@Deprecated('{{{enumName}}} has been deprecated')
{{/isDeprecated}}
class {{{enumName}}} extends EnumClass {
{{#allowableValues}}

View File

@@ -11,9 +11,6 @@ part '{{classFilename}}.g.dart';
{{/parentModel}}
{{#isDeprecated}}
@Deprecated('{{{classname}}} has been deprecated')
{{/isDeprecated}}
@JsonSerializable(
checked: true,
createToJson: true,
@@ -35,9 +32,6 @@ class {{{classname}}} {
// maximum: {{{maximum}}}
{{/maximum}}
{{/isEnum}}
{{#isDeprecated}}
@Deprecated('{{{name}}} has been deprecated')
{{/isDeprecated}}
{{^isBinary}}
@JsonKey(
{{#defaultValue}}defaultValue: {{{defaultValue}}},{{/defaultValue}}

View File

@@ -1,9 +1,6 @@
import 'package:json_annotation/json_annotation.dart';
{{#description}}/// {{{description}}}{{/description}}
{{#isDeprecated}}
@Deprecated('{{{classname}}} has been deprecated')
{{/isDeprecated}}
enum {{{classname}}} {
{{#allowableValues}}
{{#enumVars}}

View File

@@ -1,8 +1,5 @@
{{#enumName}}
{{#description}}/// {{{description}}}{{/description}}
{{#isDeprecated}}
@Deprecated('{{{enumName}}} has been deprecated')
{{/isDeprecated}}
enum {{{ enumName }}} {
{{#allowableValues}}
{{#enumVars}}

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