mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-06 12:36:09 +00:00
Compare commits
14 Commits
ruby-githu
...
v7.16.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0b72ee970 | ||
|
|
ee76a05def | ||
|
|
30096d63b7 | ||
|
|
44a3be170f | ||
|
|
e38f6c0580 | ||
|
|
2afac1aa28 | ||
|
|
bab5ca2452 | ||
|
|
c1931c10da | ||
|
|
d8d9744154 | ||
|
|
dc0d5c6839 | ||
|
|
89edad5b8a | ||
|
|
258d971f42 | ||
|
|
5e8dcc9f07 | ||
|
|
67b24330c9 |
7
.github/workflows/samples-go.yaml
vendored
7
.github/workflows/samples-go.yaml
vendored
@@ -6,13 +6,13 @@ on:
|
||||
- 'samples/server/petstore/go-echo-server/**'
|
||||
- 'samples/server/petstore/go-api-server/**'
|
||||
- 'samples/server/petstore/go-chi-server/**'
|
||||
- 'samples/server/others/go-server/no-body-path-params/**'
|
||||
- 'samples/server/others/go-server/**'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'samples/server/petstore/go-echo-server/**'
|
||||
- 'samples/server/petstore/go-api-server/**'
|
||||
- 'samples/server/petstore/go-chi-server/**'
|
||||
- 'samples/server/others/go-server/no-body-path-params/**'
|
||||
- 'samples/server/others/go-server/**'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -26,6 +26,7 @@ jobs:
|
||||
- samples/server/petstore/go-api-server/
|
||||
- samples/server/petstore/go-chi-server/
|
||||
- samples/server/others/go-server/no-body-path-params/
|
||||
- samples/server/others/go-server/optional-body/
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-go@v6
|
||||
@@ -58,4 +59,4 @@ jobs:
|
||||
go mod tidy
|
||||
- name: Run tests
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: go test ./samples_tests -v
|
||||
run: go test ./samples_tests -v
|
||||
|
||||
@@ -5,6 +5,7 @@ on:
|
||||
paths:
|
||||
- 'samples/client/petstore/java/**'
|
||||
- samples/client/petstore/jaxrs-cxf-client/**
|
||||
- samples/client/petstore/jaxrs-cxf-client-swagger2/**
|
||||
- samples/client/petstore/java-micronaut-client/**
|
||||
- samples/openapi3/client/petstore/java/jersey2-java8-special-characters/**
|
||||
- samples/openapi3/client/petstore/java/jersey2-java8-swagger1/**
|
||||
@@ -27,6 +28,7 @@ on:
|
||||
paths:
|
||||
- 'samples/client/petstore/java/**'
|
||||
- samples/client/petstore/jaxrs-cxf-client/**
|
||||
- samples/client/petstore/jaxrs-cxf-client-swagger2/**
|
||||
- samples/client/petstore/java-micronaut-client/**
|
||||
- samples/openapi3/client/petstore/java/jersey2-java8-special-characters/**
|
||||
- samples/openapi3/client/petstore/java/jersey2-java8-swagger1/**
|
||||
@@ -54,6 +56,7 @@ jobs:
|
||||
matrix:
|
||||
sample:
|
||||
# clients
|
||||
- samples/client/petstore/jaxrs-cxf-client-swagger2
|
||||
- samples/client/petstore/jaxrs-cxf-client
|
||||
- samples/client/petstore/java/native
|
||||
- samples/client/petstore/java/native-async
|
||||
|
||||
@@ -34,6 +34,7 @@ jobs:
|
||||
# server
|
||||
- samples/server/petstore/kotlin-server-required-and-nullable-properties
|
||||
- samples/server/petstore/kotlin-springboot-3
|
||||
- samples/server/petstore/kotlin-springboot-additionalproperties
|
||||
- samples/server/petstore/kotlin-springboot-delegate-nodefaults
|
||||
- samples/server/petstore/kotlin-springboot-request-cookie
|
||||
- samples/server/petstore/kotlin-server/jaxrs-spec
|
||||
@@ -67,4 +68,4 @@ jobs:
|
||||
arguments: wrapper
|
||||
- name: Build
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: ./gradlew build -x test
|
||||
run: ./gradlew build -x test
|
||||
|
||||
2
.github/workflows/samples-kotlin-server.yaml
vendored
2
.github/workflows/samples-kotlin-server.yaml
vendored
@@ -76,4 +76,4 @@ jobs:
|
||||
arguments: wrapper
|
||||
- name: Build
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: ./gradlew build -x test
|
||||
run: ./gradlew build -x test
|
||||
|
||||
@@ -34,6 +34,7 @@ jobs:
|
||||
- "3.13"
|
||||
sample:
|
||||
- samples/openapi3/client/petstore/python-aiohttp
|
||||
- samples/openapi3/client/petstore/python-httpx
|
||||
- samples/openapi3/client/petstore/python
|
||||
- samples/openapi3/client/petstore/python-lazyImports
|
||||
services:
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
name: Samples Ruby
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'samples/client/echo_api/ruby-httpx/**'
|
||||
- 'samples/client/echo_api/ruby-faraday/**'
|
||||
- 'samples/client/echo_api/ruby-typhoeus/**'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'samples/client/echo_api/ruby-httpx/**'
|
||||
- 'samples/client/echo_api/ruby-faraday/**'
|
||||
- 'samples/client/echo_api/ruby-typhoeus/**'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build Ruby
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
sample:
|
||||
- 'samples/client/echo_api/ruby-httpx/'
|
||||
- 'samples/client/echo_api/ruby-faraday/'
|
||||
- 'samples/client/echo_api/ruby-typhoeus/'
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- name: Setup node.js
|
||||
uses: actions/setup-node@v5
|
||||
- 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 &)
|
||||
- uses: actions/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 3.2
|
||||
bundler-cache: true
|
||||
- name: Install bundle
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: bundle install
|
||||
- name: Run rspec
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: rspec
|
||||
47
.github/workflows/samples-ruby.yaml
vendored
47
.github/workflows/samples-ruby.yaml
vendored
@@ -1,18 +1,16 @@
|
||||
name: Samples Ruby
|
||||
name: Samples Ruby
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- samples/client/petstore/ruby/**
|
||||
- samples/client/petstore/ruby-faraday/**
|
||||
- samples/client/petstore/ruby-httpx/**
|
||||
- samples/client/petstore/ruby-autoload/**
|
||||
- 'samples/client/echo_api/ruby-httpx/**'
|
||||
- 'samples/client/echo_api/ruby-faraday/**'
|
||||
- 'samples/client/echo_api/ruby-typhoeus/**'
|
||||
pull_request:
|
||||
paths:
|
||||
- samples/client/petstore/ruby/**
|
||||
- samples/client/petstore/ruby-faraday/**
|
||||
- samples/client/petstore/ruby-httpx/**
|
||||
- samples/client/petstore/ruby-autoload/**
|
||||
- 'samples/client/echo_api/ruby-httpx/**'
|
||||
- 'samples/client/echo_api/ruby-faraday/**'
|
||||
- 'samples/client/echo_api/ruby-typhoeus/**'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -22,28 +20,21 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
sample:
|
||||
- samples/client/petstore/ruby/
|
||||
#- samples/client/petstore/ruby-faraday/
|
||||
#- samples/client/petstore/ruby-httpx/
|
||||
#- samples/client/petstore/ruby-autoload/
|
||||
services:
|
||||
petstore-api:
|
||||
image: swaggerapi/petstore
|
||||
ports:
|
||||
- 80:8080
|
||||
env:
|
||||
SWAGGER_HOST: http://petstore.swagger.io
|
||||
SWAGGER_BASE_PATH: /v2
|
||||
- 'samples/client/echo_api/ruby-httpx/'
|
||||
- 'samples/client/echo_api/ruby-faraday/'
|
||||
- 'samples/client/echo_api/ruby-typhoeus/'
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
#- name: Add hosts to /etc/hosts
|
||||
# run: |
|
||||
# sudo echo "127.0.0.1 petstore.swagger.io" | sudo tee -a /etc/hosts
|
||||
# cat /etc/hosts
|
||||
- uses: ruby/setup-ruby@v1
|
||||
- name: Setup node.js
|
||||
uses: actions/setup-node@v5
|
||||
- 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 &)
|
||||
- uses: actions/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: '3.4' # Not needed with a .ruby-version, .tool-versions or mise.toml
|
||||
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
||||
ruby-version: 3.0
|
||||
bundler-cache: true
|
||||
- name: Install bundle
|
||||
working-directory: ${{ matrix.sample }}
|
||||
run: bundle install
|
||||
|
||||
18
README.md
18
README.md
@@ -15,7 +15,7 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.16.0`):
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.17.0`):
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://app.bitrise.io/app/4a2b10a819d12b67)
|
||||
|
||||
@@ -148,8 +148,8 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
|
||||
|
||||
| OpenAPI Generator Version | Release Date | Notes |
|
||||
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------------------------------------- |
|
||||
| 7.16.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.16.0-SNAPSHOT/) | 22.09.2025 | Minor release with breaking changes (with fallback) |
|
||||
| [7.15.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.15.0) (latest stable release) | 22.08.2025 | Minor release with breaking changes (with fallback) |
|
||||
| 7.17.0 (upcoming minor release) [SNAPSHOT](https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-to-test-with-the-latest-master-of-openapi-generator) | 24.10.2025 | Minor release with breaking changes (with fallback) |
|
||||
| [7.16.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.16.0) (latest stable release) | 28.09.2025 | Minor release with breaking changes (with fallback) |
|
||||
| [6.6.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v6.6.0) | 11.05.2023 | Minor release with breaking changes (with fallback) |
|
||||
| [5.4.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v5.4.0) | 31.01.2022 | Minor release with breaking changes (with fallback) |
|
||||
| [4.3.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v4.3.1) | 06.05.2020 | Patch release (enhancements, bug fixes, etc) |
|
||||
@@ -212,16 +212,16 @@ See the different versions of the [openapi-generator-cli](https://search.maven.o
|
||||
<!-- RELEASE_VERSION -->
|
||||
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 11 runtime at a minimum):
|
||||
|
||||
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.15.0/openapi-generator-cli-7.15.0.jar`
|
||||
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.16.0/openapi-generator-cli-7.16.0.jar`
|
||||
|
||||
For **Mac/Linux** users:
|
||||
```sh
|
||||
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.15.0/openapi-generator-cli-7.15.0.jar -O openapi-generator-cli.jar
|
||||
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.16.0/openapi-generator-cli-7.16.0.jar -O openapi-generator-cli.jar
|
||||
```
|
||||
|
||||
For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
|
||||
```
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.15.0/openapi-generator-cli-7.15.0.jar
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.16.0/openapi-generator-cli-7.16.0.jar
|
||||
```
|
||||
|
||||
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
|
||||
@@ -456,7 +456,7 @@ openapi-generator-cli version
|
||||
To use a specific version of "openapi-generator-cli"
|
||||
|
||||
```sh
|
||||
openapi-generator-cli version-manager set 7.15.0
|
||||
openapi-generator-cli version-manager set 7.16.0
|
||||
```
|
||||
|
||||
Or install it as dev-dependency:
|
||||
@@ -480,7 +480,7 @@ pip install openapi-generator-cli
|
||||
|
||||
To install a specific version
|
||||
```
|
||||
pip install openapi-generator-cli==7.15.0
|
||||
pip install openapi-generator-cli==7.16.0
|
||||
```
|
||||
|
||||
You can also install with [jdk4py](https://github.com/activeviam/jdk4py) instead of java binary. (python>=3.10 is required)
|
||||
@@ -506,7 +506,7 @@ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generat
|
||||
(if you're on Windows, replace the last command with `java -jar modules\openapi-generator-cli\target\openapi-generator-cli.jar generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g php -o c:\temp\php_api_client`)
|
||||
|
||||
<!-- RELEASE_VERSION -->
|
||||
You can also download the JAR (latest release) directly from [maven.org](https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.15.0/openapi-generator-cli-7.15.0.jar)
|
||||
You can also download the JAR (latest release) directly from [maven.org](https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.16.0/openapi-generator-cli-7.16.0.jar)
|
||||
<!-- /RELEASE_VERSION -->
|
||||
|
||||
To get a list of **general** options available, please run `java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help generate`
|
||||
|
||||
8
bin/configs/go-server-optional-body.yaml
Normal file
8
bin/configs/go-server-optional-body.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
generatorName: go-server
|
||||
outputDir: samples/server/others/go-server/optional-body
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/optional_body.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/go-server
|
||||
additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
||||
packageName: petstoreserver
|
||||
addResponseHeaders: true
|
||||
8
bin/configs/jaxrs-cxf-client-swagger2.yaml
Normal file
8
bin/configs/jaxrs-cxf-client-swagger2.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
generatorName: jaxrs-cxf-client
|
||||
outputDir: samples/client/petstore/jaxrs-cxf-client-swagger2
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/cxf
|
||||
additionalProperties:
|
||||
artifactId: jaxrs-cxf-petstore-swagger2
|
||||
documentationProvider: swagger2
|
||||
annotationLibrary: swagger2
|
||||
14
bin/configs/kotlin-spring-boot-additionalproperties.yaml
Normal file
14
bin/configs/kotlin-spring-boot-additionalproperties.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
generatorName: kotlin-spring
|
||||
outputDir: samples/server/petstore/kotlin-springboot-additionalproperties
|
||||
library: spring-boot
|
||||
inputSpec: samples/server/petstore/kotlin-springboot-additionalproperties/src/main/resources/openapi.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
|
||||
additionalProperties:
|
||||
documentationProvider: none
|
||||
annotationLibrary: none
|
||||
useSwaggerUI: "false"
|
||||
serviceImplementation: "true"
|
||||
serializableModel: "true"
|
||||
beanValidations: "true"
|
||||
useSpringBoot3: "true"
|
||||
requestMappingMode: api_interface
|
||||
15
bin/configs/python-httpx.yaml
Normal file
15
bin/configs/python-httpx.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
generatorName: python
|
||||
outputDir: samples/openapi3/client/petstore/python-httpx
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/python
|
||||
library: httpx
|
||||
additionalProperties:
|
||||
packageName: petstore_api
|
||||
mapNumberTo: float
|
||||
poetry1: true
|
||||
nameMappings:
|
||||
_type: underscore_type
|
||||
type_: type_with_underscore
|
||||
modelNameMappings:
|
||||
# The OpenAPI spec ApiResponse conflicts with the internal ApiResponse
|
||||
ApiResponse: ModelApiResponse
|
||||
@@ -61,4 +61,4 @@
|
||||
- filename: "samples/server/petstore/rust-axum/output/rust-axum-oneof/tests/oneof_with_discriminator.rs"
|
||||
sha256: 2d4f5a069fdcb3057bb078d5e75b3de63cd477b97725e457079df24bd2c30600
|
||||
- filename: "samples/server/petstore/rust-axum/output/openapi-v3/tests/oneof_untagged.rs"
|
||||
sha256: e72fbf81a9849dc7abb7e2169f2fc355c8b1cf991c0e2ffc083126abd9e966e7
|
||||
sha256: 1d3fb01f65e98290b1d3eece28014c7d3e3f2fdf18e7110249d3c591cc4642ab
|
||||
|
||||
@@ -25,7 +25,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|generateSourceCodeOnly|Specifies that only a library source code is to be generated.| |false|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||
|lazyImports|Enable lazy imports.| |false|
|
||||
|library|library template (sub-template) to use: asyncio, tornado (deprecated), urllib3| |urllib3|
|
||||
|library|library template (sub-template) to use: asyncio, tornado (deprecated), urllib3, httpx| |urllib3|
|
||||
|mapNumberTo|Map number to Union[StrictFloat, StrictInt], StrictStr or float.| |Union[StrictFloat, StrictInt]|
|
||||
|packageName|python package name (convention: snake_case).| |openapi_client|
|
||||
|packageUrl|python package URL.| |null|
|
||||
|
||||
@@ -77,6 +77,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<li>dyn</li>
|
||||
<li>else</li>
|
||||
<li>enum</li>
|
||||
<li>errors</li>
|
||||
<li>extern</li>
|
||||
<li>false</li>
|
||||
<li>final</li>
|
||||
@@ -207,8 +208,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|Composite|✓|OAS2,OAS3
|
||||
|Polymorphism|✗|OAS2,OAS3
|
||||
|Union|✗|OAS3
|
||||
|allOf|✗|OAS2,OAS3
|
||||
|anyOf|✗|OAS3
|
||||
|allOf|✓|OAS2,OAS3
|
||||
|anyOf|✓|OAS3
|
||||
|oneOf|✓|OAS3
|
||||
|not|✗|OAS3
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ npm install @openapitools/openapi-generator-cli -g
|
||||
To install a specific version of the tool, pass the version during installation:
|
||||
<!-- RELEASE_VERSION -->
|
||||
```bash
|
||||
openapi-generator-cli version-manager set 7.15.0
|
||||
openapi-generator-cli version-manager set 7.16.0
|
||||
```
|
||||
<!-- /RELEASE_VERSION -->
|
||||
To install the tool as a dev dependency in your current project:
|
||||
@@ -119,18 +119,18 @@ docker run --rm \
|
||||
<!-- RELEASE_VERSION -->
|
||||
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 11 runtime at a minimum):
|
||||
|
||||
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.15.0/openapi-generator-cli-7.15.0.jar`
|
||||
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.16.0/openapi-generator-cli-7.16.0.jar`
|
||||
|
||||
For **Mac/Linux** users:
|
||||
|
||||
```bash
|
||||
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.15.0/openapi-generator-cli-7.15.0.jar -O openapi-generator-cli.jar
|
||||
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.16.0/openapi-generator-cli-7.16.0.jar -O openapi-generator-cli.jar
|
||||
```
|
||||
|
||||
For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
|
||||
|
||||
```powershell
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.15.0/openapi-generator-cli-7.15.0.jar
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.16.0/openapi-generator-cli-7.16.0.jar
|
||||
```
|
||||
<!-- /RELEASE_VERSION -->
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
|
||||
<plugin>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<version>7.15.0</version>
|
||||
<version>7.16.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.16.0-SNAPSHOT</version>
|
||||
<version>7.16.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.16.0-SNAPSHOT</version>
|
||||
<version>7.16.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -97,7 +97,7 @@ task validateGoodSpec(type: org.openapitools.generator.gradle.plugin.tasks.Valid
|
||||
[source,group]
|
||||
----
|
||||
plugins {
|
||||
id "org.openapi.generator" version "7.15.0"
|
||||
id "org.openapi.generator" version "7.16.0"
|
||||
}
|
||||
----
|
||||
|
||||
@@ -113,7 +113,7 @@ buildscript {
|
||||
// url "https://plugins.gradle.org/m2/"
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:7.15.0"
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:7.16.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -759,7 +759,7 @@ buildscript {
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||
classpath('org.openapitools:openapi-generator-gradle-plugin:7.15.0') {
|
||||
classpath('org.openapitools:openapi-generator-gradle-plugin:7.16.0') {
|
||||
exclude group: 'com.google.guava'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=7.16.0-SNAPSHOT
|
||||
openApiGeneratorVersion=7.16.0
|
||||
# /RELEASE_VERSION
|
||||
|
||||
# BEGIN placeholders
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.16.0-SNAPSHOT</version>
|
||||
<version>7.16.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -19,5 +19,5 @@ gradle generateGoWithInvalidSpec # expected outcome: BUILD FAILED
|
||||
The samples can be tested against other versions of the plugin using the `openApiGeneratorVersion` property. For example:
|
||||
|
||||
```bash
|
||||
gradle -PopenApiGeneratorVersion=7.15.0 openApiValidate
|
||||
gradle -PopenApiGeneratorVersion=7.16.0 openApiValidate
|
||||
```
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=7.16.0-SNAPSHOT
|
||||
openApiGeneratorVersion=7.16.0
|
||||
# /RELEASE_VERSION
|
||||
|
||||
@@ -12,7 +12,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.15.0</version>
|
||||
<version>7.16.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.16.0-SNAPSHOT</version>
|
||||
<version>7.16.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.16.0-SNAPSHOT</version>
|
||||
<version>7.16.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.16.0-SNAPSHOT</version>
|
||||
<version>7.16.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.16.0-SNAPSHOT</version>
|
||||
<version>7.16.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.16.0-SNAPSHOT</version>
|
||||
<version>7.16.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.16.0-SNAPSHOT</version>
|
||||
<version>7.16.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.16.0-SNAPSHOT</version>
|
||||
<version>7.16.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.16.0-SNAPSHOT</version>
|
||||
<version>7.16.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.16.0-SNAPSHOT</version>
|
||||
<version>7.16.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -115,6 +115,15 @@ public class CodegenOperation {
|
||||
return nonEmpty(bodyParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there's at least one optional body parameter
|
||||
*
|
||||
* @return true if optional body parameter exists, false otherwise
|
||||
*/
|
||||
public boolean getHasOptionalBodyParam() {
|
||||
return nonEmpty(bodyParams) && nonEmpty(optionalParams) && bodyParams.stream().anyMatch(optionalParams::contains);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there's at least one query parameter
|
||||
*
|
||||
|
||||
@@ -410,6 +410,7 @@ public class GoServerCodegen extends AbstractGoCodegen {
|
||||
private void addConditionalImportInformation(OperationsMap operations) {
|
||||
boolean hasPathParams = false;
|
||||
boolean hasBodyParams = false;
|
||||
boolean hasOptionalBodyParams = false;
|
||||
|
||||
for (CodegenOperation op : operations.getOperations().getOperation()) {
|
||||
if (op.getHasPathParams()) {
|
||||
@@ -418,10 +419,14 @@ public class GoServerCodegen extends AbstractGoCodegen {
|
||||
if (op.getHasBodyParam()) {
|
||||
hasBodyParams = true;
|
||||
}
|
||||
if (op.getHasOptionalBodyParam()) {
|
||||
hasOptionalBodyParams = true;
|
||||
}
|
||||
}
|
||||
|
||||
additionalProperties.put("hasPathParams", hasPathParams);
|
||||
additionalProperties.put("hasBodyParams", hasBodyParams);
|
||||
additionalProperties.put("hasOptionalBodyParams", hasOptionalBodyParams);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -996,6 +996,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
private Stream<List<CodegenProperty>> getAllVarProperties(CodegenModel model) {
|
||||
return Stream.of(model.vars, model.allVars, model.optionalVars, model.requiredVars, model.readOnlyVars, model.readWriteVars);
|
||||
}
|
||||
@@ -1113,6 +1114,27 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessParameter(CodegenParameter parameter) {
|
||||
super.postProcessParameter(parameter);
|
||||
adjustEnumRefDefault(parameter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Properly set the default value for enum (reference).
|
||||
*
|
||||
* @param param codegen parameter
|
||||
*/
|
||||
private void adjustEnumRefDefault(CodegenParameter param) {
|
||||
if (StringUtils.isEmpty(param.defaultValue) || !(param.isEnum || param.isEnumRef)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String type = StringUtils.defaultIfEmpty(param.datatypeWithEnum, param.dataType);
|
||||
param.enumDefaultValue = toEnumVarName(param.defaultValue, type);
|
||||
param.defaultValue = type + "." + param.enumDefaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcess() {
|
||||
System.out.println("################################################################################");
|
||||
|
||||
@@ -157,7 +157,8 @@ public class PythonClientCodegen extends AbstractPythonCodegen implements Codege
|
||||
supportedLibraries.put("urllib3", "urllib3-based client");
|
||||
supportedLibraries.put("asyncio", "asyncio-based client");
|
||||
supportedLibraries.put("tornado", "tornado-based client (deprecated)");
|
||||
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use: asyncio, tornado (deprecated), urllib3");
|
||||
supportedLibraries.put("httpx", "httpx-based client");
|
||||
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use: asyncio, tornado (deprecated), urllib3, httpx");
|
||||
libraryOption.setDefault(DEFAULT_LIBRARY);
|
||||
cliOptions.add(libraryOption);
|
||||
setLibrary(DEFAULT_LIBRARY);
|
||||
@@ -330,10 +331,15 @@ public class PythonClientCodegen extends AbstractPythonCodegen implements Codege
|
||||
|
||||
if ("asyncio".equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("asyncio/rest.mustache", packagePath(), "rest.py"));
|
||||
additionalProperties.put("async", "true");
|
||||
additionalProperties.put("asyncio", "true");
|
||||
} else if ("tornado".equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("tornado/rest.mustache", packagePath(), "rest.py"));
|
||||
additionalProperties.put("tornado", "true");
|
||||
} else if ("httpx".equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("httpx/rest.mustache", packagePath(), "rest.py"));
|
||||
additionalProperties.put("async", "true");
|
||||
additionalProperties.put("httpx", "true");
|
||||
} else {
|
||||
supportingFiles.add(new SupportingFile("rest.mustache", packagePath(), "rest.py"));
|
||||
}
|
||||
|
||||
@@ -99,6 +99,18 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
||||
public RustAxumServerCodegen() {
|
||||
super();
|
||||
|
||||
// The `#[validate(nested)]` macro relies on an internal field named `errors` to accumulate validation results. Therefore, defining a struct like this will fail:
|
||||
//
|
||||
// ```rust
|
||||
// struct A {
|
||||
// #[validate(nested)]
|
||||
// errors: B,
|
||||
// }
|
||||
// ```
|
||||
//
|
||||
// To avoid this, either rename the field to something other than "errors", or reserve it.
|
||||
this.reservedWords.add("errors");
|
||||
|
||||
modifyFeatureSet(features -> features
|
||||
.wireFormatFeatures(EnumSet.of(
|
||||
WireFormatFeature.JSON,
|
||||
@@ -112,7 +124,9 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
||||
.schemaSupportFeatures(EnumSet.of(
|
||||
SchemaSupportFeature.Simple,
|
||||
SchemaSupportFeature.Composite,
|
||||
SchemaSupportFeature.oneOf
|
||||
SchemaSupportFeature.oneOf,
|
||||
SchemaSupportFeature.anyOf,
|
||||
SchemaSupportFeature.allOf
|
||||
))
|
||||
.excludeGlobalFeatures(
|
||||
GlobalFeature.Info,
|
||||
@@ -633,105 +647,163 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
||||
return op;
|
||||
}
|
||||
|
||||
private void postProcessOneOfModels(List<ModelMap> allModels) {
|
||||
final HashMap<String, List<String>> oneOfMapDiscriminator = new HashMap<>();
|
||||
private void postProcessPolymorphism(final List<ModelMap> allModels) {
|
||||
final HashMap<String, List<String>> discriminatorsForModel = new HashMap<>();
|
||||
|
||||
for (ModelMap mo : allModels) {
|
||||
for (final ModelMap mo : allModels) {
|
||||
final CodegenModel cm = mo.getModel();
|
||||
|
||||
final CodegenComposedSchemas cs = cm.getComposedSchemas();
|
||||
if (cs != null) {
|
||||
final List<CodegenProperty> csOneOf = cs.getOneOf();
|
||||
|
||||
if (csOneOf != null) {
|
||||
for (CodegenProperty model : csOneOf) {
|
||||
// Generate a valid name for the enum variant.
|
||||
// Mainly needed for primitive types.
|
||||
|
||||
model.datatypeWithEnum = camelize(model.dataType.replaceAll("(?:\\w+::)+(\\w+)", "$1")
|
||||
.replace("<", "Of").replace(">", ""));
|
||||
|
||||
// Primitive type is not properly set, this overrides it to guarantee adequate model generation.
|
||||
if (!model.getDataType().matches(String.format(Locale.ROOT, ".*::%s", model.getDatatypeWithEnum()))) {
|
||||
model.isPrimitiveType = true;
|
||||
}
|
||||
}
|
||||
|
||||
processPolymorphismDataType(csOneOf);
|
||||
cs.setOneOf(csOneOf);
|
||||
cm.setComposedSchemas(cs);
|
||||
}
|
||||
|
||||
final List<CodegenProperty> csAnyOf = cs.getAnyOf();
|
||||
if (csAnyOf != null) {
|
||||
processPolymorphismDataType(csAnyOf);
|
||||
cs.setAnyOf(csAnyOf);
|
||||
cm.setComposedSchemas(cs);
|
||||
}
|
||||
}
|
||||
|
||||
if (cm.discriminator != null) {
|
||||
for (String model : cm.oneOf) {
|
||||
List<String> discriminators = oneOfMapDiscriminator.getOrDefault(model, new ArrayList<>());
|
||||
for (final String model : cm.oneOf) {
|
||||
final List<String> discriminators = discriminatorsForModel.getOrDefault(model, new ArrayList<>());
|
||||
discriminators.add(cm.discriminator.getPropertyName());
|
||||
oneOfMapDiscriminator.put(model, discriminators);
|
||||
discriminatorsForModel.put(model, discriminators);
|
||||
}
|
||||
|
||||
for (final String model : cm.anyOf) {
|
||||
final List<String> discriminators = discriminatorsForModel.getOrDefault(model, new ArrayList<>());
|
||||
discriminators.add(cm.discriminator.getPropertyName());
|
||||
discriminatorsForModel.put(model, discriminators);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final var blocking = new HashSet<String>();
|
||||
for (ModelMap mo : allModels) {
|
||||
final CodegenModel cm = mo.getModel();
|
||||
|
||||
for (CodegenProperty var : cm.vars) {
|
||||
var.isDiscriminator = false;
|
||||
final List<String> discriminators = discriminatorsForModel.get(cm.getSchemaName());
|
||||
if (discriminators != null) {
|
||||
// If the discriminator field is not a defined attribute in the variant structure, create it.
|
||||
if (!discriminating(discriminators, cm)) {
|
||||
final String discriminator = discriminators.get(0);
|
||||
|
||||
CodegenProperty property = new CodegenProperty();
|
||||
|
||||
// Static attributes
|
||||
// Only strings are supported by serde for tag field types, so it's the only one we'll deal with
|
||||
property.openApiType = "string";
|
||||
property.complexType = "string";
|
||||
property.dataType = "String";
|
||||
property.datatypeWithEnum = "String";
|
||||
property.baseType = "string";
|
||||
property.required = true;
|
||||
property.isPrimitiveType = true;
|
||||
property.isString = true;
|
||||
property.isDiscriminator = true;
|
||||
|
||||
// Attributes based on the discriminator value
|
||||
property.baseName = discriminator;
|
||||
property.name = discriminator;
|
||||
property.nameInCamelCase = camelize(discriminator);
|
||||
property.nameInPascalCase = property.nameInCamelCase.substring(0, 1).toUpperCase(Locale.ROOT) + property.nameInCamelCase.substring(1);
|
||||
property.nameInSnakeCase = underscore(discriminator).toUpperCase(Locale.ROOT);
|
||||
property.getter = String.format(Locale.ROOT, "get%s", property.nameInPascalCase);
|
||||
property.setter = String.format(Locale.ROOT, "set%s", property.nameInPascalCase);
|
||||
property.defaultValueWithParam = String.format(Locale.ROOT, " = data.%s;", property.name);
|
||||
|
||||
// Attributes based on the model name
|
||||
property.defaultValue = String.format(Locale.ROOT, "r#\"%s\"#.to_string()", cm.getSchemaName());
|
||||
property.jsonSchema = String.format(Locale.ROOT, "{ \"default\":\"%s\"; \"type\":\"string\" }", cm.getSchemaName());
|
||||
|
||||
cm.vars.add(property);
|
||||
}
|
||||
}
|
||||
|
||||
final List<String> discriminatorsForModel = oneOfMapDiscriminator.get(cm.getSchemaName());
|
||||
if (cm.vars.stream().noneMatch(v -> v.isDiscriminator)) {
|
||||
blocking.add(cm.getSchemaName());
|
||||
}
|
||||
}
|
||||
|
||||
if (discriminatorsForModel != null) {
|
||||
for (String discriminator : discriminatorsForModel) {
|
||||
boolean hasDiscriminatorDefined = false;
|
||||
|
||||
for (CodegenProperty var : cm.vars) {
|
||||
if (var.baseName.equals(discriminator)) {
|
||||
var.isDiscriminator = true;
|
||||
hasDiscriminatorDefined = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If the discriminator field is not a defined attribute in the variant structure, create it.
|
||||
if (!hasDiscriminatorDefined) {
|
||||
CodegenProperty property = new CodegenProperty();
|
||||
|
||||
// Static attributes
|
||||
// Only strings are supported by serde for tag field types, so it's the only one we'll deal with
|
||||
property.openApiType = "string";
|
||||
property.complexType = "string";
|
||||
property.dataType = "String";
|
||||
property.datatypeWithEnum = "String";
|
||||
property.baseType = "string";
|
||||
property.required = true;
|
||||
property.isPrimitiveType = true;
|
||||
property.isString = true;
|
||||
property.isDiscriminator = true;
|
||||
|
||||
// Attributes based on the discriminator value
|
||||
property.baseName = discriminator;
|
||||
property.name = discriminator;
|
||||
property.nameInCamelCase = camelize(discriminator);
|
||||
property.nameInPascalCase = property.nameInCamelCase.substring(0, 1).toUpperCase(Locale.ROOT) + property.nameInCamelCase.substring(1);
|
||||
property.nameInSnakeCase = underscore(discriminator).toUpperCase(Locale.ROOT);
|
||||
property.getter = String.format(Locale.ROOT, "get%s", property.nameInPascalCase);
|
||||
property.setter = String.format(Locale.ROOT, "set%s", property.nameInPascalCase);
|
||||
property.defaultValueWithParam = String.format(Locale.ROOT, " = data.%s;", property.name);
|
||||
|
||||
// Attributes based on the model name
|
||||
property.defaultValue = String.format(Locale.ROOT, "r#\"%s\"#.to_string()", cm.getSchemaName());
|
||||
property.jsonSchema = String.format(Locale.ROOT, "{ \"default\":\"%s\"; \"type\":\"string\" }", cm.getSchemaName());
|
||||
|
||||
cm.vars.add(property);
|
||||
}
|
||||
for (final ModelMap mo : allModels) {
|
||||
final CodegenModel cm = mo.getModel();
|
||||
if (cm.discriminator != null) {
|
||||
// if no discriminator in any of variant -> disable discriminator
|
||||
if (cm.oneOf.stream().anyMatch(blocking::contains) || cm.anyOf.stream().anyMatch(blocking::contains)) {
|
||||
cm.discriminator = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean discriminating(final List<String> discriminatorsForModel, final CodegenModel cm) {
|
||||
resetDiscriminatorProperty(cm);
|
||||
|
||||
// Discriminator will be presented as enum tag -> One and only one tag is allowed
|
||||
int countString = 0;
|
||||
int countNonString = 0;
|
||||
for (final CodegenProperty var : cm.vars) {
|
||||
if (discriminatorsForModel.stream().anyMatch(discriminator -> var.baseName.equals(discriminator) || var.name.equals(discriminator))) {
|
||||
if (var.isString) {
|
||||
var.isDiscriminator = true;
|
||||
++countString;
|
||||
} else
|
||||
++countNonString;
|
||||
}
|
||||
}
|
||||
|
||||
if (countString > 0 && (countNonString > 0 || countString > 1)) {
|
||||
// at least two discriminator, one of them is string -> should not render serde tag
|
||||
resetDiscriminatorProperty(cm);
|
||||
}
|
||||
|
||||
return countNonString > 0 || countString > 0;
|
||||
}
|
||||
|
||||
private static void resetDiscriminatorProperty(final CodegenModel cm) {
|
||||
for (final CodegenProperty var : cm.vars) {
|
||||
var.isDiscriminator = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void processPolymorphismDataType(final List<CodegenProperty> cp) {
|
||||
final HashSet<String> dedupDataTypeWithEnum = new HashSet<>();
|
||||
final HashMap<String, Integer> dedupDataType = new HashMap<>();
|
||||
|
||||
int idx = 0;
|
||||
for (CodegenProperty model : cp) {
|
||||
// Generate a valid name for the enum variant.
|
||||
// Mainly needed for primitive types.
|
||||
model.datatypeWithEnum = camelize(model.dataType.replaceAll("(?:\\w+::)+(\\w+)", "$1")
|
||||
.replace("<", "Of").replace(">", "")).replace(" ", "").replace(",", "");
|
||||
if (!dedupDataTypeWithEnum.add(model.datatypeWithEnum)) {
|
||||
model.datatypeWithEnum += ++idx;
|
||||
}
|
||||
|
||||
dedupDataType.put(model.getDataType(), dedupDataType.getOrDefault(model.getDataType(), 0) + 1);
|
||||
|
||||
if (!model.getDataType().matches(String.format(Locale.ROOT, ".*::%s", model.getDatatypeWithEnum()))) {
|
||||
model.isPrimitiveType = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (CodegenProperty model : cp) {
|
||||
if (dedupDataType.get(model.getDataType()) == 1) {
|
||||
model.vendorExtensions.put("x-from-trait", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperationsMap postProcessOperationsWithModels(final OperationsMap operationsMap, List<ModelMap> allModels) {
|
||||
postProcessOneOfModels(allModels);
|
||||
postProcessPolymorphism(allModels);
|
||||
|
||||
final OperationMap operations = operationsMap.getOperations();
|
||||
operations.put("classnamePascalCase", camelize(operations.getClassname()));
|
||||
@@ -901,7 +973,7 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
||||
// restore things to sensible values.
|
||||
@Override
|
||||
public CodegenParameter fromRequestBody(RequestBody body, Set<String> imports, String bodyParameterName) {
|
||||
final Schema original_schema = ModelUtils.getSchemaFromRequestBody(body);
|
||||
final var original_schema = ModelUtils.getSchemaFromRequestBody(body);
|
||||
CodegenParameter codegenParameter = super.fromRequestBody(body, imports, bodyParameterName);
|
||||
|
||||
if (StringUtils.isNotBlank(original_schema.get$ref())) {
|
||||
@@ -920,10 +992,10 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
||||
@Override
|
||||
public String toInstantiationType(final Schema p) {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
final Schema inner = ModelUtils.getSchemaItems(p);
|
||||
final var inner = ModelUtils.getSchemaItems(p);
|
||||
return instantiationTypes.get("array") + "<" + getSchemaType(inner) + ">";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
final Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
final var inner = ModelUtils.getAdditionalProperties(p);
|
||||
return instantiationTypes.get("map") + "<" + typeMapping.get("string") + ", " + getSchemaType(inner) + ">";
|
||||
} else {
|
||||
return null;
|
||||
@@ -952,6 +1024,10 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
||||
@Override
|
||||
public String toDefaultValue(final Schema p) {
|
||||
String defaultValue = null;
|
||||
|
||||
if (ModelUtils.isEnumSchema(p))
|
||||
return null;
|
||||
|
||||
if ((ModelUtils.isNullable(p)) && (p.getDefault() != null) && ("null".equalsIgnoreCase(p.getDefault().toString())))
|
||||
return "Nullable::Null";
|
||||
|
||||
@@ -965,6 +1041,9 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
||||
} else if (ModelUtils.isNumberSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
defaultValue = p.getDefault().toString();
|
||||
if (!defaultValue.contains(".")) {
|
||||
defaultValue += ".0";
|
||||
}
|
||||
}
|
||||
} else if (ModelUtils.isIntegerSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
@@ -1081,7 +1160,7 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
||||
String cmd = System.getenv("RUST_POST_PROCESS_FILE");
|
||||
if (StringUtils.isEmpty(cmd)) {
|
||||
cmd = "rustfmt";
|
||||
command = new String[]{cmd, "--edition", "2021", fileName};
|
||||
command = new String[]{cmd, "--edition", "2024", fileName};
|
||||
} else {
|
||||
command = new String[]{cmd, fileName};
|
||||
}
|
||||
@@ -1093,7 +1172,7 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateParameterForString(CodegenParameter codegenParameter, Schema parameterSchema) {
|
||||
protected void updateParameterForString(CodegenParameter codegenParameter, final Schema parameterSchema) {
|
||||
if (ModelUtils.isEmailSchema(parameterSchema)) {
|
||||
codegenParameter.isEmail = true;
|
||||
} else if (ModelUtils.isUUIDSchema(parameterSchema)) {
|
||||
@@ -1120,7 +1199,7 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
||||
codegenParameter.isDecimal = true;
|
||||
codegenParameter.isPrimitiveType = true;
|
||||
}
|
||||
if (Boolean.TRUE.equals(codegenParameter.isString)) {
|
||||
if (codegenParameter.isString) {
|
||||
codegenParameter.isPrimitiveType = true;
|
||||
}
|
||||
}
|
||||
@@ -1152,6 +1231,16 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
final var varName = super.toVarName(name);
|
||||
|
||||
if (varName.startsWith("r#"))
|
||||
return "r_" + varName.substring(2);
|
||||
|
||||
return varName;
|
||||
}
|
||||
|
||||
static class PathMethodOperations {
|
||||
public String path;
|
||||
public ArrayList<MethodOperation> methodOperations;
|
||||
|
||||
@@ -307,69 +307,6 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
|
||||
mdl.getComposedSchemas().setOneOf(newOneOfs);
|
||||
}
|
||||
|
||||
// Handle anyOf schemas similarly to oneOf
|
||||
// This is pragmatic since Rust's untagged enum will deserialize to the first matching variant
|
||||
if (mdl.getComposedSchemas() != null && mdl.getComposedSchemas().getAnyOf() != null
|
||||
&& !mdl.getComposedSchemas().getAnyOf().isEmpty()) {
|
||||
|
||||
List<CodegenProperty> newAnyOfs = mdl.getComposedSchemas().getAnyOf().stream()
|
||||
.map(CodegenProperty::clone)
|
||||
.collect(Collectors.toList());
|
||||
List<Schema> schemas = ModelUtils.getInterfaces(model);
|
||||
if (newAnyOfs.size() != schemas.size()) {
|
||||
// For safety reasons, this should never happen unless there is an error in the code
|
||||
throw new RuntimeException("anyOf size does not match the model");
|
||||
}
|
||||
|
||||
Map<String, String> refsMapping = Optional.ofNullable(model.getDiscriminator())
|
||||
.map(Discriminator::getMapping).orElse(Collections.emptyMap());
|
||||
|
||||
// Reverse mapped references to use as baseName for anyOf, but different keys may point to the same $ref.
|
||||
// Thus, we group them by the value
|
||||
Map<String, List<String>> mappedNamesByRef = refsMapping.entrySet().stream()
|
||||
.collect(Collectors.groupingBy(Map.Entry::getValue,
|
||||
Collectors.mapping(Map.Entry::getKey, Collectors.toList())
|
||||
));
|
||||
|
||||
for (int i = 0; i < newAnyOfs.size(); i++) {
|
||||
CodegenProperty anyOf = newAnyOfs.get(i);
|
||||
Schema schema = schemas.get(i);
|
||||
|
||||
if (mappedNamesByRef.containsKey(schema.get$ref())) {
|
||||
// prefer mapped names if present
|
||||
// remove mapping not in order not to reuse for the next occurrence of the ref
|
||||
List<String> names = mappedNamesByRef.get(schema.get$ref());
|
||||
String mappedName = names.remove(0);
|
||||
anyOf.setBaseName(mappedName);
|
||||
anyOf.setName(toModelName(mappedName));
|
||||
} else if (!org.apache.commons.lang3.StringUtils.isEmpty(schema.get$ref())) {
|
||||
// use $ref if it's reference
|
||||
String refName = ModelUtils.getSimpleRef(schema.get$ref());
|
||||
if (refName != null) {
|
||||
String modelName = toModelName(refName);
|
||||
anyOf.setName(modelName);
|
||||
anyOf.setBaseName(refName);
|
||||
}
|
||||
} else if (anyOf.isArray) {
|
||||
// If the type is an array, extend the name with the inner type to prevent name collisions
|
||||
// in case multiple arrays with different types are defined. If the user has manually specified
|
||||
// a name, use that name instead.
|
||||
String collectionWithTypeName = toModelName(schema.getType()) + anyOf.containerTypeMapped + anyOf.items.dataType;
|
||||
String anyOfName = Optional.ofNullable(schema.getTitle()).orElse(collectionWithTypeName);
|
||||
anyOf.setName(anyOfName);
|
||||
}
|
||||
else {
|
||||
// In-placed type (primitive), because there is no mapping or ref for it.
|
||||
// use camelized `title` if present, otherwise use `type`
|
||||
String anyOfName = Optional.ofNullable(schema.getTitle()).orElseGet(schema::getType);
|
||||
anyOf.setName(toModelName(anyOfName));
|
||||
}
|
||||
}
|
||||
|
||||
// Set anyOf as oneOf for template processing since we want the same output
|
||||
mdl.getComposedSchemas().setOneOf(newAnyOfs);
|
||||
}
|
||||
|
||||
return mdl;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
{{>additionalOneOfTypeAnnotations}}{{>generatedAnnotation}}{{>typeInfoAnnotation}}{{>xmlAnnotation}}
|
||||
{{#vendorExtensions.x-class-extra-annotation}}
|
||||
{{{vendorExtensions.x-class-extra-annotation}}}
|
||||
{{/vendorExtensions.x-class-extra-annotation}}
|
||||
public {{>sealed}}interface {{classname}} {{#vendorExtensions.x-implements}}{{#-first}}extends {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{/vendorExtensions.x-implements}}{{>permits}}{
|
||||
{{#discriminator}}
|
||||
public {{propertyType}} {{propertyGetter}}();
|
||||
|
||||
@@ -8,7 +8,9 @@ import org.junit.Test;
|
||||
import org.junit.Before;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
{{#useBeanValidation}}
|
||||
import {{javaxPackage}}.validation.Valid;
|
||||
{{/useBeanValidation}}
|
||||
import {{javaxPackage}}.ws.rs.core.Response;
|
||||
import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
|
||||
import org.apache.cxf.jaxrs.client.ClientConfiguration;
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
@JsonSubTypes.Type(value = {{classname}}.class){{^-last}}, {{/-last}}
|
||||
{{/interfaceModels}}
|
||||
})
|
||||
{{/useDeductionForOneOfInterfaces}}
|
||||
{{/useDeductionForOneOfInterfaces}}{{#vendorExtensions.x-class-extra-annotation}}{{{vendorExtensions.x-class-extra-annotation}}}
|
||||
{{/vendorExtensions.x-class-extra-annotation}}
|
||||
{{/discriminator}}
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
|
||||
@@ -6,12 +6,10 @@ import (
|
||||
{{#hasBodyParams}}
|
||||
"encoding/json"
|
||||
{{/hasBodyParams}}
|
||||
{{#isBodyParam}}
|
||||
{{^required}}
|
||||
{{#hasOptionalBodyParams}}
|
||||
"errors"
|
||||
"io"
|
||||
{{/required}}
|
||||
{{/isBodyParam}}
|
||||
{{/hasOptionalBodyParams}}
|
||||
"net/http"
|
||||
"strings"
|
||||
{{#imports}} "{{import}}"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
{{/hasOptional}}{{/hasRequired}}{{#optionalVars}}{{>dataClassOptVar}}{{^-last}},
|
||||
{{/-last}}{{/optionalVars}}
|
||||
){{/discriminator}}{{! no newline
|
||||
}}{{#parent}} : {{{.}}}{{! no newline
|
||||
}}{{#parent}} : {{{.}}}{{#isMap}}(){{/isMap}}{{! no newline
|
||||
}}{{#serializableModel}}{{! no newline
|
||||
}}{{^vendorExtensions.x-kotlin-implements}}, Serializable{{/vendorExtensions.x-kotlin-implements}}{{! no newline
|
||||
}}{{#vendorExtensions.x-kotlin-implements}}, Serializable, {{! no newline
|
||||
|
||||
@@ -28,10 +28,10 @@ To be able to use it, you will need these dependencies in your own package that
|
||||
|
||||
* urllib3 >= 2.1.0, < 3.0.0
|
||||
* python-dateutil >= 2.8.2
|
||||
{{#asyncio}}
|
||||
{{#async}}
|
||||
* aiohttp >= 3.8.4
|
||||
* aiohttp-retry >= 2.8.3
|
||||
{{/asyncio}}
|
||||
{{/async}}
|
||||
{{#tornado}}
|
||||
* tornado >= 4.2, < 5
|
||||
{{/tornado}}
|
||||
|
||||
@@ -32,14 +32,14 @@ class {{classname}}:
|
||||
|
||||
|
||||
@validate_call
|
||||
{{#asyncio}}async {{/asyncio}}def {{operationId}}{{>partial_api_args}} -> {{{returnType}}}{{^returnType}}None{{/returnType}}:
|
||||
{{#async}}async {{/async}}def {{operationId}}{{>partial_api_args}} -> {{{returnType}}}{{^returnType}}None{{/returnType}}:
|
||||
{{>partial_api}}
|
||||
|
||||
response_data = {{#asyncio}}await {{/asyncio}}self.api_client.call_api(
|
||||
response_data = {{#async}}await {{/async}}self.api_client.call_api(
|
||||
*_param,
|
||||
_request_timeout=_request_timeout
|
||||
)
|
||||
{{#asyncio}}await {{/asyncio}}response_data.read()
|
||||
{{#async}}await {{/async}}response_data.read()
|
||||
return self.api_client.response_deserialize(
|
||||
response_data=response_data,
|
||||
response_types_map=_response_types_map,
|
||||
@@ -47,14 +47,14 @@ class {{classname}}:
|
||||
|
||||
|
||||
@validate_call
|
||||
{{#asyncio}}async {{/asyncio}}def {{operationId}}_with_http_info{{>partial_api_args}} -> ApiResponse[{{{returnType}}}{{^returnType}}None{{/returnType}}]:
|
||||
{{#async}}async {{/async}}def {{operationId}}_with_http_info{{>partial_api_args}} -> ApiResponse[{{{returnType}}}{{^returnType}}None{{/returnType}}]:
|
||||
{{>partial_api}}
|
||||
|
||||
response_data = {{#asyncio}}await {{/asyncio}}self.api_client.call_api(
|
||||
response_data = {{#async}}await {{/async}}self.api_client.call_api(
|
||||
*_param,
|
||||
_request_timeout=_request_timeout
|
||||
)
|
||||
{{#asyncio}}await {{/asyncio}}response_data.read()
|
||||
{{#async}}await {{/async}}response_data.read()
|
||||
return self.api_client.response_deserialize(
|
||||
response_data=response_data,
|
||||
response_types_map=_response_types_map,
|
||||
@@ -62,10 +62,10 @@ class {{classname}}:
|
||||
|
||||
|
||||
@validate_call
|
||||
{{#asyncio}}async {{/asyncio}}def {{operationId}}_without_preload_content{{>partial_api_args}} -> RESTResponseType:
|
||||
{{#async}}async {{/async}}def {{operationId}}_without_preload_content{{>partial_api_args}} -> RESTResponseType:
|
||||
{{>partial_api}}
|
||||
|
||||
response_data = {{#asyncio}}await {{/asyncio}}self.api_client.call_api(
|
||||
response_data = {{#async}}await {{/async}}self.api_client.call_api(
|
||||
*_param,
|
||||
_request_timeout=_request_timeout
|
||||
)
|
||||
|
||||
@@ -88,7 +88,7 @@ class ApiClient:
|
||||
self.user_agent = '{{{httpUserAgent}}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/python{{/httpUserAgent}}'
|
||||
self.client_side_validation = configuration.client_side_validation
|
||||
|
||||
{{#asyncio}}
|
||||
{{#async}}
|
||||
async def __aenter__(self):
|
||||
return self
|
||||
|
||||
@@ -97,14 +97,14 @@ class ApiClient:
|
||||
|
||||
async def close(self):
|
||||
await self.rest_client.close()
|
||||
{{/asyncio}}
|
||||
{{^asyncio}}
|
||||
{{/async}}
|
||||
{{^async}}
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
pass
|
||||
{{/asyncio}}
|
||||
{{/async}}
|
||||
|
||||
@property
|
||||
def user_agent(self):
|
||||
@@ -257,7 +257,7 @@ class ApiClient:
|
||||
{{#tornado}}
|
||||
@tornado.gen.coroutine
|
||||
{{/tornado}}
|
||||
{{#asyncio}}async {{/asyncio}}def call_api(
|
||||
{{#async}}async {{/async}}def call_api(
|
||||
self,
|
||||
method,
|
||||
url,
|
||||
@@ -280,7 +280,7 @@ class ApiClient:
|
||||
|
||||
try:
|
||||
# perform request and return response
|
||||
response_data = {{#asyncio}}await {{/asyncio}}{{#tornado}}yield {{/tornado}}self.rest_client.request(
|
||||
response_data = {{#async}}await {{/async}}{{#tornado}}yield {{/tornado}}self.rest_client.request(
|
||||
method, url,
|
||||
headers=header_params,
|
||||
body=body, post_params=post_params,
|
||||
|
||||
@@ -10,7 +10,7 @@ from pprint import pprint
|
||||
{{> python_doc_auth_partial}}
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
{{#asyncio}}async {{/asyncio}}with {{{packageName}}}.ApiClient(configuration) as api_client:
|
||||
{{#async}}async {{/async}}with {{{packageName}}}.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = {{{packageName}}}.{{{classname}}}(api_client)
|
||||
{{#allParams}}
|
||||
@@ -21,7 +21,7 @@ from pprint import pprint
|
||||
{{#summary}}
|
||||
# {{{.}}}
|
||||
{{/summary}}
|
||||
{{#returnType}}api_response = {{/returnType}}{{#asyncio}}await {{/asyncio}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}})
|
||||
{{#returnType}}api_response = {{/returnType}}{{#async}}await {{/async}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}})
|
||||
{{#returnType}}
|
||||
print("The response of {{classname}}->{{operationId}}:\n")
|
||||
pprint(api_response)
|
||||
|
||||
@@ -8,31 +8,31 @@ import unittest
|
||||
from {{apiPackage}}.{{classFilename}} import {{classname}}
|
||||
|
||||
|
||||
class {{#operations}}Test{{classname}}(unittest.{{#asyncio}}IsolatedAsyncio{{/asyncio}}TestCase):
|
||||
class {{#operations}}Test{{classname}}(unittest.{{#async}}IsolatedAsyncio{{/async}}TestCase):
|
||||
"""{{classname}} unit test stubs"""
|
||||
|
||||
{{#asyncio}}
|
||||
{{#async}}
|
||||
async def asyncSetUp(self) -> None:
|
||||
self.api = {{classname}}()
|
||||
|
||||
async def asyncTearDown(self) -> None:
|
||||
await self.api.api_client.close()
|
||||
{{/asyncio}}
|
||||
{{^asyncio}}
|
||||
{{/async}}
|
||||
{{^async}}
|
||||
def setUp(self) -> None:
|
||||
self.api = {{classname}}()
|
||||
|
||||
def tearDown(self) -> None:
|
||||
pass
|
||||
{{/asyncio}}
|
||||
{{/async}}
|
||||
|
||||
{{#operation}}
|
||||
{{#asyncio}}
|
||||
{{#async}}
|
||||
async def test_{{operationId}}(self) -> None:
|
||||
{{/asyncio}}
|
||||
{{^asyncio}}
|
||||
{{/async}}
|
||||
{{^async}}
|
||||
def test_{{operationId}}(self) -> None:
|
||||
{{/asyncio}}
|
||||
{{/async}}
|
||||
"""Test case for {{{operationId}}}
|
||||
|
||||
{{#summary}}
|
||||
|
||||
@@ -8,7 +8,7 @@ from pprint import pprint
|
||||
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
{{#asyncio}}async {{/asyncio}}with {{{packageName}}}.ApiClient(configuration) as api_client:
|
||||
{{#async}}async {{/async}}with {{{packageName}}}.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = {{{packageName}}}.{{{classname}}}(api_client)
|
||||
{{#allParams}}
|
||||
@@ -19,7 +19,7 @@ from pprint import pprint
|
||||
{{#summary}}
|
||||
# {{{.}}}
|
||||
{{/summary}}
|
||||
{{#returnType}}api_response = {{/returnType}}{{#asyncio}}await {{/asyncio}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}})
|
||||
{{#returnType}}api_response = {{/returnType}}{{#async}}await {{/async}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}})
|
||||
{{#returnType}}
|
||||
print("The response of {{classname}}->{{operationId}}:\n")
|
||||
pprint(api_response)
|
||||
|
||||
@@ -7,9 +7,9 @@ import copy
|
||||
import http.client as httplib
|
||||
import logging
|
||||
from logging import FileHandler
|
||||
{{^asyncio}}
|
||||
{{^async}}
|
||||
import multiprocessing
|
||||
{{/asyncio}}
|
||||
{{/async}}
|
||||
import sys
|
||||
from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union
|
||||
from typing_extensions import NotRequired, Self
|
||||
@@ -395,13 +395,13 @@ conf = {{{packageName}}}.Configuration(
|
||||
Set this to the SNI value expected by the server.
|
||||
"""
|
||||
|
||||
{{#asyncio}}
|
||||
{{#async}}
|
||||
self.connection_pool_maxsize = 100
|
||||
"""This value is passed to the aiohttp to limit simultaneous connections.
|
||||
Default values is 100, None means no-limit.
|
||||
"""
|
||||
{{/asyncio}}
|
||||
{{^asyncio}}
|
||||
{{/async}}
|
||||
{{^async}}
|
||||
self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
|
||||
"""urllib3 connection pool's maximum number of connections saved
|
||||
per pool. urllib3 uses 1 connection as default value, but this is
|
||||
@@ -409,7 +409,7 @@ conf = {{{packageName}}}.Configuration(
|
||||
requests to the same host, which is often the case here.
|
||||
cpu_count * 5 is used as default value to increase performance.
|
||||
"""
|
||||
{{/asyncio}}
|
||||
{{/async}}
|
||||
|
||||
self.proxy: Optional[str] = None
|
||||
"""Proxy URL
|
||||
|
||||
185
modules/openapi-generator/src/main/resources/python/httpx/rest.mustache
vendored
Normal file
185
modules/openapi-generator/src/main/resources/python/httpx/rest.mustache
vendored
Normal file
@@ -0,0 +1,185 @@
|
||||
# coding: utf-8
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
|
||||
import io
|
||||
import json
|
||||
import re
|
||||
import ssl
|
||||
from typing import Optional, Union
|
||||
|
||||
import httpx
|
||||
|
||||
from {{packageName}}.exceptions import ApiException, ApiValueError
|
||||
|
||||
RESTResponseType = httpx.Response
|
||||
|
||||
class RESTResponse(io.IOBase):
|
||||
|
||||
def __init__(self, resp) -> None:
|
||||
self.response = resp
|
||||
self.status = resp.status_code
|
||||
self.reason = resp.reason_phrase
|
||||
self.data = None
|
||||
|
||||
async def read(self):
|
||||
if self.data is None:
|
||||
self.data = await self.response.aread()
|
||||
return self.data
|
||||
|
||||
def getheaders(self):
|
||||
"""Returns a CIMultiDictProxy of the response headers."""
|
||||
return self.response.headers
|
||||
|
||||
def getheader(self, name, default=None):
|
||||
"""Returns a given response header."""
|
||||
return self.response.headers.get(name, default)
|
||||
|
||||
|
||||
class RESTClientObject:
|
||||
|
||||
def __init__(self, configuration) -> None:
|
||||
|
||||
# maxsize is number of requests to host that are allowed in parallel
|
||||
self.maxsize = configuration.connection_pool_maxsize
|
||||
|
||||
self.ssl_context = ssl.create_default_context(
|
||||
cafile=configuration.ssl_ca_cert,
|
||||
cadata=configuration.ca_cert_data,
|
||||
)
|
||||
if configuration.cert_file:
|
||||
self.ssl_context.load_cert_chain(
|
||||
configuration.cert_file, keyfile=configuration.key_file
|
||||
)
|
||||
|
||||
if not configuration.verify_ssl:
|
||||
self.ssl_context.check_hostname = False
|
||||
self.ssl_context.verify_mode = ssl.CERT_NONE
|
||||
|
||||
self.proxy = configuration.proxy
|
||||
self.proxy_headers = configuration.proxy_headers
|
||||
|
||||
self.pool_manager: Optional[httpx.AsyncClient] = None
|
||||
|
||||
async def close(self):
|
||||
if self.pool_manager is not None:
|
||||
await self.pool_manager.aclose()
|
||||
|
||||
async def request(
|
||||
self,
|
||||
method,
|
||||
url,
|
||||
headers=None,
|
||||
body=None,
|
||||
post_params=None,
|
||||
_request_timeout=None):
|
||||
"""Execute request
|
||||
|
||||
:param method: http request method
|
||||
:param url: http request url
|
||||
:param headers: http request headers
|
||||
:param body: request json body, for `application/json`
|
||||
:param post_params: request post parameters,
|
||||
`application/x-www-form-urlencoded`
|
||||
and `multipart/form-data`
|
||||
:param _request_timeout: timeout setting for this request. If one
|
||||
number provided, it will be total request
|
||||
timeout. It can also be a pair (tuple) of
|
||||
(connection, read) timeouts.
|
||||
"""
|
||||
method = method.upper()
|
||||
assert method in [
|
||||
'GET',
|
||||
'HEAD',
|
||||
'DELETE',
|
||||
'POST',
|
||||
'PUT',
|
||||
'PATCH',
|
||||
'OPTIONS'
|
||||
]
|
||||
|
||||
if post_params and body:
|
||||
raise ApiValueError(
|
||||
"body parameter cannot be used with post_params parameter."
|
||||
)
|
||||
|
||||
post_params = post_params or {}
|
||||
headers = headers or {}
|
||||
timeout = _request_timeout or 5 * 60
|
||||
|
||||
if 'Content-Type' not in headers:
|
||||
headers['Content-Type'] = 'application/json'
|
||||
|
||||
args = {
|
||||
"method": method,
|
||||
"url": url,
|
||||
"timeout": timeout,
|
||||
"headers": headers
|
||||
}
|
||||
|
||||
# For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
|
||||
if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
|
||||
if re.search('json', headers['Content-Type'], re.IGNORECASE):
|
||||
if body is not None:
|
||||
args["json"] = body
|
||||
elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501
|
||||
args["data"] = dict(post_params)
|
||||
elif headers['Content-Type'] == 'multipart/form-data':
|
||||
# must del headers['Content-Type'], or the correct
|
||||
# Content-Type which generated by httpx
|
||||
del headers['Content-Type']
|
||||
|
||||
files = []
|
||||
data = {}
|
||||
for param in post_params:
|
||||
k, v = param
|
||||
if isinstance(v, tuple) and len(v) == 3:
|
||||
files.append((k, v))
|
||||
else:
|
||||
# Ensures that dict objects are serialized
|
||||
if isinstance(v, dict):
|
||||
v = json.dumps(v)
|
||||
elif isinstance(v, int):
|
||||
v = str(v)
|
||||
data[k] = v
|
||||
|
||||
if files:
|
||||
args["files"] = files
|
||||
if data:
|
||||
args["data"] = data
|
||||
|
||||
# Pass a `bytes` parameter directly in the body to support
|
||||
# other content types than Json when `body` argument is provided
|
||||
# in serialized form
|
||||
elif isinstance(body, str) or isinstance(body, bytes):
|
||||
args["data"] = body
|
||||
else:
|
||||
# Cannot generate the request from given parameters
|
||||
msg = """Cannot prepare a request message for provided
|
||||
arguments. Please check that your arguments match
|
||||
declared content type."""
|
||||
raise ApiException(status=0, reason=msg)
|
||||
|
||||
if self.pool_manager is None:
|
||||
self.pool_manager = self._create_pool_manager()
|
||||
|
||||
r = await self.pool_manager.request(**args)
|
||||
return RESTResponse(r)
|
||||
|
||||
def _create_pool_manager(self) -> httpx.AsyncClient:
|
||||
limits = httpx.Limits(max_connections=self.maxsize)
|
||||
|
||||
proxy = None
|
||||
if self.proxy:
|
||||
proxy = httpx.Proxy(
|
||||
url=self.proxy,
|
||||
headers=self.proxy_headers
|
||||
)
|
||||
|
||||
return httpx.AsyncClient(
|
||||
limits=limits,
|
||||
proxy=proxy,
|
||||
verify=self.ssl_context,
|
||||
trust_env=True
|
||||
)
|
||||
@@ -39,6 +39,9 @@ python-dateutil = ">= 2.8.2"
|
||||
aiohttp = ">= 3.8.4"
|
||||
aiohttp-retry = ">= 2.8.3"
|
||||
{{/asyncio}}
|
||||
{{#httpx}}
|
||||
httpx = ">= 0.28.1"
|
||||
{{/httpx}}
|
||||
{{#tornado}}
|
||||
tornado = ">=4.2, <5"
|
||||
{{/tornado}}
|
||||
@@ -58,10 +61,10 @@ requires-python = ">=3.9"
|
||||
dependencies = [
|
||||
"urllib3 (>=2.1.0,<3.0.0)",
|
||||
"python-dateutil (>=2.8.2)",
|
||||
{{#asyncio}}
|
||||
{{#async}}
|
||||
"aiohttp (>=3.8.4)",
|
||||
"aiohttp-retry (>=2.8.3)",
|
||||
{{/asyncio}}
|
||||
{{/async}}
|
||||
{{#tornado}}
|
||||
"tornado (>=4.2,<5)",
|
||||
{{/tornado}}
|
||||
|
||||
@@ -4,6 +4,9 @@ python_dateutil >= 2.8.2
|
||||
aiohttp >= 3.8.4
|
||||
aiohttp-retry >= 2.8.3
|
||||
{{/asyncio}}
|
||||
{{#httpx}}
|
||||
httpx = ">= 0.28.1"
|
||||
{{/httpx}}
|
||||
{{#tornado}}
|
||||
tornado = ">= 4.2, < 5"
|
||||
{{/tornado}}
|
||||
|
||||
@@ -21,6 +21,9 @@ REQUIRES = [
|
||||
"aiohttp >= 3.8.4",
|
||||
"aiohttp-retry >= 2.8.3",
|
||||
{{/asyncio}}
|
||||
{{#httpx}}
|
||||
"httpx >= 0.28.1",
|
||||
{{/httpx}}
|
||||
{{#tornado}}
|
||||
"tornado>=4.2, < 5",
|
||||
{{/tornado}}
|
||||
|
||||
@@ -524,7 +524,7 @@ pub fn check_xss_map<T>(v: &std::collections::HashMap<String, T>) -> std::result
|
||||
/// Enumeration of values.
|
||||
/// Since this enum's variants do not hold data, we can easily define them as `#[repr(C)]`
|
||||
/// which helps with FFI.
|
||||
#[allow(non_camel_case_types)]
|
||||
#[allow(non_camel_case_types, clippy::large_enum_variant)]
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)]
|
||||
#[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))]
|
||||
@@ -751,17 +751,38 @@ impl std::str::FromStr for {{{classname}}} {
|
||||
{{^arrayModelType}}
|
||||
{{! general struct}}
|
||||
{{#anyOf.size}}
|
||||
/// Any of:
|
||||
{{#anyOf}}
|
||||
/// - {{{.}}}
|
||||
{{/anyOf}}
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct {{{classname}}}(Box<serde_json::value::RawValue>);
|
||||
{{#discriminator}}
|
||||
#[derive(Debug, Clone, PartialEq, serde::Deserialize)]
|
||||
#[serde(tag = "{{{propertyBaseName}}}")]
|
||||
{{/discriminator}}
|
||||
{{^discriminator}}
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(untagged)]
|
||||
{{/discriminator}}
|
||||
#[allow(non_camel_case_types, clippy::large_enum_variant)]
|
||||
pub enum {{{classname}}} {
|
||||
{{#composedSchemas}}
|
||||
{{#anyOf}}
|
||||
{{{datatypeWithEnum}}}({{{dataType}}}),
|
||||
{{/anyOf}}
|
||||
{{/composedSchemas}}
|
||||
}
|
||||
|
||||
impl validator::Validate for {{{classname}}}
|
||||
{
|
||||
fn validate(&self) -> std::result::Result<(), validator::ValidationErrors> {
|
||||
std::result::Result::Ok(())
|
||||
match self {
|
||||
{{#composedSchemas}}
|
||||
{{#anyOf}}
|
||||
{{^isModel}}
|
||||
Self::{{{datatypeWithEnum}}}(_) => std::result::Result::Ok(()),
|
||||
{{/isModel}}
|
||||
{{#isModel}}
|
||||
Self::{{{datatypeWithEnum}}}(v) => v.validate(),
|
||||
{{/isModel}}
|
||||
{{/anyOf}}
|
||||
{{/composedSchemas}}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -776,11 +797,32 @@ impl std::str::FromStr for {{{classname}}} {
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for {{{classname}}} {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.0.get() == other.0.get()
|
||||
{{#discriminator}}
|
||||
impl serde::Serialize for {{{classname}}} {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where S: serde::Serializer {
|
||||
match self {
|
||||
{{#composedSchemas}}
|
||||
{{#anyOf}}
|
||||
Self::{{{datatypeWithEnum}}}(x) => x.serialize(serializer),
|
||||
{{/anyOf}}
|
||||
{{/composedSchemas}}
|
||||
}
|
||||
}
|
||||
}
|
||||
{{/discriminator}}
|
||||
|
||||
{{#composedSchemas}}
|
||||
{{#anyOf}}
|
||||
{{#vendorExtensions.x-from-trait}}
|
||||
impl From<{{{dataType}}}> for {{{classname}}} {
|
||||
fn from(value: {{{dataType}}}) -> Self {
|
||||
Self::{{{datatypeWithEnum}}}(value)
|
||||
}
|
||||
}
|
||||
{{/vendorExtensions.x-from-trait}}
|
||||
{{/anyOf}}
|
||||
{{/composedSchemas}}
|
||||
|
||||
{{/anyOf.size}}
|
||||
{{#oneOf.size}}
|
||||
@@ -792,11 +834,11 @@ impl PartialEq for {{{classname}}} {
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(untagged)]
|
||||
{{/discriminator}}
|
||||
#[allow(non_camel_case_types)]
|
||||
#[allow(non_camel_case_types, clippy::large_enum_variant)]
|
||||
pub enum {{{classname}}} {
|
||||
{{#composedSchemas}}
|
||||
{{#oneOf}}
|
||||
{{{datatypeWithEnum}}}(Box<{{{dataType}}}>),
|
||||
{{{datatypeWithEnum}}}({{{dataType}}}),
|
||||
{{/oneOf}}
|
||||
{{/composedSchemas}}
|
||||
}
|
||||
@@ -807,18 +849,29 @@ impl validator::Validate for {{{classname}}}
|
||||
match self {
|
||||
{{#composedSchemas}}
|
||||
{{#oneOf}}
|
||||
{{#isPrimitiveType}}
|
||||
{{^isModel}}
|
||||
Self::{{{datatypeWithEnum}}}(_) => std::result::Result::Ok(()),
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
Self::{{{datatypeWithEnum}}}(x) => x.validate(),
|
||||
{{/isPrimitiveType}}
|
||||
{{/isModel}}
|
||||
{{#isModel}}
|
||||
Self::{{{datatypeWithEnum}}}(v) => v.validate(),
|
||||
{{/isModel}}
|
||||
{{/oneOf}}
|
||||
{{/composedSchemas}}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts Query Parameters representation (style=form, explode=false) to a {{{classname}}} value
|
||||
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde deserializer
|
||||
impl std::str::FromStr for {{{classname}}} {
|
||||
type Err = serde_json::Error;
|
||||
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
serde_json::from_str(s)
|
||||
}
|
||||
}
|
||||
|
||||
{{#discriminator}}
|
||||
impl serde::Serialize for {{{classname}}} {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
@@ -834,29 +887,18 @@ impl serde::Serialize for {{{classname}}} {
|
||||
}
|
||||
{{/discriminator}}
|
||||
|
||||
|
||||
|
||||
{{#composedSchemas}}
|
||||
{{#oneOf}}
|
||||
{{#vendorExtensions.x-from-trait}}
|
||||
impl From<{{{dataType}}}> for {{{classname}}} {
|
||||
fn from(value: {{{dataType}}}) -> Self {
|
||||
Self::{{{datatypeWithEnum}}}(Box::new(value))
|
||||
Self::{{{datatypeWithEnum}}}(value)
|
||||
}
|
||||
}
|
||||
{{/vendorExtensions.x-from-trait}}
|
||||
{{/oneOf}}
|
||||
{{/composedSchemas}}
|
||||
|
||||
/// Converts Query Parameters representation (style=form, explode=false) to a {{{classname}}} value
|
||||
/// as specified in https://swagger.io/docs/specification/serialization/
|
||||
/// Should be implemented in a serde deserializer
|
||||
impl std::str::FromStr for {{{classname}}} {
|
||||
type Err = serde_json::Error;
|
||||
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
serde_json::from_str(s)
|
||||
}
|
||||
}
|
||||
|
||||
{{/oneOf.size}}
|
||||
{{^anyOf.size}}
|
||||
{{^oneOf.size}}
|
||||
@@ -871,8 +913,10 @@ pub struct {{{classname}}} {
|
||||
/// Note: inline enums are not fully supported by openapi-generator
|
||||
{{/isEnum}}
|
||||
{{#isDiscriminator}}
|
||||
{{#isString}}
|
||||
#[serde(default = "{{{classname}}}::_name_for_{{{name}}}")]
|
||||
#[serde(serialize_with = "{{{classname}}}::_serialize_{{{name}}}")]
|
||||
{{/isString}}
|
||||
{{/isDiscriminator}}
|
||||
#[serde(rename = "{{{baseName}}}")]
|
||||
{{#hasValidation}}
|
||||
@@ -989,9 +1033,9 @@ pub struct {{{classname}}} {
|
||||
{{/vars}}
|
||||
}
|
||||
|
||||
|
||||
{{#vars}}
|
||||
{{#isDiscriminator}}
|
||||
{{#isString}}
|
||||
impl {{{classname}}} {
|
||||
fn _name_for_{{{name}}}() -> String {
|
||||
String::from("{{{classname}}}")
|
||||
@@ -1004,10 +1048,10 @@ impl {{{classname}}} {
|
||||
s.serialize_str(&Self::_name_for_{{{name}}}())
|
||||
}
|
||||
}
|
||||
{{/isString}}
|
||||
{{/isDiscriminator}}
|
||||
{{/vars}}
|
||||
|
||||
|
||||
{{#vars}}
|
||||
{{#hasValidation}}
|
||||
{{#pattern}}
|
||||
@@ -1035,9 +1079,9 @@ fn validate_byte_{{#lambda.lowercase}}{{{classname}}}_{{{name}}}{{/lambda.lowerc
|
||||
|
||||
impl {{{classname}}} {
|
||||
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
||||
pub fn new({{#vars}}{{^defaultValue}}{{{name}}}: {{#isNullable}}Nullable<{{/isNullable}}{{{dataType}}}{{#isNullable}}>{{/isNullable}}, {{/defaultValue}}{{/vars}}) -> {{{classname}}} {
|
||||
pub fn new({{#vars}}{{^isDiscriminator}}{{^defaultValue}}{{{name}}}: {{#isNullable}}Nullable<{{/isNullable}}{{{dataType}}}{{#isNullable}}>{{/isNullable}}, {{/defaultValue}}{{/isDiscriminator}}{{#isDiscriminator}}{{^isString}}{{^defaultValue}}{{{name}}}: {{#isNullable}}Nullable<{{/isNullable}}{{{dataType}}}{{#isNullable}}>{{/isNullable}}, {{/defaultValue}}{{/isString}}{{/isDiscriminator}}{{/vars}}) -> {{{classname}}} {
|
||||
{{{classname}}} {
|
||||
{{#vars}} {{#defaultValue}}{{{name}}}: {{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}{{{name}}}{{/defaultValue}},
|
||||
{{#vars}} {{^isDiscriminator}}{{#defaultValue}}{{{name}}}: {{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}{{{name}}}{{/defaultValue}}{{/isDiscriminator}}{{#isDiscriminator}}{{#isString}}{{{name}}}: Self::_name_for_{{{name}}}(){{/isString}}{{^isString}}{{#defaultValue}}{{{name}}}: {{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}{{{name}}}{{/defaultValue}}{{/isString}}{{/isDiscriminator}},
|
||||
{{/vars}}
|
||||
}
|
||||
}
|
||||
@@ -1075,7 +1119,7 @@ impl std::fmt::Display for {{{classname}}} {
|
||||
{{/isArray}}
|
||||
{{#isArray}}
|
||||
{{#isNullable}}
|
||||
Some(self.{{{name}}}.as_ref().map_or(vec!["null".to_string()], |x| x.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","))),
|
||||
Some(self.{{{name}}}.as_ref().map_or("null".to_string(), |x| x.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","))),
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
Some(self.{{{name}}}.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",")),
|
||||
@@ -1226,7 +1270,6 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<{{{classname
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{{/oneOf.size}}
|
||||
{{/anyOf.size}}
|
||||
|
||||
|
||||
@@ -121,145 +121,80 @@ impl Default for {{classname}} {
|
||||
{{!-- for non-enum schemas --}}
|
||||
{{^isEnum}}
|
||||
{{^discriminator}}
|
||||
{{#composedSchemas}}
|
||||
{{#oneOf}}
|
||||
{{#-first}}
|
||||
{{! Model with composedSchemas.oneOf - generate enum}}
|
||||
{{#vendorExtensions.x-rust-has-byte-array}}#[serde_as]
|
||||
{{/vendorExtensions.x-rust-has-byte-array}}{{#oneOf.isEmpty}}#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct {{{classname}}} {
|
||||
{{#vars}}
|
||||
{{#description}}
|
||||
/// {{{.}}}
|
||||
{{/description}}
|
||||
{{#isByteArray}}
|
||||
{{#vendorExtensions.isMandatory}}#[serde_as(as = "serde_with::base64::Base64")]{{/vendorExtensions.isMandatory}}{{^vendorExtensions.isMandatory}}#[serde_as(as = "{{^serdeAsDoubleOption}}Option{{/serdeAsDoubleOption}}{{#serdeAsDoubleOption}}super::DoubleOption{{/serdeAsDoubleOption}}<serde_with::base64::Base64>")]{{/vendorExtensions.isMandatory}}
|
||||
{{/isByteArray}}
|
||||
#[serde(rename = "{{{baseName}}}"{{^required}}{{#isNullable}}, default{{^isByteArray}}, with = "::serde_with::rust::double_option"{{/isByteArray}}{{/isNullable}}{{/required}}{{^required}}, skip_serializing_if = "Option::is_none"{{/required}}{{#required}}{{#isNullable}}, deserialize_with = "Option::deserialize"{{/isNullable}}{{/required}})]
|
||||
pub {{{name}}}: {{!
|
||||
### Option Start
|
||||
}}{{#isNullable}}Option<{{/isNullable}}{{^required}}Option<{{/required}}{{!
|
||||
### Enums
|
||||
}}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{!
|
||||
### Non-Enums Start
|
||||
}}{{^isEnum}}{{!
|
||||
### Models
|
||||
}}{{#isModel}}{{^avoidBoxedModels}}Box<{{/avoidBoxedModels}}{{{dataType}}}{{^avoidBoxedModels}}>{{/avoidBoxedModels}}{{/isModel}}{{!
|
||||
### Primative datatypes
|
||||
}}{{^isModel}}{{#isByteArray}}Vec<u8>{{/isByteArray}}{{^isByteArray}}{{{dataType}}}{{/isByteArray}}{{/isModel}}{{!
|
||||
### Non-Enums End
|
||||
}}{{/isEnum}}{{!
|
||||
### Option End (and trailing comma)
|
||||
}}{{#isNullable}}>{{/isNullable}}{{^required}}>{{/required}},
|
||||
{{/vars}}
|
||||
}
|
||||
|
||||
impl {{{classname}}} {
|
||||
{{#description}}
|
||||
/// {{{.}}}
|
||||
{{/description}}
|
||||
pub fn new({{#requiredVars}}{{{name}}}: {{!
|
||||
### Option Start
|
||||
}}{{#isNullable}}Option<{{/isNullable}}{{!
|
||||
### Enums
|
||||
}}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{!
|
||||
### Non-Enums
|
||||
}}{{^isEnum}}{{#isByteArray}}Vec<u8>{{/isByteArray}}{{^isByteArray}}{{{dataType}}}{{/isByteArray}}{{/isEnum}}{{!
|
||||
### Option End
|
||||
}}{{#isNullable}}>{{/isNullable}}{{!
|
||||
### Comma for next arguement
|
||||
}}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{{classname}}} {
|
||||
{{{classname}}} {
|
||||
{{#vars}}
|
||||
{{{name}}}{{^required}}: None{{/required}}{{#required}}{{#isModel}}{{^avoidBoxedModels}}: {{^isNullable}}Box::new({{{name}}}){{/isNullable}}{{#isNullable}}if let Some(x) = {{{name}}} {Some(Box::new(x))} else {None}{{/isNullable}}{{/avoidBoxedModels}}{{/isModel}}{{/required}},
|
||||
{{/vars}}
|
||||
}
|
||||
}
|
||||
}
|
||||
{{/oneOf.isEmpty}}
|
||||
{{^oneOf.isEmpty}}
|
||||
{{! TODO: add other vars that are not part of the oneOf}}
|
||||
{{#description}}
|
||||
/// {{{.}}}
|
||||
{{/description}}
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum {{classname}} {
|
||||
{{/-first}}
|
||||
{{/oneOf}}
|
||||
{{/composedSchemas}}
|
||||
{{#composedSchemas}}
|
||||
{{#oneOf}}
|
||||
{{#composedSchemas.oneOf}}
|
||||
{{#description}}
|
||||
/// {{{.}}}
|
||||
{{/description}}
|
||||
{{{name}}}({{#isModel}}{{^avoidBoxedModels}}Box<{{/avoidBoxedModels}}{{/isModel}}{{{dataType}}}{{#isModel}}{{^avoidBoxedModels}}>{{/avoidBoxedModels}}{{/isModel}}),
|
||||
{{/oneOf}}
|
||||
{{/composedSchemas}}
|
||||
{{#composedSchemas}}
|
||||
{{#oneOf}}
|
||||
{{#-last}}
|
||||
{{/composedSchemas.oneOf}}
|
||||
}
|
||||
|
||||
impl Default for {{classname}} {
|
||||
fn default() -> Self {
|
||||
{{#oneOf}}{{#-first}}Self::{{{name}}}(Default::default()){{/-first}}{{/oneOf}}
|
||||
{{#composedSchemas.oneOf}}{{#-first}}Self::{{{name}}}(Default::default()){{/-first}}{{/composedSchemas.oneOf}}
|
||||
}
|
||||
}
|
||||
{{/-last}}
|
||||
{{/oneOf}}
|
||||
{{^oneOf}}
|
||||
{{! composedSchemas exists but no oneOf - generate normal struct}}
|
||||
{{#vendorExtensions.x-rust-has-byte-array}}#[serde_as]
|
||||
{{/vendorExtensions.x-rust-has-byte-array}}#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct {{{classname}}} {
|
||||
{{#vars}}
|
||||
{{#description}}
|
||||
/// {{{.}}}
|
||||
{{/description}}
|
||||
{{#isByteArray}}
|
||||
{{#vendorExtensions.isMandatory}}#[serde_as(as = "serde_with::base64::Base64")]{{/vendorExtensions.isMandatory}}{{^vendorExtensions.isMandatory}}#[serde_as(as = "{{^serdeAsDoubleOption}}Option{{/serdeAsDoubleOption}}{{#serdeAsDoubleOption}}super::DoubleOption{{/serdeAsDoubleOption}}<serde_with::base64::Base64>")]{{/vendorExtensions.isMandatory}}
|
||||
{{/isByteArray}}
|
||||
#[serde(rename = "{{{baseName}}}"{{^required}}{{#isNullable}}, default{{^isByteArray}}, with = "::serde_with::rust::double_option"{{/isByteArray}}{{/isNullable}}{{/required}}{{^required}}, skip_serializing_if = "Option::is_none"{{/required}}{{#required}}{{#isNullable}}, deserialize_with = "Option::deserialize"{{/isNullable}}{{/required}})]
|
||||
pub {{{name}}}: {{!
|
||||
### Option Start
|
||||
}}{{#isNullable}}Option<{{/isNullable}}{{^required}}Option<{{/required}}{{!
|
||||
### Enums
|
||||
}}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{!
|
||||
### Non-Enums Start
|
||||
}}{{^isEnum}}{{!
|
||||
### Models
|
||||
}}{{#isModel}}{{^avoidBoxedModels}}Box<{{/avoidBoxedModels}}{{{dataType}}}{{^avoidBoxedModels}}>{{/avoidBoxedModels}}{{/isModel}}{{!
|
||||
### Primative datatypes
|
||||
}}{{^isModel}}{{#isByteArray}}Vec<u8>{{/isByteArray}}{{^isByteArray}}{{{dataType}}}{{/isByteArray}}{{/isModel}}{{!
|
||||
### Non-Enums End
|
||||
}}{{/isEnum}}{{!
|
||||
### Option End (and trailing comma)
|
||||
}}{{#isNullable}}>{{/isNullable}}{{^required}}>{{/required}},
|
||||
{{/vars}}
|
||||
}
|
||||
|
||||
impl {{{classname}}} {
|
||||
{{#description}}
|
||||
/// {{{.}}}
|
||||
{{/description}}
|
||||
pub fn new({{#requiredVars}}{{{name}}}: {{!
|
||||
### Option Start
|
||||
}}{{#isNullable}}Option<{{/isNullable}}{{!
|
||||
### Enums
|
||||
}}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{!
|
||||
### Non-Enums
|
||||
}}{{^isEnum}}{{#isByteArray}}Vec<u8>{{/isByteArray}}{{^isByteArray}}{{{dataType}}}{{/isByteArray}}{{/isEnum}}{{!
|
||||
### Option End
|
||||
}}{{#isNullable}}>{{/isNullable}}{{!
|
||||
### Comma for next arguement
|
||||
}}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{{classname}}} {
|
||||
{{{classname}}} {
|
||||
{{#vars}}
|
||||
{{{name}}}{{^required}}: None{{/required}}{{#required}}{{#isModel}}{{^avoidBoxedModels}}: {{^isNullable}}Box::new({{{name}}}){{/isNullable}}{{#isNullable}}if let Some(x) = {{{name}}} {Some(Box::new(x))} else {None}{{/isNullable}}{{/avoidBoxedModels}}{{/isModel}}{{/required}},
|
||||
{{/vars}}
|
||||
}
|
||||
}
|
||||
}
|
||||
{{/oneOf}}
|
||||
{{/composedSchemas}}
|
||||
{{^composedSchemas}}
|
||||
{{! Normal struct without composedSchemas}}
|
||||
{{#vendorExtensions.x-rust-has-byte-array}}#[serde_as]
|
||||
{{/vendorExtensions.x-rust-has-byte-array}}#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct {{{classname}}} {
|
||||
{{#vars}}
|
||||
{{#description}}
|
||||
/// {{{.}}}
|
||||
{{/description}}
|
||||
{{#isByteArray}}
|
||||
{{#vendorExtensions.isMandatory}}#[serde_as(as = "serde_with::base64::Base64")]{{/vendorExtensions.isMandatory}}{{^vendorExtensions.isMandatory}}#[serde_as(as = "{{^serdeAsDoubleOption}}Option{{/serdeAsDoubleOption}}{{#serdeAsDoubleOption}}super::DoubleOption{{/serdeAsDoubleOption}}<serde_with::base64::Base64>")]{{/vendorExtensions.isMandatory}}
|
||||
{{/isByteArray}}
|
||||
#[serde(rename = "{{{baseName}}}"{{^required}}{{#isNullable}}, default{{^isByteArray}}, with = "::serde_with::rust::double_option"{{/isByteArray}}{{/isNullable}}{{/required}}{{^required}}, skip_serializing_if = "Option::is_none"{{/required}}{{#required}}{{#isNullable}}, deserialize_with = "Option::deserialize"{{/isNullable}}{{/required}})]
|
||||
pub {{{name}}}: {{!
|
||||
### Option Start
|
||||
}}{{#isNullable}}Option<{{/isNullable}}{{^required}}Option<{{/required}}{{!
|
||||
### Enums
|
||||
}}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{!
|
||||
### Non-Enums Start
|
||||
}}{{^isEnum}}{{!
|
||||
### Models
|
||||
}}{{#isModel}}{{^avoidBoxedModels}}Box<{{/avoidBoxedModels}}{{{dataType}}}{{^avoidBoxedModels}}>{{/avoidBoxedModels}}{{/isModel}}{{!
|
||||
### Primative datatypes
|
||||
}}{{^isModel}}{{#isByteArray}}Vec<u8>{{/isByteArray}}{{^isByteArray}}{{{dataType}}}{{/isByteArray}}{{/isModel}}{{!
|
||||
### Non-Enums End
|
||||
}}{{/isEnum}}{{!
|
||||
### Option End (and trailing comma)
|
||||
}}{{#isNullable}}>{{/isNullable}}{{^required}}>{{/required}},
|
||||
{{/vars}}
|
||||
}
|
||||
|
||||
impl {{{classname}}} {
|
||||
{{#description}}
|
||||
/// {{{.}}}
|
||||
{{/description}}
|
||||
pub fn new({{#requiredVars}}{{{name}}}: {{!
|
||||
### Option Start
|
||||
}}{{#isNullable}}Option<{{/isNullable}}{{!
|
||||
### Enums
|
||||
}}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{!
|
||||
### Non-Enums
|
||||
}}{{^isEnum}}{{#isByteArray}}Vec<u8>{{/isByteArray}}{{^isByteArray}}{{{dataType}}}{{/isByteArray}}{{/isEnum}}{{!
|
||||
### Option End
|
||||
}}{{#isNullable}}>{{/isNullable}}{{!
|
||||
### Comma for next arguement
|
||||
}}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{{classname}}} {
|
||||
{{{classname}}} {
|
||||
{{#vars}}
|
||||
{{{name}}}{{^required}}: None{{/required}}{{#required}}{{#isModel}}{{^avoidBoxedModels}}: {{^isNullable}}Box::new({{{name}}}){{/isNullable}}{{#isNullable}}if let Some(x) = {{{name}}} {Some(Box::new(x))} else {None}{{/isNullable}}{{/avoidBoxedModels}}{{/isModel}}{{/required}},
|
||||
{{/vars}}
|
||||
}
|
||||
}
|
||||
}
|
||||
{{/composedSchemas}}
|
||||
{{/oneOf.isEmpty}}
|
||||
{{/discriminator}}
|
||||
{{/isEnum}}
|
||||
{{!-- for properties that are of enum type --}}
|
||||
|
||||
@@ -22,7 +22,7 @@ import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObj
|
||||
import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '{{apiRelativeToRoot}}base{{importFileExtension}}';
|
||||
{{#imports}}
|
||||
// @ts-ignore
|
||||
import type { {{classname}} } from '{{apiRelativeToRoot}}{{tsModelPackage}}{{importFileExtension}}';
|
||||
import type { {{classname}} } from '{{apiRelativeToRoot}}{{tsModelPackage}}{{#importFileExtension}}/index{{importFileExtension}}{{/importFileExtension}}';
|
||||
{{/imports}}
|
||||
{{/withSeparateModelsAndApi}}
|
||||
{{^withSeparateModelsAndApi}}
|
||||
|
||||
@@ -5,4 +5,4 @@
|
||||
|
||||
export * from "./api{{importFileExtension}}";
|
||||
export * from "./configuration{{importFileExtension}}";
|
||||
{{#withSeparateModelsAndApi}}export * from "./{{tsModelPackage}}{{importFileExtension}}";{{/withSeparateModelsAndApi}}
|
||||
{{#withSeparateModelsAndApi}}export * from "./{{tsModelPackage}}{{#importFileExtension}}/index{{importFileExtension}}{{/importFileExtension}}";{{/withSeparateModelsAndApi}}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
{{/packageAsSourceOnlyLibrary}}
|
||||
{{^packageAsSourceOnlyLibrary}}
|
||||
"main": "./dist/index.js",
|
||||
"typings": "./dist/index.d.ts",
|
||||
"types": "./dist/index.d.ts",
|
||||
{{#supportsES6}}
|
||||
"module": "./dist/esm/index.js",
|
||||
"sideEffects": false,
|
||||
|
||||
@@ -3982,4 +3982,21 @@ public class JavaClientCodegenTest {
|
||||
}
|
||||
assertTrue(speciesSeen);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneOfClassWithAnnotation() throws IOException {
|
||||
final Map<String, File> files = generateFromContract("src/test/resources/3_0/java/oneOf-with-annotations.yaml", RESTCLIENT);
|
||||
JavaFileAssert.assertThat(files.get("Fruit.java"))
|
||||
.isNormalClass()
|
||||
.assertTypeAnnotations().containsWithName("SuppressWarnings");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneOfInterfaceWithAnnotation() throws IOException {
|
||||
final Map<String, File> files = generateFromContract("src/test/resources/3_0/java/oneOf-with-annotations.yaml", RESTCLIENT,
|
||||
Map.of(USE_ONE_OF_INTERFACES, "true"));
|
||||
JavaFileAssert.assertThat(files.get("Fruit.java"))
|
||||
.isInterface()
|
||||
.assertTypeAnnotations().containsWithName("SuppressWarnings");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5730,4 +5730,12 @@ public class SpringCodegenTest {
|
||||
javaFileAssert
|
||||
.hasImports("java.util.concurrent.atomic.AtomicInteger");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneOfInterfaceWithAnnotation() throws IOException {
|
||||
final Map<String, File> files = generateFromContract("src/test/resources/3_0/java/oneOf-with-annotations.yaml", SPRING_BOOT);
|
||||
JavaFileAssert.assertThat(files.get("Fruit.java"))
|
||||
.isInterface()
|
||||
.assertTypeAnnotations().containsWithName("SuppressWarnings");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +91,24 @@ public class KotlinClientCodegenApiTest {
|
||||
assertFileContainsLine(lines, "suspend fun deletePet(@Path(\"petId\") petId: kotlin.Long, @Header(\"api_key\") apiKey: kotlin.String? = null)" + expectedUnitResponse);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEnumDefaultForReferencedSchemaParameterJvmOkhttp4() throws IOException {
|
||||
OpenAPI openAPI = readOpenAPI("3_0/kotlin/enum-default-query.yaml");
|
||||
|
||||
KotlinClientCodegen codegen = createCodegen(ClientLibrary.JVM_OKHTTP4);
|
||||
codegen.additionalProperties().put("enumPropertyNaming", "UPPERCASE");
|
||||
|
||||
ClientOptInput input = createClientOptInput(openAPI, codegen);
|
||||
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
enableOnlyApiGeneration(generator);
|
||||
|
||||
List<File> files = generator.opts(input).generate();
|
||||
File statusApi = files.stream().filter(file -> file.getName().equals("StatusApi.kt")).findAny().orElseThrow();
|
||||
|
||||
assertFileContains(statusApi.toPath(), "state: PetStatus? = PetStatus.AVAILABLE");
|
||||
}
|
||||
|
||||
private static void assertFileContainsLine(List<String> lines, String line) {
|
||||
Assert.assertListContains(lines, s -> s.equals(line), line);
|
||||
}
|
||||
|
||||
@@ -271,37 +271,4 @@ public class RustClientCodegenTest {
|
||||
TestUtils.assertFileExists(outputPath);
|
||||
TestUtils.assertFileContains(outputPath, enumSpec);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnyOfSupport() throws IOException {
|
||||
Path target = Files.createTempDirectory("test-anyof");
|
||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||
.setGeneratorName("rust")
|
||||
.setInputSpec("src/test/resources/3_0/rust/rust-anyof-test.yaml")
|
||||
.setSkipOverwrite(false)
|
||||
.setOutputDir(target.toAbsolutePath().toString().replace("\\", "/"));
|
||||
List<File> files = new DefaultGenerator().opts(configurator.toClientOptInput()).generate();
|
||||
files.forEach(File::deleteOnExit);
|
||||
|
||||
// Test that ModelIdentifier generates an untagged enum, not an empty struct
|
||||
Path modelIdentifierPath = Path.of(target.toString(), "/src/models/model_identifier.rs");
|
||||
TestUtils.assertFileExists(modelIdentifierPath);
|
||||
|
||||
// Should generate an untagged enum
|
||||
TestUtils.assertFileContains(modelIdentifierPath, "#[serde(untagged)]");
|
||||
TestUtils.assertFileContains(modelIdentifierPath, "pub enum ModelIdentifier");
|
||||
|
||||
// Should have String variant (for anyOf with string types)
|
||||
TestUtils.assertFileContains(modelIdentifierPath, "String(String)");
|
||||
|
||||
// Should NOT generate an empty struct
|
||||
TestUtils.assertFileNotContains(modelIdentifierPath, "pub struct ModelIdentifier {");
|
||||
TestUtils.assertFileNotContains(modelIdentifierPath, "pub fn new()");
|
||||
|
||||
// Test AnotherAnyOfTest with mixed types
|
||||
Path anotherTestPath = Path.of(target.toString(), "/src/models/another_any_of_test.rs");
|
||||
TestUtils.assertFileExists(anotherTestPath);
|
||||
TestUtils.assertFileContains(anotherTestPath, "#[serde(untagged)]");
|
||||
TestUtils.assertFileContains(anotherTestPath, "pub enum AnotherAnyOfTest");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
openapi: 3.0.1
|
||||
info:
|
||||
title: fruity
|
||||
version: 0.0.1
|
||||
paths:
|
||||
/:
|
||||
get:
|
||||
responses:
|
||||
'200':
|
||||
description: desc
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/fruit'
|
||||
components:
|
||||
schemas:
|
||||
fruit:
|
||||
title: fruit
|
||||
x-class-extra-annotation: '@SuppressWarnings("unchecked")'
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
oneOf:
|
||||
- $ref: '#/components/schemas/apple'
|
||||
- $ref: '#/components/schemas/banana'
|
||||
- $ref: '#/components/schemas/orange'
|
||||
apple:
|
||||
title: apple
|
||||
type: object
|
||||
properties:
|
||||
kind:
|
||||
type: string
|
||||
banana:
|
||||
title: banana
|
||||
type: object
|
||||
properties:
|
||||
count:
|
||||
type: number
|
||||
orange:
|
||||
title: orange
|
||||
type: object
|
||||
properties:
|
||||
sweet:
|
||||
type: boolean
|
||||
@@ -0,0 +1,26 @@
|
||||
openapi: 3.0.1
|
||||
info:
|
||||
title: Enum default test
|
||||
version: 1.0.0
|
||||
paths:
|
||||
/status:
|
||||
get:
|
||||
tags:
|
||||
- Status
|
||||
operationId: getStatus
|
||||
parameters:
|
||||
- name: state
|
||||
in: query
|
||||
schema:
|
||||
$ref: '#/components/schemas/PetStatus'
|
||||
responses:
|
||||
'200':
|
||||
description: OK
|
||||
components:
|
||||
schemas:
|
||||
PetStatus:
|
||||
type: string
|
||||
enum:
|
||||
- available
|
||||
- pending
|
||||
default: available
|
||||
@@ -0,0 +1,35 @@
|
||||
openapi: 3.0.3
|
||||
info:
|
||||
title: optional body
|
||||
version: 1.0.1
|
||||
servers:
|
||||
- url: https://api.123.com/api/v1
|
||||
tags:
|
||||
- name: just-api
|
||||
description: Everything about API functions
|
||||
paths:
|
||||
/silly:
|
||||
post:
|
||||
tags:
|
||||
- just-api
|
||||
operationId: send_optional_payload
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Payload"
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
application/text:
|
||||
schema:
|
||||
type: string
|
||||
components:
|
||||
schemas:
|
||||
Payload:
|
||||
type: object
|
||||
properties:
|
||||
token:
|
||||
type: string
|
||||
description: Some kind of token - usually received by Email
|
||||
@@ -31,7 +31,6 @@ paths:
|
||||
$ref: '#/components/schemas/Foo'
|
||||
/pet:
|
||||
servers:
|
||||
- url: 'http://127.0.0.1/v2'
|
||||
- url: 'http://petstore.swagger.io/v2'
|
||||
- url: 'http://path-server-test.petstore.local/v2'
|
||||
- url: 'http://{server}.swagger.io:{port}/v2'
|
||||
@@ -189,7 +188,6 @@ paths:
|
||||
deprecated: true
|
||||
'/pet/{petId}':
|
||||
servers:
|
||||
- url: 'http://127.0.0.1/v2'
|
||||
- url: 'http://petstore.swagger.io/v2'
|
||||
- url: 'http://path-server-test.petstore.local/v2'
|
||||
- url: 'http://{server}.swagger.io:{port}/v2'
|
||||
@@ -1360,8 +1358,6 @@ paths:
|
||||
200:
|
||||
description: OK
|
||||
servers:
|
||||
- url: https://127.0.0.1/v2
|
||||
description: The local server without variables
|
||||
- url: 'http://{server}.swagger.io:{port}/v2'
|
||||
description: petstore server
|
||||
variables:
|
||||
@@ -1384,6 +1380,8 @@ servers:
|
||||
- 'v1'
|
||||
- 'v2'
|
||||
default: 'v2'
|
||||
- url: https://127.0.0.1/no_varaible
|
||||
description: The local server without variables
|
||||
- url: http://server.{version}.openapi-generator.tech
|
||||
description: The openapi-generator test server
|
||||
variables:
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
openapi: 3.0.0
|
||||
info:
|
||||
title: Rust anyOf Test
|
||||
version: 1.0.0
|
||||
paths:
|
||||
/model:
|
||||
get:
|
||||
responses:
|
||||
'200':
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TestResponse'
|
||||
components:
|
||||
schemas:
|
||||
TestResponse:
|
||||
type: object
|
||||
properties:
|
||||
model:
|
||||
$ref: '#/components/schemas/ModelIdentifier'
|
||||
status:
|
||||
type: string
|
||||
ModelIdentifier:
|
||||
description: Model identifier that can be a string or specific enum value
|
||||
anyOf:
|
||||
- type: string
|
||||
description: Any model name as string
|
||||
- type: string
|
||||
enum:
|
||||
- gpt-4
|
||||
- gpt-3.5-turbo
|
||||
- dall-e-3
|
||||
description: Known model enum values
|
||||
AnotherAnyOfTest:
|
||||
description: Another test case with different types
|
||||
anyOf:
|
||||
- type: string
|
||||
- type: integer
|
||||
- type: array
|
||||
items:
|
||||
type: string
|
||||
2
pom.xml
2
pom.xml
@@ -15,7 +15,7 @@
|
||||
<packaging>pom</packaging>
|
||||
<name>openapi-generator-project</name>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.16.0-SNAPSHOT</version>
|
||||
<version>7.16.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<url>https://github.com/openapitools/openapi-generator</url>
|
||||
<scm>
|
||||
|
||||
@@ -52,13 +52,13 @@ try {
|
||||
| **pathDefault** | **kotlin.String**| path default | |
|
||||
| **pathNullable** | **kotlin.String**| path_nullable | |
|
||||
| **queryDefault** | **kotlin.String**| query default | [optional] [default to "available"] |
|
||||
| **queryDefaultEnum** | **kotlin.String**| query default enum | [optional] [default to B] [enum: A, B, C] |
|
||||
| **queryDefaultEnum** | **kotlin.String**| query default enum | [optional] [default to QueryDefaultEnum.B] [enum: A, B, C] |
|
||||
| **queryDefaultInt** | **java.math.BigDecimal**| query default int | [optional] [default to 3] |
|
||||
| **headerDefault** | **kotlin.String**| header default | [optional] [default to "available"] |
|
||||
| **headerDefaultEnum** | **kotlin.String**| header default enum | [optional] [default to B] [enum: A, B, C] |
|
||||
| **headerDefaultEnum** | **kotlin.String**| header default enum | [optional] [default to HeaderDefaultEnum.B] [enum: A, B, C] |
|
||||
| **headerDefaultInt** | **java.math.BigDecimal**| header default int | [optional] [default to 3] |
|
||||
| **cookieDefault** | **kotlin.String**| cookie default | [optional] [default to "available"] |
|
||||
| **cookieDefaultEnum** | **kotlin.String**| cookie default enum | [optional] [default to B] [enum: A, B, C] |
|
||||
| **cookieDefaultEnum** | **kotlin.String**| cookie default enum | [optional] [default to CookieDefaultEnum.B] [enum: A, B, C] |
|
||||
| **cookieDefaultInt** | **java.math.BigDecimal**| cookie default int | [optional] [default to 3] |
|
||||
| **queryNullable** | **kotlin.String**| query nullable | [optional] |
|
||||
| **headerNullable** | **kotlin.String**| header nullable | [optional] |
|
||||
|
||||
@@ -105,13 +105,13 @@ class DefaultApi(basePath: kotlin.String = defaultBasePath, client: Call.Factory
|
||||
* @param pathDefault path default
|
||||
* @param pathNullable path_nullable
|
||||
* @param queryDefault query default (optional, default to "available")
|
||||
* @param queryDefaultEnum query default enum (optional, default to B)
|
||||
* @param queryDefaultEnum query default enum (optional, default to QueryDefaultEnum.B)
|
||||
* @param queryDefaultInt query default int (optional, default to 3)
|
||||
* @param headerDefault header default (optional, default to "available")
|
||||
* @param headerDefaultEnum header default enum (optional, default to B)
|
||||
* @param headerDefaultEnum header default enum (optional, default to HeaderDefaultEnum.B)
|
||||
* @param headerDefaultInt header default int (optional, default to 3)
|
||||
* @param cookieDefault cookie default (optional, default to "available")
|
||||
* @param cookieDefaultEnum cookie default enum (optional, default to B)
|
||||
* @param cookieDefaultEnum cookie default enum (optional, default to CookieDefaultEnum.B)
|
||||
* @param cookieDefaultInt cookie default int (optional, default to 3)
|
||||
* @param queryNullable query nullable (optional)
|
||||
* @param headerNullable header nullable (optional)
|
||||
@@ -150,13 +150,13 @@ class DefaultApi(basePath: kotlin.String = defaultBasePath, client: Call.Factory
|
||||
* @param pathDefault path default
|
||||
* @param pathNullable path_nullable
|
||||
* @param queryDefault query default (optional, default to "available")
|
||||
* @param queryDefaultEnum query default enum (optional, default to B)
|
||||
* @param queryDefaultEnum query default enum (optional, default to QueryDefaultEnum.B)
|
||||
* @param queryDefaultInt query default int (optional, default to 3)
|
||||
* @param headerDefault header default (optional, default to "available")
|
||||
* @param headerDefaultEnum header default enum (optional, default to B)
|
||||
* @param headerDefaultEnum header default enum (optional, default to HeaderDefaultEnum.B)
|
||||
* @param headerDefaultInt header default int (optional, default to 3)
|
||||
* @param cookieDefault cookie default (optional, default to "available")
|
||||
* @param cookieDefaultEnum cookie default enum (optional, default to B)
|
||||
* @param cookieDefaultEnum cookie default enum (optional, default to CookieDefaultEnum.B)
|
||||
* @param cookieDefaultInt cookie default int (optional, default to 3)
|
||||
* @param queryNullable query nullable (optional)
|
||||
* @param headerNullable header nullable (optional)
|
||||
@@ -181,13 +181,13 @@ class DefaultApi(basePath: kotlin.String = defaultBasePath, client: Call.Factory
|
||||
* @param pathDefault path default
|
||||
* @param pathNullable path_nullable
|
||||
* @param queryDefault query default (optional, default to "available")
|
||||
* @param queryDefaultEnum query default enum (optional, default to B)
|
||||
* @param queryDefaultEnum query default enum (optional, default to QueryDefaultEnum.B)
|
||||
* @param queryDefaultInt query default int (optional, default to 3)
|
||||
* @param headerDefault header default (optional, default to "available")
|
||||
* @param headerDefaultEnum header default enum (optional, default to B)
|
||||
* @param headerDefaultEnum header default enum (optional, default to HeaderDefaultEnum.B)
|
||||
* @param headerDefaultInt header default int (optional, default to 3)
|
||||
* @param cookieDefault cookie default (optional, default to "available")
|
||||
* @param cookieDefaultEnum cookie default enum (optional, default to B)
|
||||
* @param cookieDefaultEnum cookie default enum (optional, default to CookieDefaultEnum.B)
|
||||
* @param cookieDefaultInt cookie default int (optional, default to 3)
|
||||
* @param queryNullable query nullable (optional)
|
||||
* @param headerNullable header nullable (optional)
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
||||
@@ -0,0 +1,10 @@
|
||||
pom.xml
|
||||
src/gen/java/org/openapitools/api/PetApi.java
|
||||
src/gen/java/org/openapitools/api/StoreApi.java
|
||||
src/gen/java/org/openapitools/api/UserApi.java
|
||||
src/gen/java/org/openapitools/model/Category.java
|
||||
src/gen/java/org/openapitools/model/ModelApiResponse.java
|
||||
src/gen/java/org/openapitools/model/Order.java
|
||||
src/gen/java/org/openapitools/model/Pet.java
|
||||
src/gen/java/org/openapitools/model/Tag.java
|
||||
src/gen/java/org/openapitools/model/User.java
|
||||
@@ -0,0 +1 @@
|
||||
7.16.0-SNAPSHOT
|
||||
197
samples/client/petstore/jaxrs-cxf-client-swagger2/pom.xml
Normal file
197
samples/client/petstore/jaxrs-cxf-client-swagger2/pom.xml
Normal file
@@ -0,0 +1,197 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>jaxrs-cxf-petstore-swagger2</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>jaxrs-cxf-petstore-swagger2</name>
|
||||
<description>This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.</description>
|
||||
<version>1.0.0</version>
|
||||
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!--plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>${jetty-version}</version>
|
||||
<configuration>
|
||||
<webApp>
|
||||
<contextPath>/</contextPath>
|
||||
</webApp>
|
||||
<webAppSourceDirectory>target/${project.artifactId}-${project.version}</webAppSourceDirectory>
|
||||
<stopPort>8079</stopPort>
|
||||
<stopKey>stopit</stopKey>
|
||||
<httpConnector>
|
||||
<port></port>
|
||||
<idleTimeout>60000</idleTimeout>
|
||||
</httpConnector>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>start-jetty</id>
|
||||
<phase>pre-integration-test</phase>
|
||||
<goals>
|
||||
<goal>start</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<scanIntervalSeconds>0</scanIntervalSeconds>
|
||||
<daemon>true</daemon>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>stop-jetty</id>
|
||||
<phase>post-integration-test</phase>
|
||||
<goals>
|
||||
<goal>stop</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin-->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>1.9.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-source</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>src/gen/java</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson</groupId>
|
||||
<artifactId>jackson-bom</artifactId>
|
||||
<version>${jackson-jaxrs-version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.swagger.core.v3</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>${swagger-annotations-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>${logback-version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-core</artifactId>
|
||||
<version>${logback-version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- CXF Client -->
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-rs-client</artifactId>
|
||||
<version>${cxf-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- CXF server -->
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
|
||||
<version>${cxf-version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-rs-service-description</artifactId>
|
||||
<version>${cxf-version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-ws-policy</artifactId>
|
||||
<version>${cxf-version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-wsdl</artifactId>
|
||||
<version>${cxf-version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.jaxrs</groupId>
|
||||
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
||||
<version>${jackson-jaxrs-version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
<version>${jackson-jaxrs-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.annotation</groupId>
|
||||
<artifactId>jakarta.annotation-api</artifactId>
|
||||
<version>${jakarta-annotation-version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>2.10.13</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>sonatype-snapshots</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<swagger-annotations-version>2.2.7</swagger-annotations-version>
|
||||
<jetty-version>9.2.9.v20150224</jetty-version>
|
||||
<junit-version>4.13.2</junit-version>
|
||||
<logback-version>1.5.13</logback-version>
|
||||
<cxf-version>3.5.9</cxf-version>
|
||||
<jackson-jaxrs-version>2.17.1</jackson-jaxrs-version>
|
||||
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
</project>
|
||||
@@ -0,0 +1,161 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import java.io.File;
|
||||
import org.openapitools.model.ModelApiResponse;
|
||||
import org.openapitools.model.Pet;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.ws.rs.*;
|
||||
import org.apache.cxf.jaxrs.ext.multipart.*;
|
||||
|
||||
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.info.Info;
|
||||
import io.swagger.v3.oas.annotations.media.ArraySchema;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* <p>This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
*/
|
||||
@Path("/pet")
|
||||
@OpenAPIDefinition(
|
||||
info = @Info(
|
||||
title = "OpenAPI Petstore",
|
||||
description = "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.",
|
||||
version = "1.0.0"
|
||||
)
|
||||
)
|
||||
public interface PetApi {
|
||||
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@POST
|
||||
|
||||
@Consumes({ "application/json", "application/xml" })
|
||||
@Produces({ "application/xml", "application/json" })
|
||||
@Operation(operationId = "addPet", summary = "Add a new pet to the store", tags={ })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Pet.class))),
|
||||
@ApiResponse(responseCode = "405", description = "Invalid input") })
|
||||
public Pet addPet(Pet pet);
|
||||
|
||||
/**
|
||||
* Deletes a pet
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@DELETE
|
||||
@Path("/{petId}")
|
||||
@Operation(operationId = "deletePet", summary = "Deletes a pet", tags={ })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "400", description = "Invalid pet value") })
|
||||
public void deletePet(@PathParam("petId") Long petId, @HeaderParam("api_key") String apiKey);
|
||||
|
||||
/**
|
||||
* Finds Pets by status
|
||||
*
|
||||
* Multiple status values can be provided with comma separated strings
|
||||
*
|
||||
*/
|
||||
@GET
|
||||
@Path("/findByStatus")
|
||||
@Produces({ "application/xml", "application/json" })
|
||||
@Operation(operationId = "findPetsByStatus", summary = "Finds Pets by status", tags={ })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid status value") })
|
||||
public List<Pet> findPetsByStatus(@QueryParam("status") List<String> status);
|
||||
|
||||
/**
|
||||
* Finds Pets by tags
|
||||
*
|
||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
*
|
||||
*/
|
||||
@GET
|
||||
@Path("/findByTags")
|
||||
@Produces({ "application/xml", "application/json" })
|
||||
@Operation(operationId = "findPetsByTags", summary = "Finds Pets by tags", deprecated = true, tags={ })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid tag value") })
|
||||
public List<Pet> findPetsByTags(@QueryParam("tags") List<String> tags);
|
||||
|
||||
/**
|
||||
* Find pet by ID
|
||||
*
|
||||
* Returns a single pet
|
||||
*
|
||||
*/
|
||||
@GET
|
||||
@Path("/{petId}")
|
||||
@Produces({ "application/xml", "application/json" })
|
||||
@Operation(operationId = "getPetById", summary = "Find pet by ID", tags={ })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Pet.class))),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
|
||||
@ApiResponse(responseCode = "404", description = "Pet not found") })
|
||||
public Pet getPetById(@PathParam("petId") Long petId);
|
||||
|
||||
/**
|
||||
* Update an existing pet
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@PUT
|
||||
|
||||
@Consumes({ "application/json", "application/xml" })
|
||||
@Produces({ "application/xml", "application/json" })
|
||||
@Operation(operationId = "updatePet", summary = "Update an existing pet", tags={ })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Pet.class))),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
|
||||
@ApiResponse(responseCode = "404", description = "Pet not found"),
|
||||
@ApiResponse(responseCode = "405", description = "Validation exception") })
|
||||
public Pet updatePet(Pet pet);
|
||||
|
||||
/**
|
||||
* Updates a pet in the store with form data
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@POST
|
||||
@Path("/{petId}")
|
||||
@Consumes({ "application/x-www-form-urlencoded" })
|
||||
@Operation(operationId = "updatePetWithForm", summary = "Updates a pet in the store with form data", tags={ })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "405", description = "Invalid input") })
|
||||
public void updatePetWithForm(@PathParam("petId") Long petId, @Multipart(value = "name", required = false) String name, @Multipart(value = "status", required = false) String status);
|
||||
|
||||
/**
|
||||
* uploads an image
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@POST
|
||||
@Path("/{petId}/uploadImage")
|
||||
@Consumes({ "multipart/form-data" })
|
||||
@Produces({ "application/json" })
|
||||
@Operation(operationId = "uploadFile", summary = "uploads an image", tags={ })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = ModelApiResponse.class))) })
|
||||
public ModelApiResponse uploadFile(@PathParam("petId") Long petId, @Multipart(value = "additionalMetadata", required = false) String additionalMetadata, @Multipart(value = "file" , required = false) Attachment _fileDetail);
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import org.openapitools.model.Order;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.ws.rs.*;
|
||||
import org.apache.cxf.jaxrs.ext.multipart.*;
|
||||
|
||||
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.info.Info;
|
||||
import io.swagger.v3.oas.annotations.media.ArraySchema;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* <p>This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
*/
|
||||
@Path("/store")
|
||||
@OpenAPIDefinition(
|
||||
info = @Info(
|
||||
title = "OpenAPI Petstore",
|
||||
description = "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.",
|
||||
version = "1.0.0"
|
||||
)
|
||||
)
|
||||
public interface StoreApi {
|
||||
|
||||
/**
|
||||
* Delete purchase order by ID
|
||||
*
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
*
|
||||
*/
|
||||
@DELETE
|
||||
@Path("/order/{orderId}")
|
||||
@Operation(operationId = "deleteOrder", summary = "Delete purchase order by ID", tags={ })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
|
||||
@ApiResponse(responseCode = "404", description = "Order not found") })
|
||||
public void deleteOrder(@PathParam("orderId") String orderId);
|
||||
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
*
|
||||
* Returns a map of status codes to quantities
|
||||
*
|
||||
*/
|
||||
@GET
|
||||
@Path("/inventory")
|
||||
@Produces({ "application/json" })
|
||||
@Operation(operationId = "getInventory", summary = "Returns pet inventories by status", tags={ })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Map.class)))) })
|
||||
public Map<String, Integer> getInventory();
|
||||
|
||||
/**
|
||||
* Find purchase order by ID
|
||||
*
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
|
||||
*
|
||||
*/
|
||||
@GET
|
||||
@Path("/order/{orderId}")
|
||||
@Produces({ "application/xml", "application/json" })
|
||||
@Operation(operationId = "getOrderById", summary = "Find purchase order by ID", tags={ })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Order.class))),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
|
||||
@ApiResponse(responseCode = "404", description = "Order not found") })
|
||||
public Order getOrderById(@PathParam("orderId") Long orderId);
|
||||
|
||||
/**
|
||||
* Place an order for a pet
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@POST
|
||||
@Path("/order")
|
||||
@Consumes({ "application/json" })
|
||||
@Produces({ "application/xml", "application/json" })
|
||||
@Operation(operationId = "placeOrder", summary = "Place an order for a pet", tags={ })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Order.class))),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid Order") })
|
||||
public Order placeOrder(Order order);
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import java.util.Date;
|
||||
import org.openapitools.model.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.ws.rs.*;
|
||||
import org.apache.cxf.jaxrs.ext.multipart.*;
|
||||
|
||||
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.info.Info;
|
||||
import io.swagger.v3.oas.annotations.media.ArraySchema;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* <p>This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
*/
|
||||
@Path("/user")
|
||||
@OpenAPIDefinition(
|
||||
info = @Info(
|
||||
title = "OpenAPI Petstore",
|
||||
description = "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.",
|
||||
version = "1.0.0"
|
||||
)
|
||||
)
|
||||
public interface UserApi {
|
||||
|
||||
/**
|
||||
* Create user
|
||||
*
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
*/
|
||||
@POST
|
||||
|
||||
@Consumes({ "application/json" })
|
||||
@Operation(operationId = "createUser", summary = "Create user", tags={ })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation") })
|
||||
public void createUser(User user);
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@POST
|
||||
@Path("/createWithArray")
|
||||
@Consumes({ "application/json" })
|
||||
@Operation(operationId = "createUsersWithArrayInput", summary = "Creates list of users with given input array", tags={ })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation") })
|
||||
public void createUsersWithArrayInput(List<User> user);
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@POST
|
||||
@Path("/createWithList")
|
||||
@Consumes({ "application/json" })
|
||||
@Operation(operationId = "createUsersWithListInput", summary = "Creates list of users with given input array", tags={ })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation") })
|
||||
public void createUsersWithListInput(List<User> user);
|
||||
|
||||
/**
|
||||
* Delete user
|
||||
*
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
*/
|
||||
@DELETE
|
||||
@Path("/{username}")
|
||||
@Operation(operationId = "deleteUser", summary = "Delete user", tags={ })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "400", description = "Invalid username supplied"),
|
||||
@ApiResponse(responseCode = "404", description = "User not found") })
|
||||
public void deleteUser(@PathParam("username") String username);
|
||||
|
||||
/**
|
||||
* Get user by user name
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@GET
|
||||
@Path("/{username}")
|
||||
@Produces({ "application/xml", "application/json" })
|
||||
@Operation(operationId = "getUserByName", summary = "Get user by user name", tags={ })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = User.class))),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid username supplied"),
|
||||
@ApiResponse(responseCode = "404", description = "User not found") })
|
||||
public User getUserByName(@PathParam("username") String username);
|
||||
|
||||
/**
|
||||
* Logs user into the system
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@GET
|
||||
@Path("/login")
|
||||
@Produces({ "application/xml", "application/json" })
|
||||
@Operation(operationId = "loginUser", summary = "Logs user into the system", tags={ })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = String.class))),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid username/password supplied") })
|
||||
public String loginUser(@QueryParam("username") String username, @QueryParam("password") String password);
|
||||
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@GET
|
||||
@Path("/logout")
|
||||
@Operation(operationId = "logoutUser", summary = "Logs out current logged in user session", tags={ })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation") })
|
||||
public void logoutUser();
|
||||
|
||||
/**
|
||||
* Updated user
|
||||
*
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
*/
|
||||
@PUT
|
||||
@Path("/{username}")
|
||||
@Consumes({ "application/json" })
|
||||
@Operation(operationId = "updateUser", summary = "Updated user", tags={ })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "400", description = "Invalid user supplied"),
|
||||
@ApiResponse(responseCode = "404", description = "User not found") })
|
||||
public void updateUser(@PathParam("username") String username, User user);
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package org.openapitools.model;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* A category for a pet
|
||||
*/
|
||||
@Schema(description="A category for a pet")
|
||||
|
||||
public class Category {
|
||||
|
||||
@Schema(description = "")
|
||||
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "")
|
||||
|
||||
private String name;
|
||||
/**
|
||||
* Get id
|
||||
* @return id
|
||||
**/
|
||||
@JsonProperty("id")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Category id(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
* @return name
|
||||
**/
|
||||
@JsonProperty("name")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Category name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Category category = (Category) o;
|
||||
return Objects.equals(this.id, category.id) &&
|
||||
Objects.equals(this.name, category.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Category {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private static String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
package org.openapitools.model;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Describes the result of uploading an image resource
|
||||
*/
|
||||
@Schema(description="Describes the result of uploading an image resource")
|
||||
|
||||
public class ModelApiResponse {
|
||||
|
||||
@Schema(description = "")
|
||||
|
||||
private Integer code;
|
||||
|
||||
@Schema(description = "")
|
||||
|
||||
private String type;
|
||||
|
||||
@Schema(description = "")
|
||||
|
||||
private String message;
|
||||
/**
|
||||
* Get code
|
||||
* @return code
|
||||
**/
|
||||
@JsonProperty("code")
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public ModelApiResponse code(Integer code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get type
|
||||
* @return type
|
||||
**/
|
||||
@JsonProperty("type")
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ModelApiResponse type(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get message
|
||||
* @return message
|
||||
**/
|
||||
@JsonProperty("message")
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public ModelApiResponse message(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ModelApiResponse _apiResponse = (ModelApiResponse) o;
|
||||
return Objects.equals(this.code, _apiResponse.code) &&
|
||||
Objects.equals(this.type, _apiResponse.type) &&
|
||||
Objects.equals(this.message, _apiResponse.message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(code, type, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ModelApiResponse {\n");
|
||||
|
||||
sb.append(" code: ").append(toIndentedString(code)).append("\n");
|
||||
sb.append(" type: ").append(toIndentedString(type)).append("\n");
|
||||
sb.append(" message: ").append(toIndentedString(message)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private static String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,231 @@
|
||||
package org.openapitools.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* An order for a pets from the pet store
|
||||
*/
|
||||
@Schema(description="An order for a pets from the pet store")
|
||||
|
||||
public class Order {
|
||||
|
||||
@Schema(description = "")
|
||||
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "")
|
||||
|
||||
private Long petId;
|
||||
|
||||
@Schema(description = "")
|
||||
|
||||
private Integer quantity;
|
||||
|
||||
@Schema(description = "")
|
||||
|
||||
private Date shipDate;
|
||||
|
||||
public enum StatusEnum {
|
||||
|
||||
PLACED(String.valueOf("placed")), APPROVED(String.valueOf("approved")), DELIVERED(String.valueOf("delivered"));
|
||||
|
||||
|
||||
private String value;
|
||||
|
||||
StatusEnum (String v) {
|
||||
value = v;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
public static StatusEnum fromValue(String value) {
|
||||
for (StatusEnum b : StatusEnum.values()) {
|
||||
if (b.value.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
*/
|
||||
@Schema(description = "Order Status")
|
||||
|
||||
private StatusEnum status;
|
||||
|
||||
@Schema(description = "")
|
||||
|
||||
private Boolean complete = false;
|
||||
/**
|
||||
* Get id
|
||||
* @return id
|
||||
**/
|
||||
@JsonProperty("id")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Order id(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get petId
|
||||
* @return petId
|
||||
**/
|
||||
@JsonProperty("petId")
|
||||
public Long getPetId() {
|
||||
return petId;
|
||||
}
|
||||
|
||||
public void setPetId(Long petId) {
|
||||
this.petId = petId;
|
||||
}
|
||||
|
||||
public Order petId(Long petId) {
|
||||
this.petId = petId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get quantity
|
||||
* @return quantity
|
||||
**/
|
||||
@JsonProperty("quantity")
|
||||
public Integer getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public void setQuantity(Integer quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public Order quantity(Integer quantity) {
|
||||
this.quantity = quantity;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get shipDate
|
||||
* @return shipDate
|
||||
**/
|
||||
@JsonProperty("shipDate")
|
||||
public Date getShipDate() {
|
||||
return shipDate;
|
||||
}
|
||||
|
||||
public void setShipDate(Date shipDate) {
|
||||
this.shipDate = shipDate;
|
||||
}
|
||||
|
||||
public Order shipDate(Date shipDate) {
|
||||
this.shipDate = shipDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
* @return status
|
||||
**/
|
||||
@JsonProperty("status")
|
||||
public String getStatus() {
|
||||
if (status == null) {
|
||||
return null;
|
||||
}
|
||||
return status.value();
|
||||
}
|
||||
|
||||
public void setStatus(StatusEnum status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Order status(StatusEnum status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get complete
|
||||
* @return complete
|
||||
**/
|
||||
@JsonProperty("complete")
|
||||
public Boolean getComplete() {
|
||||
return complete;
|
||||
}
|
||||
|
||||
public void setComplete(Boolean complete) {
|
||||
this.complete = complete;
|
||||
}
|
||||
|
||||
public Order complete(Boolean complete) {
|
||||
this.complete = complete;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Order order = (Order) o;
|
||||
return Objects.equals(this.id, order.id) &&
|
||||
Objects.equals(this.petId, order.petId) &&
|
||||
Objects.equals(this.quantity, order.quantity) &&
|
||||
Objects.equals(this.shipDate, order.shipDate) &&
|
||||
Objects.equals(this.status, order.status) &&
|
||||
Objects.equals(this.complete, order.complete);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, petId, quantity, shipDate, status, complete);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Order {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" petId: ").append(toIndentedString(petId)).append("\n");
|
||||
sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n");
|
||||
sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n");
|
||||
sb.append(" status: ").append(toIndentedString(status)).append("\n");
|
||||
sb.append(" complete: ").append(toIndentedString(complete)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private static String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,245 @@
|
||||
package org.openapitools.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.openapitools.model.Category;
|
||||
import org.openapitools.model.Tag;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* A pet for sale in the pet store
|
||||
*/
|
||||
@Schema(description="A pet for sale in the pet store")
|
||||
|
||||
public class Pet {
|
||||
|
||||
@Schema(description = "")
|
||||
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "")
|
||||
|
||||
private Category category;
|
||||
|
||||
@Schema(description = "", example = "doggie", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
|
||||
private String name;
|
||||
|
||||
@Schema(description = "", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
|
||||
private List<String> photoUrls = new ArrayList<>();
|
||||
|
||||
@Schema(description = "")
|
||||
|
||||
private List<Tag> tags = new ArrayList<>();
|
||||
|
||||
public enum StatusEnum {
|
||||
|
||||
AVAILABLE(String.valueOf("available")), PENDING(String.valueOf("pending")), SOLD(String.valueOf("sold"));
|
||||
|
||||
|
||||
private String value;
|
||||
|
||||
StatusEnum (String v) {
|
||||
value = v;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
public static StatusEnum fromValue(String value) {
|
||||
for (StatusEnum b : StatusEnum.values()) {
|
||||
if (b.value.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
*/
|
||||
@Schema(description = "pet status in the store")
|
||||
|
||||
private StatusEnum status;
|
||||
/**
|
||||
* Get id
|
||||
* @return id
|
||||
**/
|
||||
@JsonProperty("id")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Pet id(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get category
|
||||
* @return category
|
||||
**/
|
||||
@JsonProperty("category")
|
||||
public Category getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(Category category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public Pet category(Category category) {
|
||||
this.category = category;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
* @return name
|
||||
**/
|
||||
@JsonProperty("name")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Pet name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get photoUrls
|
||||
* @return photoUrls
|
||||
**/
|
||||
@JsonProperty("photoUrls")
|
||||
public List<String> getPhotoUrls() {
|
||||
return photoUrls;
|
||||
}
|
||||
|
||||
public void setPhotoUrls(List<String> photoUrls) {
|
||||
this.photoUrls = photoUrls;
|
||||
}
|
||||
|
||||
public Pet photoUrls(List<String> photoUrls) {
|
||||
this.photoUrls = photoUrls;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Pet addPhotoUrlsItem(String photoUrlsItem) {
|
||||
this.photoUrls.add(photoUrlsItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tags
|
||||
* @return tags
|
||||
**/
|
||||
@JsonProperty("tags")
|
||||
public List<Tag> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(List<Tag> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public Pet tags(List<Tag> tags) {
|
||||
this.tags = tags;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Pet addTagsItem(Tag tagsItem) {
|
||||
this.tags.add(tagsItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
* @return status
|
||||
**/
|
||||
@JsonProperty("status")
|
||||
public String getStatus() {
|
||||
if (status == null) {
|
||||
return null;
|
||||
}
|
||||
return status.value();
|
||||
}
|
||||
|
||||
public void setStatus(StatusEnum status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Pet status(StatusEnum status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Pet pet = (Pet) o;
|
||||
return Objects.equals(this.id, pet.id) &&
|
||||
Objects.equals(this.category, pet.category) &&
|
||||
Objects.equals(this.name, pet.name) &&
|
||||
Objects.equals(this.photoUrls, pet.photoUrls) &&
|
||||
Objects.equals(this.tags, pet.tags) &&
|
||||
Objects.equals(this.status, pet.status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, category, name, photoUrls, tags, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Pet {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" category: ").append(toIndentedString(category)).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n");
|
||||
sb.append(" tags: ").append(toIndentedString(tags)).append("\n");
|
||||
sb.append(" status: ").append(toIndentedString(status)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private static String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
package org.openapitools.model;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* A tag for a pet
|
||||
*/
|
||||
@Schema(description="A tag for a pet")
|
||||
|
||||
public class Tag {
|
||||
|
||||
@Schema(description = "")
|
||||
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "")
|
||||
|
||||
private String name;
|
||||
/**
|
||||
* Get id
|
||||
* @return id
|
||||
**/
|
||||
@JsonProperty("id")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Tag id(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
* @return name
|
||||
**/
|
||||
@JsonProperty("name")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Tag name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Tag tag = (Tag) o;
|
||||
return Objects.equals(this.id, tag.id) &&
|
||||
Objects.equals(this.name, tag.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Tag {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private static String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,245 @@
|
||||
package org.openapitools.model;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* A User who is purchasing from the pet store
|
||||
*/
|
||||
@Schema(description="A User who is purchasing from the pet store")
|
||||
|
||||
public class User {
|
||||
|
||||
@Schema(description = "")
|
||||
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "")
|
||||
|
||||
private String username;
|
||||
|
||||
@Schema(description = "")
|
||||
|
||||
private String firstName;
|
||||
|
||||
@Schema(description = "")
|
||||
|
||||
private String lastName;
|
||||
|
||||
@Schema(description = "")
|
||||
|
||||
private String email;
|
||||
|
||||
@Schema(description = "")
|
||||
|
||||
private String password;
|
||||
|
||||
@Schema(description = "")
|
||||
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* User Status
|
||||
*/
|
||||
@Schema(description = "User Status")
|
||||
|
||||
private Integer userStatus;
|
||||
/**
|
||||
* Get id
|
||||
* @return id
|
||||
**/
|
||||
@JsonProperty("id")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public User id(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get username
|
||||
* @return username
|
||||
**/
|
||||
@JsonProperty("username")
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public User username(String username) {
|
||||
this.username = username;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get firstName
|
||||
* @return firstName
|
||||
**/
|
||||
@JsonProperty("firstName")
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public User firstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get lastName
|
||||
* @return lastName
|
||||
**/
|
||||
@JsonProperty("lastName")
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public User lastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email
|
||||
* @return email
|
||||
**/
|
||||
@JsonProperty("email")
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public User email(String email) {
|
||||
this.email = email;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get password
|
||||
* @return password
|
||||
**/
|
||||
@JsonProperty("password")
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public User password(String password) {
|
||||
this.password = password;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get phone
|
||||
* @return phone
|
||||
**/
|
||||
@JsonProperty("phone")
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public User phone(String phone) {
|
||||
this.phone = phone;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* User Status
|
||||
* @return userStatus
|
||||
**/
|
||||
@JsonProperty("userStatus")
|
||||
public Integer getUserStatus() {
|
||||
return userStatus;
|
||||
}
|
||||
|
||||
public void setUserStatus(Integer userStatus) {
|
||||
this.userStatus = userStatus;
|
||||
}
|
||||
|
||||
public User userStatus(Integer userStatus) {
|
||||
this.userStatus = userStatus;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
User user = (User) o;
|
||||
return Objects.equals(this.id, user.id) &&
|
||||
Objects.equals(this.username, user.username) &&
|
||||
Objects.equals(this.firstName, user.firstName) &&
|
||||
Objects.equals(this.lastName, user.lastName) &&
|
||||
Objects.equals(this.email, user.email) &&
|
||||
Objects.equals(this.password, user.password) &&
|
||||
Objects.equals(this.phone, user.phone) &&
|
||||
Objects.equals(this.userStatus, user.userStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class User {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" username: ").append(toIndentedString(username)).append("\n");
|
||||
sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n");
|
||||
sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n");
|
||||
sb.append(" email: ").append(toIndentedString(email)).append("\n");
|
||||
sb.append(" password: ").append(toIndentedString(password)).append("\n");
|
||||
sb.append(" phone: ").append(toIndentedString(phone)).append("\n");
|
||||
sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private static String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package org.openapitools.api;
|
||||
|
||||
import java.io.File;
|
||||
import org.openapitools.model.ModelApiResponse;
|
||||
import org.openapitools.model.Pet;
|
||||
import org.junit.Test;
|
||||
import org.junit.Before;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
|
||||
import org.apache.cxf.jaxrs.client.ClientConfiguration;
|
||||
import org.apache.cxf.jaxrs.client.WebClient;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* <p>This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* API tests for PetApi
|
||||
*/
|
||||
public class PetApiTest {
|
||||
|
||||
|
||||
private PetApi api;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
JacksonJsonProvider provider = new JacksonJsonProvider();
|
||||
List providers = new ArrayList();
|
||||
providers.add(provider);
|
||||
|
||||
api = JAXRSClientFactory.create("http://petstore.swagger.io/v2", PetApi.class, providers);
|
||||
org.apache.cxf.jaxrs.client.Client client = WebClient.client(api);
|
||||
|
||||
ClientConfiguration config = WebClient.getConfig(client);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void addPetTest() {
|
||||
Pet pet = null;
|
||||
//Pet response = api.addPet(pet);
|
||||
//assertNotNull(response);
|
||||
// TODO: test validations
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a pet
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void deletePetTest() {
|
||||
Long petId = null;
|
||||
String apiKey = null;
|
||||
//api.deletePet(petId, apiKey);
|
||||
|
||||
// TODO: test validations
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds Pets by status
|
||||
*
|
||||
* Multiple status values can be provided with comma separated strings
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void findPetsByStatusTest() {
|
||||
List<String> status = null;
|
||||
//List<Pet> response = api.findPetsByStatus(status);
|
||||
//assertNotNull(response);
|
||||
// TODO: test validations
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds Pets by tags
|
||||
*
|
||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void findPetsByTagsTest() {
|
||||
List<String> tags = null;
|
||||
//List<Pet> response = api.findPetsByTags(tags);
|
||||
//assertNotNull(response);
|
||||
// TODO: test validations
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Find pet by ID
|
||||
*
|
||||
* Returns a single pet
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void getPetByIdTest() {
|
||||
Long petId = null;
|
||||
//Pet response = api.getPetById(petId);
|
||||
//assertNotNull(response);
|
||||
// TODO: test validations
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing pet
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void updatePetTest() {
|
||||
Pet pet = null;
|
||||
//Pet response = api.updatePet(pet);
|
||||
//assertNotNull(response);
|
||||
// TODO: test validations
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a pet in the store with form data
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void updatePetWithFormTest() {
|
||||
Long petId = null;
|
||||
String name = null;
|
||||
String status = null;
|
||||
//api.updatePetWithForm(petId, name, status);
|
||||
|
||||
// TODO: test validations
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* uploads an image
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void uploadFileTest() {
|
||||
Long petId = null;
|
||||
String additionalMetadata = null;
|
||||
File _file = null;
|
||||
//ModelApiResponse response = api.uploadFile(petId, additionalMetadata, _file);
|
||||
//assertNotNull(response);
|
||||
// TODO: test validations
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package org.openapitools.api;
|
||||
|
||||
import org.openapitools.model.Order;
|
||||
import org.junit.Test;
|
||||
import org.junit.Before;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
|
||||
import org.apache.cxf.jaxrs.client.ClientConfiguration;
|
||||
import org.apache.cxf.jaxrs.client.WebClient;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* <p>This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* API tests for StoreApi
|
||||
*/
|
||||
public class StoreApiTest {
|
||||
|
||||
|
||||
private StoreApi api;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
JacksonJsonProvider provider = new JacksonJsonProvider();
|
||||
List providers = new ArrayList();
|
||||
providers.add(provider);
|
||||
|
||||
api = JAXRSClientFactory.create("http://petstore.swagger.io/v2", StoreApi.class, providers);
|
||||
org.apache.cxf.jaxrs.client.Client client = WebClient.client(api);
|
||||
|
||||
ClientConfiguration config = WebClient.getConfig(client);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete purchase order by ID
|
||||
*
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void deleteOrderTest() {
|
||||
String orderId = null;
|
||||
//api.deleteOrder(orderId);
|
||||
|
||||
// TODO: test validations
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
*
|
||||
* Returns a map of status codes to quantities
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void getInventoryTest() {
|
||||
//Map<String, Integer> response = api.getInventory();
|
||||
//assertNotNull(response);
|
||||
// TODO: test validations
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Find purchase order by ID
|
||||
*
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void getOrderByIdTest() {
|
||||
Long orderId = null;
|
||||
//Order response = api.getOrderById(orderId);
|
||||
//assertNotNull(response);
|
||||
// TODO: test validations
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Place an order for a pet
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void placeOrderTest() {
|
||||
Order order = null;
|
||||
//Order response = api.placeOrder(order);
|
||||
//assertNotNull(response);
|
||||
// TODO: test validations
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package org.openapitools.api;
|
||||
|
||||
import java.util.Date;
|
||||
import org.openapitools.model.User;
|
||||
import org.junit.Test;
|
||||
import org.junit.Before;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
|
||||
import org.apache.cxf.jaxrs.client.ClientConfiguration;
|
||||
import org.apache.cxf.jaxrs.client.WebClient;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* <p>This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* API tests for UserApi
|
||||
*/
|
||||
public class UserApiTest {
|
||||
|
||||
|
||||
private UserApi api;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
JacksonJsonProvider provider = new JacksonJsonProvider();
|
||||
List providers = new ArrayList();
|
||||
providers.add(provider);
|
||||
|
||||
api = JAXRSClientFactory.create("http://petstore.swagger.io/v2", UserApi.class, providers);
|
||||
org.apache.cxf.jaxrs.client.Client client = WebClient.client(api);
|
||||
|
||||
ClientConfiguration config = WebClient.getConfig(client);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create user
|
||||
*
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void createUserTest() {
|
||||
User user = null;
|
||||
//api.createUser(user);
|
||||
|
||||
// TODO: test validations
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void createUsersWithArrayInputTest() {
|
||||
List<User> user = null;
|
||||
//api.createUsersWithArrayInput(user);
|
||||
|
||||
// TODO: test validations
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void createUsersWithListInputTest() {
|
||||
List<User> user = null;
|
||||
//api.createUsersWithListInput(user);
|
||||
|
||||
// TODO: test validations
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete user
|
||||
*
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void deleteUserTest() {
|
||||
String username = null;
|
||||
//api.deleteUser(username);
|
||||
|
||||
// TODO: test validations
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user by user name
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void getUserByNameTest() {
|
||||
String username = null;
|
||||
//User response = api.getUserByName(username);
|
||||
//assertNotNull(response);
|
||||
// TODO: test validations
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs user into the system
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void loginUserTest() {
|
||||
String username = null;
|
||||
String password = null;
|
||||
//String response = api.loginUser(username, password);
|
||||
//assertNotNull(response);
|
||||
// TODO: test validations
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void logoutUserTest() {
|
||||
//api.logoutUser();
|
||||
|
||||
// TODO: test validations
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updated user
|
||||
*
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void updateUserTest() {
|
||||
String username = null;
|
||||
User user = null;
|
||||
//api.updateUser(username, user);
|
||||
|
||||
// TODO: test validations
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -72,7 +72,7 @@ end
|
||||
|
||||
## Documentation for API Endpoints
|
||||
|
||||
All URIs are relative to *https://127.0.0.1/v2*
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Petstore::AnotherFakeApi
|
||||
|
||||
All URIs are relative to *https://127.0.0.1/v2*
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
| Method | HTTP request | Description |
|
||||
| ------ | ------------ | ----------- |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Petstore::DefaultApi
|
||||
|
||||
All URIs are relative to *https://127.0.0.1/v2*
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
| Method | HTTP request | Description |
|
||||
| ------ | ------------ | ----------- |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Petstore::FakeApi
|
||||
|
||||
All URIs are relative to *https://127.0.0.1/v2*
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
| Method | HTTP request | Description |
|
||||
| ------ | ------------ | ----------- |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Petstore::FakeClassnameTags123Api
|
||||
|
||||
All URIs are relative to *https://127.0.0.1/v2*
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
| Method | HTTP request | Description |
|
||||
| ------ | ------------ | ----------- |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Petstore::PetApi
|
||||
|
||||
All URIs are relative to *https://127.0.0.1/v2*
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
| Method | HTTP request | Description |
|
||||
| ------ | ------------ | ----------- |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Petstore::StoreApi
|
||||
|
||||
All URIs are relative to *https://127.0.0.1/v2*
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
| Method | HTTP request | Description |
|
||||
| ------ | ------------ | ----------- |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Petstore::UserApi
|
||||
|
||||
All URIs are relative to *https://127.0.0.1/v2*
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
| Method | HTTP request | Description |
|
||||
| ------ | ------------ | ----------- |
|
||||
|
||||
@@ -156,8 +156,8 @@ module Petstore
|
||||
attr_accessor :force_ending_format
|
||||
|
||||
def initialize
|
||||
@scheme = 'https'
|
||||
@host = '127.0.0.1'
|
||||
@scheme = 'http'
|
||||
@host = 'petstore.swagger.io'
|
||||
@base_path = '/v2'
|
||||
@server_index = nil
|
||||
@server_operation_index = {}
|
||||
@@ -290,10 +290,6 @@ module Petstore
|
||||
# Returns an array of Server setting
|
||||
def server_settings
|
||||
[
|
||||
{
|
||||
url: "https://127.0.0.1/v2",
|
||||
description: "The local server without variables",
|
||||
},
|
||||
{
|
||||
url: "http://{server}.swagger.io:{port}/v2",
|
||||
description: "petstore server",
|
||||
@@ -331,6 +327,10 @@ module Petstore
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
url: "https://127.0.0.1/no_varaible",
|
||||
description: "The local server without variables",
|
||||
},
|
||||
{
|
||||
url: "http://server.{version}.openapi-generator.tech",
|
||||
description: "The openapi-generator test server",
|
||||
@@ -351,10 +351,6 @@ module Petstore
|
||||
def operation_server_settings
|
||||
{
|
||||
"PetApi.add_pet": [
|
||||
{
|
||||
url: "http://127.0.0.1/v2",
|
||||
description: "No description provided",
|
||||
},
|
||||
{
|
||||
url: "http://petstore.swagger.io/v2",
|
||||
description: "No description provided",
|
||||
@@ -402,10 +398,6 @@ module Petstore
|
||||
}
|
||||
],
|
||||
"PetApi.delete_pet": [
|
||||
{
|
||||
url: "http://127.0.0.1/v2",
|
||||
description: "No description provided",
|
||||
},
|
||||
{
|
||||
url: "http://petstore.swagger.io/v2",
|
||||
description: "No description provided",
|
||||
@@ -453,10 +445,6 @@ module Petstore
|
||||
}
|
||||
],
|
||||
"PetApi.get_pet_by_id": [
|
||||
{
|
||||
url: "http://127.0.0.1/v2",
|
||||
description: "No description provided",
|
||||
},
|
||||
{
|
||||
url: "http://petstore.swagger.io/v2",
|
||||
description: "No description provided",
|
||||
@@ -504,10 +492,6 @@ module Petstore
|
||||
}
|
||||
],
|
||||
"PetApi.update_pet": [
|
||||
{
|
||||
url: "http://127.0.0.1/v2",
|
||||
description: "No description provided",
|
||||
},
|
||||
{
|
||||
url: "http://petstore.swagger.io/v2",
|
||||
description: "No description provided",
|
||||
@@ -555,10 +539,6 @@ module Petstore
|
||||
}
|
||||
],
|
||||
"PetApi.update_pet_with_form": [
|
||||
{
|
||||
url: "http://127.0.0.1/v2",
|
||||
description: "No description provided",
|
||||
},
|
||||
{
|
||||
url: "http://petstore.swagger.io/v2",
|
||||
description: "No description provided",
|
||||
|
||||
@@ -72,7 +72,7 @@ end
|
||||
|
||||
## Documentation for API Endpoints
|
||||
|
||||
All URIs are relative to *https://127.0.0.1/v2*
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Petstore::AnotherFakeApi
|
||||
|
||||
All URIs are relative to *https://127.0.0.1/v2*
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
| Method | HTTP request | Description |
|
||||
| ------ | ------------ | ----------- |
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user