forked from loafle/openapi-generator-original
Compare commits
37 Commits
timcbaoth-
...
appdescrip
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6efa58341 | ||
|
|
d45b1c8f37 | ||
|
|
a00549cd65 | ||
|
|
3bd6d67cc0 | ||
|
|
1bb4d42216 | ||
|
|
d7b808e2e9 | ||
|
|
efb7e5624d | ||
|
|
50945d0e17 | ||
|
|
fbe2e0b18f | ||
|
|
4dc8531a67 | ||
|
|
59ba346306 | ||
|
|
7036b99e91 | ||
|
|
dc96d648f7 | ||
|
|
1d67d0632d | ||
|
|
d71df6ab85 | ||
|
|
58aad760f0 | ||
|
|
99b5fe9f9c | ||
|
|
a724c754bc | ||
|
|
cbf52aefe4 | ||
|
|
36911c773e | ||
|
|
c64d569a7d | ||
|
|
406d00fe9b | ||
|
|
d25c5a8b26 | ||
|
|
73bca68fea | ||
|
|
2217a7b0f2 | ||
|
|
6568bc54a5 | ||
|
|
c8e835cac7 | ||
|
|
93f4323364 | ||
|
|
d99affda96 | ||
|
|
514c0d6448 | ||
|
|
807250a430 | ||
|
|
cce4139af6 | ||
|
|
7609273a02 | ||
|
|
dd97def5fa | ||
|
|
213564a5aa | ||
|
|
7b0f963c74 | ||
|
|
c109399f3f |
17
.github/workflows/openapi-generator.yaml
vendored
17
.github/workflows/openapi-generator.yaml
vendored
@@ -140,8 +140,23 @@ jobs:
|
||||
with:
|
||||
name: openapi-generator-cli.jar
|
||||
path: modules/openapi-generator-cli/target
|
||||
- name: Delete samples that are entirely generated
|
||||
run: |
|
||||
rm -rf samples/client/petstore/csharp/generichost/net8/AllOf
|
||||
rm -rf samples/client/petstore/csharp/generichost/net8/AnyOf
|
||||
rm -rf samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare
|
||||
rm -rf samples/client/petstore/csharp/generichost/net8/FormModels
|
||||
rm -rf samples/client/petstore/csharp/generichost/net8/NullReferenceTypes
|
||||
rm -rf samples/client/petstore/csharp/generichost/net8/OneOf
|
||||
rm -rf samples/client/petstore/csharp/generichost/net8/Petstore
|
||||
rm -rf samples/client/petstore/csharp/generichost/net8/SourceGeneration
|
||||
rm -rf samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate
|
||||
rm -rf samples/client/petstore/csharp/generichost/standard2.0/Petstore
|
||||
- name: Generate samples
|
||||
run: bash bin/generate-samples.sh
|
||||
run: |
|
||||
bash bin/generate-samples.sh
|
||||
# when a sample is deleted, you have to generate it twice for all files to get created
|
||||
bash bin/generate-samples.sh
|
||||
- name: Verify git status
|
||||
run: |
|
||||
if [[ "$(git status --porcelain)" != "" ]]; then
|
||||
|
||||
@@ -73,6 +73,7 @@ jobs:
|
||||
- samples/client/petstore/java/resttemplate-swagger2/
|
||||
- samples/openapi3/client/petstore/java/jersey2-java8-swagger2/
|
||||
- samples/client/others/java/okhttp-gson-oneOf/
|
||||
- samples/client/echo_api/java/okhttp-gson-user-defined-templates/
|
||||
- samples/client/others/java/resttemplate-useAbstractionForFiles/
|
||||
- samples/client/others/java/webclient-useAbstractionForFiles/
|
||||
- samples/client/others/java/jersey2-oneOf-duplicates/
|
||||
|
||||
3
.github/workflows/samples-php8.yaml
vendored
3
.github/workflows/samples-php8.yaml
vendored
@@ -4,9 +4,11 @@ on:
|
||||
push:
|
||||
paths:
|
||||
- samples/server/petstore/php-symfony/SymfonyBundle-php/**
|
||||
- samples/server/petstore/php-flight/**
|
||||
pull_request:
|
||||
paths:
|
||||
- samples/server/petstore/php-symfony/SymfonyBundle-php/**
|
||||
- samples/server/petstore/php-flight/**
|
||||
jobs:
|
||||
build:
|
||||
name: Build PHP projects
|
||||
@@ -17,6 +19,7 @@ jobs:
|
||||
sample:
|
||||
# servers
|
||||
- samples/server/petstore/php-symfony/SymfonyBundle-php/
|
||||
- samples/server/petstore/php-flight/
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup PHP with tools
|
||||
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -85,6 +85,11 @@ samples/client/petstore/cpp-restsdk/CMakeCache.txt
|
||||
samples/client/petstore/cpp-restsdk/CMakeFiles/
|
||||
samples/client/petstore/cpp-restsdk/Makefile
|
||||
samples/client/petstore/cpp-restsdk/cmake_install.cmake
|
||||
samples/client/petstore/cpp-restsdk/client/CMakeFiles
|
||||
samples/client/petstore/cpp-restsdk/client/Makefile
|
||||
samples/client/petstore/cpp-restsdk/client/cmake_install.cmake
|
||||
samples/client/petstore/cpp-restsdk/client/CppRestPetstoreClientConfig.cmake
|
||||
samples/client/petstore/cpp-restsdk/client/CMakeCache.txt
|
||||
|
||||
#Java/Android
|
||||
**/.gradle
|
||||
|
||||
@@ -31,7 +31,7 @@ Please file the pull request against the correct branch, e.g. `master` for non-b
|
||||
|
||||
All the code generators can be found in [modules/openapi-generator/src/main/java/org/openapitools/codegen/languages](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages)
|
||||
|
||||
If you want to add a new generator, follow the [new-generator](https://openapi-generator.tech/docs/new-generator) guide.
|
||||
If you want to add a new generator, follow the [new-generator](https://openapi-generator.tech/docs/new-generator) guide.
|
||||
|
||||
### Templates
|
||||
|
||||
@@ -84,6 +84,26 @@ For [Vendor Extensions](https://github.com/OAI/OpenAPI-Specification/blob/master
|
||||
- For language-specified vendor extension, put it in the form of `x-{lang}-{extension-name}`. e.g. `x-objc-operation-id`, `x-java-feign-retry-limit`
|
||||
- For a list of existing vendor extensions in use, please refer to https://github.com/openapitools/openapi-generator/wiki/Vendor-Extensions. If you've added new vendor extensions as part of your PR, please update the wiki page.
|
||||
|
||||
### Building
|
||||
|
||||
The `openapi-generator-cli` can be built using the following command. This will generate the `openapi-generator-cli.jar` in the `modules/openapi-generator-cli/target` directory without running the tests and generating the Javadocs.
|
||||
|
||||
```shell
|
||||
./mvnw clean install -DskipTests -Dmaven.javadoc.skip=true
|
||||
```
|
||||
|
||||
Or on Windows:
|
||||
|
||||
```shell
|
||||
mvnw.cmd clean install -DskipTests -Dmaven.javadoc.skip=true
|
||||
```
|
||||
|
||||
The binary can run via `java -jar`. For example:
|
||||
|
||||
```shell
|
||||
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help
|
||||
```
|
||||
|
||||
### Testing
|
||||
|
||||
To add test cases (optional) covering the change in the code generator, please refer to [modules/openapi-generator/src/test/java/org/openapitools/codegen](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/test/java/org/openapitools/codegen)
|
||||
@@ -112,5 +132,5 @@ See [OpenAPI Tools wiki](https://github.com/OpenAPITools/openapi-generator/wiki/
|
||||
- File a PR with meaningful title, description and commit messages
|
||||
- Make sure the option "Allow edits from maintainers" in the PR is selected so that the maintainers can update your PRs with minor fixes, if needed.
|
||||
- Recommended git settings
|
||||
- `git config core.autocrlf input` to tell Git convert CRLF to LF on commit but not the other way around
|
||||
- `git config core.autocrlf input` to tell Git convert CRLF to LF on commit but not the other way around
|
||||
- To close an issue (e.g. issue 1542) automatically after a PR is merged, use keywords "fix", "close", "resolve" in the PR description, e.g. `fix #1542`. (Ref: [closing issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/))
|
||||
|
||||
17
README.md
17
README.md
@@ -15,7 +15,7 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.5.0`):
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`7.6.0`):
|
||||
[](https://app.travis-ci.com/github/OpenAPITools/openapi-generator/builds)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator)
|
||||
@@ -85,7 +85,7 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
|
||||
| | Languages/Frameworks |
|
||||
| -------------------------------- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| **API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.1, .NET Core 3.1, .NET 5.0. Libraries: RestSharp, GenericHost, HttpClient), **C++** (Arduino, cpp-restsdk, Qt5, Tizen, Unreal Engine 4), **Clojure**, **Crystal**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Apache HttpClient 4.x, Apache HttpClient 5.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client, MicroProfile Rest Client, Helidon), **Jetbrains HTTP Client**, **Julia**, **k6**, **Kotlin**, **Lua**, **N4JS**, **Nim**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types, Apollo GraphQL DataStore), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (hyper, reqwest, rust-server), **Scala** (akka, http4s, scalaz, sttp, swagger-async-httpclient, pekko), **Swift** (2.x, 3.x, 4.x, 5.x), **Typescript** (AngularJS, Angular (9.x - 17.x), Aurelia, Axios, Fetch, Inversify, jQuery, Nestjs, Node, redux-query, Rxjs), **XoJo**, **Zapier** |
|
||||
| **Server stubs** | **Ada**, **C#** (ASP.NET Core, Azure Functions), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin, Echo), **Haskell** (Servant, Yesod), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/), [Apache Camel](https://camel.apache.org/), [Helidon](https://helidon.io/)), **Julia**, **Kotlin** (Spring Boot, [Ktor](https://github.com/ktorio/ktor), [Vert.x](https://vertx.io/)), **PHP** (Laravel, Lumen, [Mezzio (fka Zend Expressive)](https://github.com/mezzio/mezzio), Slim, Silex, [Symfony](https://symfony.com/)), **Python** (FastAPI, Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** ([rust-server](https://openapi-generator.tech/docs/generators/rust-server/)), **Scala** (Akka, [Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), [Cask](https://github.com/com-lihaoyi/cask), Scalatra) |
|
||||
| **Server stubs** | **Ada**, **C#** (ASP.NET Core, Azure Functions), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin, Echo), **Haskell** (Servant, Yesod), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/), [Apache Camel](https://camel.apache.org/), [Helidon](https://helidon.io/)), **Julia**, **Kotlin** (Spring Boot, [Ktor](https://github.com/ktorio/ktor), [Vert.x](https://vertx.io/)), **PHP** ([Flight](https://docs.flightphp.com/), Laravel, Lumen, [Mezzio (fka Zend Expressive)](https://github.com/mezzio/mezzio), Slim, Silex, [Symfony](https://symfony.com/)), **Python** (FastAPI, Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** ([rust-server](https://openapi-generator.tech/docs/generators/rust-server/)), **Scala** (Akka, [Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), [Cask](https://github.com/com-lihaoyi/cask), Scalatra) |
|
||||
| **API documentation generators** | **HTML**, **Confluence Wiki**, **Asciidoc**, **Markdown**, **PlantUML** |
|
||||
| **Configuration files** | [**Apache2**](https://httpd.apache.org/) |
|
||||
| **Others** | **GraphQL**, **JMeter**, **Ktorm**, **MySQL Schema**, **Postman Collection**, **Protocol Buffer**, **WSDL** |
|
||||
@@ -126,8 +126,8 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
|
||||
|
||||
| OpenAPI Generator Version | Release Date | Notes |
|
||||
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------------------------------------- |
|
||||
| 7.5.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.5.0-SNAPSHOT/) | 12.04.2024 | Minor release with breaking changes (with fallback) |
|
||||
| [7.4.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.4.0) (latest stable release) | 11.03.2024 | Minor release with breaking changes (with fallback) |
|
||||
| 7.6.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/7.6.0-SNAPSHOT/) | 17.54.2024 | Minor release with breaking changes (with fallback) |
|
||||
| [7.5.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v7.5.0) (latest stable release) | 17.04.2024 | 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) |
|
||||
@@ -190,16 +190,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.4.0/openapi-generator-cli-7.4.0.jar`
|
||||
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.5.0/openapi-generator-cli-7.5.0.jar`
|
||||
|
||||
For **Mac/Linux** users:
|
||||
```sh
|
||||
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.4.0/openapi-generator-cli-7.4.0.jar -O openapi-generator-cli.jar
|
||||
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.5.0/openapi-generator-cli-7.5.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.4.0/openapi-generator-cli-7.4.0.jar
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.5.0/openapi-generator-cli-7.5.0.jar
|
||||
```
|
||||
|
||||
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
|
||||
@@ -705,6 +705,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- [REST United](https://restunited.com)
|
||||
- [Robocorp](https://www.robocorp.com)
|
||||
- [Robotinfra](https://www.robotinfra.com)
|
||||
- [SearchApi](https://www.searchapi.io/)
|
||||
- [SmartHR](https://smarthr.co.jp/)
|
||||
- [Sony Interactive Entertainment](https://www.sie.com/en/index.html)
|
||||
- [Splitit](https://www.splitit.com/)
|
||||
@@ -931,6 +932,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- 2023-12-10 - [UnityでOpenAPI Generatorを使う](https://www.youtube.com/watch?v=CbNwKVV5LRM) by [Soup Tori](https://www.youtube.com/@souptori8417)
|
||||
- 2024-03-04 - [Generating TypeScript Types with OpenAPI for REST API Consumption](https://www.pullrequest.com/blog/generating-typescript-types-with-openapi-for-rest-api-consumption/) by [PullRequest](https://www.pullrequest.com/)
|
||||
- 2024-03-07 - [Fully typed Web Apps with OpenAPI (Part 1)](https://medium.com/@gfox1984/fully-typed-web-apps-with-openapi-part-1-595d55766670) by [Guillaume Renard](https://medium.com/@gfox1984)
|
||||
- 2024-03-08 - [Laravel OpenAPIによる "辛くない" スキーマ駆動開発](https://fortee.jp/phperkaigi-2024/proposal/9e2e6c38-d078-4efa-99b4-83ebf9033b34) by [KentarouTakeda](https://twitter.com/KentarouTakeda)
|
||||
|
||||
## [6 - About Us](#table-of-contents)
|
||||
|
||||
@@ -1090,6 +1092,7 @@ Here is a list of template creators:
|
||||
* Kotlin (Vertx): @Wooyme
|
||||
* Kotlin (JAX-RS): @anttileppa
|
||||
* NodeJS Express: @YishTish
|
||||
* PHP Flight: @daniel-sc
|
||||
* PHP Laravel: @renepardon
|
||||
* PHP Lumen: @abcsun
|
||||
* PHP Mezzio (with Path Handler): @Articus
|
||||
|
||||
17
bin/configs/java-okhttp-user-defined-templates.yaml
Normal file
17
bin/configs/java-okhttp-user-defined-templates.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
generatorName: java
|
||||
outputDir: samples/client/echo_api/java/okhttp-gson-user-defined-templates
|
||||
library: okhttp-gson
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/Java
|
||||
additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
||||
files:
|
||||
README.md:
|
||||
destinationFilename: info.md
|
||||
api_doc.mustache:
|
||||
templateType: APIDocs
|
||||
destinationFilename: Documentation.md
|
||||
pojo.mustache:
|
||||
templateType: Model
|
||||
folder: modelCopy
|
||||
destinationFilename: .java
|
||||
15
bin/configs/jaxrs-spec-quarkus-mutiny.yaml
Normal file
15
bin/configs/jaxrs-spec-quarkus-mutiny.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
generatorName: jaxrs-spec
|
||||
outputDir: samples/server/petstore/jaxrs-spec-quarkus-mutiny
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaJaxRS/spec
|
||||
additionalProperties:
|
||||
artifactId: jaxrs-spec-petstore-server
|
||||
serializableModel: "true"
|
||||
hideGenerationTimestamp: "true"
|
||||
implicitHeadersRegex: (api_key|enum_header_string)
|
||||
generateBuilders: "true"
|
||||
useMicroProfileOpenAPIAnnotations: "true"
|
||||
useAsync: "true"
|
||||
useMutiny: "true"
|
||||
library: "quarkus"
|
||||
dateLibrary: "java8-localdatetime"
|
||||
@@ -7,4 +7,6 @@ additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
||||
packageName: petstore-with-fake-endpoints-models-for-testing
|
||||
publishRustRegistry: crates-io
|
||||
enablePostProcessFile: true
|
||||
globalProperties:
|
||||
skipFormModel: false
|
||||
enablePostProcessFile: true
|
||||
|
||||
@@ -6,4 +6,6 @@ generateAliasAsModel: true
|
||||
additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
||||
packageName: petstore
|
||||
globalProperties:
|
||||
skipFormModel: false
|
||||
enablePostProcessFile: true
|
||||
|
||||
6
bin/configs/php-flight.yaml
Normal file
6
bin/configs/php-flight.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
generatorName: php-flight
|
||||
outputDir: samples/server/petstore/php-flight
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/php-flight
|
||||
additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
||||
@@ -35,7 +35,7 @@ Please file the pull request against the correct branch, e.g. `master` for non-b
|
||||
|
||||
All the code generators can be found in [modules/openapi-generator/src/main/java/org/openapitools/codegen/languages](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages)
|
||||
|
||||
If you want to add a new generator, follow the [new-generator](https://openapi-generator.tech/docs/new-generator) guide.
|
||||
If you want to add a new generator, follow the [new-generator](https://openapi-generator.tech/docs/new-generator) guide.
|
||||
|
||||
### Templates
|
||||
|
||||
@@ -88,6 +88,26 @@ For [Vendor Extensions](https://github.com/OAI/OpenAPI-Specification/blob/master
|
||||
- For language-specified vendor extension, put it in the form of `x-{lang}-{extension-name}`. e.g. `x-objc-operation-id`, `x-java-feign-retry-limit`
|
||||
- For a list of existing vendor extensions in use, please refer to https://github.com/openapitools/openapi-generator/wiki/Vendor-Extensions. If you've added new vendor extensions as part of your PR, please update the wiki page.
|
||||
|
||||
### Building
|
||||
|
||||
The `openapi-generator-cli` can be built using the following command. This will generate the `openapi-generator-cli.jar` in the `modules/openapi-generator-cli/target` directory without running the tests and generating the Javadocs.
|
||||
|
||||
```shell
|
||||
./mvnw clean install -DskipTests -Dmaven.javadoc.skip=true
|
||||
```
|
||||
|
||||
Or on Windows:
|
||||
|
||||
```shell
|
||||
mvnw.cmd clean install -DskipTests -Dmaven.javadoc.skip=true
|
||||
```
|
||||
|
||||
The binary can run via `java -jar`. For example:
|
||||
|
||||
```shell
|
||||
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar help
|
||||
```
|
||||
|
||||
### Testing
|
||||
|
||||
To add test cases (optional) covering the change in the code generator, please refer to [modules/openapi-generator/src/test/java/org/openapitools/codegen](https://github.com/openapitools/openapi-generator/tree/master/modules/openapi-generator/src/test/java/org/openapitools/codegen)
|
||||
@@ -116,5 +136,5 @@ See [OpenAPI Tools wiki](https://github.com/OpenAPITools/openapi-generator/wiki/
|
||||
- File a PR with meaningful title, description and commit messages
|
||||
- Make sure the option "Allow edits from maintainers" in the PR is selected so that the maintainers can update your PRs with minor fixes, if needed.
|
||||
- Recommended git settings
|
||||
- `git config core.autocrlf input` to tell Git convert CRLF to LF on commit but not the other way around
|
||||
- `git config core.autocrlf input` to tell Git convert CRLF to LF on commit but not the other way around
|
||||
- To close an issue (e.g. issue 1542) automatically after a PR is merged, use keywords "fix", "close", "resolve" in the PR description, e.g. `fix #1542`. (Ref: [closing issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/))
|
||||
|
||||
@@ -120,6 +120,7 @@ The following generators are available:
|
||||
* [kotlin-spring](generators/kotlin-spring.md)
|
||||
* [kotlin-vertx (beta)](generators/kotlin-vertx.md)
|
||||
* [nodejs-express-server (beta)](generators/nodejs-express-server.md)
|
||||
* [php-flight (experimental)](generators/php-flight.md)
|
||||
* [php-laravel](generators/php-laravel.md)
|
||||
* [php-lumen](generators/php-lumen.md)
|
||||
* [php-mezzio-ph](generators/php-mezzio-ph.md)
|
||||
|
||||
@@ -32,6 +32,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|
||||
| Type/Alias | Imports |
|
||||
| ---------- | ------- |
|
||||
|AnyType|#include "AnyType.h"|
|
||||
|HttpContent|#include "HttpContent.h"|
|
||||
|Object|#include "Object.h"|
|
||||
|std::map|#include <map>|
|
||||
@@ -184,7 +185,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|Uuid|✗|
|
||||
|Array|✓|OAS2,OAS3
|
||||
|Null|✗|OAS3
|
||||
|AnyType|✗|OAS2,OAS3
|
||||
|AnyType|✓|OAS2,OAS3
|
||||
|Object|✓|OAS2,OAS3
|
||||
|Maps|✓|ToolingExtension
|
||||
|CollectionFormat|✓|OAS2
|
||||
|
||||
@@ -22,6 +22,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|enumClassPrefix|Prefix enum with class name| |false|
|
||||
|generateInterfaces|Generate interfaces for api classes| |false|
|
||||
|generateMarshalJSON|Generate MarshalJSON method| |true|
|
||||
|generateUnmarshalJSON|Generate UnmarshalJSON method| |true|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||
|isGoSubmodule|whether the generated Go module is a submodule| |false|
|
||||
|packageName|Go package name (convention: lowercase).| |openapi|
|
||||
|
||||
@@ -47,7 +47,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|dynamicOperations|Generate operations dynamically at runtime from an OAS| |false|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.</dd></dl>|false|
|
||||
|errorObjectType|Error Object type. (This option is for okhttp-gson-next-gen only)| |null|
|
||||
|errorObjectType|Error Object type. (This option is for okhttp-gson only)| |null|
|
||||
|generateClientAsBean|For resttemplate, configure whether to create `ApiClient.java` and Apis clients as bean (with `@Component` annotation).| |false|
|
||||
|gradleProperties|Append additional Gradle properties to the gradle.properties file| |null|
|
||||
|groupId|groupId in generated pom.xml| |org.openapitools|
|
||||
|
||||
@@ -78,6 +78,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|useBeanValidation|Use BeanValidation API annotations| |true|
|
||||
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|
||||
|useMicroProfileOpenAPIAnnotations|Whether to generate Microprofile OpenAPI annotations. Only valid when library is set to quarkus.| |false|
|
||||
|useMutiny|Whether to use Smallrye Mutiny instead of CompletionStage for asynchronous computation. Only valid when library is set to quarkus.| |false|
|
||||
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
|
||||
|useSwaggerAnnotations|Whether to generate Swagger annotations.| |true|
|
||||
|useTags|use tags for creating interface and controller classnames| |false|
|
||||
|
||||
@@ -78,6 +78,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|useBeanValidation|Use BeanValidation API annotations| |true|
|
||||
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|
||||
|useMicroProfileOpenAPIAnnotations|Whether to generate Microprofile OpenAPI annotations. Only valid when library is set to quarkus.| |false|
|
||||
|useMutiny|Whether to use Smallrye Mutiny instead of CompletionStage for asynchronous computation. Only valid when library is set to quarkus.| |false|
|
||||
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
|
||||
|useSwaggerAnnotations|Whether to generate Swagger annotations.| |true|
|
||||
|useTags|use tags for creating interface and controller classnames| |false|
|
||||
|
||||
270
docs/generators/php-flight.md
Normal file
270
docs/generators/php-flight.md
Normal file
@@ -0,0 +1,270 @@
|
||||
---
|
||||
title: Documentation for the php-flight Generator
|
||||
---
|
||||
|
||||
## METADATA
|
||||
|
||||
| Property | Value | Notes |
|
||||
| -------- | ----- | ----- |
|
||||
| generator name | php-flight | pass this to the generate command after -g |
|
||||
| generator stability | EXPERIMENTAL | |
|
||||
| generator type | SERVER | |
|
||||
| generator language | PHP | |
|
||||
| generator default templating engine | mustache | |
|
||||
| helpTxt | Generates a PHP Flight Framework server library. | |
|
||||
|
||||
## CONFIG OPTIONS
|
||||
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.
|
||||
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |null|
|
||||
|artifactUrl|artifact URL in generated pom.xml| |null|
|
||||
|artifactVersion|The version to use in the composer package version field. e.g. 1.2.3| |null|
|
||||
|composerPackageName|The name to use in the composer package name field. e.g. `vendor/project` (must be lowercase and consist of words separated by `-`, `.` or `_`).| |null|
|
||||
|developerOrganization|developer organization in generated pom.xml| |null|
|
||||
|developerOrganizationUrl|developer organization URL in generated pom.xml| |null|
|
||||
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.</dd></dl>|false|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||
|invokerPackage|The main namespace to use for all classes. e.g. Yay\Pets| |null|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|licenseName|The name of the license| |null|
|
||||
|modelPackage|package for generated models| |null|
|
||||
|packageName|The main package name for classes. e.g. GeneratedPetstore| |null|
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||
|srcBasePath|The directory to serve as source root.| |null|
|
||||
|variableNamingConvention|naming convention of variable name, e.g. camelCase.| |camelCase|
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
||||
| Type/Alias | Imports |
|
||||
| ---------- | ------- |
|
||||
|
||||
|
||||
## INSTANTIATION TYPES
|
||||
|
||||
| Type/Alias | Instantiated By |
|
||||
| ---------- | --------------- |
|
||||
|array|array|
|
||||
|map|array|
|
||||
|
||||
|
||||
## LANGUAGE PRIMITIVES
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>\DateTime</li>
|
||||
<li>\SplFileObject</li>
|
||||
<li>array</li>
|
||||
<li>bool</li>
|
||||
<li>boolean</li>
|
||||
<li>byte</li>
|
||||
<li>float</li>
|
||||
<li>int</li>
|
||||
<li>integer</li>
|
||||
<li>mixed</li>
|
||||
<li>number</li>
|
||||
<li>object</li>
|
||||
<li>string</li>
|
||||
<li>void</li>
|
||||
</ul>
|
||||
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>__halt_compiler</li>
|
||||
<li>_header_accept</li>
|
||||
<li>_tempbody</li>
|
||||
<li>abstract</li>
|
||||
<li>and</li>
|
||||
<li>array</li>
|
||||
<li>as</li>
|
||||
<li>break</li>
|
||||
<li>callable</li>
|
||||
<li>case</li>
|
||||
<li>catch</li>
|
||||
<li>class</li>
|
||||
<li>clone</li>
|
||||
<li>const</li>
|
||||
<li>continue</li>
|
||||
<li>declare</li>
|
||||
<li>default</li>
|
||||
<li>die</li>
|
||||
<li>do</li>
|
||||
<li>echo</li>
|
||||
<li>else</li>
|
||||
<li>elseif</li>
|
||||
<li>empty</li>
|
||||
<li>enddeclare</li>
|
||||
<li>endfor</li>
|
||||
<li>endforeach</li>
|
||||
<li>endif</li>
|
||||
<li>endswitch</li>
|
||||
<li>endwhile</li>
|
||||
<li>eval</li>
|
||||
<li>exit</li>
|
||||
<li>extends</li>
|
||||
<li>final</li>
|
||||
<li>for</li>
|
||||
<li>foreach</li>
|
||||
<li>formparams</li>
|
||||
<li>function</li>
|
||||
<li>global</li>
|
||||
<li>goto</li>
|
||||
<li>headerparams</li>
|
||||
<li>httpbody</li>
|
||||
<li>if</li>
|
||||
<li>implements</li>
|
||||
<li>include</li>
|
||||
<li>include_once</li>
|
||||
<li>instanceof</li>
|
||||
<li>insteadof</li>
|
||||
<li>interface</li>
|
||||
<li>isset</li>
|
||||
<li>list</li>
|
||||
<li>namespace</li>
|
||||
<li>new</li>
|
||||
<li>or</li>
|
||||
<li>print</li>
|
||||
<li>private</li>
|
||||
<li>protected</li>
|
||||
<li>public</li>
|
||||
<li>queryparams</li>
|
||||
<li>require</li>
|
||||
<li>require_once</li>
|
||||
<li>resourcepath</li>
|
||||
<li>return</li>
|
||||
<li>static</li>
|
||||
<li>switch</li>
|
||||
<li>throw</li>
|
||||
<li>trait</li>
|
||||
<li>try</li>
|
||||
<li>unset</li>
|
||||
<li>use</li>
|
||||
<li>var</li>
|
||||
<li>while</li>
|
||||
<li>xor</li>
|
||||
</ul>
|
||||
|
||||
## FEATURE SET
|
||||
|
||||
|
||||
### Client Modification Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|BasePath|✗|ToolingExtension
|
||||
|Authorizations|✗|ToolingExtension
|
||||
|UserAgent|✗|ToolingExtension
|
||||
|MockServer|✗|ToolingExtension
|
||||
|
||||
### Data Type Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Custom|✗|OAS2,OAS3
|
||||
|Int32|✓|OAS2,OAS3
|
||||
|Int64|✓|OAS2,OAS3
|
||||
|Float|✓|OAS2,OAS3
|
||||
|Double|✓|OAS2,OAS3
|
||||
|Decimal|✓|ToolingExtension
|
||||
|String|✓|OAS2,OAS3
|
||||
|Byte|✓|OAS2,OAS3
|
||||
|Binary|✓|OAS2,OAS3
|
||||
|Boolean|✓|OAS2,OAS3
|
||||
|Date|✓|OAS2,OAS3
|
||||
|DateTime|✓|OAS2,OAS3
|
||||
|Password|✓|OAS2,OAS3
|
||||
|File|✓|OAS2
|
||||
|Uuid|✗|
|
||||
|Array|✓|OAS2,OAS3
|
||||
|Null|✗|OAS3
|
||||
|AnyType|✗|OAS2,OAS3
|
||||
|Object|✓|OAS2,OAS3
|
||||
|Maps|✓|ToolingExtension
|
||||
|CollectionFormat|✓|OAS2
|
||||
|CollectionFormatMulti|✓|OAS2
|
||||
|Enum|✓|OAS2,OAS3
|
||||
|ArrayOfEnum|✓|ToolingExtension
|
||||
|ArrayOfModel|✓|ToolingExtension
|
||||
|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
|
||||
|ArrayOfCollectionOfModel|✓|ToolingExtension
|
||||
|ArrayOfCollectionOfEnum|✓|ToolingExtension
|
||||
|MapOfEnum|✗|ToolingExtension
|
||||
|MapOfModel|✗|ToolingExtension
|
||||
|MapOfCollectionOfPrimitives|✓|ToolingExtension
|
||||
|MapOfCollectionOfModel|✗|ToolingExtension
|
||||
|MapOfCollectionOfEnum|✗|ToolingExtension
|
||||
|
||||
### Documentation Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Readme|✓|ToolingExtension
|
||||
|Model|✓|ToolingExtension
|
||||
|Api|✓|ToolingExtension
|
||||
|
||||
### Global Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Host|✓|OAS2,OAS3
|
||||
|BasePath|✓|OAS2,OAS3
|
||||
|Info|✓|OAS2,OAS3
|
||||
|Schemes|✗|OAS2,OAS3
|
||||
|PartialSchemes|✓|OAS2,OAS3
|
||||
|Consumes|✓|OAS2
|
||||
|Produces|✓|OAS2
|
||||
|ExternalDocumentation|✓|OAS2,OAS3
|
||||
|Examples|✓|OAS2,OAS3
|
||||
|XMLStructureDefinitions|✗|OAS2,OAS3
|
||||
|MultiServer|✗|OAS3
|
||||
|ParameterizedServer|✗|OAS3
|
||||
|ParameterStyling|✗|OAS3
|
||||
|Callbacks|✗|OAS3
|
||||
|LinkObjects|✗|OAS3
|
||||
|
||||
### Parameter Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Path|✓|OAS2,OAS3
|
||||
|Query|✓|OAS2,OAS3
|
||||
|Header|✓|OAS2,OAS3
|
||||
|Body|✓|OAS2
|
||||
|FormUnencoded|✗|OAS2
|
||||
|FormMultipart|✗|OAS2
|
||||
|Cookie|✗|OAS3
|
||||
|
||||
### Schema Support Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Simple|✓|OAS2,OAS3
|
||||
|Composite|✓|OAS2,OAS3
|
||||
|Polymorphism|✗|OAS2,OAS3
|
||||
|Union|✗|OAS3
|
||||
|allOf|✗|OAS2,OAS3
|
||||
|anyOf|✗|OAS3
|
||||
|oneOf|✗|OAS3
|
||||
|not|✗|OAS3
|
||||
|
||||
### Security Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|BasicAuth|✓|OAS2,OAS3
|
||||
|ApiKey|✓|OAS2,OAS3
|
||||
|OpenIDConnect|✗|OAS3
|
||||
|BearerToken|✓|OAS3
|
||||
|OAuth2_Implicit|✓|OAS2,OAS3
|
||||
|OAuth2_Password|✗|OAS2,OAS3
|
||||
|OAuth2_ClientCredentials|✗|OAS2,OAS3
|
||||
|OAuth2_AuthorizationCode|✗|OAS2,OAS3
|
||||
|SignatureAuth|✗|OAS3
|
||||
|AWSV4Signature|✗|ToolingExtension
|
||||
|
||||
### Wire Format Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|JSON|✓|OAS2,OAS3
|
||||
|XML|✗|OAS2,OAS3
|
||||
|PROTOBUF|✗|ToolingExtension
|
||||
|Custom|✗|OAS2,OAS3
|
||||
@@ -21,6 +21,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|
||||
|apiPackage|package for generated api classes| |null|
|
||||
|artifactId|artifactId in generated pom.xml. This also becomes part of the generated library's filename| |null|
|
||||
|artifactVersion|artifact version in generated pom.xml. This also becomes part of the generated library's filename. If not provided, uses the version from the OpenAPI specification file. If that's also not present, uses the default value of the artifactVersion option.| |null|
|
||||
|dateLibrary|Option. Date library to use|<dl><dt>**joda**</dt><dd>Joda (for legacy app)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (preferred for JDK 1.8+)</dd></dl>|java8|
|
||||
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<version>7.6.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<version>7.6.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</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.2.0"
|
||||
id "org.openapi.generator" version "7.5.0"
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=7.5.0-SNAPSHOT
|
||||
openApiGeneratorVersion=7.6.0-SNAPSHOT
|
||||
# /RELEASE_VERSION
|
||||
|
||||
# BEGIN placeholders
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<version>7.6.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# RELEASE_VERSION
|
||||
openApiGeneratorVersion=7.5.0-SNAPSHOT
|
||||
openApiGeneratorVersion=7.6.0-SNAPSHOT
|
||||
# /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.2.0</version>
|
||||
<version>7.5.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<version>7.6.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<version>7.6.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<version>7.6.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<version>7.6.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<version>7.6.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<version>7.6.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<version>7.6.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -54,4 +54,4 @@ The `GENERATOR_HOST` variable is used here to ensure download links generated by
|
||||
## Environment
|
||||
|
||||
`GENERATOR_HOST` can be set to force the scheme/host/port used for download link generation. In most cases, this environment variable is not
|
||||
necessary to be set and the download link will be generated to match the originating request. The variable is provided simply as a fallback.
|
||||
necessary to be set and the download link will be generated to match the originating request. The variable is provided simply as a fallback.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<version>7.6.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>7.5.0-SNAPSHOT</version>
|
||||
<version>7.6.0-SNAPSHOT</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -442,6 +442,8 @@ public class CodegenConstants {
|
||||
public static final String GENERATE_MARSHAL_JSON = "generateMarshalJSON";
|
||||
public static final String GENERATE_MARSHAL_JSON_DESC = "Generate MarshalJSON method";
|
||||
|
||||
public static final String GENERATE_UNMARSHAL_JSON = "generateUnmarshalJSON";
|
||||
public static final String GENERATE_UNMARSHAL_JSON_DESC = "Generate UnmarshalJSON method";
|
||||
public static final String MAX_ATTEMPTS_FOR_RETRY = "maxAttemptsForRetry";
|
||||
|
||||
public static final String WAIT_TIME_OF_THREAD = "waitTimeMillis";
|
||||
|
||||
@@ -52,6 +52,7 @@ import org.openapitools.codegen.api.TemplatingEngineAdapter;
|
||||
import org.openapitools.codegen.config.GlobalSettings;
|
||||
import org.openapitools.codegen.examples.ExampleGenerator;
|
||||
import org.openapitools.codegen.languages.PhpNextgenClientCodegen;
|
||||
import org.openapitools.codegen.languages.RustAxumServerCodegen;
|
||||
import org.openapitools.codegen.languages.RustServerCodegen;
|
||||
import org.openapitools.codegen.meta.FeatureSet;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
@@ -4742,7 +4743,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
contentType = contentType.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
if (contentType != null &&
|
||||
(contentType.startsWith("application/x-www-form-urlencoded") ||
|
||||
((!(this instanceof RustAxumServerCodegen) && contentType.startsWith("application/x-www-form-urlencoded")) ||
|
||||
contentType.startsWith("multipart"))) {
|
||||
// process form parameters
|
||||
formParams = fromRequestBodyToFormParameters(requestBody, imports);
|
||||
|
||||
@@ -292,13 +292,11 @@ public class DefaultGenerator implements Generator {
|
||||
// set OpenAPI to make these available to all methods
|
||||
config.setOpenAPI(openAPI);
|
||||
|
||||
if (!config.additionalProperties().containsKey("generatorVersion")) {
|
||||
config.additionalProperties().put("generatorVersion", ImplementationVersion.read());
|
||||
}
|
||||
config.additionalProperties().put("generatedDate", ZonedDateTime.now().toString());
|
||||
config.additionalProperties().put("generatedYear", String.valueOf(ZonedDateTime.now().getYear()));
|
||||
config.additionalProperties().put("generatorClass", config.getClass().getName());
|
||||
config.additionalProperties().put("inputSpec", config.getInputSpec());
|
||||
config.additionalProperties().putIfAbsent("generatorVersion", ImplementationVersion.read());
|
||||
config.additionalProperties().putIfAbsent("generatedDate", ZonedDateTime.now().toString());
|
||||
config.additionalProperties().putIfAbsent("generatedYear", String.valueOf(ZonedDateTime.now().getYear()));
|
||||
config.additionalProperties().putIfAbsent("generatorClass", config.getClass().getName());
|
||||
config.additionalProperties().putIfAbsent("inputSpec", config.getInputSpec());
|
||||
|
||||
if (openAPI.getExtensions() != null) {
|
||||
config.vendorExtensions().putAll(openAPI.getExtensions());
|
||||
@@ -322,59 +320,59 @@ public class DefaultGenerator implements Generator {
|
||||
return;
|
||||
}
|
||||
if (info.getTitle() != null) {
|
||||
config.additionalProperties().put("appName", config.escapeText(info.getTitle()));
|
||||
config.additionalProperties().putIfAbsent("appName", config.escapeText(info.getTitle()));
|
||||
}
|
||||
if (info.getVersion() != null) {
|
||||
config.additionalProperties().put("appVersion", config.escapeText(info.getVersion()));
|
||||
config.additionalProperties().putIfAbsent("appVersion", config.escapeText(info.getVersion()));
|
||||
} else {
|
||||
LOGGER.error("Missing required field info version. Default appVersion set to 1.0.0");
|
||||
config.additionalProperties().put("appVersion", "1.0.0");
|
||||
config.additionalProperties().putIfAbsent("appVersion", "1.0.0");
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(info.getDescription())) {
|
||||
// set a default description if none if provided
|
||||
config.additionalProperties().put("appDescription",
|
||||
config.additionalProperties().putIfAbsent("appDescription",
|
||||
"No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)");
|
||||
config.additionalProperties().put("appDescriptionWithNewLines", config.additionalProperties().get("appDescription"));
|
||||
config.additionalProperties().put("unescapedAppDescription", "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)");
|
||||
config.additionalProperties().putIfAbsent("appDescriptionWithNewLines", config.additionalProperties().get("appDescription"));
|
||||
config.additionalProperties().putIfAbsent("unescapedAppDescription", "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)");
|
||||
} else {
|
||||
config.additionalProperties().put("appDescription", config.escapeText(info.getDescription()));
|
||||
config.additionalProperties().put("appDescriptionWithNewLines", config.escapeTextWhileAllowingNewLines(info.getDescription()));
|
||||
config.additionalProperties().put("unescapedAppDescription", info.getDescription());
|
||||
config.additionalProperties().putIfAbsent("appDescription", config.escapeText(info.getDescription()));
|
||||
config.additionalProperties().putIfAbsent("appDescriptionWithNewLines", config.escapeTextWhileAllowingNewLines(info.getDescription()));
|
||||
config.additionalProperties().putIfAbsent("unescapedAppDescription", info.getDescription());
|
||||
}
|
||||
|
||||
if (info.getContact() != null) {
|
||||
Contact contact = info.getContact();
|
||||
if (contact.getEmail() != null) {
|
||||
config.additionalProperties().put("infoEmail", config.escapeText(contact.getEmail()));
|
||||
config.additionalProperties().putIfAbsent("infoEmail", config.escapeText(contact.getEmail()));
|
||||
}
|
||||
if (contact.getName() != null) {
|
||||
config.additionalProperties().put("infoName", config.escapeText(contact.getName()));
|
||||
config.additionalProperties().putIfAbsent("infoName", config.escapeText(contact.getName()));
|
||||
}
|
||||
if (contact.getUrl() != null) {
|
||||
config.additionalProperties().put("infoUrl", config.escapeText(contact.getUrl()));
|
||||
config.additionalProperties().putIfAbsent("infoUrl", config.escapeText(contact.getUrl()));
|
||||
}
|
||||
}
|
||||
|
||||
if (info.getLicense() != null) {
|
||||
License license = info.getLicense();
|
||||
if (license.getName() != null) {
|
||||
config.additionalProperties().put("licenseInfo", config.escapeText(license.getName()));
|
||||
config.additionalProperties().putIfAbsent("licenseInfo", config.escapeText(license.getName()));
|
||||
}
|
||||
if (license.getUrl() != null) {
|
||||
config.additionalProperties().put("licenseUrl", config.escapeText(license.getUrl()));
|
||||
config.additionalProperties().putIfAbsent("licenseUrl", config.escapeText(license.getUrl()));
|
||||
}
|
||||
}
|
||||
|
||||
if (info.getVersion() != null) {
|
||||
config.additionalProperties().put("version", config.escapeText(info.getVersion()));
|
||||
config.additionalProperties().putIfAbsent("version", config.escapeText(info.getVersion()));
|
||||
} else {
|
||||
LOGGER.error("Missing required field info version. Default version set to 1.0.0");
|
||||
config.additionalProperties().put("version", "1.0.0");
|
||||
config.additionalProperties().putIfAbsent("version", "1.0.0");
|
||||
}
|
||||
|
||||
if (info.getTermsOfService() != null) {
|
||||
config.additionalProperties().put("termsOfService", config.escapeText(info.getTermsOfService()));
|
||||
config.additionalProperties().putIfAbsent("termsOfService", config.escapeText(info.getTermsOfService()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -585,7 +585,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
List<CodegenProperty> allOf = composedSchemas.getAllOf();
|
||||
if (allOf != null) {
|
||||
for (CodegenProperty property : allOf) {
|
||||
property.name = patchPropertyName(model, property.baseType);
|
||||
property.name = patchPropertyName(model, camelize(property.baseType));
|
||||
patchPropertyVendorExtensions(property);
|
||||
}
|
||||
}
|
||||
@@ -594,7 +594,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
if (anyOf != null) {
|
||||
removePropertiesDeclaredInComposedTypes(objs, model, anyOf);
|
||||
for (CodegenProperty property : anyOf) {
|
||||
property.name = patchPropertyName(model, property.baseType);
|
||||
property.name = patchPropertyName(model, camelize(property.baseType));
|
||||
property.isNullable = true;
|
||||
patchPropertyVendorExtensions(property);
|
||||
}
|
||||
@@ -604,7 +604,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
if (oneOf != null) {
|
||||
removePropertiesDeclaredInComposedTypes(objs, model, oneOf);
|
||||
for (CodegenProperty property : oneOf) {
|
||||
property.name = patchPropertyName(model, property.baseType);
|
||||
property.name = patchPropertyName(model, camelize(property.baseType));
|
||||
property.isNullable = true;
|
||||
patchPropertyVendorExtensions(property);
|
||||
}
|
||||
|
||||
@@ -48,6 +48,8 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
protected boolean generateInterfaces = false;
|
||||
protected boolean withGoMod = false;
|
||||
protected boolean generateMarshalJSON = true;
|
||||
protected boolean generateUnmarshalJSON = true;
|
||||
|
||||
|
||||
protected String packageName = "openapi";
|
||||
protected Set<String> numberTypes;
|
||||
@@ -775,7 +777,11 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
}
|
||||
|
||||
if (generateMarshalJSON) {
|
||||
model.vendorExtensions.put("x-go-generate-marshal-json", true);
|
||||
model.vendorExtensions.putIfAbsent("x-go-generate-marshal-json", true);
|
||||
}
|
||||
|
||||
if (generateUnmarshalJSON) {
|
||||
model.vendorExtensions.putIfAbsent("x-go-generate-unmarshal-json", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -932,6 +938,10 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
this.generateMarshalJSON = generateMarshalJSON;
|
||||
}
|
||||
|
||||
public void setGenerateUnmarshalJSON(boolean generateUnmarshalJSON) {
|
||||
this.generateUnmarshalJSON = generateUnmarshalJSON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toDefaultValue(Schema schema) {
|
||||
schema = unaliasSchema(schema);
|
||||
|
||||
@@ -111,6 +111,8 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
||||
.excludeParameterFeatures(
|
||||
ParameterFeature.Cookie
|
||||
)
|
||||
.includeDataTypeFeatures(
|
||||
DataTypeFeature.AnyType)
|
||||
);
|
||||
|
||||
apiPackage = "org.openapitools.client.api";
|
||||
@@ -174,6 +176,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
||||
importMapping.put("std::string", "#include <string>");
|
||||
importMapping.put("HttpContent", "#include \"HttpContent.h\"");
|
||||
importMapping.put("Object", "#include \"Object.h\"");
|
||||
importMapping.put("AnyType", "#include \"AnyType.h\"");
|
||||
importMapping.put("utility::string_t", "#include <cpprest/details/basic_types.h>");
|
||||
importMapping.put("utility::datetime", "#include <cpprest/details/basic_types.h>");
|
||||
}
|
||||
@@ -214,11 +217,14 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
||||
|
||||
importMapping.put("HttpContent", "#include \"" + packageName + "/" + "HttpContent.h\"");
|
||||
importMapping.put("Object", "#include \"" + packageName + "/" + "Object.h\"");
|
||||
importMapping.put("AnyType", "#include \"" + packageName + "/" + "AnyType.h\"");
|
||||
|
||||
supportingFiles.add(new SupportingFile("modelbase-header.mustache", getHeaderFolder(), "ModelBase.h"));
|
||||
supportingFiles.add(new SupportingFile("modelbase-source.mustache", getSourceFolder(), "ModelBase.cpp"));
|
||||
supportingFiles.add(new SupportingFile("object-header.mustache", getHeaderFolder(), "Object.h"));
|
||||
supportingFiles.add(new SupportingFile("object-source.mustache", getSourceFolder(), "Object.cpp"));
|
||||
supportingFiles.add(new SupportingFile("anytype-header.mustache", getHeaderFolder(), "AnyType.h"));
|
||||
supportingFiles.add(new SupportingFile("anytype-source.mustache", getSourceFolder(), "AnyType.cpp"));
|
||||
supportingFiles.add(new SupportingFile("apiclient-header.mustache", getHeaderFolder(), "ApiClient.h"));
|
||||
supportingFiles.add(new SupportingFile("apiclient-source.mustache", getSourceFolder(), "ApiClient.cpp"));
|
||||
supportingFiles.add(new SupportingFile("apiconfiguration-header.mustache", getHeaderFolder(), "ApiConfiguration.h"));
|
||||
|
||||
@@ -150,6 +150,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
this.setDisallowAdditionalPropertiesIfNotPresent(true);
|
||||
cliOptions.add(CliOption.newBoolean(WITH_GO_MOD, "Generate go.mod and go.sum", true));
|
||||
cliOptions.add(CliOption.newBoolean(CodegenConstants.GENERATE_MARSHAL_JSON, CodegenConstants.GENERATE_MARSHAL_JSON_DESC, true));
|
||||
cliOptions.add(CliOption.newBoolean(CodegenConstants.GENERATE_UNMARSHAL_JSON, CodegenConstants.GENERATE_UNMARSHAL_JSON_DESC, true));
|
||||
this.setWithGoMod(true);
|
||||
}
|
||||
|
||||
@@ -287,6 +288,11 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
setGenerateMarshalJSON(Boolean.parseBoolean(additionalProperties.get(CodegenConstants.GENERATE_MARSHAL_JSON).toString()));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.GENERATE_UNMARSHAL_JSON)) {
|
||||
setGenerateUnmarshalJSON(Boolean.parseBoolean(additionalProperties.get(CodegenConstants.GENERATE_UNMARSHAL_JSON).toString()));
|
||||
}
|
||||
|
||||
|
||||
// add lambda for mustache templates to handle oneOf/anyOf naming
|
||||
// e.g. []string => ArrayOfString
|
||||
additionalProperties.put("lambda.type-to-name", (Mustache.Lambda) (fragment, writer) -> writer.write(typeToName(fragment.execute())));
|
||||
|
||||
@@ -333,13 +333,14 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
|
||||
/**
|
||||
* Internal method to set the generateToSchema parameter.
|
||||
*
|
||||
* <p>
|
||||
* Basically we're generating ToSchema instances (generically) for all schemas.
|
||||
* However, if any of the contained datatypes doesn't have the ToSchema instance,
|
||||
* we cannot generate it for its "ancestor" type.
|
||||
* This is the case with the "Data.Aeson.Value" type: it doesn't (and cannot) have
|
||||
* a Swagger-compatible ToSchema instance. So we have to detect its presence "downstream"
|
||||
* the current schema, and if we find it we just don't generate any ToSchema instance.
|
||||
*
|
||||
* @param model
|
||||
*/
|
||||
private void setGenerateToSchema(CodegenModel model) {
|
||||
@@ -356,7 +357,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
|
||||
List<CodegenModel> children = model.getChildren();
|
||||
if (children != null) {
|
||||
for(CodegenModel child : children) {
|
||||
for (CodegenModel child : children) {
|
||||
setGenerateToSchema(child);
|
||||
}
|
||||
}
|
||||
@@ -512,7 +513,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
// Query parameters appended to routes
|
||||
for (CodegenParameter param : op.queryParams) {
|
||||
String paramType = param.dataType;
|
||||
if (param.contentType == "application/json") {
|
||||
if ("application/json".equals(param.contentType)) {
|
||||
if (param.isArray) {
|
||||
paramType = "[JSONQueryParam " + paramType.substring(1, paramType.length() - 1) + "]";
|
||||
} else {
|
||||
@@ -554,7 +555,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
path.add("Header \"" + param.baseName + "\" " + param.dataType);
|
||||
|
||||
String paramType = param.dataType;
|
||||
if (param.contentType == "application/json") {
|
||||
if ("application/json".equals(param.contentType)) {
|
||||
if (param.isArray) {
|
||||
paramType = "(JSONQueryParam " + paramType.substring(1, paramType.length() - 1) + ")";
|
||||
} else {
|
||||
@@ -721,5 +722,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.HASKELL; }
|
||||
public GeneratorLanguage generatorLanguage() {
|
||||
return GeneratorLanguage.HASKELL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,10 +182,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
.includeDocumentationFeatures(DocumentationFeature.Readme)
|
||||
.includeGlobalFeatures(GlobalFeature.ParameterizedServer)
|
||||
.includeSecurityFeatures(SecurityFeature.OAuth2_AuthorizationCode,
|
||||
SecurityFeature.OAuth2_ClientCredentials,
|
||||
SecurityFeature.OAuth2_Password,
|
||||
SecurityFeature.SignatureAuth,//jersey only
|
||||
SecurityFeature.AWSV4Signature)//okhttp-gson only
|
||||
SecurityFeature.OAuth2_ClientCredentials,
|
||||
SecurityFeature.OAuth2_Password,
|
||||
SecurityFeature.SignatureAuth,//jersey only
|
||||
SecurityFeature.AWSV4Signature)//okhttp-gson only
|
||||
);
|
||||
|
||||
outputFolder = "generated-code" + File.separator + "java";
|
||||
@@ -222,7 +222,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
cliOptions.add(CliOption.newBoolean(SUPPORT_STREAMING, "Support streaming endpoint (beta)", this.supportStreaming));
|
||||
cliOptions.add(CliOption.newBoolean(CodegenConstants.WITH_AWSV4_SIGNATURE_COMMENT, CodegenConstants.WITH_AWSV4_SIGNATURE_COMMENT_DESC + " (only available for okhttp-gson library)", this.withAWSV4Signature));
|
||||
cliOptions.add(CliOption.newString(GRADLE_PROPERTIES, "Append additional Gradle properties to the gradle.properties file"));
|
||||
cliOptions.add(CliOption.newString(ERROR_OBJECT_TYPE, "Error Object type. (This option is for okhttp-gson-next-gen only)"));
|
||||
cliOptions.add(CliOption.newString(ERROR_OBJECT_TYPE, "Error Object type. (This option is for okhttp-gson only)"));
|
||||
cliOptions.add(CliOption.newString(CONFIG_KEY, "Config key in @RegisterRestClient. Default to none. Only `microprofile` supports this option."));
|
||||
cliOptions.add(CliOption.newBoolean(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP_DESC + " Only jersey2, jersey3, native, okhttp-gson support this option."));
|
||||
cliOptions.add(CliOption.newString(MICROPROFILE_REST_CLIENT_VERSION, "Version of MicroProfile Rest Client API."));
|
||||
@@ -472,15 +472,13 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.MAX_ATTEMPTS_FOR_RETRY)) {
|
||||
this.setMaxAttemptsForRetry(Integer.parseInt(additionalProperties.get(CodegenConstants.MAX_ATTEMPTS_FOR_RETRY).toString()));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
additionalProperties.put(CodegenConstants.MAX_ATTEMPTS_FOR_RETRY, maxAttemptsForRetry);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.WAIT_TIME_OF_THREAD)) {
|
||||
this.setWaitTimeMillis(Long.parseLong((additionalProperties.get(CodegenConstants.WAIT_TIME_OF_THREAD).toString())));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
additionalProperties.put(CodegenConstants.WAIT_TIME_OF_THREAD, waitTimeMillis);
|
||||
}
|
||||
writePropertyBack(USE_ENUM_CASE_INSENSITIVE, useEnumCaseInsensitive);
|
||||
@@ -1264,11 +1262,11 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
|
||||
public void setMaxAttemptsForRetry(int maxAttemptsForRetry) {
|
||||
this.maxAttemptsForRetry= maxAttemptsForRetry;
|
||||
this.maxAttemptsForRetry = maxAttemptsForRetry;
|
||||
}
|
||||
|
||||
public void setWaitTimeMillis(long waitTimeMillis) {
|
||||
this.waitTimeMillis= waitTimeMillis;
|
||||
this.waitTimeMillis = waitTimeMillis;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,6 +38,7 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||
public static final String GENERATE_POM = "generatePom";
|
||||
public static final String USE_SWAGGER_ANNOTATIONS = "useSwaggerAnnotations";
|
||||
public static final String USE_MICROPROFILE_OPENAPI_ANNOTATIONS = "useMicroProfileOpenAPIAnnotations";
|
||||
public static final String USE_MUTINY = "useMutiny";
|
||||
public static final String OPEN_API_SPEC_FILE_LOCATION = "openApiSpecFileLocation";
|
||||
public static final String GENERATE_BUILDERS = "generateBuilders";
|
||||
|
||||
@@ -53,6 +54,7 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||
private boolean generateBuilders = false;
|
||||
private boolean useSwaggerAnnotations = true;
|
||||
private boolean useMicroProfileOpenAPIAnnotations = false;
|
||||
private boolean useMutiny = false;
|
||||
|
||||
protected boolean useGzipFeature = false;
|
||||
private boolean useJackson = false;
|
||||
@@ -120,6 +122,7 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||
cliOptions.add(CliOption.newBoolean(USE_MICROPROFILE_OPENAPI_ANNOTATIONS, "Whether to generate Microprofile OpenAPI annotations. Only valid when library is set to quarkus.", useMicroProfileOpenAPIAnnotations));
|
||||
cliOptions.add(CliOption.newString(OPEN_API_SPEC_FILE_LOCATION, "Location where the file containing the spec will be generated in the output folder. No file generated when set to null or empty string."));
|
||||
cliOptions.add(CliOption.newBoolean(SUPPORT_ASYNC, "Wrap responses in CompletionStage type, allowing asynchronous computation (requires JAX-RS 2.1).", supportAsync));
|
||||
cliOptions.add(CliOption.newBoolean(USE_MUTINY, "Whether to use Smallrye Mutiny instead of CompletionStage for asynchronous computation. Only valid when library is set to quarkus.", useMutiny));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -167,6 +170,12 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||
writePropertyBack(USE_MICROPROFILE_OPENAPI_ANNOTATIONS, useMicroProfileOpenAPIAnnotations);
|
||||
}
|
||||
|
||||
if (QUARKUS_LIBRARY.equals(library)) {
|
||||
if (additionalProperties.containsKey(USE_MUTINY)) {
|
||||
useMutiny = Boolean.parseBoolean(additionalProperties.get(USE_MUTINY).toString());
|
||||
}
|
||||
writePropertyBack(USE_MUTINY, useMutiny);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(GENERATE_BUILDERS)) {
|
||||
generateBuilders = Boolean.parseBoolean(additionalProperties.get(GENERATE_BUILDERS).toString());
|
||||
|
||||
@@ -578,9 +578,14 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
private void processKotlinxDate() {
|
||||
additionalProperties.put(DateLibrary.KOTLINX_DATETIME.value, true);
|
||||
|
||||
typeMapping.put("date-time", "kotlinx.datetime.Instant");
|
||||
typeMapping.put("date-time", "Instant");
|
||||
typeMapping.put("date", "LocalDate");
|
||||
|
||||
typeMapping.put("DateTime", "Instant");
|
||||
typeMapping.put("Date", "LocalDate");
|
||||
|
||||
importMapping.put("Instant", "kotlinx.datetime.Instant");
|
||||
importMapping.put("LocalDate", "kotlinx.datetime.LocalDate");
|
||||
}
|
||||
|
||||
private void processJVMRetrofit2Library(String infrastructureFolder) {
|
||||
@@ -957,7 +962,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
|
||||
if (param.isQueryParam && "form".equals(param.style) && param.isExplode && param.isModel) {
|
||||
// query parameter (style: form, explode) referencing models need to import
|
||||
// models defined in the properties of the models
|
||||
operations.put("x-koltin-import-models", true);
|
||||
operations.put("x-kotlin-import-models", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,326 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.servers.Server;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.meta.features.DataTypeFeature;
|
||||
import org.openapitools.codegen.meta.features.DocumentationFeature;
|
||||
import org.openapitools.codegen.meta.features.GlobalFeature;
|
||||
import org.openapitools.codegen.meta.features.ParameterFeature;
|
||||
import org.openapitools.codegen.meta.features.SchemaSupportFeature;
|
||||
import org.openapitools.codegen.meta.features.SecurityFeature;
|
||||
import org.openapitools.codegen.meta.features.WireFormatFeature;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
import org.openapitools.codegen.model.OperationMap;
|
||||
import org.openapitools.codegen.model.OperationsMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class PhpFlightServerCodegen extends AbstractPhpCodegen {
|
||||
|
||||
private final Logger LOGGER = LoggerFactory.getLogger(PhpFlightServerCodegen.class);
|
||||
|
||||
// Type-hintable primitive types
|
||||
// ref: http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration
|
||||
protected HashSet<String> typeHintable = new HashSet<>(
|
||||
Arrays.asList(
|
||||
"array",
|
||||
"bool",
|
||||
"float",
|
||||
"int",
|
||||
"string"
|
||||
)
|
||||
);
|
||||
|
||||
public PhpFlightServerCodegen() {
|
||||
super();
|
||||
|
||||
modifyFeatureSet(features -> features
|
||||
.includeDocumentationFeatures(DocumentationFeature.Readme)
|
||||
.wireFormatFeatures(EnumSet.of(WireFormatFeature.JSON))
|
||||
.securityFeatures(EnumSet.of(
|
||||
SecurityFeature.BasicAuth,
|
||||
SecurityFeature.BearerToken,
|
||||
SecurityFeature.ApiKey,
|
||||
SecurityFeature.OAuth2_Implicit))
|
||||
.excludeDataTypeFeatures(
|
||||
DataTypeFeature.MapOfCollectionOfEnum,
|
||||
DataTypeFeature.MapOfEnum,
|
||||
DataTypeFeature.MapOfCollectionOfModel,
|
||||
DataTypeFeature.MapOfModel)
|
||||
.excludeParameterFeatures(
|
||||
ParameterFeature.FormMultipart,
|
||||
ParameterFeature.FormUnencoded,
|
||||
ParameterFeature.Cookie)
|
||||
.excludeGlobalFeatures(
|
||||
GlobalFeature.XMLStructureDefinitions,
|
||||
GlobalFeature.Callbacks,
|
||||
GlobalFeature.LinkObjects,
|
||||
GlobalFeature.ParameterStyling
|
||||
)
|
||||
.excludeSchemaSupportFeatures(
|
||||
SchemaSupportFeature.Polymorphism
|
||||
)
|
||||
);
|
||||
|
||||
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
|
||||
.stability(Stability.EXPERIMENTAL)
|
||||
.build();
|
||||
|
||||
embeddedTemplateDir = templateDir = "php-flight";
|
||||
|
||||
// clear import mapping (from default generator) as slim does not use it
|
||||
// at the moment
|
||||
importMapping.clear();
|
||||
|
||||
srcBasePath = "";
|
||||
|
||||
defaultIncludes = new HashSet<>(
|
||||
Arrays.asList(
|
||||
"\\DateTime"
|
||||
)
|
||||
);
|
||||
|
||||
variableNamingConvention = "camelCase";
|
||||
artifactVersion = "1.0.0";
|
||||
setInvokerPackage("OpenAPIServer");
|
||||
testPackage = invokerPackage + "\\Test";
|
||||
apiPackage = invokerPackage + "\\" + apiDirName;
|
||||
modelPackage = invokerPackage + "\\" + modelDirName;
|
||||
outputFolder = "generated-code" + File.separator + "php-flight";
|
||||
|
||||
// no doc files
|
||||
modelDocTemplateFiles.clear();
|
||||
apiDocTemplateFiles.clear();
|
||||
apiTestTemplateFiles.clear();
|
||||
|
||||
embeddedTemplateDir = templateDir = "php-flight";
|
||||
|
||||
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC)
|
||||
.defaultValue(Boolean.TRUE.toString()));
|
||||
cliOptions.stream().filter(o -> Objects.equals(o.getOpt(), VARIABLE_NAMING_CONVENTION)).findFirst().ifPresent(o -> o.defaultValue("camelCase"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.SERVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "php-flight";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a PHP Flight Framework server library.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
if (apiPackage.startsWith(invokerPackage + "\\")) {
|
||||
// need to strip out invokerPackage from path
|
||||
return (outputFolder + File.separator + toSrcPath(StringUtils.removeStart(apiPackage, invokerPackage + "\\"), srcBasePath));
|
||||
}
|
||||
return (outputFolder + File.separator + toSrcPath(apiPackage, srcBasePath));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelFileFolder() {
|
||||
if (modelPackage.startsWith(invokerPackage + "\\")) {
|
||||
// need to strip out invokerPackage from path
|
||||
return (outputFolder + File.separator + toSrcPath(StringUtils.removeStart(modelPackage, invokerPackage + "\\"), srcBasePath));
|
||||
}
|
||||
return (outputFolder + File.separator + toSrcPath(modelPackage, srcBasePath));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
inlineSchemaOption.put("RESOLVE_INLINE_ENUMS", "true");
|
||||
|
||||
// add trailing slash for mustache templates
|
||||
additionalProperties.put("relativeSrcBasePath", srcBasePath.isEmpty() ? "" : srcBasePath + "/");
|
||||
additionalProperties.put("modelSrcPath", "." + "/" + toSrcPath(modelPackage, srcBasePath));
|
||||
additionalProperties.put("apiSrcPath", "." + "/" + toSrcPath(apiPackage, srcBasePath));
|
||||
additionalProperties.put("testSrcPath", "." + "/" + toSrcPath(testPackage, srcBasePath));
|
||||
additionalProperties.put("escapedModelPackage", modelPackage.replace("\\", "\\\\"));
|
||||
|
||||
if (additionalProperties.containsKey("testPackage")) {
|
||||
// Update model package to contain the specified model package name and the invoker package
|
||||
testPackage = invokerPackage + "\\" + (String) additionalProperties.get("testPackage");
|
||||
}
|
||||
additionalProperties.put("testPackage", testPackage);
|
||||
|
||||
supportingFiles.add(new SupportingFile("composer.mustache", "", "composer.json"));
|
||||
supportingFiles.add(new SupportingFile("phpunit.mustache", "", "phpunit.xml.dist"));
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("register_routes.mustache", toSrcPath(invokerPackage, srcBasePath), "RegisterRoutes.php"));
|
||||
supportingFiles.add(new SupportingFile("register_routes_test.mustache", toSrcPath(testPackage, srcBasePath), "RegisterRoutesTest.php"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
List<CodegenOperation> operationList = operations.getOperation();
|
||||
operationList.forEach(operation -> {
|
||||
operation.vendorExtensions.put("x-path", mapToFlightPath(operation.path));
|
||||
String returnType = operation.responses.stream().filter(r -> r.is2xx && r.dataType != null).map(r -> this.getTypeHint(r.dataType, false, false)).filter(t -> !t.isEmpty()).map(t -> t + "|null").findFirst().orElse("void");
|
||||
operation.vendorExtensions.put("x-return-type", returnType);
|
||||
operation.vendorExtensions.put("x-return-type-is-void", returnType.equals("void"));
|
||||
operation.vendorExtensions.put("x-return-type-comment",
|
||||
operation.responses.stream().filter(r -> r.is2xx && r.dataType != null).map(r -> this.getTypeHint(r.dataType, true, false)).filter(t -> !t.isEmpty()).map(t -> t + "|null").findFirst().orElse("void"));
|
||||
operation.vendorExtensions.put("x-nonFormParams", operation.allParams.stream().filter(p -> !p.isFormParam).toArray());
|
||||
|
||||
operation.allParams.forEach(param -> {
|
||||
param.vendorExtensions.put("x-parameter-type", param.required ? getTypeHint(param.dataType, false, false) : getTypeHintNullable(param.dataType, false));
|
||||
String commentType = param.required ? getTypeHint(param.dataType, true, false) : getTypeHintNullable(param.dataType, false);
|
||||
param.vendorExtensions.put("x-comment-type", commentType);
|
||||
param.vendorExtensions.put("x-comment-type-escaped", commentType.replace("\\", "\\\\"));
|
||||
});
|
||||
});
|
||||
escapeMediaType(operationList);
|
||||
return objs;
|
||||
}
|
||||
|
||||
private String mapToFlightPath(String path) {
|
||||
return path.replaceAll("\\{([^}]+)}", "@$1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelsMap postProcessModels(ModelsMap objs) {
|
||||
objs = super.postProcessModels(objs);
|
||||
|
||||
ModelMap models = objs.getModels().get(0);
|
||||
CodegenModel model = models.getModel();
|
||||
|
||||
// Simplify model var type
|
||||
for (CodegenProperty var : model.vars) {
|
||||
if (var.dataType != null) {
|
||||
// Determine if the parameter type is supported as a type hint and make it available
|
||||
// to the templating engine
|
||||
var.vendorExtensions.put("x-parameter-type", var.required ? getTypeHint(var.dataType, false, true) : getTypeHintNullable(var.dataType, true));
|
||||
var.vendorExtensions.put("x-comment-type", var.required ? getTypeHint(var.dataType, true, true) : getTypeHintNullableForComments(var.dataType, true));
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
protected String getTypeHintNullable(String type, boolean modelContext) {
|
||||
String typeHint = getTypeHint(type, false, modelContext);
|
||||
if (!typeHint.equals("")) {
|
||||
return "?" + typeHint;
|
||||
}
|
||||
|
||||
return typeHint;
|
||||
}
|
||||
|
||||
protected String getTypeHintNullableForComments(String type, boolean modelContext) {
|
||||
String typeHint = getTypeHint(type, true, modelContext);
|
||||
if (!typeHint.equals("")) {
|
||||
return typeHint + "|null";
|
||||
}
|
||||
|
||||
return typeHint;
|
||||
}
|
||||
|
||||
protected String getTypeHint(String type, boolean forComments, boolean modelContext) {
|
||||
// Type hint array types
|
||||
if (type.endsWith("[]")) {
|
||||
if (forComments) {
|
||||
//Make type hints for array in comments. Call getTypeHint recursive for extractSimpleName for models
|
||||
String typeWithoutArray = type.substring(0, type.length() - 2);
|
||||
return this.getTypeHint(typeWithoutArray, true, modelContext) + "[]";
|
||||
} else {
|
||||
return "array";
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the type is a native type that is type hintable in PHP
|
||||
if (typeHintable.contains(type)) {
|
||||
return type;
|
||||
}
|
||||
|
||||
// Default includes are referenced by their fully-qualified class name (including namespace)
|
||||
if (defaultIncludes.contains(type)) {
|
||||
return type;
|
||||
}
|
||||
|
||||
// Model classes are assumed to be imported and we reference them by their class name
|
||||
if (isModelClass(type)) {
|
||||
// This parameter is an instance of a model
|
||||
return modelContext ? extractSimpleName(type) : type;
|
||||
}
|
||||
|
||||
// PHP does not support type hinting for this parameter data type
|
||||
return "";
|
||||
}
|
||||
|
||||
protected Boolean isModelClass(String type) {
|
||||
return Boolean.valueOf(type.contains(modelPackage()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
if (name.length() == 0) {
|
||||
return toAbstractName("DefaultApi");
|
||||
}
|
||||
return toAbstractName(camelize(name) + "Api");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiTestFilename(String name) {
|
||||
if (name.length() == 0) {
|
||||
return "DefaultApiTest";
|
||||
}
|
||||
return camelize(name) + "ApiTest";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenOperation fromOperation(String path,
|
||||
String httpMethod,
|
||||
Operation operation,
|
||||
List<Server> servers) {
|
||||
CodegenOperation op = super.fromOperation(path, httpMethod, operation, servers);
|
||||
op.path = encodePath(path);
|
||||
return op;
|
||||
}
|
||||
}
|
||||
@@ -270,10 +270,10 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
|
||||
|
||||
@Override
|
||||
public ModelsMap postProcessModels(ModelsMap objs) {
|
||||
// Remove the discriminator field from the model, serde will take care of this
|
||||
for (ModelMap model : objs.getModels()) {
|
||||
CodegenModel cm = model.getModel();
|
||||
|
||||
// Remove the discriminator field from the model, serde will take care of this
|
||||
if (cm.discriminator != null) {
|
||||
String reserved_var_name = cm.discriminator.getPropertyBaseName();
|
||||
|
||||
@@ -284,6 +284,14 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Flag structs with byteArrays in them so that we can annotate them with the serde_as macro
|
||||
for (CodegenProperty cp : cm.vars) {
|
||||
if (cp.isByteArray) {
|
||||
cm.vendorExtensions.put("x-rust-has-byte-array", true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// process enum in models
|
||||
return postProcessModelsEnum(objs);
|
||||
@@ -537,6 +545,11 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
|
||||
if (property.isNullable && !property.required) {
|
||||
additionalProperties.put("serdeWith", true);
|
||||
}
|
||||
|
||||
// If a property is a base64-encoded byte array, use `serde_with` for deserialization.
|
||||
if (property.isByteArray) {
|
||||
additionalProperties.put("serdeWith", true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -118,6 +118,7 @@ public class ScalaCaskServerCodegen extends AbstractScalaCodegen implements Code
|
||||
|
||||
cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, CodegenConstants.GROUP_ID_DESC));
|
||||
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, CodegenConstants.ARTIFACT_ID_DESC));
|
||||
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_VERSION, CodegenConstants.ARTIFACT_VERSION_DESC));
|
||||
cliOptions.add(new CliOption(CodegenConstants.GIT_REPO_ID, CodegenConstants.GIT_REPO_ID_DESC));
|
||||
cliOptions.add(new CliOption(CodegenConstants.GIT_USER_ID, CodegenConstants.GIT_USER_ID_DESC));
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, CodegenConstants.PACKAGE_DESCRIPTION));
|
||||
@@ -134,7 +135,7 @@ public class ScalaCaskServerCodegen extends AbstractScalaCodegen implements Code
|
||||
|
||||
@Override
|
||||
public String testPackage() {
|
||||
return "src/test/scala";
|
||||
return "jvm/src/test/scala";
|
||||
}
|
||||
|
||||
public String toModelTestFilename(String name) {
|
||||
@@ -158,6 +159,7 @@ public class ScalaCaskServerCodegen extends AbstractScalaCodegen implements Code
|
||||
final String groupId = ensureProp(CodegenConstants.GROUP_ID, "org.openapitools");
|
||||
ensureProp(CodegenConstants.ARTIFACT_ID, "caskgen");
|
||||
artifactVersion = ensureProp(CodegenConstants.ARTIFACT_VERSION, "0.0.1");
|
||||
|
||||
gitRepoId = ensureProp(CodegenConstants.GIT_REPO_ID, "<your git repo -- set 'gitRepoId'>");
|
||||
gitUserId = ensureProp(CodegenConstants.GIT_USER_ID, "<your git user -- set 'gitUserId'>");
|
||||
|
||||
@@ -166,8 +168,8 @@ public class ScalaCaskServerCodegen extends AbstractScalaCodegen implements Code
|
||||
modelPackage = ensureProp(CodegenConstants.MODEL_PACKAGE, basePackage + ".model");
|
||||
|
||||
|
||||
final String apiPath = "src/main/scala/" + apiPackage.replace('.', '/');
|
||||
final String modelPath = "src/main/scala/" + modelPackage.replace('.', '/');
|
||||
final String apiPath = "jvm/src/main/scala/" + apiPackage.replace('.', '/');
|
||||
final String modelPath = "shared/src/main/scala/" + modelPackage.replace('.', '/');
|
||||
|
||||
final List<String> appFullPath = Arrays.stream(apiPath.split("/")).collect(Collectors.toList());
|
||||
final String appFolder = String.join("/", appFullPath.subList(0, appFullPath.size() - 1));
|
||||
@@ -186,7 +188,7 @@ public class ScalaCaskServerCodegen extends AbstractScalaCodegen implements Code
|
||||
supportingFiles.add(new SupportingFile("Dockerfile.mustache", "example", "Dockerfile"));
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("build.sbt.mustache", "", "build.sbt"));
|
||||
supportingFiles.add(new SupportingFile("bulidAndPublish.yml.mustache", "", ".github/workflows/bulidAndPublish.yml"));
|
||||
supportingFiles.add(new SupportingFile("buildAndPublish.yml.mustache", "", ".github/workflows/buildAndPublish.yml"));
|
||||
supportingFiles.add(new SupportingFile("build.sc.mustache", "", "build.sc"));
|
||||
supportingFiles.add(new SupportingFile(".scalafmt.conf.mustache", "", ".scalafmt.conf"));
|
||||
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
||||
@@ -274,6 +276,16 @@ public class ScalaCaskServerCodegen extends AbstractScalaCodegen implements Code
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + "/jvm/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + "/shared/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
static String capitalise(String p) {
|
||||
if (p.length() < 2) {
|
||||
return p.toUpperCase(Locale.ROOT);
|
||||
@@ -323,7 +335,7 @@ public class ScalaCaskServerCodegen extends AbstractScalaCodegen implements Code
|
||||
String jsonOpenAPI = SerializerUtils.toJsonString(openAPI);
|
||||
|
||||
try {
|
||||
String outputFile = getOutputDir() + "/" + getResourceFolder() + "/openapi.json";
|
||||
String outputFile = getOutputDir() + "/jvm/" + getResourceFolder() + "/openapi.json";
|
||||
FileUtils.writeStringToFile(new File(outputFile), jsonOpenAPI, StandardCharsets.UTF_8);
|
||||
LOGGER.info("wrote file to {}", outputFile);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -340,6 +340,12 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
this.processCodeGenModel(cm);
|
||||
}
|
||||
|
||||
// Add supporting file only if we plan to generate files in /models
|
||||
if (!objs.isEmpty() && !addedModelIndex) {
|
||||
addedModelIndex = true;
|
||||
supportingFiles.add(new SupportingFile("models.index.mustache", modelPackage().replace('.', File.separatorChar), "index.ts"));
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}}{{#vendorExtensi
|
||||
{{#jsonb}}@JsonbCreator{{/jsonb}}{{#jackson}}@JsonCreator{{/jackson}}
|
||||
public {{classname}}(
|
||||
{{#readOnlyVars}}
|
||||
{{#jsonb}}@JsonbProperty(value = "{{baseName}}"{{^required}}, nillable = true{{/required}}){{/jsonb}}{{#jackson}}@JsonProperty(JSON_PROPERTY_{{nameInSnakeCase}}{{#required}}, required = true{{/required}}){{/jackson}} {{{datatypeWithEnum}}} {{name}}{{^-last}}, {{/-last}}
|
||||
{{#jsonb}}@JsonbProperty(value = "{{baseName}}"{{^required}}, nillable = true{{/required}}){{/jsonb}}{{#jackson}}@JsonProperty(value = JSON_PROPERTY_{{nameInSnakeCase}}{{#required}}, required = true{{/required}}){{/jackson}} {{{datatypeWithEnum}}} {{name}}{{^-last}}, {{/-last}}
|
||||
{{/readOnlyVars}}
|
||||
) {
|
||||
{{#readOnlyVars}}
|
||||
|
||||
@@ -15,8 +15,13 @@ import io.swagger.annotations.*;
|
||||
{{/useSwaggerAnnotations}}
|
||||
|
||||
{{#supportAsync}}
|
||||
{{#useMutiny}}
|
||||
import io.smallrye.mutiny.Uni;
|
||||
{{/useMutiny}}
|
||||
{{^useMutiny}}
|
||||
import java.util.concurrent.CompletionStage;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
{{/useMutiny}}
|
||||
{{/supportAsync}}
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
@@ -40,6 +40,6 @@
|
||||
{{^vendorExtensions.x-java-is-response-void}}@org.eclipse.microprofile.openapi.annotations.media.Content(schema = @org.eclipse.microprofile.openapi.annotations.media.Schema(implementation = {{{baseType}}}.class{{#vendorExtensions.x-microprofile-open-api-return-schema-container}}, type = {{{.}}} {{/vendorExtensions.x-microprofile-open-api-return-schema-container}}{{#vendorExtensions.x-microprofile-open-api-return-unique-items}}, uniqueItems = true {{/vendorExtensions.x-microprofile-open-api-return-unique-items}})){{/vendorExtensions.x-java-is-response-void}}
|
||||
}){{^-last}},{{/-last}}{{/responses}}
|
||||
}){{/hasProduces}}{{/useMicroProfileOpenAPIAnnotations}}
|
||||
public {{#supportAsync}}CompletionStage<{{/supportAsync}}Response{{#supportAsync}}>{{/supportAsync}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>cookieParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}) {
|
||||
return {{#supportAsync}}CompletableFuture.supplyAsync(() -> {{/supportAsync}}Response.ok().entity("magic!").build(){{#supportAsync}}){{/supportAsync}};
|
||||
public {{#supportAsync}}{{#useMutiny}}Uni{{/useMutiny}}{{^useMutiny}}CompletionStage{{/useMutiny}}<{{/supportAsync}}Response{{#supportAsync}}>{{/supportAsync}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>cookieParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}) {
|
||||
return {{#supportAsync}}{{#useMutiny}}Uni.createFrom().item({{/useMutiny}}{{^useMutiny}}CompletableFuture.supplyAsync(() -> {{/useMutiny}}{{/supportAsync}}Response.ok().entity("magic!").build(){{#supportAsync}}){{/supportAsync}};
|
||||
}
|
||||
@@ -44,6 +44,9 @@
|
||||
{{#useSwaggerAnnotations}}
|
||||
<io.swagger.annotations.version>1.6.10</io.swagger.annotations.version>
|
||||
{{/useSwaggerAnnotations}}
|
||||
{{#useMutiny}}
|
||||
<smallrye.rest.client.version>1.2.1</smallrye.rest.client.version>
|
||||
{{/useMutiny}}
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
@@ -109,6 +112,14 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
{{/useSwaggerAnnotations}}
|
||||
{{#useMutiny}}
|
||||
<dependency>
|
||||
<groupId>io.smallrye</groupId>
|
||||
<artifactId>smallrye-rest-client</artifactId>
|
||||
<version>${smallrye.rest.client.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
{{/useMutiny}}
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{{#useMutiny}}Uni{{/useMutiny}}{{^useMutiny}}CompletionStage{{/useMutiny}}<{{#returnResponse}}Response{{/returnResponse}}{{^returnResponse}}{{#returnContainer}}{{#isMap}}Map<String, {{{returnBaseType}}}>{{/isMap}}{{#isArray}}{{{returnContainer}}}<{{{returnBaseType}}}>{{/isArray}}{{/returnContainer}}{{^returnContainer}}{{{returnBaseType}}}{{/returnContainer}}{{/returnResponse}}>
|
||||
@@ -91,6 +91,7 @@ org.openapitools.codegen.languages.OpenAPIYamlGenerator
|
||||
org.openapitools.codegen.languages.PlantumlDocumentationCodegen
|
||||
org.openapitools.codegen.languages.PerlClientCodegen
|
||||
org.openapitools.codegen.languages.PhpClientCodegen
|
||||
org.openapitools.codegen.languages.PhpFlightServerCodegen
|
||||
org.openapitools.codegen.languages.PhpNextgenClientCodegen
|
||||
org.openapitools.codegen.languages.PhpLaravelServerCodegen
|
||||
org.openapitools.codegen.languages.PhpLumenServerCodegen
|
||||
|
||||
46
modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/anytype-header.mustache
vendored
Normal file
46
modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/anytype-header.mustache
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
{{>licenseInfo}}
|
||||
/*
|
||||
* AnyType.h
|
||||
*
|
||||
* This is the implementation of an any JSON type.
|
||||
*/
|
||||
|
||||
#ifndef {{modelHeaderGuardPrefix}}_AnyType_H_
|
||||
#define {{modelHeaderGuardPrefix}}_AnyType_H_
|
||||
|
||||
{{{defaultInclude}}}
|
||||
#include "{{packageName}}/Object.h"
|
||||
|
||||
#include <cpprest/details/basic_types.h>
|
||||
#include <cpprest/json.h>
|
||||
|
||||
{{#modelNamespaceDeclarations}}
|
||||
namespace {{this}} {
|
||||
{{/modelNamespaceDeclarations}}
|
||||
|
||||
class {{declspec}} AnyType : public Object {
|
||||
public:
|
||||
AnyType();
|
||||
virtual ~AnyType();
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// ModelBase overrides
|
||||
void validate() override;
|
||||
|
||||
web::json::value toJson() const override;
|
||||
bool fromJson(const web::json::value &json) override;
|
||||
|
||||
void toMultipart(std::shared_ptr<MultipartFormData> multipart,
|
||||
const utility::string_t &namePrefix) const override;
|
||||
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart,
|
||||
const utility::string_t &namePrefix) override;
|
||||
|
||||
private:
|
||||
web::json::value m_value;
|
||||
};
|
||||
|
||||
{{#modelNamespaceDeclarations}}
|
||||
}
|
||||
{{/modelNamespaceDeclarations}}
|
||||
|
||||
#endif /* {{modelHeaderGuardPrefix}}_AnyType_H_ */
|
||||
40
modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/anytype-source.mustache
vendored
Normal file
40
modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/anytype-source.mustache
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
{{>licenseInfo}}
|
||||
#include "{{packageName}}/AnyType.h"
|
||||
|
||||
{{#modelNamespaceDeclarations}}
|
||||
namespace {{this}} {
|
||||
{{/modelNamespaceDeclarations}}
|
||||
|
||||
AnyType::AnyType() { m_value = web::json::value::null(); }
|
||||
|
||||
AnyType::~AnyType() {}
|
||||
|
||||
void AnyType::validate() {}
|
||||
|
||||
web::json::value AnyType::toJson() const { return m_value; }
|
||||
|
||||
bool AnyType::fromJson(const web::json::value &val) {
|
||||
m_value = val;
|
||||
m_IsSet = true;
|
||||
return isSet();
|
||||
}
|
||||
|
||||
void AnyType::toMultipart(std::shared_ptr<MultipartFormData> multipart,
|
||||
const utility::string_t &prefix) const {
|
||||
if (m_value.is_object()) {
|
||||
return Object::toMultipart(multipart, prefix);
|
||||
}
|
||||
throw std::runtime_error("AnyType::toMultipart: unsupported type");
|
||||
}
|
||||
|
||||
bool AnyType::fromMultiPart(std::shared_ptr<MultipartFormData> multipart,
|
||||
const utility::string_t &prefix) {
|
||||
if (m_value.is_object()) {
|
||||
return Object::fromMultiPart(multipart, prefix);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
{{#modelNamespaceDeclarations}}
|
||||
}
|
||||
{{/modelNamespaceDeclarations}}
|
||||
@@ -82,7 +82,7 @@ namespace {{packageName}}.Client
|
||||
/// <param name="path">Path</param>
|
||||
/// <param name="requestOptions">Request options</param>
|
||||
/// <returns>Http signed headers</returns>
|
||||
internal Dictionary<string, string> GetHttpSignedHeader(string basePath,string method, string path, RequestOptions requestOptions)
|
||||
public Dictionary<string, string> GetHttpSignedHeader(string basePath,string method, string path, RequestOptions requestOptions)
|
||||
{
|
||||
const string HEADER_REQUEST_TARGET = "(request-target)";
|
||||
//The time when the HTTP signature expires. The API server should reject HTTP requests
|
||||
|
||||
@@ -300,14 +300,14 @@
|
||||
|
||||
{{/-last}}
|
||||
{{/required}}
|
||||
return new {{classname}}({{#lambda.joinWithComma}}{{#model.composedSchemas.anyOf}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}ParsedValue{{#required}}.Value{{^isNullable}}{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{nrt!}}{{/vendorExtensions.x-is-value-type}}{{/isNullable}}{{/required}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#required}}.Value{{nrt!}}{{^isNullable}}{{#vendorExtensions.x-is-value-type}}.Value{{nrt!}}{{/vendorExtensions.x-is-value-type}}{{/isNullable}}{{/required}} {{/allVars}}{{/lambda.joinWithComma}});
|
||||
return new {{classname}}({{#lambda.joinWithComma}}{{#model.composedSchemas.anyOf}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}ParsedValue{{#required}}.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{nrt!}}{{/vendorExtensions.x-is-value-type}}{{/required}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#required}}.Value{{nrt!}}{{^isNullable}}{{#vendorExtensions.x-is-value-type}}.Value{{nrt!}}{{/vendorExtensions.x-is-value-type}}{{/isNullable}}{{/required}} {{/allVars}}{{/lambda.joinWithComma}});
|
||||
{{/composedSchemas.oneOf}}
|
||||
{{^model.discriminator}}
|
||||
{{#composedSchemas}}
|
||||
{{#oneOf}}
|
||||
{{^vendorExtensions.x-duplicated-data-type}}
|
||||
if ({{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}} != null)
|
||||
return new {{classname}}({{#lambda.joinWithComma}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{#model.composedSchemas.anyOf}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#required}}ParsedValue{{/required}} {{/allVars}}{{/lambda.joinWithComma}});
|
||||
return new {{classname}}({{#lambda.joinWithComma}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#vendorExtensions.x-is-value-type}}.Value{{/vendorExtensions.x-is-value-type}} {{#model.composedSchemas.anyOf}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#vendorExtensions.x-is-value-type}}{{^isNullable}}.Value{{/isNullable}}{{/vendorExtensions.x-is-value-type}} {{/model.composedSchemas.anyOf}}{{#allVars}}{{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}{{#required}}ParsedValue{{/required}} {{/allVars}}{{/lambda.joinWithComma}});
|
||||
|
||||
{{/vendorExtensions.x-duplicated-data-type}}
|
||||
{{#-last}}
|
||||
|
||||
@@ -24,7 +24,7 @@ require (
|
||||
github.com/ugorji/go/codec v1.2.11 // indirect
|
||||
golang.org/x/arch v0.3.0 // indirect
|
||||
golang.org/x/crypto v0.9.0 // indirect
|
||||
golang.org/x/net v0.10.0 // indirect
|
||||
golang.org/x/net v0.23.0 // indirect
|
||||
golang.org/x/sys v0.8.0 // indirect
|
||||
golang.org/x/text v0.9.0 // indirect
|
||||
google.golang.org/protobuf v1.33.0 // indirect
|
||||
|
||||
@@ -337,6 +337,7 @@ func (o {{classname}}) ToMap() (map[string]interface{}, error) {
|
||||
return toSerialize, nil
|
||||
}
|
||||
|
||||
{{#vendorExtensions.x-go-generate-unmarshal-json}}
|
||||
{{#isAdditionalPropertiesTrue}}
|
||||
func (o *{{{classname}}}) UnmarshalJSON(data []byte) (err error) {
|
||||
{{/isAdditionalPropertiesTrue}}
|
||||
@@ -514,4 +515,5 @@ func (o *{{{classname}}}) UnmarshalJSON(data []byte) (err error) {
|
||||
}
|
||||
|
||||
{{/isArray}}
|
||||
{{/vendorExtensions.x-go-generate-unmarshal-json}}
|
||||
{{>nullable_model}}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<version.logback>1.4.13</version.logback>
|
||||
<version.junit>4.13.2</version.junit>
|
||||
<version.mockito>2.1.0-beta.124</version.mockito>
|
||||
<version.undertow>2.3.5.Final</version.undertow>
|
||||
<version.undertow>2.3.12.Final</version.undertow>
|
||||
<version.jsonpath>2.2.0</version.jsonpath>
|
||||
<version.httpclient>4.5.13</version.httpclient>
|
||||
<version.httpasyncclient>4.1.2</version.httpasyncclient>
|
||||
|
||||
@@ -59,10 +59,10 @@ import kotlinx.serialization.*
|
||||
{{/imports}}
|
||||
|
||||
{{#operations}}
|
||||
{{#x-koltin-import-models}}
|
||||
import {{{packageName}}}.models.*
|
||||
{{#x-kotlin-import-models}}
|
||||
import {{{modelPackage}}}.*
|
||||
|
||||
{{/x-koltin-import-models}}
|
||||
{{/x-kotlin-import-models}}
|
||||
{{#x-kotlin-multipart-import}}
|
||||
{{^isMultipart}}
|
||||
import okhttp3.MultipartBody
|
||||
|
||||
@@ -99,13 +99,13 @@ import kotlinx.serialization.encoding.*
|
||||
{{/hasBodyParam}}
|
||||
|
||||
val localVariableQuery = mutableMapOf<String, List<String>>(){{#queryParams}}
|
||||
{{{paramName}}}?.apply { localVariableQuery["{{baseName}}"] = {{#isContainer}}toMultiValue(this, "{{collectionFormat}}"){{/isContainer}}{{^isContainer}}listOf("${{{paramName}}}"){{/isContainer}} }{{/queryParams}}
|
||||
{{{paramName}}}?.apply { localVariableQuery["{{baseName}}"] = {{#isContainer}}toMultiValue(this, "{{collectionFormat}}"){{/isContainer}}{{^isContainer}}listOf({{^isEnum}}"${{{paramName}}}"{{/isEnum}}{{#isEnum}}"${ {{paramName}}.value }"{{/isEnum}}){{/isContainer}} }{{/queryParams}}
|
||||
val localVariableHeaders = mutableMapOf<String, String>(){{#headerParams}}
|
||||
{{{paramName}}}?.apply { localVariableHeaders["{{baseName}}"] = {{#isContainer}}this.joinToString(separator = collectionDelimiter("{{collectionFormat}}")){{/isContainer}}{{^isContainer}}this.toString(){{/isContainer}} }{{/headerParams}}
|
||||
|
||||
val localVariableConfig = RequestConfig<kotlin.Any?>(
|
||||
RequestMethod.{{httpMethod}},
|
||||
"{{path}}"{{#pathParams}}.replace("{" + "{{baseName}}" + "}", {{#isContainer}}{{paramName}}.joinToString(","){{/isContainer}}{{^isContainer}}"${{{paramName}}}"{{/isContainer}}){{/pathParams}},
|
||||
"{{path}}"{{#pathParams}}.replace("{" + "{{baseName}}" + "}", {{#isContainer}}{{paramName}}.joinToString(","){{/isContainer}}{{^isContainer}}{{^isEnum}}"${{{paramName}}}"{{/isEnum}}{{#isEnum}}"${ {{paramName}}.value }"{{/isEnum}}{{/isContainer}}){{/pathParams}},
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders,
|
||||
requiresAuthentication = {{#hasAuthMethods}}true{{/hasAuthMethods}}{{^hasAuthMethods}}false{{/hasAuthMethods}},
|
||||
|
||||
10
modules/openapi-generator/src/main/resources/php-flight/README.mustache
vendored
Normal file
10
modules/openapi-generator/src/main/resources/php-flight/README.mustache
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
## Requirements
|
||||
|
||||
PHP 8.1 and later
|
||||
|
||||
## Installation & Usage
|
||||
|
||||
1. Set up flight as usual - see [Flight documentation](https://docs.flightphp.com/install)
|
||||
2. Generate using the OpenAPI generator
|
||||
3. Subclass some/all generated `Abstract*Api` and overwrite the methods you'd like handled. When implementing the `*Stream` methods, make sure to stream the response and not implement the non-stream method.
|
||||
4. Register routes for your subclassed apis: `RegisterRoutes::registerRoutes(new MyApiHandler());`
|
||||
57
modules/openapi-generator/src/main/resources/php-flight/api.mustache
vendored
Normal file
57
modules/openapi-generator/src/main/resources/php-flight/api.mustache
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
{{>licenseInfo}}
|
||||
|
||||
namespace {{apiPackage}};
|
||||
|
||||
|
||||
{{#operations}}abstract class {{classname}}
|
||||
{
|
||||
|
||||
{{#operation}}
|
||||
/**
|
||||
* Operation {{{operationId}}}
|
||||
* Path: {{{path}}}
|
||||
*
|
||||
{{#summary}}
|
||||
* {{{summary}}}
|
||||
*
|
||||
{{/summary}}
|
||||
{{#vendorExtensions.x-nonFormParams}}
|
||||
* @param {{vendorExtensions.x-parameter-type}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}
|
||||
{{/vendorExtensions.x-nonFormParams}}
|
||||
*
|
||||
* @return {{vendorExtensions.x-return-type-comment}}
|
||||
{{#isDeprecated}}
|
||||
* @deprecated
|
||||
{{/isDeprecated}}
|
||||
*/
|
||||
public function {{operationId}}({{#vendorExtensions.x-nonFormParams}}{{vendorExtensions.x-parameter-type}} ${{paramName}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-nonFormParams}}): {{vendorExtensions.x-return-type}}
|
||||
{
|
||||
throw new \Exception('Not implemented');
|
||||
}
|
||||
|
||||
{{#returnContainer}}
|
||||
/**
|
||||
* Operation {{{operationId}}} (stream)
|
||||
*
|
||||
{{#summary}}
|
||||
* {{{summary}}}
|
||||
*
|
||||
{{/summary}}
|
||||
{{#vendorExtensions.x-nonFormParams}}
|
||||
* @param {{vendorExtensions.x-parameter-type}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}
|
||||
{{/vendorExtensions.x-nonFormParams}}
|
||||
*
|
||||
{{#isDeprecated}}
|
||||
* @deprecated
|
||||
{{/isDeprecated}}
|
||||
*/
|
||||
public function {{operationId}}Stream({{#vendorExtensions.x-nonFormParams}}{{vendorExtensions.x-parameter-type}} ${{paramName}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-nonFormParams}}): void
|
||||
{
|
||||
throw new \Exception('Not implemented');
|
||||
}
|
||||
{{/returnContainer}}
|
||||
{{/operation}}
|
||||
}
|
||||
{{/operations}}
|
||||
39
modules/openapi-generator/src/main/resources/php-flight/composer.mustache
vendored
Normal file
39
modules/openapi-generator/src/main/resources/php-flight/composer.mustache
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
{{#composerPackageName}}
|
||||
"name": "{{{.}}}",
|
||||
{{/composerPackageName}}
|
||||
"description": "{{appDescription}}.",
|
||||
"keywords": ["openapi", "php", "framework", "flightphp"],
|
||||
{{#artifactVersion}}
|
||||
"version": "{{.}}",
|
||||
{{/artifactVersion}}
|
||||
"homepage": "{{{artifactUrl}}}",
|
||||
"license": "{{{licenseName}}}",
|
||||
"authors": [
|
||||
{
|
||||
"name": "{{{developerOrganization}}}",
|
||||
"homepage": "{{{developerOrganizationUrl}}}"
|
||||
}
|
||||
],
|
||||
"type": "library",
|
||||
"require": {
|
||||
"php": "^8.1.0",
|
||||
"flightphp/core": "^3.5.1",
|
||||
"ext-json": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.5"
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"{{escapedInvokerPackage}}\\": ""
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore
|
||||
|
||||
composer.phar
|
||||
/vendor/
|
||||
|
||||
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
|
||||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
|
||||
# composer.lock
|
||||
|
||||
# phplint tool creates cache file which is not necessary in a codebase
|
||||
/.phplint-cache
|
||||
|
||||
# Do not commit local PHPUnit config
|
||||
/phpunit.xml
|
||||
/.phpunit.result.cache
|
||||
|
||||
# Do not commit local PHP_CodeSniffer config
|
||||
/phpcs.xml
|
||||
|
||||
# Application config may contain sensitive data
|
||||
/config/**/*.*
|
||||
!/config/.htaccess
|
||||
!/config/dev/default.inc.php
|
||||
!/config/prod/default.inc.php
|
||||
|
||||
# Logs folder
|
||||
/logs/**/*.*
|
||||
!/logs/.htaccess
|
||||
23
modules/openapi-generator/src/main/resources/php-flight/licenseInfo.mustache
vendored
Normal file
23
modules/openapi-generator/src/main/resources/php-flight/licenseInfo.mustache
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
{{#appName}}
|
||||
* {{{.}}}
|
||||
{{/appName}}
|
||||
* PHP version 8.x
|
||||
*
|
||||
* @package {{invokerPackage}}
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
*/
|
||||
|
||||
/**
|
||||
{{#appDescription}}
|
||||
* {{{.}}}
|
||||
{{/appDescription}}
|
||||
{{#version}}
|
||||
* The version of the OpenAPI document: {{{.}}}
|
||||
{{/version}}
|
||||
{{#infoEmail}}
|
||||
* Contact: {{{.}}}
|
||||
{{/infoEmail}}
|
||||
* Generated by: https://github.com/openapitools/openapi-generator.git
|
||||
*/
|
||||
31
modules/openapi-generator/src/main/resources/php-flight/model.mustache
vendored
Normal file
31
modules/openapi-generator/src/main/resources/php-flight/model.mustache
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
/**
|
||||
* {{classname}}
|
||||
*
|
||||
* PHP version 8.1.1
|
||||
*
|
||||
* @category Class
|
||||
* @package {{modelPackage}}
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://github.com/openapitools/openapi-generator
|
||||
*/
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
namespace {{modelPackage}};
|
||||
|
||||
/**
|
||||
* Class representing the {{classname}} model.
|
||||
*
|
||||
{{#description}}
|
||||
* {{.}}
|
||||
*
|
||||
{{/description}}
|
||||
* @package {{modelPackage}}
|
||||
* @author OpenAPI Generator team
|
||||
*/
|
||||
{{#isEnum}}{{>model_enum}}{{/isEnum}}
|
||||
{{^isEnum}}{{>model_generic}}{{/isEnum}}
|
||||
{{/model}}{{/models}}
|
||||
8
modules/openapi-generator/src/main/resources/php-flight/model_enum.mustache
vendored
Normal file
8
modules/openapi-generator/src/main/resources/php-flight/model_enum.mustache
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
enum {{classname}}: {{dataType}}
|
||||
{
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
case {{{name}}} = {{{value}}};
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
}
|
||||
90
modules/openapi-generator/src/main/resources/php-flight/model_generic.mustache
vendored
Normal file
90
modules/openapi-generator/src/main/resources/php-flight/model_generic.mustache
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}} implements \JsonSerializable
|
||||
{
|
||||
{{#vars}}{{>model_variables}}
|
||||
{{/vars}}
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
{{#vars}}
|
||||
* @param {{vendorExtensions.x-comment-type}} ${{name}}
|
||||
{{/vars}}
|
||||
*/
|
||||
public function __construct({{#vars}}{{vendorExtensions.x-parameter-type}} ${{name}}{{^-last}}, {{/-last}}{{/vars}})
|
||||
{
|
||||
{{#vars}}
|
||||
$this->{{name}} = ${{name}};
|
||||
{{/vars}}
|
||||
}
|
||||
|
||||
public static function fromArray(array $data): self
|
||||
{
|
||||
return new self(
|
||||
{{#vars}}
|
||||
{{#isDateTime}}
|
||||
isset($data['{{baseName}}']) ? new \DateTime($data['{{baseName}}']) : null{{^last}}, {{/last}}
|
||||
{{/isDateTime}}
|
||||
{{#isEnum}}
|
||||
isset($data['{{baseName}}']) ? {{enumName}}::tryFrom($data['{{baseName}}']) : null{{^last}}, {{/last}}
|
||||
{{/isEnum}}
|
||||
{{#isEnumRef}}
|
||||
isset($data['{{baseName}}']) ? {{complexType}}::tryFrom($data['{{baseName}}']) : null{{^last}}, {{/last}}
|
||||
{{/isEnumRef}}
|
||||
{{#isModel}}
|
||||
isset($data['{{baseName}}']) ? {{complexType}}::fromArray($data['{{baseName}}']) : null{{^last}}, {{/last}}
|
||||
{{/isModel}}
|
||||
{{#isArray}}
|
||||
{{#items.isEnumRef}}
|
||||
isset($data['{{baseName}}']) ? array_map(fn($item) => {{items.complexType}}::tryFrom($item), $data['{{baseName}}']) : null{{^last}}, {{/last}}
|
||||
{{/items.isEnumRef}}
|
||||
{{#items.isModel}}
|
||||
isset($data['{{baseName}}']) ? array_map(fn($item) => {{items.complexType}}::fromArray($item), $data['{{baseName}}']) : null{{^last}}, {{/last}}
|
||||
{{/items.isModel}}
|
||||
{{#items.isDateTime}}
|
||||
isset($data['{{baseName}}']) ? array_map(fn($item) => new \DateTime($item), $data['{{baseName}}']) : null{{^last}}, {{/last}}
|
||||
{{/items.isDateTime}}
|
||||
{{^items.isEnumRef}}
|
||||
{{^items.isModel}}
|
||||
{{^items.isDateTime}}
|
||||
$data['{{baseName}}'] ?? null{{^last}}, {{/last}}
|
||||
{{/items.isDateTime}}
|
||||
{{/items.isModel}}
|
||||
{{/items.isEnumRef}}
|
||||
{{/isArray}}
|
||||
{{^isEnumRef}}
|
||||
{{^isEnum}}
|
||||
{{^isModel}}
|
||||
{{^isArray}}
|
||||
{{^isDateTime}}
|
||||
$data['{{baseName}}'] ?? null{{^last}}, {{/last}}
|
||||
{{/isDateTime}}
|
||||
{{/isArray}}
|
||||
{{/isModel}}
|
||||
{{/isEnum}}
|
||||
{{/isEnumRef}}
|
||||
{{/vars}}
|
||||
);
|
||||
}
|
||||
|
||||
public function jsonSerialize(): mixed {
|
||||
return [
|
||||
{{#vars}}
|
||||
{{#isDateTime}}
|
||||
'{{baseName}}' => $this->{{name}}?->format('c'){{^last}}, {{/last}}
|
||||
{{/isDateTime}}
|
||||
{{#isArray}}
|
||||
{{#items.isDateTime}}
|
||||
'{{baseName}}' => $this->{{name}} ? array_map(fn($item) => $item->format('c'), $this->{{name}}) : null{{^last}}, {{/last}}
|
||||
{{/items.isDateTime}}
|
||||
{{^items.isDateTime}}
|
||||
'{{baseName}}' => $this->{{name}}{{^last}}, {{/last}}
|
||||
{{/items.isDateTime}}
|
||||
{{/isArray}}
|
||||
{{^isDateTime}}
|
||||
{{^isArray}}
|
||||
'{{baseName}}' => $this->{{name}}{{^last}}, {{/last}}
|
||||
{{/isArray}}
|
||||
{{/isDateTime}}
|
||||
{{/vars}}
|
||||
];
|
||||
}
|
||||
}
|
||||
113
modules/openapi-generator/src/main/resources/php-flight/model_variables.mustache
vendored
Normal file
113
modules/openapi-generator/src/main/resources/php-flight/model_variables.mustache
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
/**
|
||||
{{#description}}
|
||||
* {{.}}
|
||||
*
|
||||
{{/description}}
|
||||
* @var {{{vendorExtensions.x-comment-type}}}
|
||||
* @SerializedName("{{baseName}}")
|
||||
{{#required}}
|
||||
* @Assert\NotNull()
|
||||
{{^isPrimitiveType}}
|
||||
* @Assert\Valid()
|
||||
{{/isPrimitiveType}}
|
||||
{{/required}}
|
||||
{{#isEnum}}
|
||||
{{#isContainer}}
|
||||
* @Assert\All({
|
||||
{{#items}}
|
||||
* @Assert\Choice({ {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}} })
|
||||
{{/items}}
|
||||
* })
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
* @Assert\Choice({ {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}} })
|
||||
{{/isContainer}}
|
||||
{{/isEnum}}
|
||||
{{#isContainer}}
|
||||
* @Assert\All({
|
||||
{{#items}}
|
||||
* @Assert\Type("{{dataType}}")
|
||||
{{/items}}
|
||||
* })
|
||||
{{#isMap}}
|
||||
{{#items}}
|
||||
* @Type("array<string, {{dataType}}>")
|
||||
{{/items}}
|
||||
{{/isMap}}
|
||||
{{^isMap}}
|
||||
{{#items}}
|
||||
{{#isEnumRef}}
|
||||
* @Accessor(getter="getSerialized{{nameInPascalCase}}")
|
||||
* @Type("array<string>")
|
||||
{{/isEnumRef}}
|
||||
{{^isEnumRef}}
|
||||
* @Type("array<{{dataType}}>")
|
||||
{{/isEnumRef}}
|
||||
{{/items}}
|
||||
{{/isMap}}
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
{{#isDate}}
|
||||
* @Assert\Type("\Date")
|
||||
* @Type("DateTime<'Y-m-d'>")
|
||||
{{/isDate}}
|
||||
{{#isDateTime}}
|
||||
* @Assert\Type("\DateTime"))
|
||||
* @Type("DateTime")
|
||||
{{/isDateTime}}
|
||||
{{#isEnumRef}}
|
||||
* @Accessor(getter="getSerialized{{nameInPascalCase}}")
|
||||
* @Type("string")
|
||||
{{/isEnumRef}}
|
||||
{{^isDate}}
|
||||
{{^isDateTime}}
|
||||
{{^isEnumRef}}
|
||||
* @Assert\Type("{{dataType}}")
|
||||
* @Type("{{dataType}}")
|
||||
{{/isEnumRef}}
|
||||
{{/isDateTime}}
|
||||
{{/isDate}}
|
||||
{{/isContainer}}
|
||||
{{#hasValidation}}
|
||||
{{#maxLength}}
|
||||
* @Assert\Length(
|
||||
* max = {{.}}
|
||||
* )
|
||||
{{/maxLength}}
|
||||
{{#minLength}}
|
||||
* @Assert\Length(
|
||||
* min = {{.}}
|
||||
* )
|
||||
{{/minLength}}
|
||||
{{#minimum}}
|
||||
{{#exclusiveMinimum}}
|
||||
* @Assert\GreaterThan({{minimum}})
|
||||
{{/exclusiveMinimum}}
|
||||
{{^exclusiveMinimum}}
|
||||
* @Assert\GreaterThanOrEqual({{minimum}})
|
||||
{{/exclusiveMinimum}}
|
||||
{{/minimum}}
|
||||
{{#maximum}}
|
||||
{{#exclusiveMaximum}}
|
||||
* @Assert\LessThan({{maximum}})
|
||||
{{/exclusiveMaximum}}
|
||||
{{^exclusiveMaximum}}
|
||||
* @Assert\LessThanOrEqual({{maximum}})
|
||||
{{/exclusiveMaximum}}
|
||||
{{/maximum}}
|
||||
{{#pattern}}
|
||||
* @Assert\Regex("/{{.}}/")
|
||||
{{/pattern}}
|
||||
{{#maxItems}}
|
||||
* @Assert\Count(
|
||||
* max = {{.}}
|
||||
* )
|
||||
{{/maxItems}}
|
||||
{{#minItems}}
|
||||
* @Assert\Count(
|
||||
* min = {{.}}
|
||||
* )
|
||||
{{/minItems}}
|
||||
{{/hasValidation}}
|
||||
*/
|
||||
public {{{vendorExtensions.x-parameter-type}}} ${{name}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}};
|
||||
14
modules/openapi-generator/src/main/resources/php-flight/partial_header.mustache
vendored
Normal file
14
modules/openapi-generator/src/main/resources/php-flight/partial_header.mustache
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
{{#appName}}
|
||||
* {{{.}}}
|
||||
*
|
||||
{{/appName}}
|
||||
{{#appDescription}}
|
||||
* {{{.}}}
|
||||
*
|
||||
{{/appDescription}}
|
||||
* {{#version}}The version of the OpenAPI document: {{{.}}}{{/version}}
|
||||
* {{#infoEmail}}Contact: {{{.}}}{{/infoEmail}}
|
||||
* Generated by: https://github.com/openapitools/openapi-generator.git
|
||||
*
|
||||
*/
|
||||
28
modules/openapi-generator/src/main/resources/php-flight/phpunit.mustache
vendored
Normal file
28
modules/openapi-generator/src/main/resources/php-flight/phpunit.mustache
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
bootstrap="./vendor/autoload.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
stopOnFailure="false"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd">
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
<directory suffix=".php">{{#lambda.forwardslash}}{{apiSrcPath}}{{/lambda.forwardslash}}</directory>
|
||||
<directory suffix=".php">{{#lambda.forwardslash}}{{modelSrcPath}}{{/lambda.forwardslash}}</directory>
|
||||
<directory suffix=".php">.</directory>
|
||||
</include>
|
||||
<exclude>
|
||||
<directory suffix=".php">{{#lambda.forwardslash}}{{testSrcPath}}{{/lambda.forwardslash}}</directory>
|
||||
</exclude>
|
||||
</coverage>
|
||||
<testsuites>
|
||||
<testsuite name="Default test suite">
|
||||
<directory>{{#lambda.forwardslash}}{{testSrcPath}}{{/lambda.forwardslash}}</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<php>
|
||||
<ini name="error_reporting" value="E_ALL" />
|
||||
</php>
|
||||
</phpunit>
|
||||
85
modules/openapi-generator/src/main/resources/php-flight/register_routes.mustache
vendored
Normal file
85
modules/openapi-generator/src/main/resources/php-flight/register_routes.mustache
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
{{>licenseInfo}}
|
||||
|
||||
namespace {{invokerPackage}};
|
||||
{{#apiInfo}}
|
||||
|
||||
class RegisterRoutes {
|
||||
|
||||
static public function registerRoutes({{#apis}}\{{apiPackage}}\{{classname}}{{^-last}}|{{/-last}}{{/apis}} $handler): void
|
||||
{
|
||||
$reflectionClass = new \ReflectionClass($handler);
|
||||
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
if (declaresMethod($reflectionClass, '{{operationId}}') && declaresMethod($reflectionClass, '{{operationId}}Stream')) {
|
||||
throw new \Exception('Operation {{operationId}} cannot be both streaming and non-streaming');
|
||||
}
|
||||
if (declaresMethod($reflectionClass, '{{operationId}}')) {
|
||||
\Flight::route('{{httpMethod}} {{vendorExtensions.x-path}}', function ({{#pathParams}}string ${{paramName}}{{^-last}}, {{/-last}}{{/pathParams}}) use ($handler) {
|
||||
$r = \Flight::request();
|
||||
{{^vendorExtensions.x-return-type-is-void}}$result = {{/vendorExtensions.x-return-type-is-void}}$handler->{{operationId}}(
|
||||
{{#vendorExtensions.x-nonFormParams}}
|
||||
parseParam({{#isBodyParam}}json_decode($r->getBody(), true){{/isBodyParam}}{{#isQueryParam}}$r->query['{{baseName}}'] ?? null{{/isQueryParam}}{{#isPathParam}}${{paramName}}{{/isPathParam}}{{#isHeaderParam}}$r->getHeader('{{baseName}}'){{/isHeaderParam}}, '{{vendorExtensions.x-comment-type-escaped}}'){{^-last}}, {{/-last}}
|
||||
{{/vendorExtensions.x-nonFormParams}}
|
||||
);
|
||||
{{^vendorExtensions.x-return-type-is-void}}
|
||||
if ($result === null) {
|
||||
\Flight::halt(204);
|
||||
} else {
|
||||
\Flight::json($result);
|
||||
}
|
||||
{{/vendorExtensions.x-return-type-is-void}}
|
||||
{{#vendorExtensions.x-return-type-is-void}}
|
||||
\Flight::halt(204);
|
||||
{{/vendorExtensions.x-return-type-is-void}}
|
||||
});
|
||||
}
|
||||
{{#returnContainer}}
|
||||
if (declaresMethod($reflectionClass, '{{operationId}}Stream')) {
|
||||
\Flight::route('{{httpMethod}} {{vendorExtensions.x-path}}', function ({{#pathParams}}string ${{paramName}}{{^-last}}, {{/-last}}{{/pathParams}}) use ($handler) {
|
||||
$r = \Flight::request();
|
||||
$handler->{{operationId}}Stream(
|
||||
{{#vendorExtensions.x-nonFormParams}}
|
||||
parseParam({{#isBodyParam}}json_decode($r->getBody(), true){{/isBodyParam}}{{#isQueryParam}}$r->query['{{baseName}}'] ?? null{{/isQueryParam}}{{#isPathParam}}${{paramName}}{{/isPathParam}}{{#isHeaderParam}}$r->getHeader('{{baseName}}'){{/isHeaderParam}}, '{{vendorExtensions.x-comment-type-escaped}}'){{^-last}}, {{/-last}}
|
||||
{{/vendorExtensions.x-nonFormParams}}
|
||||
);
|
||||
// ignore return value: streaming expected
|
||||
})->streamWithHeaders(['Content-Type' => 'application/json']);
|
||||
}
|
||||
{{/returnContainer}}
|
||||
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
}
|
||||
}
|
||||
|
||||
{{/apiInfo}}
|
||||
|
||||
function parseParam(mixed $param, string $type)
|
||||
{
|
||||
$nonNullType = str_replace('?', '', $type);
|
||||
if ($param === null) {
|
||||
return null;
|
||||
} elseif ($nonNullType === 'int') {
|
||||
return intval($param);
|
||||
} elseif ($nonNullType === 'float') {
|
||||
return floatval($param);
|
||||
} elseif ($nonNullType === 'bool') {
|
||||
return filter_var($param, FILTER_VALIDATE_BOOLEAN);
|
||||
} elseif (str_ends_with($type, '[]')) {
|
||||
return array_map(fn($el) => parseParam($el, substr($type, 0, -2)), $param);
|
||||
} elseif (str_starts_with($nonNullType, '\\{{escapedModelPackage}}')) {
|
||||
return new $nonNullType($param);
|
||||
} else {
|
||||
return $param;
|
||||
}
|
||||
}
|
||||
|
||||
function declaresMethod(\ReflectionClass $reflectionClass, string $methodName): bool
|
||||
{
|
||||
return $reflectionClass->hasMethod($methodName) && $reflectionClass->getMethod($methodName)->getDeclaringClass()->getName() === $reflectionClass->getName();
|
||||
}
|
||||
31
modules/openapi-generator/src/main/resources/php-flight/register_routes_test.mustache
vendored
Normal file
31
modules/openapi-generator/src/main/resources/php-flight/register_routes_test.mustache
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
{{>licenseInfo}}
|
||||
|
||||
{{#apiInfo}}
|
||||
namespace {{testPackage}};
|
||||
|
||||
class RegisterRoutesTest extends \PHPUnit\Framework\TestCase {
|
||||
{{#apis}}
|
||||
public function testRegisterRoutes{{classname}}(): void
|
||||
{
|
||||
$handler = new class extends \{{apiPackage}}\{{classname}} {
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{#-first}}
|
||||
public function {{operationId}}({{#vendorExtensions.x-nonFormParams}}{{^isFormParam}}{{vendorExtensions.x-parameter-type}} ${{paramName}}{{^-last}}, {{/-last}}{{/isFormParam}}{{/vendorExtensions.x-nonFormParams}}): {{vendorExtensions.x-return-type}}
|
||||
{
|
||||
{{^vendorExtensions.x-return-type-is-void}}
|
||||
return null;
|
||||
{{/vendorExtensions.x-return-type-is-void}}
|
||||
}
|
||||
{{/-first}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
};
|
||||
\{{invokerPackage}}\RegisterRoutes::registerRoutes($handler);
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
{{/apis}}
|
||||
}
|
||||
{{/apiInfo}}
|
||||
@@ -35,7 +35,7 @@ homepage = "{{.}}
|
||||
serde = "^1.0"
|
||||
serde_derive = "^1.0"
|
||||
{{#serdeWith}}
|
||||
serde_with = "^2.0"
|
||||
serde_with = { version = "^3", default-features = false, features = ["base64", "std", "macros"] }
|
||||
{{/serdeWith}}
|
||||
serde_json = "^1.0"
|
||||
url = "^2.2"
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
use crate::models;
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
|
||||
{{^isEnum}}{{#vendorExtensions.x-rust-has-byte-array}}
|
||||
use serde_with::serde_as;
|
||||
{{/vendorExtensions.x-rust-has-byte-array}}{{/isEnum}}
|
||||
{{#description}}
|
||||
/// {{{classname}}} : {{{description}}}
|
||||
{{/description}}
|
||||
@@ -85,15 +87,18 @@ impl Default for {{classname}} {
|
||||
{{!-- for non-enum schemas --}}
|
||||
{{^isEnum}}
|
||||
{{^discriminator}}
|
||||
{{#oneOf.isEmpty}}
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
{{#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}}
|
||||
{{#required}}#[serde_as(as = "serde_with::base64::Base64")]{{/required}}{{^required}}#[serde_as(as = "Option<serde_with::base64::Base64>")]{{/required}}
|
||||
{{/isByteArray}}
|
||||
#[serde(rename = "{{{baseName}}}"{{^required}}{{#isNullable}}, default, with = "::serde_with::rust::double_option"{{/isNullable}}{{/required}}{{^required}}, skip_serializing_if = "Option::is_none"{{/required}}{{#required}}{{#isNullable}}, deserialize_with = "Option::deserialize"{{/isNullable}}{{/required}})]
|
||||
pub {{{name}}}: {{#isNullable}}Option<{{/isNullable}}{{^required}}Option<{{/required}}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{#isModel}}{{^avoidBoxedModels}}Box<{{/avoidBoxedModels}}{{{dataType}}}{{^avoidBoxedModels}}>{{/avoidBoxedModels}}{{/isModel}}{{^isModel}}{{{dataType}}}{{/isModel}}{{/isEnum}}{{#isNullable}}>{{/isNullable}}{{^required}}>{{/required}},
|
||||
pub {{{name}}}: {{#isNullable}}Option<{{/isNullable}}{{^required}}Option<{{/required}}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{#isModel}}{{^avoidBoxedModels}}Box<{{/avoidBoxedModels}}{{{dataType}}}{{^avoidBoxedModels}}>{{/avoidBoxedModels}}{{/isModel}}{{^isModel}}{{#isByteArray}}Vec<u8>{{/isByteArray}}{{^isByteArray}}{{{dataType}}}{{/isByteArray}}{{/isModel}}{{/isEnum}}{{#isNullable}}>{{/isNullable}}{{^required}}>{{/required}},
|
||||
{{/vars}}
|
||||
}
|
||||
|
||||
@@ -101,7 +106,7 @@ impl {{{classname}}} {
|
||||
{{#description}}
|
||||
/// {{{.}}}
|
||||
{{/description}}
|
||||
pub fn new({{#requiredVars}}{{{name}}}: {{#isNullable}}Option<{{/isNullable}}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}}>{{/isNullable}}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{{classname}}} {
|
||||
pub fn new({{#requiredVars}}{{{name}}}: {{#isNullable}}Option<{{/isNullable}}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{#isByteArray}}Vec<u8>{{/isByteArray}}{{^isByteArray}}{{{dataType}}}{{/isByteArray}}{{/isEnum}}{{#isNullable}}>{{/isNullable}}{{^-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}},
|
||||
|
||||
@@ -1,23 +1,47 @@
|
||||
name := "{{artifactId}}"
|
||||
organization:="{{groupId}}"
|
||||
version := "0.0.1-SNAPSHOT"
|
||||
scalaVersion := "3.3.1"
|
||||
scalafmtOnCompile := true
|
||||
libraryDependencies ++= Seq(
|
||||
"com.lihaoyi" %% "cask" % "0.9.2" ,
|
||||
"com.lihaoyi" %% "upickle" % "3.2.0",
|
||||
"org.scalatest" %% "scalatest" % "3.2.18" % Test
|
||||
ThisBuild / name := "{{artifactId}}"
|
||||
ThisBuild / organization := "{{groupId}}"
|
||||
ThisBuild / version := "{{artifactVersion}}"
|
||||
ThisBuild / scalaVersion := "3.4.1"
|
||||
ThisBuild / scalafmtOnCompile := true
|
||||
ThisBuild / versionScheme := Some("early-semver")
|
||||
|
||||
// Common settings
|
||||
lazy val commonSettings = Seq(
|
||||
libraryDependencies ++= Seq(
|
||||
"com.lihaoyi" %%% "upickle" % "3.2.0",
|
||||
"org.scalatest" %%% "scalatest" % "3.2.18" % Test
|
||||
),
|
||||
name := "{{artifactId}}"
|
||||
)
|
||||
|
||||
publishMavenStyle := true
|
||||
|
||||
lazy val app = crossProject(JSPlatform, JVMPlatform).in(file(".")).
|
||||
settings(commonSettings).
|
||||
jvmSettings(
|
||||
libraryDependencies += "com.lihaoyi" %% "cask" % "0.9.2"
|
||||
).
|
||||
jsSettings(
|
||||
scalaJSUseMainModuleInitializer := true
|
||||
)
|
||||
|
||||
|
||||
lazy val root = project.in(file(".")).
|
||||
aggregate(app.js, app.jvm).
|
||||
settings(
|
||||
publish := {},
|
||||
publishLocal := {},
|
||||
)
|
||||
|
||||
|
||||
ThisBuild / publishMavenStyle := true
|
||||
|
||||
val githubUser = "{{{gitUserId}}}"
|
||||
val githubRepo = "{{{gitRepoId}}}"
|
||||
publishTo := Some("GitHub Package Registry" at s"https://maven.pkg.github.com/$githubUser/$githubRepo")
|
||||
ThisBuild / publishTo := Some("GitHub Package Registry" at s"https://maven.pkg.github.com/$githubUser/$githubRepo")
|
||||
|
||||
sys.env.get("GITHUB_TOKEN") match {
|
||||
case Some(token) if !token.isEmpty =>
|
||||
credentials += Credentials(
|
||||
ThisBuild / credentials += Credentials(
|
||||
"GitHub Package Registry",
|
||||
"maven.pkg.github.com",
|
||||
githubUser,
|
||||
|
||||
@@ -8,7 +8,7 @@ import mill._, scalalib._, scalafmt._, publish._
|
||||
// mill _.publishLocal
|
||||
// mill _.test.test
|
||||
object {{artifactId}} extends SbtModule with ScalafmtModule with PublishModule {
|
||||
def scalaVersion = "3.3.1"
|
||||
def scalaVersion = "3.4.1"
|
||||
|
||||
def pomSettings = PomSettings(
|
||||
description = "{{artifactId}}",
|
||||
@@ -21,15 +21,15 @@ object {{artifactId}} extends SbtModule with ScalafmtModule with PublishModule {
|
||||
)
|
||||
)
|
||||
|
||||
def publishVersion: mill.T[String] = T("0.0.1-SNAPSHOT")
|
||||
def publishVersion: mill.T[String] = T("{{artifactVersion}}")
|
||||
|
||||
def ivyDeps = Agg(
|
||||
ivy"com.lihaoyi::cask:0.9.2" ,
|
||||
ivy"com.lihaoyi::upickle:3.2.0"
|
||||
)
|
||||
|
||||
override def sources = T.sources(millSourcePath / os.up / "src" / "main" / "scala")
|
||||
override def resources = T.sources(millSourcePath / os.up / "src" / "main" / "resources")
|
||||
override def sources = T.sources(millSourcePath / os.up / "shared" / "src" / "main" / "scala")
|
||||
override def resources = T.sources(millSourcePath / os.up / "shared" / "src" / "main" / "resources")
|
||||
|
||||
object test extends SbtModuleTests {
|
||||
def ivyDeps = Agg(
|
||||
|
||||
@@ -30,10 +30,7 @@ jobs:
|
||||
${{{openbrackets}}} runner.os {{{closebrackets}}}-sbt-
|
||||
|
||||
- name: Build with sbt
|
||||
run: sbt clean compile
|
||||
|
||||
- name: Test with sbt
|
||||
run: sbt test
|
||||
run: sbt clean compile test
|
||||
|
||||
- name: Publish to GitHub Packages
|
||||
run: sbt publish
|
||||
@@ -1,5 +1,5 @@
|
||||
//> using scala "3.3.1"
|
||||
//> using lib "{{groupId}}::{{artifactId}}:0.0.1-SNAPSHOT"
|
||||
//> using scala "3.4.1"
|
||||
//> using lib "{{groupId}}::{{artifactId}}:{{artifactVersion}}"
|
||||
//> using repositories https://maven.pkg.github.com/{{{gitUserId}}}/{{{gitRepoId}}}
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")
|
||||
|
||||
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
|
||||
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
|
||||
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.2.0")
|
||||
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0")
|
||||
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")
|
||||
@@ -130,9 +130,9 @@ extension NullEncodable: Codable where Wrapped: Codable {
|
||||
}
|
||||
{{/useAlamofire}}
|
||||
{{^useAlamofire}}
|
||||
private var task: URLSessionTask?
|
||||
private var task: URLSessionDataTaskProtocol?
|
||||
|
||||
internal func set(task: URLSessionTask) {
|
||||
internal func set(task: URLSessionDataTaskProtocol) {
|
||||
lock.lock()
|
||||
defer { lock.unlock() }
|
||||
self.task = task
|
||||
|
||||
@@ -12,11 +12,33 @@ import MobileCoreServices
|
||||
import UniformTypeIdentifiers
|
||||
#endif
|
||||
|
||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} protocol URLSessionProtocol {
|
||||
func dataTask(with request: URLRequest, completionHandler: @escaping @Sendable (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
|
||||
// Protocol defined for a session data task. This allows mocking out the URLSessionProtocol below since
|
||||
// you may not want to create or return a real URLSessionDataTask.
|
||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} protocol URLSessionDataTaskProtocol {
|
||||
func resume()
|
||||
|
||||
var taskIdentifier: Int { get }
|
||||
|
||||
var progress: Progress { get }
|
||||
|
||||
func cancel()
|
||||
}
|
||||
|
||||
extension URLSession: URLSessionProtocol {}
|
||||
// Protocol allowing implementations to alter what is returned or to test their implementations.
|
||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} protocol URLSessionProtocol {
|
||||
// Task which performs the network fetch. Expected to be from URLSession.dataTask(with:completionHandler:) such that a network request
|
||||
// is sent off when `.resume()` is called.
|
||||
func dataTaskFromProtocol(with request: URLRequest, completionHandler: @escaping @Sendable (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTaskProtocol
|
||||
}
|
||||
|
||||
extension URLSession: URLSessionProtocol {
|
||||
// Passthrough to URLSession.dataTask(with:completionHandler) since URLSessionDataTask conforms to URLSessionDataTaskProtocol and fetches the network data.
|
||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} func dataTaskFromProtocol(with request: URLRequest, completionHandler: @escaping @Sendable (Data?, URLResponse?, (any Error)?) -> Void) -> any URLSessionDataTaskProtocol {
|
||||
return dataTask(with: request, completionHandler: completionHandler)
|
||||
}
|
||||
}
|
||||
|
||||
extension URLSessionDataTask: URLSessionDataTaskProtocol {}
|
||||
|
||||
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||
@@ -136,7 +158,7 @@ private var credentialStore = SynchronizedDictionary<Int, URLCredential>()
|
||||
}
|
||||
}
|
||||
|
||||
let dataTask = urlSession.dataTask(with: request) { data, response, error in
|
||||
let dataTask = urlSession.dataTaskFromProtocol(with: request) { data, response, error in
|
||||
apiResponseQueue.async {
|
||||
self.processRequestResponse(urlRequest: request, data: data, response: response, error: error, completion: completion)
|
||||
cleanupRequest()
|
||||
|
||||
@@ -2,9 +2,17 @@ export interface {{classname}}{{#allParents}}{{#-first}} extends {{/-first}}{{{.
|
||||
{{#vars}}
|
||||
{{#description}}
|
||||
/**
|
||||
* {{{.}}}
|
||||
* {{{description}}}
|
||||
{{#deprecated}}
|
||||
* @deprecated
|
||||
{{/deprecated}}
|
||||
*/
|
||||
{{/description}}
|
||||
{{^description}}
|
||||
{{#deprecated}}
|
||||
/** @deprecated */
|
||||
{{/deprecated}}
|
||||
{{/description}}
|
||||
{{#isReadOnly}}readonly {{/isReadOnly}}{{{name}}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}} | null{{/isNullable}};
|
||||
{{/vars}}
|
||||
}{{>modelGenericEnums}}
|
||||
|
||||
@@ -118,50 +118,10 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any,
|
||||
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
|
||||
: nonString;
|
||||
return needsSerialization
|
||||
? JSON.stringify(value !== undefined ? convertMapsAndSetsToPlain(value) : {})
|
||||
? JSON.stringify(value !== undefined ? value : {})
|
||||
: (value || "");
|
||||
}
|
||||
|
||||
function convertMapsAndSetsToPlain(value: any): any {
|
||||
if (typeof Set === "undefined") return value;
|
||||
if (typeof Map === "undefined") return value;
|
||||
if (typeof value !== "object" || !value) {
|
||||
return value;
|
||||
}
|
||||
if (value instanceof Set) {
|
||||
return Array.from(value).map(item => convertMapsAndSetsToPlain(item));
|
||||
}
|
||||
if (value instanceof Map) {
|
||||
const entries: Array<[string, any]> = [];
|
||||
value.forEach((value: any, key: any) => {
|
||||
entries.push([key, convertMapsAndSetsToPlain(value)])
|
||||
});
|
||||
return objectFromEntries(entries);
|
||||
}
|
||||
if (Array.isArray(value)) {
|
||||
return value.map(it => convertMapsAndSetsToPlain(it));
|
||||
}
|
||||
return objectFromEntries(objectEntries(value)
|
||||
.map(([k, v]) => [k, convertMapsAndSetsToPlain(v)]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ponyfill for Object.entries
|
||||
*/
|
||||
function objectEntries(object: Record<string, any>): Array<[string, any]> {
|
||||
return Object.keys(object).map(key => [key, object[key]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ponyfill for Object.fromEntries
|
||||
*/
|
||||
function objectFromEntries(entries: any): Record<string, any> {
|
||||
return [...entries].reduce((object, [key, val]) => {
|
||||
object[key] = val;
|
||||
return object;
|
||||
}, {});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
|
||||
@@ -3,7 +3,7 @@ import { DynamicModule, Module, Global, Provider } from '@nestjs/common';
|
||||
import { HttpModule, HttpService } from '@nestjs/axios';
|
||||
{{/useAxiosHttpModule}}
|
||||
{{^useAxiosHttpModule}}
|
||||
import { DynamicModule, HttpService, HttpModule, Module, Global } from '@nestjs/common';
|
||||
import { DynamicModule, HttpService, HttpModule, Module, Global, Provider } from '@nestjs/common';
|
||||
{{/useAxiosHttpModule}}
|
||||
import { AsyncConfiguration, Configuration, ConfigurationFactory } from './configuration';
|
||||
|
||||
|
||||
@@ -9,11 +9,12 @@ import { HttpService } from '@nestjs/axios';
|
||||
import { HttpService, Inject, Injectable, Optional } from '@nestjs/common';
|
||||
{{/useAxiosHttpModule}}
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, from, of, switchMap } from 'rxjs';
|
||||
{{#imports}}
|
||||
import { {{classname}} } from '../{{filename}}';
|
||||
{{/imports}}
|
||||
import { Configuration } from '../configuration';
|
||||
import { COLLECTION_FORMATS } from '../variables';
|
||||
{{#withInterfaces}}
|
||||
import { {{classname}}Interface } from './{{classFilename}}Interface';
|
||||
{{/withInterfaces}}
|
||||
@@ -117,6 +118,8 @@ export class {{classname}} {
|
||||
{{/isArray}}
|
||||
{{/headerParams}}
|
||||
|
||||
let accessTokenObservable: Observable<any> = of(null);
|
||||
|
||||
{{#authMethods}}
|
||||
// authentication ({{name}}) required
|
||||
{{#isApiKey}}
|
||||
@@ -144,17 +147,16 @@ export class {{classname}} {
|
||||
{{/isBasicBasic}}
|
||||
{{#isBasicBearer}}
|
||||
if (typeof this.configuration.accessToken === 'function') {
|
||||
headers['Authorization'] = `Bearer ${this.configuration.accessToken()}`;
|
||||
accessTokenObservable = from(Promise.resolve(this.configuration.accessToken()));
|
||||
} else if (this.configuration.accessToken) {
|
||||
headers['Authorization'] = `Bearer ${this.configuration.accessToken}`;
|
||||
accessTokenObservable = from(Promise.resolve(this.configuration.accessToken));
|
||||
}
|
||||
{{/isBasicBearer}}
|
||||
{{#isOAuth}}
|
||||
if (this.configuration.accessToken) {
|
||||
const accessToken = typeof this.configuration.accessToken === 'function'
|
||||
? this.configuration.accessToken()
|
||||
: this.configuration.accessToken;
|
||||
headers['Authorization'] = 'Bearer ' + accessToken;
|
||||
accessTokenObservable = typeof this.configuration.accessToken === 'function'
|
||||
? from(Promise.resolve(this.configuration.accessToken()))
|
||||
: from(Promise.resolve(this.configuration.accessToken))
|
||||
}
|
||||
|
||||
{{/isOAuth}}
|
||||
@@ -224,18 +226,26 @@ export class {{classname}} {
|
||||
{{/formParams}}
|
||||
|
||||
{{/hasFormParams}}
|
||||
return this.httpClient.{{httpMethod}}{{^isResponseFile}}<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>{{/isResponseFile}}(`${this.basePath}{{{path}}}`,{{#isBodyAllowed}}
|
||||
{{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}{{#hasFormParams}}convertFormParamsToString ? formParams!.toString() : formParams!{{/hasFormParams}}{{^hasFormParams}}null{{/hasFormParams}}{{/bodyParam}},{{/isBodyAllowed}}
|
||||
{
|
||||
{{#hasQueryParams}}
|
||||
params: queryParameters,
|
||||
{{/hasQueryParams}}
|
||||
{{#isResponseFile}}
|
||||
responseType: "blob",
|
||||
{{/isResponseFile}}
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: headers
|
||||
}
|
||||
return accessTokenObservable.pipe(
|
||||
switchMap((accessToken) => {
|
||||
if (accessToken) {
|
||||
headers['Authorization'] = `Bearer ${accessToken}`;
|
||||
}
|
||||
|
||||
return this.httpClient.{{httpMethod}}{{^isResponseFile}}<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>{{/isResponseFile}}(`${this.basePath}{{{path}}}`,{{#isBodyAllowed}}
|
||||
{{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}{{#hasFormParams}}convertFormParamsToString ? formParams!.toString() : formParams!{{/hasFormParams}}{{^hasFormParams}}null{{/hasFormParams}}{{/bodyParam}},{{/isBodyAllowed}}
|
||||
{
|
||||
{{#hasQueryParams}}
|
||||
params: queryParameters,
|
||||
{{/hasQueryParams}}
|
||||
{{#isResponseFile}}
|
||||
responseType: "blob",
|
||||
{{/isResponseFile}}
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: headers
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
{{/operation}}
|
||||
|
||||
@@ -72,6 +72,7 @@ public class AsciidocGeneratorTest {
|
||||
markupFileGenerated = true;
|
||||
String markupContent = FileUtils.readFileToString(file, StandardCharsets.UTF_8);
|
||||
// check on some basic asciidoc markup content
|
||||
Assert.assertEquals("", markupContent);
|
||||
Assert.assertTrue(markupContent.contains("= ping test"),
|
||||
"expected = header in: " + markupContent.substring(0, 50));
|
||||
Assert.assertTrue(markupContent.contains(":toc: "),
|
||||
|
||||
@@ -312,6 +312,48 @@ public class GoClientCodegenTest {
|
||||
"BaseItem");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVendorExtensionGenerateUnmarshalJson() throws IOException {
|
||||
File output = Files.createTempDirectory("test").toFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||
.setGeneratorName("go")
|
||||
.setGitUserId("OpenAPITools")
|
||||
.setGitRepoId("openapi-generator")
|
||||
.setInputSpec("src/test/resources/3_0/go/allof_with_unmarshal_json.yaml")
|
||||
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
List<File> files = generator.opts(configurator.toClientOptInput()).generate();
|
||||
files.forEach(File::deleteOnExit);
|
||||
|
||||
TestUtils.assertFileExists(Paths.get(output + "/model_base_item.go"));
|
||||
TestUtils.assertFileContains(Paths.get(output + "/model_base_item.go"),
|
||||
"func (o *BaseItem) UnmarshalJSON(data []byte) (err error) {");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVendorExtensionSkipGenerateUnmarshalJson() throws IOException {
|
||||
File output = Files.createTempDirectory("test").toFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||
.setGeneratorName("go")
|
||||
.setGitUserId("OpenAPITools")
|
||||
.setGitRepoId("openapi-generator")
|
||||
.setInputSpec("src/test/resources/3_0/go/allof_skip_unmarshal_json.yaml")
|
||||
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
List<File> files = generator.opts(configurator.toClientOptInput()).generate();
|
||||
files.forEach(File::deleteOnExit);
|
||||
|
||||
TestUtils.assertFileExists(Paths.get(output + "/model_base_item.go"));
|
||||
TestUtils.assertFileNotContains(Paths.get(output + "/model_base_item.go"),
|
||||
"func (o *BaseItem) UnmarshalJSON(data []byte) (err error) {");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAdditionalPropertiesWithGoMod() throws Exception {
|
||||
File output = Files.createTempDirectory("test").toFile();
|
||||
|
||||
@@ -53,5 +53,6 @@ public class GoClientOptionsTest extends AbstractOptionsTest {
|
||||
verify(clientCodegen).setUseOneOfDiscriminatorLookup(GoClientOptionsProvider.USE_ONE_OF_DISCRIMINATOR_LOOKUP_VALUE);
|
||||
verify(clientCodegen).setWithGoMod(GoClientOptionsProvider.WITH_GO_MOD_VALUE);
|
||||
verify(clientCodegen).setGenerateMarshalJSON(GoClientOptionsProvider.GENERATE_MARSHAL_JSON_VALUE);
|
||||
verify(clientCodegen).setGenerateUnmarshalJSON(GoClientOptionsProvider.GENERATE_UNMARSHAL_JSON_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1899,6 +1899,38 @@ public class JavaClientCodegenTest {
|
||||
.containsWithNameAndAttributes("JsonbProperty", ImmutableMap.of("value", "\"c\""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMicroprofileGenerateCorrectJacksonGenerator_issue18336() throws Exception {
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put(JavaClientCodegen.MICROPROFILE_REST_CLIENT_VERSION, "3.0");
|
||||
properties.put(CodegenConstants.SERIALIZATION_LIBRARY, JavaClientCodegen.SERIALIZATION_LIBRARY_JACKSON);
|
||||
|
||||
File output = Files.createTempDirectory("test").toFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||
|
||||
.setAdditionalProperties(properties)
|
||||
.setGeneratorName("java")
|
||||
.setLibrary(JavaClientCodegen.MICROPROFILE)
|
||||
.setInputSpec("src/test/resources/bugs/issue_18336.yaml")
|
||||
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||
|
||||
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
Map<String, File> files = generator.opts(clientOptInput).generate().stream()
|
||||
.collect(Collectors.toMap(File::getName, Function.identity()));
|
||||
|
||||
JavaFileAssert.assertThat(files.get("Pet.java"))
|
||||
.assertConstructor("String")
|
||||
.assertConstructorAnnotations()
|
||||
.containsWithName("JsonCreator")
|
||||
.toConstructor()
|
||||
.hasParameter("name")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithNameAndAttributes("JsonProperty", ImmutableMap.of("value", "JSON_PROPERTY_NAME", "required", "true"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJavaClientDefaultValues_issueNoNumber() throws Exception {
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
|
||||
@@ -808,6 +808,103 @@ public class JavaJAXRSSpecServerCodegenTest extends JavaJaxrsBaseTest {
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generateApiForQuarkusWithoutMutiny() throws Exception {
|
||||
final File output = Files.createTempDirectory("test").toFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
final OpenAPI openAPI = new OpenAPIParser()
|
||||
.readLocation("src/test/resources/3_0/issue_4832.yaml", null, new ParseOptions()).getOpenAPI();
|
||||
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
codegen.setLibrary(QUARKUS_LIBRARY);
|
||||
codegen.additionalProperties().put(SUPPORT_ASYNC, true);
|
||||
codegen.additionalProperties().put(USE_TAGS, true); //And use tags to generate everything in PingApi.java
|
||||
|
||||
final ClientOptInput input = new ClientOptInput()
|
||||
.openAPI(openAPI)
|
||||
.config(codegen); //Using JavaJAXRSSpecServerCodegen
|
||||
|
||||
final DefaultGenerator generator = new DefaultGenerator();
|
||||
final List<File> files = generator.opts(input).generate(); //When generating files
|
||||
|
||||
//Then the java files are compilable
|
||||
validateJavaSourceFiles(files);
|
||||
|
||||
//And the generated class contains CompletionStage<Response>
|
||||
TestUtils.ensureContainsFile(files, output, "src/gen/java/org/openapitools/api/PingApi.java");
|
||||
TestUtils.assertFileContains(output.toPath().resolve("src/gen/java/org/openapitools/api/PingApi.java"),
|
||||
"CompletionStage<Response> pingGetBoolean", //Support primitive types response
|
||||
"CompletionStage<Response> pingGetInteger" //Support primitive types response
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generateApiForQuarkusWithMutinyApi() throws Exception {
|
||||
final File output = Files.createTempDirectory("test").toFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
final OpenAPI openAPI = new OpenAPIParser()
|
||||
.readLocation("src/test/resources/3_0/issue_4832.yaml", null, new ParseOptions()).getOpenAPI();
|
||||
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
codegen.setLibrary(QUARKUS_LIBRARY);
|
||||
codegen.additionalProperties().put(USE_TAGS, true); //And use tags to generate everything in PingApi.java
|
||||
codegen.additionalProperties().put(SUPPORT_ASYNC, true);
|
||||
codegen.additionalProperties().put(INTERFACE_ONLY, true);
|
||||
codegen.additionalProperties().put(USE_MUTINY, true);
|
||||
|
||||
final ClientOptInput input = new ClientOptInput()
|
||||
.openAPI(openAPI)
|
||||
.config(codegen); //Using JavaJAXRSSpecServerCodegen
|
||||
|
||||
final DefaultGenerator generator = new DefaultGenerator();
|
||||
final List<File> files = generator.opts(input).generate(); //When generating files
|
||||
|
||||
//Then the java files are compilable
|
||||
validateJavaSourceFiles(files);
|
||||
|
||||
//And the generated class contains CompletionStage<Response>
|
||||
TestUtils.ensureContainsFile(files, output, "src/gen/java/org/openapitools/api/PingApi.java");
|
||||
TestUtils.assertFileContains(output.toPath().resolve("src/gen/java/org/openapitools/api/PingApi.java"),
|
||||
"Uni<Boolean> pingGetBoolean", //Support primitive types response
|
||||
"Uni<Integer> pingGetInteger" //Support primitive types response
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void generateApiForQuarkusWithMutinyImpl() throws Exception {
|
||||
final File output = Files.createTempDirectory("test").toFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
final OpenAPI openAPI = new OpenAPIParser()
|
||||
.readLocation("src/test/resources/3_0/issue_4832.yaml", null, new ParseOptions()).getOpenAPI();
|
||||
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
codegen.setLibrary(QUARKUS_LIBRARY);
|
||||
codegen.additionalProperties().put(USE_TAGS, true); //And use tags to generate everything in PingApi.java
|
||||
codegen.additionalProperties().put(SUPPORT_ASYNC, true);
|
||||
codegen.additionalProperties().put(USE_MUTINY, true);
|
||||
|
||||
final ClientOptInput input = new ClientOptInput()
|
||||
.openAPI(openAPI)
|
||||
.config(codegen); //Using JavaJAXRSSpecServerCodegen
|
||||
|
||||
final DefaultGenerator generator = new DefaultGenerator();
|
||||
final List<File> files = generator.opts(input).generate(); //When generating files
|
||||
|
||||
//Then the java files are compilable
|
||||
validateJavaSourceFiles(files);
|
||||
|
||||
//And the generated class contains CompletionStage<Response>
|
||||
TestUtils.ensureContainsFile(files, output, "src/gen/java/org/openapitools/api/PingApi.java");
|
||||
TestUtils.assertFileContains(output.toPath().resolve("src/gen/java/org/openapitools/api/PingApi.java"),
|
||||
"Uni<Response> pingGetBoolean", //Support primitive types response
|
||||
"Uni<Response> pingGetInteger" //Support primitive types response
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleRequiredAndReadOnlyPropertiesCorrectly() throws Exception {
|
||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||
|
||||
@@ -38,6 +38,7 @@ public class GoClientOptionsProvider implements OptionsProvider {
|
||||
public static final boolean USE_ONE_OF_DISCRIMINATOR_LOOKUP_VALUE = true;
|
||||
public static final boolean WITH_GO_MOD_VALUE = true;
|
||||
public static final boolean GENERATE_MARSHAL_JSON_VALUE = true;
|
||||
public static final boolean GENERATE_UNMARSHAL_JSON_VALUE = true;
|
||||
|
||||
@Override
|
||||
public String getLanguage() {
|
||||
@@ -60,6 +61,7 @@ public class GoClientOptionsProvider implements OptionsProvider {
|
||||
.put(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, "true")
|
||||
.put(CodegenConstants.WITH_GO_MOD, "true")
|
||||
.put(CodegenConstants.GENERATE_MARSHAL_JSON, "true")
|
||||
.put(CodegenConstants.GENERATE_UNMARSHAL_JSON, "true")
|
||||
.put("generateInterfaces", "true")
|
||||
.put("structPrefix", "true")
|
||||
.build();
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package org.openapitools.codegen.php.flight;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.openapitools.codegen.ClientOptInput;
|
||||
import org.openapitools.codegen.DefaultGenerator;
|
||||
import org.openapitools.codegen.TestUtils;
|
||||
import org.openapitools.codegen.config.CodegenConfigurator;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class PhpFlightServerCodegenTest {
|
||||
|
||||
@Test
|
||||
public void shouldGenerateModel() throws Exception {
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
|
||||
File output = Files.createTempDirectory("test").toFile();
|
||||
|
||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||
.setGeneratorName("php-flight")
|
||||
.setAdditionalProperties(properties)
|
||||
.setInputSpec("src/test/resources/3_0/petstore-php-flight.yaml")
|
||||
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||
|
||||
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
List<File> files = generator.opts(clientOptInput).generate();
|
||||
|
||||
TestUtils.ensureContainsFile(files, output, "Api/AbstractPetApi.php");
|
||||
TestUtils.ensureContainsFile(files, output, "Model/Pet.php");
|
||||
TestUtils.ensureContainsFile(files, output, "Model/StandaloneEnum.php");
|
||||
TestUtils.ensureContainsFile(files, output, "Model/PetStatus.php"); // inline enum
|
||||
TestUtils.ensureContainsFile(files, output, "README.md");
|
||||
TestUtils.ensureContainsFile(files, output, "RegisterRoutes.php");
|
||||
|
||||
java.nio.file.Path petModelFile = files.stream().filter(f -> f.getName().contains("Pet.php")).findFirst().orElseThrow().toPath();
|
||||
TestUtils.assertFileContains(petModelFile, "namespace OpenAPIServer\\Model;");
|
||||
TestUtils.assertFileContains(petModelFile, "public int $id;");
|
||||
TestUtils.assertFileContains(petModelFile, "public ?string $name;");
|
||||
TestUtils.assertFileContains(petModelFile, "public ?\\DateTime $dateTimeAttribute;");
|
||||
TestUtils.assertFileContains(petModelFile, "@var Order[]|null");
|
||||
TestUtils.assertFileContains(petModelFile, "public ?array $objectList;");
|
||||
TestUtils.assertFileContains(petModelFile, "$data['photo_urls'] ?? null,");
|
||||
TestUtils.assertFileContains(petModelFile, "'photo_urls' => $this->photoUrls");
|
||||
|
||||
TestUtils.assertFileContains(petModelFile, "isset($data['category']) ? Category::fromArray($data['category']) : null,");
|
||||
TestUtils.assertFileContains(petModelFile, "isset($data['status']) ? PetStatus::tryFrom($data['status']) : null");
|
||||
TestUtils.assertFileContains(petModelFile, "isset($data['refEnum']) ? StandaloneEnum::tryFrom($data['refEnum']) : null");
|
||||
TestUtils.assertFileContains(petModelFile, "isset($data['dateTimeAttribute']) ? new \\DateTime($data['dateTimeAttribute']) : null");
|
||||
|
||||
java.nio.file.Path petApiFile = files.stream().filter(f -> f.getName().contains("AbstractPetApi.php")).findFirst().orElseThrow().toPath();
|
||||
TestUtils.assertFileContains(petApiFile, "namespace OpenAPIServer\\Api;");
|
||||
TestUtils.assertFileContains(petApiFile, "public function getPetById(int $petId)");
|
||||
TestUtils.assertFileContains(petApiFile, "public function updatePet(\\OpenAPIServer\\Model\\Pet $pet): \\OpenAPIServer\\Model\\Pet|null");
|
||||
|
||||
java.nio.file.Path registerRoutesFile = files.stream().filter(f -> f.getName().contains("RegisterRoutes.php")).findFirst().orElseThrow().toPath();
|
||||
TestUtils.assertFileContains(registerRoutesFile, "function registerRoutes(\\OpenAPIServer\\Api\\AbstractPetApi|\\OpenAPIServer\\Api\\AbstractUserApi $handler): void");
|
||||
TestUtils.assertFileContains(registerRoutesFile,
|
||||
"Flight::route('POST /user/createWithArray/@pathParamInt/@pathParamString', function (string $pathParamInt, string $pathParamString) use ($handler) {");
|
||||
TestUtils.assertFileContains(registerRoutesFile, "parseParam($pathParamInt, 'int')");
|
||||
TestUtils.assertFileContains(registerRoutesFile, "parseParam($pathParamString, 'string')");
|
||||
TestUtils.assertFileContains(registerRoutesFile, "parseParam(json_decode($r->getBody(), true), '\\\\OpenAPIServer\\\\Model\\\\User[]')");
|
||||
TestUtils.assertFileContains(registerRoutesFile, "parseParam($r->getHeader('api_key'), '?string')");
|
||||
|
||||
Files.readAllLines(files.stream().filter(f -> f.getName().contains("RegisterRoutesTest.php")).findFirst().orElseThrow().toPath()).forEach(System.out::println);
|
||||
java.nio.file.Path registerRoutesTestFile = files.stream().filter(f -> f.getName().contains("RegisterRoutesTest.php")).findFirst().orElseThrow().toPath();
|
||||
TestUtils.assertFileContains(registerRoutesTestFile, "namespace OpenAPIServer\\Test;");
|
||||
|
||||
output.deleteOnExit();
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user