mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-09 01:26:09 +00:00
Compare commits
71 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5745f6df70 | ||
|
|
d49fb1c777 | ||
|
|
f4d7403ed6 | ||
|
|
f987306a15 | ||
|
|
62abd51a02 | ||
|
|
b8db2af4bb | ||
|
|
8e1e05e86c | ||
|
|
09a62d7fef | ||
|
|
2544ace262 | ||
|
|
a1205f6109 | ||
|
|
4558e49c7e | ||
|
|
5926ee5f1f | ||
|
|
8689227b3e | ||
|
|
5cd5143b80 | ||
|
|
1ea0a1e856 | ||
|
|
b505795bf7 | ||
|
|
e3bd47921c | ||
|
|
15cec0ae09 | ||
|
|
4401407c7c | ||
|
|
40d815946a | ||
|
|
37fd4264ac | ||
|
|
39e9206976 | ||
|
|
50c6ac34f1 | ||
|
|
6a00b2a802 | ||
|
|
010b469914 | ||
|
|
f802f8b7d7 | ||
|
|
219a88e9c6 | ||
|
|
79dacb20a0 | ||
|
|
f2b0adfa05 | ||
|
|
4830be0ea4 | ||
|
|
4a5bd50202 | ||
|
|
6a47d49ee8 | ||
|
|
3d06900e68 | ||
|
|
3259bf71e6 | ||
|
|
526e980a69 | ||
|
|
ab09909f99 | ||
|
|
d8b597b168 | ||
|
|
9bc335b35e | ||
|
|
227f2779d7 | ||
|
|
2ffda45adf | ||
|
|
bb2712fe45 | ||
|
|
cbf61d5524 | ||
|
|
39763a8ca7 | ||
|
|
aa19369466 | ||
|
|
3f65d6c350 | ||
|
|
99646e6436 | ||
|
|
450d624474 | ||
|
|
ca0c35aa15 | ||
|
|
fcfd8ea76e | ||
|
|
2044c36398 | ||
|
|
d374e1c160 | ||
|
|
ee491a0e5e | ||
|
|
e605882451 | ||
|
|
b91c8e17a7 | ||
|
|
dcc622d374 | ||
|
|
a3e5edc367 | ||
|
|
bd7c9e30d3 | ||
|
|
62dfb749f1 | ||
|
|
3b9de3baa3 | ||
|
|
d593988e5d | ||
|
|
0191210145 | ||
|
|
0f30a052b2 | ||
|
|
1c6ab3f831 | ||
|
|
5ffc297a69 | ||
|
|
e7340bfe5b | ||
|
|
ca651becf8 | ||
|
|
6de09688ad | ||
|
|
94806b8036 | ||
|
|
fa52826c24 | ||
|
|
7b8f51a465 | ||
|
|
79b993e6d5 |
25
.gitignore
vendored
25
.gitignore
vendored
@@ -59,6 +59,12 @@ samples/client/petstore/qt5cpp/PetStore/PetStore
|
||||
samples/client/petstore/qt5cpp/PetStore/Makefile
|
||||
samples/client/petstore/qt5cpp/PetStore/PetStore.pro.user
|
||||
|
||||
# cpprestsdk
|
||||
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
|
||||
|
||||
#Java/Android
|
||||
**/.gradle
|
||||
samples/client/petstore/java/hello.txt
|
||||
@@ -87,21 +93,6 @@ samples/client/petstore/java/jersey2-java6/project/
|
||||
samples/client/petstore/java/jersey2-java8/project/
|
||||
samples/client/petstore/java/jersey2/project/
|
||||
|
||||
#PHP
|
||||
samples/client/petstore/php/OpenAPIToolsClient-php/composer.lock
|
||||
samples/client/petstore/php/OpenAPIToolsClient-php/vendor/
|
||||
samples/client/petstore/silex/SwaggerServer/composer.lock
|
||||
samples/client/petstore/silex/SwaggerServer/venodr/
|
||||
**/vendor/
|
||||
**/composer.lock
|
||||
|
||||
#PHP-Symfony
|
||||
samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/cache/
|
||||
samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/logs/
|
||||
|
||||
#PHP-laravel
|
||||
samples/server/petstore/php-laravel/node_modules
|
||||
|
||||
# Perl
|
||||
samples/client/petstore/perl/deep_module_test/
|
||||
|
||||
@@ -124,14 +115,14 @@ samples/client/petstore/swift/**/SwaggerClientTests/SwaggerClient.xcworkspace/xc
|
||||
samples/client/petstore/swift/**/SwaggerClientTests/Pods/
|
||||
#samples/client/petstore/swift/**/SwaggerClientTests/Pods/Pods.xcodeproj/xcuserdata
|
||||
#samples/client/petstore/swift/**/SwaggerClientTests/Pods/Pods.xcodeproj/xcshareddata/xcschemes
|
||||
samples/client/petstore/swift/**/SwaggerClientTests/Podfile.lock
|
||||
samples/client/petstore/swift/**/SwaggerClientTests/Podfile.lock
|
||||
# Swift3
|
||||
samples/client/petstore/swift3/**/SwaggerClientTests/SwaggerClient.xcodeproj/xcuserdata
|
||||
samples/client/petstore/swift3/**/SwaggerClientTests/SwaggerClient.xcworkspace/xcuserdata
|
||||
#samples/client/petstore/swift3/**/SwaggerClientTests/Pods/
|
||||
#samples/client/petstore/swift3/**/SwaggerClientTests/Pods/Pods.xcodeproj/xcuserdata
|
||||
#samples/client/petstore/swift3/**/SwaggerClientTests/Pods/Pods.xcodeproj/xcshareddata/xcschemes
|
||||
samples/client/petstore/swift3/**/SwaggerClientTests/Podfile.lock
|
||||
samples/client/petstore/swift3/**/SwaggerClientTests/Podfile.lock
|
||||
|
||||
# C#
|
||||
*.csproj.user
|
||||
|
||||
36
.hub.cli.dockerfile
Normal file
36
.hub.cli.dockerfile
Normal file
@@ -0,0 +1,36 @@
|
||||
## The builder labeled image acts as a transient container which is meant to
|
||||
## hold all non-artifact code.
|
||||
##
|
||||
## You can build _just_ this part with:
|
||||
## docker --target builder -t container-name:builder -f .hub.cli.dockerfile .
|
||||
FROM jimschubert/8-jdk-alpine-mvn:1.0 as builder
|
||||
|
||||
RUN set -x && \
|
||||
apk add --no-cache bash
|
||||
|
||||
ENV GEN_DIR /opt/openapi-generator
|
||||
WORKDIR ${GEN_DIR}
|
||||
COPY . ${GEN_DIR}
|
||||
|
||||
# Pre-compile openapi-generator-cli
|
||||
RUN mvn -am -pl "modules/openapi-generator-cli" package
|
||||
|
||||
## The final (release) image
|
||||
## The resulting container here only needs the target jar
|
||||
## and ca-certificates (to be able to query HTTPS hosted specs)
|
||||
FROM openjdk:8-jre-alpine
|
||||
|
||||
ENV GEN_DIR /opt/openapi-generator
|
||||
|
||||
RUN apk --no-cache add ca-certificates bash
|
||||
RUN mkdir -p ${GEN_DIR}/modules/openapi-generator-cli/target
|
||||
|
||||
WORKDIR ${GEN_DIR}/modules/openapi-generator-cli/target
|
||||
|
||||
COPY --from=builder ${GEN_DIR}/modules/openapi-generator-cli/target/openapi-generator-cli.jar ${GEN_DIR}/modules/openapi-generator-cli/target/openapi-generator-cli.jar
|
||||
|
||||
COPY docker-entrypoint.sh /usr/local/bin/
|
||||
|
||||
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||
|
||||
CMD ["help"]
|
||||
35
.hub.online.dockerfile
Normal file
35
.hub.online.dockerfile
Normal file
@@ -0,0 +1,35 @@
|
||||
## The builder labeled image acts as a transient container which is meant to
|
||||
## hold all non-artifact code.
|
||||
##
|
||||
## You can build _just_ this part with:
|
||||
## docker --target builder -t container-name:builder -f .hub.online.dockerfile .
|
||||
FROM jimschubert/8-jdk-alpine-mvn:1.0 as builder
|
||||
|
||||
RUN set -x && \
|
||||
apk add --no-cache bash
|
||||
|
||||
ENV GEN_DIR /opt/openapi-generator
|
||||
WORKDIR ${GEN_DIR}
|
||||
COPY . ${GEN_DIR}
|
||||
|
||||
# Pre-compile openapi-generator-online
|
||||
RUN mvn -am -pl "modules/openapi-generator-online" package
|
||||
|
||||
## The final (release) image
|
||||
## The resulting container here only needs the target jar
|
||||
FROM openjdk:8-jre-alpine
|
||||
|
||||
ENV GEN_DIR /opt/openapi-generator
|
||||
ENV TARGET_DIR /generator
|
||||
|
||||
RUN mkdir -p ${TARGET_DIR}
|
||||
|
||||
WORKDIR ${TARGET_DIR}
|
||||
|
||||
COPY --from=builder ${GEN_DIR}/modules/openapi-generator-online/target/openapi-generator-online.jar ${TARGET_DIR}/openapi-generator-online.jar
|
||||
|
||||
ENV GENERATOR_HOST=http://localhost
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["java", "-jar", "/generator/openapi-generator-online.jar"]
|
||||
@@ -31,6 +31,8 @@ cache:
|
||||
- $HOME/.cargo
|
||||
- $HOME/.stack
|
||||
- $HOME/samples/server/petstore/cpp-pistache/pistache
|
||||
- $HOME/.npm
|
||||
- $HOME/.rvm/gems/ruby-2.4.1
|
||||
|
||||
services:
|
||||
- docker
|
||||
@@ -57,7 +59,7 @@ before_install:
|
||||
- gem install bundler
|
||||
- npm install -g typescript
|
||||
- npm install -g npm
|
||||
- npm install -g elm
|
||||
- npm install -g elm@0.18.0-exp5
|
||||
- npm config set registry http://registry.npmjs.org/
|
||||
# set python 3.6.3 as default
|
||||
- source ~/virtualenv/python3.6/bin/activate
|
||||
@@ -123,7 +125,7 @@ after_success:
|
||||
./gradlew -Psigning.keyId="$SIGNING_KEY" -Psigning.password="$SIGNING_PASSPHRASE" -Psigning.secretKeyRingFile="${TRAVIS_BUILD_DIR}/sec.gpg" -PossrhUsername="${SONATYPE_USERNAME}" -PossrhPassword="${SONATYPE_PASSWORD}" uploadArchives --no-daemon;
|
||||
echo "Finished ./gradlew uploadArchives";
|
||||
popd;
|
||||
elif ([ "$TRAVIS_BRANCH" == "4.0.x" ]) ; then
|
||||
elif ([[ "$TRAVIS_BRANCH" =~ ^[0-9]+\.[0-9]+\.x$ ]]) ; then
|
||||
mvn clean deploy --settings CI/settings.xml;
|
||||
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
|
||||
pushd .;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>openapi-generator-project</name>
|
||||
<version>3.2.1</version>
|
||||
<version>3.2.3</version>
|
||||
<url>https://github.com/openapi-tools/openapi-generator</url>
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:openapi-tools/openapi-generator.git</connection>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>openapi-generator-project</name>
|
||||
<version>3.2.1</version>
|
||||
<version>3.2.3</version>
|
||||
<url>https://github.com/openapitools/openapi-generator</url>
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
|
||||
@@ -899,6 +899,7 @@
|
||||
<module>samples/client/petstore/java/retrofit2</module>
|
||||
<module>samples/client/petstore/java/retrofit2rx</module>
|
||||
<module>samples/client/petstore/java/retrofit2-play25</module>
|
||||
<module>samples/client/petstore/java/retrofit2-play26</module>
|
||||
<module>samples/client/petstore/jaxrs-cxf-client</module>
|
||||
<module>samples/client/petstore/java/resttemplate</module>
|
||||
<module>samples/client/petstore/java/resttemplate-withXml</module>
|
||||
@@ -957,6 +958,7 @@
|
||||
<module>samples/server/petstore/scala-lagom-server</module>
|
||||
<module>samples/server/petstore/scalatra</module>
|
||||
<module>samples/server/petstore/finch</module>
|
||||
<module>samples/server/petstore/kotlin-springboot</module>
|
||||
</modules>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>openapi-generator-project</name>
|
||||
<version>3.2.1</version>
|
||||
<version>3.2.3</version>
|
||||
<url>https://github.com/openapitools/openapi-generator</url>
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>openapi-generator-project</name>
|
||||
<version>3.2.1</version>
|
||||
<version>3.2.3</version>
|
||||
<url>https://github.com/openapitools/openapi-generator</url>
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ApiClientTest {
|
||||
assertEquals(dateStr, apiClient.formatDate(apiClient.parseDate("2015-11-07T02:49:09.356-01:00")));
|
||||
|
||||
// custom date format: without milli-seconds, custom time zone
|
||||
DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
|
||||
DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX", Locale.ROOT);
|
||||
format.setTimeZone(TimeZone.getTimeZone("GMT+10"));
|
||||
apiClient.setDateFormat(format);
|
||||
dateStr = "2015-11-07T13:49:09+10:00";
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ApiClientTest {
|
||||
assertEquals(dateStr, apiClient.formatDate(apiClient.parseDate("2015-11-07T02:49:09.356-01:00")));
|
||||
|
||||
// custom date format: without milli-seconds, custom time zone
|
||||
DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
|
||||
DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX", Locale.ROOT);
|
||||
format.setTimeZone(TimeZone.getTimeZone("GMT+10"));
|
||||
apiClient.setDateFormat(format);
|
||||
dateStr = "2015-11-07T13:49:09+10:00";
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import okio.ByteString;
|
||||
@@ -46,7 +47,7 @@ public class JSONTest {
|
||||
assertEquals(json.deserialize("\"2015-11-07T03:49:09.356" + getCurrentTimezoneOffset() + "\"", java.sql.Date.class).toString(), date.toString());
|
||||
|
||||
// custom date format: without day
|
||||
DateFormat format = new SimpleDateFormat("yyyy-MM");
|
||||
DateFormat format = new SimpleDateFormat("yyyy-MM", Locale.ROOT);
|
||||
apiClient.setSqlDateFormat(format);
|
||||
String dateStr = "\"2015-11\"";
|
||||
assertEquals(dateStr, json.serialize(json.deserialize("\"2015-11-07T03:49:09Z\"", java.sql.Date.class)));
|
||||
@@ -79,7 +80,7 @@ public class JSONTest {
|
||||
assertEquals(utcDate, json.serialize(date));
|
||||
|
||||
// custom datetime format: without milli-seconds, custom time zone
|
||||
DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
|
||||
DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX", Locale.ROOT);
|
||||
format.setTimeZone(TimeZone.getTimeZone("GMT+10"));
|
||||
apiClient.setDateFormat(format);
|
||||
|
||||
@@ -190,10 +191,10 @@ public class JSONTest {
|
||||
public static String getCurrentTimezoneOffset() {
|
||||
|
||||
TimeZone tz = TimeZone.getDefault();
|
||||
Calendar cal = GregorianCalendar.getInstance(tz);
|
||||
Calendar cal = GregorianCalendar.getInstance(tz, Locale.ROOT);
|
||||
int offsetInMillis = tz.getOffset(cal.getTimeInMillis());
|
||||
|
||||
String offset = String.format("%02d:%02d", Math.abs(offsetInMillis / 3600000), Math.abs((offsetInMillis / 60000) % 60));
|
||||
String offset = String.format(Locale.ROOT,"%02d:%02d", Math.abs(offsetInMillis / 3600000), Math.abs((offsetInMillis / 60000) % 60));
|
||||
offset = (offsetInMillis >= 0 ? "+" : "-") + offset;
|
||||
|
||||
return offset;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class ApiClientTest {
|
||||
assertEquals(dateStr, apiClient.formatDate(apiClient.parseDate("2015-11-07T02:49:09.356-01:00")));
|
||||
|
||||
// custom date format: without milli-seconds, custom time zone
|
||||
DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
|
||||
DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX", Locale.ROOT);
|
||||
format.setTimeZone(TimeZone.getTimeZone("GMT+10"));
|
||||
apiClient.setDateFormat(format);
|
||||
dateStr = "2015-11-07T13:49:09+10:00";
|
||||
|
||||
52
README.md
52
README.md
@@ -2,7 +2,7 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`3.2.2`): [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||
[Master](https://github.com/OpenAPITools/openapi-generator/tree/master) (`3.3.0`): [](https://travis-ci.org/OpenAPITools/openapi-generator)
|
||||
[](https://circleci.com/gh/OpenAPITools/openapi-generator)
|
||||
[](https://app.shippable.com/github/OpenAPITools/openapi-generator)
|
||||
[](https://ci.appveyor.com/project/WilliamCheng/openapi-generator-wh2wu)
|
||||
@@ -42,8 +42,8 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
|
||||
|
||||
| | Languages/Frameworks |
|
||||
|-|-|
|
||||
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C#** (.net 2.0, 3.5 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured), **Kotlin**, **Lua**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types) **Objective-C**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 6.x), Aurelia, Fetch, Inversify, jQuery, Node)
|
||||
**Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed), **Erlang**, **Go**, **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples)), **Kotlin**, **PHP** (Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** ([Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), Scalatra)
|
||||
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C#** (.net 2.0, 3.5 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client), **Kotlin**, **Lua**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types) **Objective-C**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 6.x), Aurelia, Fetch, Inversify, jQuery, Node)
|
||||
**Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed), **Erlang**, **Go**, **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples)), **Kotlin** (Spring Boot), **PHP** (Laravel, Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** ([Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), Scalatra)
|
||||
**API documentation generators** | **HTML**, **Confluence Wiki**
|
||||
**Configuration files** | [**Apache2**](https://httpd.apache.org/)
|
||||
**Others** | **JMeter**
|
||||
@@ -80,22 +80,17 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
|
||||
|
||||
The OpenAPI Specification has undergone 3 revisions since initial creation in 2010. The openapi-generator project has the following compatibilities with the OpenAPI Specification:
|
||||
|
||||
OpenAPI Generator Version | Release Date | OpenAPI Spec compatibility | Notes
|
||||
---------------------------- | ------------ | -------------------------- | -----
|
||||
4.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.0.0-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | Major release with breaking changes (no fallback)
|
||||
3.3.0 (upcoming minor release)| TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | Minor release (breaking changes with fallbacks)
|
||||
3.2.2 (current master, upcoming patch release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/3.2.2-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | Bugfix release
|
||||
[3.2.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.2.1) | 14.08.2018 | 1.0, 1.1, 1.2, 2.0, 3.0 | Bugfix release
|
||||
[3.2.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.2.0) | 06.08.2018 | 1.0, 1.1, 1.2, 2.0, 3.0 | Bugfix release
|
||||
[3.1.2](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.1.2) | 25.07.2018 | 1.0, 1.1, 1.2, 2.0, 3.0 | Bugfix release
|
||||
[3.1.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.1.1) | 18.07.2018 | 1.0, 1.1, 1.2, 2.0, 3.0 | Bugfix release
|
||||
[3.1.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.1.0) | 06.07.2018 | 1.0, 1.1, 1.2, 2.0, 3.0 | Minor release (breaking changes with fallbacks)
|
||||
[3.0.3](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.0.3) | 27.06.2018 | 1.0, 1.1, 1.2, 2.0, 3.0 | Bugfix release
|
||||
[3.0.2](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.0.2) | 18.06.2018 | 1.0, 1.1, 1.2, 2.0, 3.0 | Bugfix release
|
||||
[3.0.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.0.1) | 11.06.2018 | 1.0, 1.1, 1.2, 2.0, 3.0 | Bugfix release
|
||||
[3.0.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.0.0) | 01.06.2018 | 1.0, 1.1, 1.2, 2.0, 3.0 | First release with breaking changes
|
||||
OpenAPI Generator Version | Release Date | Notes
|
||||
---------------------------- | ------------ | -----
|
||||
4.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.0.0-SNAPSHOT/)| TBD | Major release with breaking changes (no fallback)
|
||||
3.3.0 (current master, upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/3.3.0-SNAPSHOT/) | 07.09.2018 | Minor release (breaking changes with fallbacks)
|
||||
[3.2.3](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.2.3) (latest stable release) | 30.08.2018 | Bugfix release
|
||||
|
||||
### [1.2 - Artifacts on Maven Central](#table-of-contents)
|
||||
OpenAPI Spec compatibility: 1.0, 1.1, 1.2, 2.0, 3.0
|
||||
|
||||
For old releases, please refer to the [**Release**](https://github.com/OpenAPITools/openapi-generator/releases) page.
|
||||
|
||||
## [1.2 - Artifacts on Maven Central](#table-of-contents)
|
||||
|
||||
You can find our released artefacts on maven central:
|
||||
|
||||
@@ -145,16 +140,16 @@ See the different versions of the [openapi-generator-cli](https://mvnrepository.
|
||||
|
||||
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum):
|
||||
|
||||
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.2.1/openapi-generator-cli-3.2.1.jar`
|
||||
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.2.3/openapi-generator-cli-3.2.3.jar`
|
||||
|
||||
For **Mac/Linux** users:
|
||||
```sh
|
||||
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.2.1/openapi-generator-cli-3.2.1.jar -O openapi-generator-cli.jar
|
||||
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.2.3/openapi-generator-cli-3.2.3.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 http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.2.1/openapi-generator-cli-3.2.1.jar
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.2.3/openapi-generator-cli-3.2.3.jar
|
||||
```
|
||||
|
||||
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
|
||||
@@ -167,7 +162,7 @@ export PATH=${JAVA_HOME}/bin:$PATH
|
||||
|
||||
### Launcher Script
|
||||
|
||||
One downside to manual jar downloads is that you don't keep up-to-date with the latest released version. We have a Bash launcher script at [bin/utils/openapi-generator.cli.sh](./bin/utils/openapi-generator.cli.sh) which resolves this issue.
|
||||
One downside to manual jar downloads is that you don't keep up-to-date with the latest released version. We have a Bash launcher script at [bin/utils/openapi-generator.cli.sh](./bin/utils/openapi-generator-cli.sh) which resolves this issue.
|
||||
|
||||
To install the launcher script, copy the contents of the script to a location on your path and make the script executable.
|
||||
|
||||
@@ -410,13 +405,14 @@ SYNOPSIS
|
||||
[--invoker-package <invoker package>]
|
||||
[(-l <language> | --lang <language>)]
|
||||
[--language-specific-primitives <language specific primitives>...]
|
||||
[--library <library>] [--model-name-prefix <model name prefix>]
|
||||
[--library <library>] [--log-to-stderr]
|
||||
[--model-name-prefix <model name prefix>]
|
||||
[--model-name-suffix <model name suffix>]
|
||||
[--model-package <model package>]
|
||||
[(-o <output directory> | --output <output directory>)]
|
||||
[--release-note <release note>] [--remove-operation-id-prefix]
|
||||
[--reserved-words-mappings <reserved word mappings>...]
|
||||
[(-s | --skip-overwrite)]
|
||||
[(-s | --skip-overwrite)] [--skip-validate-spec]
|
||||
[(-t <template directory> | --template-dir <template directory>)]
|
||||
[--type-mappings <type mappings>...] [(-v | --verbose)]
|
||||
|
||||
@@ -472,12 +468,15 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
|
||||
- [Angular.Schule](https://angular.schule/)
|
||||
- [Bithost GmbH](https://www.bithost.ch)
|
||||
- [Boxever](https://www.boxever.com/)
|
||||
- [GMO Pepabo](https://pepabo.com/en/)
|
||||
- [Raiffeisen Schweiz Genossenschaft](https://www.raiffeisen.ch)
|
||||
- [RepreZen API Studio](https://www.reprezen.com/swagger-openapi-code-generation-api-first-microservices-enterprise-development)
|
||||
- [REST United](https://restunited.com)
|
||||
- [Suva](https://www.suva.ch/)
|
||||
- [Telstra](https://dev.telstra.com)
|
||||
- [unblu inc.](https://www.unblu.com/)
|
||||
- [Zalando](https://www.zalando.com)
|
||||
|
||||
## [5 - Presentations/Videos/Tutorials/Books](#table-of-contents)
|
||||
|
||||
@@ -486,7 +485,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
|
||||
- 2018/05/15 - [REST API仕様からAPIクライアントやスタブサーバを自動生成する「OpenAPI Generator」オープンソースで公開。Swagger Codegenからのフォーク](https://www.publickey1.jp/blog/18/rest_apiapiopenapi_generatorswagger_generator.html) by [Publickey](https://www.publickey1.jp)
|
||||
- 2018/06/08 - [Swagger Codegen is now OpenAPI Generator](https://angular.schule/blog/2018-06-swagger-codegen-is-now-openapi-generator) by [JohannesHoppe](https://github.com/JohannesHoppe)
|
||||
- 2018/06/21 - [Connect your JHipster apps to the world of APIs with OpenAPI and gRPC](https://fr.slideshare.net/chbornet/jhipster-conf-2018-connect-your-jhipster-apps-to-the-world-of-apis-with-openapi-and-grpc) by [Christophe Bornet](https://github.com/cbornet) at [JHipster Conf 2018](https://jhipster-conf.github.io/)
|
||||
- 2018/06/27 - [Lessons Learned from Leading an Open-Source Project Supporting 30+ Programming Languages](https://speakerdeck.com/wing328/lessons-learned-from-leading-an-open-source-project-supporting-30-plus-programming-languages) - [William Cheng](https://github.com/wing328) at [LinuxCon + ContainerCon + CloudOpen China 2018](https://www.lfasiallc.com/events/lc3-2018/)
|
||||
- 2018/06/27 - [Lessons Learned from Leading an Open-Source Project Supporting 30+ Programming Languages](https://speakerdeck.com/wing328/lessons-learned-from-leading-an-open-source-project-supporting-30-plus-programming-languages) - [William Cheng](https://github.com/wing328) at [LinuxCon + ContainerCon + CloudOpen China 2018](http://bit.ly/2waDKKX)
|
||||
- 2018/07/19 - [OpenAPI Generator Contribution Quickstart - RingCentral Go SDK](https://medium.com/ringcentral-developers/openapi-generator-for-go-contribution-quickstart-8cc72bf37b53) by [John Wang](https://github.com/grokify)
|
||||
|
||||
## [6 - About Us](#table-of-contents)
|
||||
@@ -578,6 +577,7 @@ Here is a list of template creators:
|
||||
* JAX-RS CXF (CDI): @nickcmaynard
|
||||
* JAX-RS RestEasy (JBoss EAP): @jfiala
|
||||
* Kotlin: @jimschubert
|
||||
* Kotlin (Spring Boot): @dr4ke616
|
||||
* PHP Laravel: @renepardon
|
||||
* PHP Lumen: @abcsun
|
||||
* PHP Slim: @jfastnacht
|
||||
@@ -641,7 +641,7 @@ If you want to join the committee, please kindly apply by sending an email to te
|
||||
| Groovy | |
|
||||
| Haskell | |
|
||||
| Java | @bbdouglas (2017/07) @JFCote (2017/08) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) |
|
||||
| Kotlin | @jimschubert (2017/09) |
|
||||
| Kotlin | @jimschubert (2017/09) @dr4ke616 (2018/08) |
|
||||
| Lua | @daurnimator (2017/08) |
|
||||
| NodeJS/Javascript | @CodeNinjai (2017/07) @frol (2017/07) @cliffano (2017/07) |
|
||||
| ObjC | |
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
./bin/java8-petstore-jersey2.sh
|
||||
./bin/java-petstore-retrofit2-play24.sh
|
||||
./bin/java-petstore-retrofit2-play25.sh
|
||||
./bin/java-petstore-retrofit2-play26.sh
|
||||
./bin/java-petstore-jersey2-java6.sh
|
||||
./bin/java-petstore-resttemplate.sh
|
||||
./bin/java-petstore-resttemplate-withxml.sh
|
||||
|
||||
1
bin/java-petstore-retrofit2-play26.json
Normal file
1
bin/java-petstore-retrofit2-play26.json
Normal file
@@ -0,0 +1 @@
|
||||
{"useBeanValidation":"true","enableBuilderSupport":"true","library":"retrofit2","usePlayWS":"true","playVersion":"play26"}
|
||||
35
bin/java-petstore-retrofit2-play26.sh
Executable file
35
bin/java-petstore-retrofit2-play26.sh
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate --artifact-id petstore-java-client-retrofit2-play26 -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g java -c bin/java-petstore-retrofit2-play26.json -o samples/client/petstore/java/retrofit2-play26 -DhideGenerationTimestamp=true $@"
|
||||
|
||||
echo "Removing files and folders under samples/client/petstore/java/retrofit2-play26/src/main"
|
||||
rm -rf samples/client/petstore/java/retrofit2-play26/src/main
|
||||
find samples/client/petstore/java/retrofit2-play26 -maxdepth 1 -type f ! -name "README.md" -exec rm {} +
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
35
bin/kotlin-springboot-petstore-server.sh
Executable file
35
bin/kotlin-springboot-petstore-server.sh
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=$(ls -ld "$SCRIPT")
|
||||
link=$(expr "$ls" : '.*-> \(.*\)$')
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=$(dirname "$SCRIPT")/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=$(dirname "$SCRIPT")/..
|
||||
APP_DIR=$(cd "${APP_DIR}"; pwd)
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -t modules/openapi-generator/src/main/resources/kotlin-spring -g kotlin-spring -o samples/server/petstore/kotlin-springboot --additional-properties=library=spring-boot,beanValidations=true,swaggerAnnotations=true,serviceImplementation=true"
|
||||
|
||||
echo "Cleaning previously generated files if any from samples/server/petstore/kotlin-springboot"
|
||||
rm -rf samples/server/petstore/kotlin-springboot
|
||||
|
||||
echo "Generating Kotling Spring Boot server..."
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -26,11 +26,11 @@ then
|
||||
fi
|
||||
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="meta -n myClientCodegen -p com.my.company.codegen -o samples/meta-codegen/lib $@"
|
||||
ags="meta -n myClientCodegen -t DOCUMENTATION -p com.my.company.codegen -o samples/meta-codegen/lib $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
mvn verify -f samples/meta-codegen/lib/pom.xml
|
||||
mvn clean package -f samples/meta-codegen/pom.xml
|
||||
|
||||
ags2="generate -g myClientCodegen -i modules/openapi-generator/src/test/resources/2_0/petstore.json -o samples/meta-codegen/usage $@"
|
||||
|
||||
|
||||
0
bin/openapi3/jaxrs-jersey-petstore.sh
Normal file → Executable file
0
bin/openapi3/jaxrs-jersey-petstore.sh
Normal file → Executable file
35
bin/openapi3/kotlin-springboot-petstore-server.sh
Executable file
35
bin/openapi3/kotlin-springboot-petstore-server.sh
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=$(ls -ld "$SCRIPT")
|
||||
link=$(expr "$ls" : '.*-> \(.*\)$')
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=$(dirname "$SCRIPT")/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=$(dirname "$SCRIPT")/..
|
||||
APP_DIR=$(cd "${APP_DIR}"; pwd)
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -t modules/openapi-generator/src/main/resources/kotlin-spring -g kotlin-spring -o samples/server/openapi3/petstore/kotlin-springboot --additional-properties=library=spring-boot,beanValidations=true,swaggerAnnotations=true,serviceImplementation=true"
|
||||
|
||||
echo "Cleaning previously generated files if any from samples/server/openapi3/petstore/kotlin-springboot"
|
||||
rm -rf samples/server/openapi3/petstore/kotlin-springboot
|
||||
|
||||
echo "Generating Kotling Spring Boot server..."
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -27,6 +27,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/php-silex -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g php-silex -o samples/server/petstore-security-test/silex $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/php-silex -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g php-silex -o samples/server/petstore-security-test/silex/SwaggerServer $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
33
bin/tests/run-all-test
Executable file
33
bin/tests/run-all-test
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
# this bash script will loop through all the .sh files under bin/tests
|
||||
# execute the script and check the result (exit code) to see if
|
||||
# there's any error
|
||||
|
||||
echo "IMPORTANT: this script should be run by the CI (e.g. Shippable) only. There's no need to run this script manually."
|
||||
echo "Please press CTRL+C to stop or the script will continue in 10 seconds."
|
||||
|
||||
sleep 10
|
||||
|
||||
successes=0
|
||||
failures=0
|
||||
for SCRIPT in $(ls -l ./bin/tests/*.sh | grep -v all)
|
||||
do
|
||||
if [ -f ${SCRIPT} -a -x ${SCRIPT} ]; then
|
||||
echo "Running $SCRIPT (output to /dev/null)"
|
||||
${SCRIPT} 2>&1 > /dev/null
|
||||
rc=$?
|
||||
if [[ ${rc} != 0 ]]; then
|
||||
>&2 echo "ERROR!! FAILED TO RUN ${SCRIPT}"
|
||||
((failures+=1))
|
||||
else
|
||||
((successes+=1))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if (( failures > 0 )); then
|
||||
>&2 echo "[ERROR] ${failures} out of $((failures+successes)) scripts failed."
|
||||
exit 1
|
||||
else
|
||||
echo "[SUCCESS] ${successes} generators finished."
|
||||
fi
|
||||
38
bin/tests/test-debug-supporting-files.sh
Executable file
38
bin/tests/test-debug-supporting-files.sh
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package $@
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/python -i modules/openapi-generator/src/test/resources/3_0/issue_241.yaml -g python -o /tmp/test-debug-supporting-files/ -DpackageName=petstore_api -DdebugSupportingFiles=true $@"
|
||||
|
||||
if [[ $(java $JAVA_OPTS -jar $executable $ags 2>&1 | grep "StackOverflowError") ]]; then
|
||||
echo "There are StackOverflowError. Please check the result."
|
||||
exit 1
|
||||
else
|
||||
echo "No StackOverflowError found."
|
||||
fi
|
||||
|
||||
@@ -10,7 +10,7 @@ echo "Please press CTRL+C to stop or the script will continue in 5 seconds."
|
||||
sleep 5
|
||||
|
||||
# LIST OF SCRIPTS:
|
||||
./bin/ruby-petstore.sh > /dev/null 2>&1
|
||||
./bin/ruby-client-petstore.sh > /dev/null 2>&1
|
||||
./bin/java-petstore-all.sh > /dev/null 2>&1
|
||||
./bin/java-jaxrs-petstore-server-all.sh > /dev/null 2>&1
|
||||
./bin/spring-all-pestore.sh > /dev/null 2>&1
|
||||
@@ -32,6 +32,7 @@ sleep 5
|
||||
./bin/rust-server-petstore.sh > /dev/null 2>&1
|
||||
./bin/openapi3/haskell-http-client-petstore.sh > /dev/null 2>&1
|
||||
./bin/csharp-petstore.sh > /dev/null 2>&1
|
||||
./bin/meta-codegen.sh > /dev/null 2>&1
|
||||
|
||||
# Check:
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
|
||||
@@ -45,7 +45,7 @@ declare -a files=("CI/pom.xml.bash"
|
||||
"modules/openapi-generator-maven-plugin/pom.xml"
|
||||
"modules/openapi-generator-online/pom.xml"
|
||||
"modules/openapi-generator/pom.xml"
|
||||
"modules/openapi-generator-online/Dockerfile"
|
||||
"samples/meta-codegen/lib/pom.xml"
|
||||
"pom.xml")
|
||||
|
||||
for filename in "${files[@]}"; do
|
||||
|
||||
10
bin/windows/kotlin-springboot-petstore-server.bat
Normal file
10
bin/windows/kotlin-springboot-petstore-server.bat
Normal file
@@ -0,0 +1,10 @@
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g kotlin-spring -o samples\server\petstore\kotlin-springboot --additional-properties=library=spring-boot
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
10
bin/windows/openapi3/kotlin-springboot-petstore-server.bat
Normal file
10
bin/windows/openapi3/kotlin-springboot-petstore-server.bat
Normal file
@@ -0,0 +1,10 @@
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g kotlin-spring -o samples\server\openapi3\petstore\kotlin-springboot --additional-properties=library=spring-boot
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
@@ -35,6 +35,8 @@ These names can be anything you like. If you are building a client for the white
|
||||
|
||||
**NOTE** Convention is to use kebab casing for names passed to `-n`. Example, `scala-finatra` would become `ScalaFinatraGenerator`.
|
||||
|
||||
#### Use your new generator with the CLI
|
||||
|
||||
To compile your library, enter the `out/generators/my-codegen` directory, run `mvn package` and execute the generator:
|
||||
|
||||
```sh
|
||||
@@ -50,11 +52,59 @@ Note the `my-codegen` is an option for `-g` now, and you can use the usual argum
|
||||
|
||||
```sh
|
||||
java -cp out/codegens/customCodegen/target/my-codegen-openapi-generator-1.0.0.jar:modules/openapi-generator-cli/target/openapi-generator-cli.jar \
|
||||
io.openapitools.codegen.OpenAPIGenerator generate -g my-codegen \
|
||||
org.openapitools.codegen.OpenAPIGenerator generate -g my-codegen \
|
||||
-i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml \
|
||||
-o ./out/myClient
|
||||
```
|
||||
|
||||
For Windows users:
|
||||
```
|
||||
java -cp out/codegens/customCodegen/target/my-codegen-openapi-generator-1.0.0.jar;modules/openapi-generator-cli/target/openapi-generator-cli.jar \
|
||||
org.openapitools.codegen.OpenAPIGenerator generate -g my-codegen \
|
||||
-i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml \
|
||||
-o ./out/myClient
|
||||
```
|
||||
|
||||
#### Use your new generator with the maven plugin
|
||||
|
||||
Install your library to your local maven repository by running:
|
||||
|
||||
```
|
||||
mvn clean install -f out/generators/my-codegen
|
||||
```
|
||||
|
||||
This will install `org.openapitools:my-codegen-openapi-generator:1.0.0` to your local maven repository.
|
||||
|
||||
You can use this as additional dependency of the `openapi-generator-maven-plugin` plugin and use `my-codegen` as `generatorName` value:
|
||||
|
||||
```xml
|
||||
<plugin>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<version>${openapi-generator-version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate-client-code</id>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<generatorName>my-codegen</generatorName>
|
||||
<!-- other configuration ... -->
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>my-codegen-openapi-generator</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
```
|
||||
|
||||
If you publish your artifact to a distant maven repository, do not forget to add this repository as `pluginRepository` for your project.
|
||||
|
||||
### Selective generation
|
||||
You may not want to generate *all* models in your project. Likewise you may want just one or two apis to be written. If that's the case, you can use system properties to control the output:
|
||||
@@ -106,6 +156,14 @@ java -Dapis -DmodelTests=false {opts}
|
||||
|
||||
When using selective generation, _only_ the templates needed for the specific generation will be used.
|
||||
|
||||
To skip models defined as the form parameters in "requestBody", please use `skipFormModel` (default to false) (this option is introduced at v3.2.2)
|
||||
|
||||
```sh
|
||||
java -DskipFormModel=true
|
||||
```
|
||||
|
||||
This option will be helpful to skip model generation due to the form parameter, which is defined differently in OAS3 as there's no form parameter in OAS3
|
||||
|
||||
### Ignore file format
|
||||
|
||||
OpenAPI Generator supports a `.openapi-generator-ignore` file, similar to `.gitignore` or `.dockerignore` you're probably already familiar with.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<version>3.2.3</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -24,6 +24,8 @@ import io.airlift.airline.ParseOptionMissingException;
|
||||
import io.airlift.airline.ParseOptionMissingValueException;
|
||||
import org.openapitools.codegen.cmd.*;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* User: lanwen Date: 24.03.15 Time: 17:56
|
||||
* <p>
|
||||
@@ -40,6 +42,7 @@ public class OpenAPIGenerator {
|
||||
Cli.<Runnable>builder("openapi-generator-cli")
|
||||
.withDescription(
|
||||
String.format(
|
||||
Locale.ROOT,
|
||||
"OpenAPI generator CLI (version %s).",
|
||||
version))
|
||||
.withDefaultCommand(ListGenerators.class)
|
||||
@@ -69,10 +72,10 @@ public class OpenAPIGenerator {
|
||||
System.exit(1);
|
||||
}
|
||||
} catch (ParseArgumentsUnexpectedException e) {
|
||||
System.err.printf("[error] %s%n%nSee 'openapi-generator-cli help' for usage.%n", e.getMessage());
|
||||
System.err.printf(Locale.ROOT,"[error] %s%n%nSee 'openapi-generator-cli help' for usage.%n", e.getMessage());
|
||||
System.exit(1);
|
||||
} catch (ParseOptionMissingException | ParseOptionMissingValueException e) {
|
||||
System.err.printf("[error] %s%n", e.getMessage());
|
||||
System.err.printf(Locale.ROOT,"[error] %s%n", e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
package org.openapitools.codegen.cmd;
|
||||
|
||||
import ch.qos.logback.classic.LoggerContext;
|
||||
import ch.qos.logback.core.spi.FilterAttachable;
|
||||
import io.airlift.airline.Command;
|
||||
import io.airlift.airline.Option;
|
||||
import org.openapitools.codegen.ClientOptInput;
|
||||
@@ -32,6 +34,7 @@ import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* User: lanwen Date: 24.03.15 Time: 20:22
|
||||
@@ -199,8 +202,23 @@ public class Generate implements Runnable {
|
||||
description = "Skips the default behavior of validating an input specification.")
|
||||
private Boolean skipValidateSpec;
|
||||
|
||||
@Option(name = {"--log-to-stderr"},
|
||||
title = "Log to STDERR",
|
||||
description = "write all log messages (not just errors) to STDOUT."
|
||||
+ " Useful for piping the JSON output of debug options (e.g. `-DdebugOperations`) to an external parser directly while testing a generator.")
|
||||
private Boolean logToStderr;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (logToStderr != null) {
|
||||
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
|
||||
Stream.of(Logger.ROOT_LOGGER_NAME, "io.swagger", "org.openapitools")
|
||||
.map(lc::getLogger)
|
||||
.peek(logger -> logger.detachAppender("STDOUT"))
|
||||
.reduce((logger, next) -> logger.getName().equals(Logger.ROOT_LOGGER_NAME) ? logger : next)
|
||||
.map(root -> root.getAppender("STDERR"))
|
||||
.ifPresent(FilterAttachable::clearAllFilters);
|
||||
}
|
||||
|
||||
// attempt to read from config file
|
||||
CodegenConfigurator configurator = CodegenConfigurator.fromFile(configFile);
|
||||
|
||||
@@ -21,6 +21,8 @@ import ch.lambdaj.collection.LambdaIterable;
|
||||
import io.airlift.airline.Command;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import static ch.lambdaj.Lambda.on;
|
||||
import static ch.lambdaj.collection.LambdaCollections.with;
|
||||
import static java.util.ServiceLoader.load;
|
||||
@@ -34,6 +36,6 @@ public class Langs implements Runnable {
|
||||
public void run() {
|
||||
LambdaIterable<String> langs =
|
||||
with(load(CodegenConfig.class)).extract(on(CodegenConfig.class).getName());
|
||||
System.out.printf("Available languages (generators): %s%n", langs);
|
||||
System.out.printf(Locale.ROOT, "Available languages (generators): %s%n", langs);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package org.openapitools.codegen.cmd;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import io.airlift.airline.Command;
|
||||
import io.airlift.airline.Option;
|
||||
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConfigLoader;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
@@ -9,6 +12,8 @@ import org.openapitools.codegen.CodegenType;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
// NOTE: List can later have subcommands such as list languages, list types, list frameworks, etc.
|
||||
@Command(name = "list", description = "Lists the available generators")
|
||||
@@ -40,19 +45,29 @@ public class ListGenerators implements Runnable {
|
||||
sb.append(System.lineSeparator());
|
||||
|
||||
for (CodegenType type : types) {
|
||||
sb.append(type.name()).append(" generators:");
|
||||
sb.append(System.lineSeparator());
|
||||
|
||||
generators.stream()
|
||||
.filter(g -> g.getTag().equals(type))
|
||||
.sorted(Comparator.comparing(CodegenConfig::getName))
|
||||
.forEach(generator -> sb.append(" - ").append(generator.getName()).append(System.lineSeparator()));
|
||||
|
||||
sb.append(System.lineSeparator());
|
||||
sb.append(System.lineSeparator());
|
||||
appendForType(sb, type, type.name(), generators);
|
||||
}
|
||||
appendForType(sb, null, "UNSPECIFIED", generators);
|
||||
}
|
||||
|
||||
System.out.printf("%s%n", sb.toString());
|
||||
System.out.printf(Locale.ROOT, "%s%n", sb.toString());
|
||||
}
|
||||
|
||||
private void appendForType(StringBuilder sb, CodegenType type, String typeName, List<CodegenConfig> generators) {
|
||||
List<CodegenConfig> list = generators.stream()
|
||||
.filter(g -> Objects.equal(type, g.getTag()))
|
||||
.sorted(Comparator.comparing(CodegenConfig::getName))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if(list.size() > 0) {
|
||||
sb.append(typeName).append(" generators:");
|
||||
sb.append(System.lineSeparator());
|
||||
|
||||
list.stream()
|
||||
.forEach(generator -> sb.append(" - ").append(generator.getName()).append(System.lineSeparator()));
|
||||
|
||||
sb.append(System.lineSeparator());
|
||||
sb.append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,11 @@ public class Meta implements Runnable {
|
||||
description = "the package to put the main class into (defaults to org.openapitools.codegen)")
|
||||
private String targetPackage = "org.openapitools.codegen";
|
||||
|
||||
@Option(name = {"-t", "--type"}, title = "type",
|
||||
description = "the type of generator that is created",
|
||||
allowedValues = {"CLIENT", "SERVER", "DOCUMENTATION", "CONFIG", "OTHER"})
|
||||
private String type = "OTHER";
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final File targetDir = new File(outputFolder);
|
||||
@@ -87,8 +92,11 @@ public class Meta implements Runnable {
|
||||
String currentVersion = Version.readVersionFromResources();
|
||||
|
||||
Map<String, Object> data =
|
||||
new ImmutableMap.Builder<String, Object>().put("generatorPackage", targetPackage)
|
||||
.put("generatorClass", mainClass).put("name", name)
|
||||
new ImmutableMap.Builder<String, Object>()
|
||||
.put("generatorPackage", targetPackage)
|
||||
.put("generatorClass", mainClass)
|
||||
.put("name", name)
|
||||
.put("generatorType", type)
|
||||
.put("fullyQualifiedGeneratorClass", targetPackage + "." + mainClass)
|
||||
.put("openapiGeneratorVersion", currentVersion).build();
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
This document describes the gradle plugin for OpenAPI Generator.
|
||||
|
||||
This gradle plugin offers a declarative DSL via _extensions_ (these are Gradle project extensions).
|
||||
These map almost fully 1:1 with the options you'd pass to the CLI or Maven plugin. The plugin maps the extensions to a task of the same name to provide a clean API. If you're interested in the extension/task mapping concept from a high-level, you can https://docs.gradle.org/current/userguide/custom_plugins.html#sec:mapping_extension_properties_to_task_properties[check out Gradle's docs].
|
||||
|
||||
== Tasks
|
||||
|
||||
Tasks are listed under the "OpenAPI Tools" tasks heading.
|
||||
@@ -24,6 +27,17 @@ Tasks are listed under the "OpenAPI Tools" tasks heading.
|
||||
|Validates an Open API 2.0 or 3.x specification document.
|
||||
|===
|
||||
|
||||
|
||||
[NOTE]
|
||||
====
|
||||
The plugin implements the above tasks as project extensions of the same name. If you'd like to declare
|
||||
these tasks as dependencies to other tasks (using `dependsOn`), you'll need a task reference. e.g.:
|
||||
|
||||
```
|
||||
compileJava.dependsOn tasks.openApiGenerate
|
||||
```
|
||||
====
|
||||
|
||||
== Plugin Setup
|
||||
|
||||
[source,groovy]
|
||||
@@ -34,7 +48,7 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:3.2.1"
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:3.2.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,3 +469,65 @@ Run with --stacktrace option to get the stack trace. Run with --info or --debug
|
||||
----
|
||||
$ ./gradlew openApiValidate --input=/Users/jim/projects/openapi-generator/modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
----
|
||||
|
||||
=== Generate multiple sources
|
||||
|
||||
If you want to perform multiple generation tasks, you'd want to create a task that inherits from the `GenerateTask`.
|
||||
Examples can be found in https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle[samples/local-spec/build.gradle].
|
||||
|
||||
You can define any number of generator tasks; the generated code does _not_ need to be a JVM language.
|
||||
|
||||
```gradle
|
||||
task buildGoClient(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask){
|
||||
generatorName = "go"
|
||||
inputSpec = "$rootDir/petstore-v3.0.yaml".toString()
|
||||
additionalProperties = [
|
||||
packageName: "petstore"
|
||||
]
|
||||
outputDir = "$buildDir/go".toString()
|
||||
configOptions = [
|
||||
dateLibrary: "threetenp"
|
||||
]
|
||||
}
|
||||
task buildKotlinClient(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask){
|
||||
generatorName = "kotlin"
|
||||
inputSpec = "$rootDir/petstore-v3.0.yaml".toString()
|
||||
outputDir = "$buildDir/kotlin".toString()
|
||||
apiPackage = "org.openapitools.example.api"
|
||||
invokerPackage = "org.openapitools.example.invoker"
|
||||
modelPackage = "org.openapitools.example.model"
|
||||
configOptions = [
|
||||
dateLibrary: "java8"
|
||||
]
|
||||
systemProperties = [
|
||||
modelDocs: "false"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
To execute your specs, you'd then do:
|
||||
|
||||
```
|
||||
./gradlew buildGoClient buildKotlinClient
|
||||
```
|
||||
|
||||
If you want to simplify the execution, you could create a new task with `dependsOn`.
|
||||
|
||||
```gradle
|
||||
task codegen(dependsOn: ['buildGoClient', 'buildKotlinClient'])
|
||||
```
|
||||
|
||||
Or, if you're generating the code on compile, you can add these as a dependency to `compileJava` or any other existing task.
|
||||
You can also mix the default task `openApiGenerate` with custom tasks:
|
||||
|
||||
```gradle
|
||||
compileJava.dependsOn buildKotlinClient, tasks.openApiGenerate
|
||||
```
|
||||
|
||||
[NOTE]
|
||||
====
|
||||
`openApiGenerate` is a project extension _and_ a task. If you want to use this in `dependsOn`,
|
||||
you need a task reference or instance. One way to do this is to access it as `tasks.openApiGenerate`.
|
||||
|
||||
You can run `gradle tasks --debug` to see this registration.
|
||||
====
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
openApiGeneratorVersion=3.2.1
|
||||
openApiGeneratorVersion=3.2.3
|
||||
|
||||
# BEGIN placeholders
|
||||
# these are just placeholders to allow contributors to build directly
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<version>3.2.3</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -17,5 +17,5 @@ gradle generateGoWithInvalidSpec
|
||||
The samples can be tested against other versions of the plugin using the `openApiGeneratorVersion` property. For example:
|
||||
|
||||
```bash
|
||||
gradle -PopenApiGeneratorVersion=3.2.1 openApiValidate
|
||||
gradle -PopenApiGeneratorVersion=3.2.3 openApiValidate
|
||||
```
|
||||
|
||||
@@ -1 +1 @@
|
||||
openApiGeneratorVersion=3.2.1
|
||||
openApiGeneratorVersion=3.2.3
|
||||
|
||||
@@ -11,7 +11,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
|
||||
<plugin>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<version>3.2.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<plugin>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<version>3.2.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<plugin>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<version>3.2.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<plugin>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<version>3.2.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<version>3.2.3</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
|
||||
@@ -2,7 +2,7 @@ FROM openjdk:8-jre-alpine
|
||||
|
||||
WORKDIR /generator
|
||||
|
||||
COPY target/openapi-generator-online-3.2.1.jar /generator/openapi-generator-online.jar
|
||||
COPY target/openapi-generator-online.jar /generator/openapi-generator-online.jar
|
||||
|
||||
ENV GENERATOR_HOST=http://localhost
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<version>3.2.3</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<artifactId>openapi-generator-online</artifactId>
|
||||
@@ -27,6 +27,7 @@
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<build>
|
||||
<finalName>openapi-generator-online</finalName>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
||||
@@ -19,11 +19,16 @@ package org.openapitools.codegen.online.service;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.swagger.parser.OpenAPIParser;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.parser.core.models.ParseOptions;
|
||||
import org.openapitools.codegen.*;
|
||||
import io.swagger.v3.parser.core.models.AuthorizationValue;
|
||||
import io.swagger.v3.core.util.Json;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.parser.core.models.AuthorizationValue;
|
||||
import io.swagger.v3.parser.core.models.ParseOptions;
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.ClientOptInput;
|
||||
import org.openapitools.codegen.ClientOpts;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConfigLoader;
|
||||
import org.openapitools.codegen.DefaultGenerator;
|
||||
import org.openapitools.codegen.online.model.GeneratorInput;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -34,6 +39,7 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class Generator {
|
||||
@@ -44,7 +50,7 @@ public class Generator {
|
||||
try {
|
||||
config = CodegenConfigLoader.forName(language);
|
||||
} catch (Exception e) {
|
||||
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, String.format("Unsupported target %s supplied. %s",
|
||||
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, String.format(Locale.ROOT,"Unsupported target %s supplied. %s",
|
||||
language, e));
|
||||
}
|
||||
Map<String, CliOption> map = new LinkedHashMap<>();
|
||||
@@ -77,7 +83,7 @@ public class Generator {
|
||||
}
|
||||
|
||||
private static String generate(String language, GeneratorInput opts, Type type) {
|
||||
LOGGER.debug(String.format("generate %s for %s", type.getTypeName(), language));
|
||||
LOGGER.debug(String.format(Locale.ROOT,"generate %s for %s", type.getTypeName(), language));
|
||||
if (opts == null) {
|
||||
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "No options were supplied");
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<version>3.2.3</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
* Copyright 2018 SmartBear Software
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CodegenCallback {
|
||||
public String name;
|
||||
public boolean hasMore;
|
||||
public List<Url> urls = new ArrayList<>();
|
||||
public Map<String, Object> vendorExtensions = new HashMap<>();
|
||||
|
||||
public static class Url {
|
||||
public String expression;
|
||||
public boolean hasMore;
|
||||
public List<CodegenOperation> requests = new ArrayList<>();
|
||||
public Map<String, Object> vendorExtensions = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Url that = (Url) o;
|
||||
return Objects.equals(that.expression, expression) && Objects.equals(that.hasMore, hasMore) &&
|
||||
Objects.equals(that.requests, requests) && Objects.equals(that.vendorExtensions, vendorExtensions);
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(expression, hasMore, requests, vendorExtensions);
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("CodegenCallback.Urls {\n");
|
||||
sb.append(" expression: ").append(expression).append("\n");
|
||||
requests.forEach(r -> sb.append(" ").append(r).append("\n"));
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
CodegenCallback that = (CodegenCallback) o;
|
||||
return Objects.equals(that.name, name) && Objects.equals(that.hasMore, hasMore) &&
|
||||
Objects.equals(that.urls, urls) && Objects.equals(that.vendorExtensions, vendorExtensions);
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, hasMore, urls, vendorExtensions);
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("CodegenCallback {\n");
|
||||
sb.append(" name: ").append(name).append("\n");
|
||||
urls.forEach(u -> sb.append(" ").append(u).append("\n"));
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,8 @@ import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||
import io.swagger.v3.oas.models.servers.Server;
|
||||
import io.swagger.v3.oas.models.servers.ServerVariable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -113,6 +115,10 @@ public interface CodegenConfig {
|
||||
|
||||
List<CodegenSecurity> fromSecurity(Map<String, SecurityScheme> schemas);
|
||||
|
||||
List<CodegenServer> fromServers(List<Server> servers);
|
||||
|
||||
List<CodegenServerVariable> fromServerVariables(Map<String, ServerVariable> variables);
|
||||
|
||||
Set<String> defaultIncludes();
|
||||
|
||||
Map<String, String> typeMapping();
|
||||
|
||||
@@ -31,6 +31,7 @@ public class CodegenConstants {
|
||||
public static final String API_TESTS = "apiTests";
|
||||
public static final String API_DOCS = "apiDocs";
|
||||
public static final String WITH_XML = "withXml";
|
||||
public static final String SKIP_FORM_MODEL = "skipFormModel";
|
||||
/* /end System Properties */
|
||||
|
||||
public static final String API_PACKAGE = "apiPackage";
|
||||
|
||||
@@ -22,11 +22,15 @@ import io.swagger.v3.oas.models.ExternalDocumentation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
@JsonIgnoreProperties({"parentModel", "interfaceModels"})
|
||||
public class CodegenModel {
|
||||
public String parent, parentSchema;
|
||||
public List<String> interfaces;
|
||||
@@ -76,7 +80,7 @@ public class CodegenModel {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s(%s)", name, classname);
|
||||
return String.format(Locale.ROOT, "%s(%s)", name, classname);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -35,7 +36,7 @@ public class CodegenOperation {
|
||||
isListContainer, isMultipart, hasMore = true,
|
||||
isResponseBinary = false, isResponseFile = false, hasReference = false,
|
||||
isRestfulIndex, isRestfulShow, isRestfulCreate, isRestfulUpdate, isRestfulDestroy,
|
||||
isRestful, isDeprecated;
|
||||
isRestful, isDeprecated, isCallbackRequest;
|
||||
public String path, operationId, returnType, httpMethod, returnBaseType,
|
||||
returnContainer, summary, unescapedNotes, notes, baseName, defaultResponse;
|
||||
public CodegenDiscriminator discriminator;
|
||||
@@ -53,6 +54,7 @@ public class CodegenOperation {
|
||||
public List<CodegenSecurity> authMethods;
|
||||
public List<Tag> tags;
|
||||
public List<CodegenResponse> responses = new ArrayList<CodegenResponse>();
|
||||
public List<CodegenCallback> callbacks = new ArrayList<>();
|
||||
public Set<String> imports = new HashSet<String>();
|
||||
public List<Map<String, String>> examples;
|
||||
public List<Map<String, String>> requestBodyExamples;
|
||||
@@ -196,7 +198,7 @@ public class CodegenOperation {
|
||||
* @return true if act as Restful update method, false otherwise
|
||||
*/
|
||||
public boolean isRestfulUpdate() {
|
||||
return Arrays.asList("PUT", "PATCH").contains(httpMethod.toUpperCase()) && isMemberPath();
|
||||
return Arrays.asList("PUT", "PATCH").contains(httpMethod.toUpperCase(Locale.ROOT)) && isMemberPath();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,7 +207,7 @@ public class CodegenOperation {
|
||||
* @return true request method is PUT, PATCH or POST; false otherwise
|
||||
*/
|
||||
public boolean isBodyAllowed() {
|
||||
return Arrays.asList("PUT", "PATCH", "POST").contains(httpMethod.toUpperCase());
|
||||
return Arrays.asList("PUT", "PATCH", "POST").contains(httpMethod.toUpperCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -232,7 +234,7 @@ public class CodegenOperation {
|
||||
* @return the substring
|
||||
*/
|
||||
private String pathWithoutBaseName() {
|
||||
return baseName != null ? path.replace("/" + baseName.toLowerCase(), "") : path;
|
||||
return baseName != null ? path.replace("/" + baseName.toLowerCase(Locale.ROOT), "") : path;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,7 +250,7 @@ public class CodegenOperation {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s(%s)", baseName, path);
|
||||
return String.format(Locale.ROOT, "%s(%s)", baseName, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -292,6 +294,8 @@ public class CodegenOperation {
|
||||
return false;
|
||||
if (isDeprecated != that.isDeprecated)
|
||||
return false;
|
||||
if (isCallbackRequest != that.isCallbackRequest)
|
||||
return false;
|
||||
if (path != null ? !path.equals(that.path) : that.path != null)
|
||||
return false;
|
||||
if (operationId != null ? !operationId.equals(that.operationId) : that.operationId != null)
|
||||
@@ -346,6 +350,8 @@ public class CodegenOperation {
|
||||
return false;
|
||||
if (responses != null ? !responses.equals(that.responses) : that.responses != null)
|
||||
return false;
|
||||
if (callbacks != null ? !callbacks.equals(that.callbacks) : that.callbacks != null)
|
||||
return false;
|
||||
if (imports != null ? !imports.equals(that.imports) : that.imports != null)
|
||||
return false;
|
||||
if (examples != null ? !examples.equals(that.examples) : that.examples != null)
|
||||
@@ -385,6 +391,7 @@ public class CodegenOperation {
|
||||
result = 31 * result + (isResponseFile ? 13:31);
|
||||
result = 31 * result + (hasReference ? 13:31);
|
||||
result = 31 * result + (isDeprecated ? 13:31);
|
||||
result = 31 * result + (isCallbackRequest ? 13:31);
|
||||
result = 31 * result + (path != null ? path.hashCode() : 0);
|
||||
result = 31 * result + (operationId != null ? operationId.hashCode() : 0);
|
||||
result = 31 * result + (returnType != null ? returnType.hashCode() : 0);
|
||||
@@ -412,6 +419,7 @@ public class CodegenOperation {
|
||||
result = 31 * result + (authMethods != null ? authMethods.hashCode() : 0);
|
||||
result = 31 * result + (tags != null ? tags.hashCode() : 0);
|
||||
result = 31 * result + (responses != null ? responses.hashCode() : 0);
|
||||
result = 31 * result + (callbacks != null ? callbacks.hashCode() : 0);
|
||||
result = 31 * result + (imports != null ? imports.hashCode() : 0);
|
||||
result = 31 * result + (examples != null ? examples.hashCode() : 0);
|
||||
result = 31 * result + (externalDocs != null ? externalDocs.hashCode() : 0);
|
||||
|
||||
@@ -41,6 +41,7 @@ public class CodegenParameter {
|
||||
public CodegenProperty mostInnerItems;
|
||||
public Map<String, Object> vendorExtensions = new HashMap<String, Object>();
|
||||
public boolean hasValidation;
|
||||
public boolean isNullable;
|
||||
|
||||
/**
|
||||
* Determines whether this parameter is mandatory. If the parameter is in "path",
|
||||
@@ -150,6 +151,7 @@ public class CodegenParameter {
|
||||
output.vendorExtensions = new HashMap<String, Object>(this.vendorExtensions);
|
||||
}
|
||||
output.hasValidation = this.hasValidation;
|
||||
output.isNullable = this.isNullable;
|
||||
output.isBinary = this.isBinary;
|
||||
output.isByteArray = this.isByteArray;
|
||||
output.isString = this.isString;
|
||||
@@ -269,6 +271,8 @@ public class CodegenParameter {
|
||||
return false;
|
||||
if (hasValidation != that.hasValidation)
|
||||
return false;
|
||||
if (isNullable != that.isNullable)
|
||||
return false;
|
||||
if (required != that.required)
|
||||
return false;
|
||||
if (maximum != null ? !maximum.equals(that.maximum) : that.maximum != null)
|
||||
@@ -344,6 +348,7 @@ public class CodegenParameter {
|
||||
result = 31 * result + (mostInnerItems != null ? mostInnerItems.hashCode() : 0);
|
||||
result = 31 * result + (vendorExtensions != null ? vendorExtensions.hashCode() : 0);
|
||||
result = 31 * result + (hasValidation ? 13:31);
|
||||
result = 31 * result + (isNullable ? 13:31);
|
||||
result = 31 * result + (required ? 13:31);
|
||||
result = 31 * result + (maximum != null ? maximum.hashCode() : 0);
|
||||
result = 31 * result + (exclusiveMaximum ? 13:31);
|
||||
@@ -409,6 +414,7 @@ public class CodegenParameter {
|
||||
", mostInnerItems=" + mostInnerItems +
|
||||
", vendorExtensions=" + vendorExtensions +
|
||||
", hasValidation=" + hasValidation +
|
||||
", isNullable=" + isNullable +
|
||||
", required=" + required +
|
||||
", maximum='" + maximum + '\'' +
|
||||
", exclusiveMaximum=" + exclusiveMaximum +
|
||||
|
||||
@@ -59,7 +59,9 @@ public class CodegenProperty implements Cloneable {
|
||||
public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary, isFile, isBoolean, isDate, isDateTime, isUuid;
|
||||
public boolean isListContainer, isMapContainer;
|
||||
public boolean isEnum;
|
||||
public boolean isReadOnly = false;
|
||||
public boolean isReadOnly;
|
||||
public boolean isWriteOnly;
|
||||
public boolean isNullable;
|
||||
public List<String> _enum;
|
||||
public Map<String, Object> allowableValues;
|
||||
public CodegenProperty items;
|
||||
@@ -437,6 +439,8 @@ public class CodegenProperty implements Cloneable {
|
||||
result = prime * result + ((isNotContainer ? 13:31));
|
||||
result = prime * result + ((isPrimitiveType ? 13:31));
|
||||
result = prime * result + ((isReadOnly ? 13:31));
|
||||
result = prime * result + ((isWriteOnly ? 13:31));
|
||||
result = prime * result + ((isNullable ? 13:31));
|
||||
result = prime * result + ((items == null) ? 0 : items.hashCode());
|
||||
result = prime * result + ((mostInnerItems == null) ? 0 : mostInnerItems.hashCode());
|
||||
result = prime * result + ((jsonSchema == null) ? 0 : jsonSchema.hashCode());
|
||||
@@ -587,6 +591,12 @@ public class CodegenProperty implements Cloneable {
|
||||
if (this.isReadOnly != other.isReadOnly) {
|
||||
return false;
|
||||
}
|
||||
if (this.isWriteOnly != other.isWriteOnly) {
|
||||
return false;
|
||||
}
|
||||
if (this.isNullable != other.isNullable) {
|
||||
return false;
|
||||
}
|
||||
if (this._enum != other._enum && (this._enum == null || !this._enum.equals(other._enum))) {
|
||||
return false;
|
||||
}
|
||||
@@ -769,6 +779,8 @@ public class CodegenProperty implements Cloneable {
|
||||
", isMapContainer=" + isMapContainer +
|
||||
", isEnum=" + isEnum +
|
||||
", isReadOnly=" + isReadOnly +
|
||||
", isWriteOnly=" + isWriteOnly+
|
||||
", isNullable=" + isNullable +
|
||||
", _enum=" + _enum +
|
||||
", allowableValues=" + allowableValues +
|
||||
", items=" + items +
|
||||
|
||||
@@ -20,6 +20,7 @@ package org.openapitools.codegen;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class CodegenResponse {
|
||||
@@ -47,7 +48,7 @@ public class CodegenResponse {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s(%s)", code, containerType);
|
||||
return String.format(Locale.ROOT, "%s(%s)", code, containerType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,6 +21,7 @@ import io.swagger.v3.oas.models.security.Scopes;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class CodegenSecurity {
|
||||
@@ -38,7 +39,7 @@ public class CodegenSecurity {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s(%s)", name, type);
|
||||
return String.format(Locale.ROOT, "%s(%s)", name, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.openapitools.codegen;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CodegenServer {
|
||||
public String url;
|
||||
public String description;
|
||||
public List<CodegenServerVariable> variables;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.openapitools.codegen;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CodegenServerVariable {
|
||||
public String name;
|
||||
public String defaultValue;
|
||||
public String description;
|
||||
public List<String> enumValues;
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public enum CodegenType {
|
||||
@@ -30,7 +31,7 @@ public enum CodegenType {
|
||||
|
||||
@JsonCreator
|
||||
public static CodegenType forValue(String value) {
|
||||
return names.get(value.toLowerCase());
|
||||
return names.get(value.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
@@ -50,4 +51,4 @@ public enum CodegenType {
|
||||
names.put("documentation", DOCUMENTATION);
|
||||
names.put("other", OTHER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.samskivert.mustache.Mustache.Compiler;
|
||||
import io.swagger.v3.core.util.Json;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.callbacks.Callback;
|
||||
import io.swagger.v3.oas.models.examples.Example;
|
||||
import io.swagger.v3.oas.models.headers.Header;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
@@ -43,11 +44,14 @@ import io.swagger.v3.oas.models.responses.ApiResponses;
|
||||
import io.swagger.v3.oas.models.security.OAuthFlow;
|
||||
import io.swagger.v3.oas.models.security.OAuthFlows;
|
||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||
import io.swagger.v3.oas.models.servers.Server;
|
||||
import io.swagger.v3.oas.models.servers.ServerVariable;
|
||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.openapitools.codegen.CodegenDiscriminator.MappedModel;
|
||||
import org.openapitools.codegen.examples.ExampleGenerator;
|
||||
import org.openapitools.codegen.serializer.SerializerUtils;
|
||||
@@ -64,7 +68,9 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
@@ -74,6 +80,10 @@ import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
import static org.openapitools.codegen.utils.StringUtils.escape;
|
||||
|
||||
public class DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultCodegen.class);
|
||||
|
||||
@@ -182,7 +192,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
.get(CodegenConstants.REMOVE_OPERATION_ID_PREFIX).toString()));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.DOCEXTENSION)){
|
||||
if (additionalProperties.containsKey(CodegenConstants.DOCEXTENSION)) {
|
||||
this.setDocExtension(String.valueOf(additionalProperties
|
||||
.get(CodegenConstants.DOCEXTENSION).toString()));
|
||||
}
|
||||
@@ -281,6 +291,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
enumVar.put("isString", isDataTypeString(cm.dataType));
|
||||
enumVars.add(enumVar);
|
||||
}
|
||||
// if "x-enum-varnames" defined, update varnames
|
||||
updateEnumVarsWithExtensions(enumVars, cm.getVendorExtensions());
|
||||
cm.allowableValues.put("enumVars", enumVars);
|
||||
}
|
||||
|
||||
@@ -355,7 +367,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return "EMPTY";
|
||||
}
|
||||
|
||||
String var = value.replaceAll("\\W+", "_").toUpperCase();
|
||||
String var = value.replaceAll("\\W+", "_").toUpperCase(Locale.ROOT);
|
||||
if (var.matches("\\d.*")) {
|
||||
return "_" + var;
|
||||
} else {
|
||||
@@ -768,8 +780,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
public String toVarName(String name) {
|
||||
if (reservedWords.contains(name)) {
|
||||
return escapeReservedWord(name);
|
||||
} else if (((CharSequence) name).chars().anyMatch(character -> specialCharReplacements.keySet().contains( "" + ((char) character)))) {
|
||||
return escapeSpecialCharacters(name, null, null);
|
||||
} else if (((CharSequence) name).chars().anyMatch(character -> specialCharReplacements.keySet().contains("" + ((char) character)))) {
|
||||
return escape(name, specialCharReplacements, null, null);
|
||||
} else {
|
||||
return name;
|
||||
}
|
||||
@@ -786,8 +798,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
name = removeNonNameElementToCamelCase(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
if (reservedWords.contains(name)) {
|
||||
return escapeReservedWord(name);
|
||||
} else if (((CharSequence) name).chars().anyMatch(character -> specialCharReplacements.keySet().contains( "" + ((char) character)))) {
|
||||
return escapeSpecialCharacters(name, null, null);
|
||||
} else if (((CharSequence) name).chars().anyMatch(character -> specialCharReplacements.keySet().contains("" + ((char) character)))) {
|
||||
return escape(name, specialCharReplacements, null, null);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
@@ -835,21 +847,13 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* @return the escaped word
|
||||
* <p>
|
||||
* throws Runtime exception as word is not escaped properly.
|
||||
* @deprecated since version 3.2.3, may be removed with the next major release (4.0)
|
||||
* @see org.openapitools.codegen.utils.StringUtils#escape directly instead
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public String escapeSpecialCharacters(String name, List<String> charactersToAllow, String appdendixToReplacement) {
|
||||
String result = (String) ((CharSequence) name).chars().mapToObj(c -> {
|
||||
String character = "" + (char) c;
|
||||
if (charactersToAllow != null && charactersToAllow.contains(character)) {
|
||||
return character;
|
||||
} else if (specialCharReplacements.containsKey(character)) {
|
||||
return specialCharReplacements.get(character) + (appdendixToReplacement != null ? appdendixToReplacement: "");
|
||||
} else {
|
||||
return character;
|
||||
}
|
||||
}).reduce( (c1, c2) -> "" + c1 + c2).orElse(null);
|
||||
|
||||
if (result != null) return result;
|
||||
throw new RuntimeException("Word '" + name + "' could not be escaped.");
|
||||
return escape(name, specialCharReplacements, charactersToAllow, appdendixToReplacement);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1091,7 +1095,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
*/
|
||||
public String toInstantiationType(Schema schema) {
|
||||
if (ModelUtils.isMapSchema(schema)) {
|
||||
Schema additionalProperties = (Schema) schema.getAdditionalProperties();
|
||||
Schema additionalProperties = ModelUtils.getAdditionalProperties(schema);
|
||||
String type = additionalProperties.getType();
|
||||
if (null == type) {
|
||||
LOGGER.error("No Type defined for Additional Property " + additionalProperties + "\n" //
|
||||
@@ -1680,13 +1684,13 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
private CodegenDiscriminator createDiscriminator(String schemaName, Schema schema, Map<String, Schema> allDefinitions) {
|
||||
if(schema.getDiscriminator() == null) {
|
||||
if (schema.getDiscriminator() == null) {
|
||||
return null;
|
||||
}
|
||||
CodegenDiscriminator discriminator = new CodegenDiscriminator();
|
||||
discriminator.setPropertyName(schema.getDiscriminator().getPropertyName());
|
||||
discriminator.setMapping(schema.getDiscriminator().getMapping());
|
||||
if(schema.getDiscriminator().getMapping() != null && !schema.getDiscriminator().getMapping().isEmpty()) {
|
||||
if (schema.getDiscriminator().getMapping() != null && !schema.getDiscriminator().getMapping().isEmpty()) {
|
||||
for (Entry<String, String> e : schema.getDiscriminator().getMapping().entrySet()) {
|
||||
String name = ModelUtils.getSimpleRef(e.getValue());
|
||||
discriminator.getMappedModels().add(new MappedModel(e.getKey(), name));
|
||||
@@ -1695,9 +1699,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
allDefinitions.forEach((childName, child) -> {
|
||||
if (child instanceof ComposedSchema && ((ComposedSchema) child).getAllOf() != null) {
|
||||
Set<String> parentSchemas = ((ComposedSchema) child).getAllOf().stream()
|
||||
.filter(s -> s.get$ref() != null)
|
||||
.map(s -> ModelUtils.getSimpleRef(s.get$ref()))
|
||||
.collect(Collectors.toSet());
|
||||
.filter(s -> s.get$ref() != null)
|
||||
.map(s -> ModelUtils.getSimpleRef(s.get$ref()))
|
||||
.collect(Collectors.toSet());
|
||||
if (parentSchemas.contains(schemaName)) {
|
||||
discriminator.getMappedModels().add(new MappedModel(childName, childName));
|
||||
}
|
||||
@@ -1747,7 +1751,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (name == null || name.length() == 0) {
|
||||
return name;
|
||||
}
|
||||
return camelize(toVarName(name));
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(toVarName(name));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1766,7 +1770,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
CodegenProperty property = CodegenModelFactory.newInstance(CodegenModelType.PROPERTY);
|
||||
property.name = toVarName(name);
|
||||
property.baseName = name;
|
||||
property.nameInCamelCase = camelize(property.name, false);
|
||||
property.nameInCamelCase = org.openapitools.codegen.utils.StringUtils.camelize(property.name, false);
|
||||
property.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, property.nameInCamelCase);
|
||||
property.description = escapeText(p.getDescription());
|
||||
property.unescapedDescription = p.getDescription();
|
||||
@@ -1783,6 +1787,13 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (p.getReadOnly() != null) {
|
||||
property.isReadOnly = p.getReadOnly();
|
||||
}
|
||||
if (p.getWriteOnly() != null) {
|
||||
property.isWriteOnly = p.getWriteOnly();
|
||||
}
|
||||
if (p.getNullable() != null) {
|
||||
property.isNullable = p.getNullable();
|
||||
}
|
||||
|
||||
if (p.getXml() != null) {
|
||||
if (p.getXml().getAttribute() != null) {
|
||||
property.isXmlAttribute = p.getXml().getAttribute();
|
||||
@@ -1995,7 +2006,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
property.maxItems = p.getMaxProperties();
|
||||
|
||||
// handle inner property
|
||||
CodegenProperty cp = fromProperty("inner", (Schema) p.getAdditionalProperties());
|
||||
CodegenProperty cp = fromProperty("inner", ModelUtils.getAdditionalProperties(p));
|
||||
updatePropertyForMap(property, cp);
|
||||
} else { // model
|
||||
// TODO revise the logic below
|
||||
@@ -2218,14 +2229,17 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
Map<String, Schema> schemas,
|
||||
OpenAPI openAPI) {
|
||||
LOGGER.debug("fromOperation => operation: " + operation);
|
||||
if (operation == null)
|
||||
throw new RuntimeException("operation cannot be null in fromOperation");
|
||||
|
||||
CodegenOperation op = CodegenModelFactory.newInstance(CodegenModelType.OPERATION);
|
||||
Set<String> imports = new HashSet<String>();
|
||||
if (operation.getExtensions() != null && !operation.getExtensions().isEmpty()) {
|
||||
op.vendorExtensions.putAll(operation.getExtensions());
|
||||
}
|
||||
|
||||
if (operation == null)
|
||||
throw new RuntimeException("operation cannot be null in fromOperation");
|
||||
Object isCallbackRequest = op.vendorExtensions.remove("x-callback-request");
|
||||
op.isCallbackRequest = Boolean.TRUE.equals(isCallbackRequest);
|
||||
}
|
||||
|
||||
// store the original operationId for plug-in
|
||||
op.operationIdOriginal = operation.getOperationId();
|
||||
@@ -2239,6 +2253,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
operationId = removeNonNameElementToCamelCase(operationId);
|
||||
|
||||
op.path = path;
|
||||
op.operationId = toOperationId(operationId);
|
||||
op.summary = escapeText(operation.getSummary());
|
||||
@@ -2257,7 +2272,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
for (String key : operation.getResponses().keySet()) {
|
||||
ApiResponse response = operation.getResponses().get(key);
|
||||
addProducesInfo(openAPI, response, op);
|
||||
CodegenResponse r = fromResponse(key, response);
|
||||
CodegenResponse r = fromResponse(openAPI, key, response);
|
||||
r.hasMore = true;
|
||||
if (r.baseType != null &&
|
||||
!defaultIncludes.contains(r.baseType) &&
|
||||
@@ -2285,7 +2300,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
CodegenProperty innerProperty = fromProperty("response", as.getItems());
|
||||
op.returnBaseType = innerProperty.baseType;
|
||||
} else if (ModelUtils.isMapSchema(responseSchema)) {
|
||||
CodegenProperty innerProperty = fromProperty("response", (Schema) responseSchema.getAdditionalProperties());
|
||||
CodegenProperty innerProperty = fromProperty("response", ModelUtils.getAdditionalProperties(responseSchema));
|
||||
op.returnBaseType = innerProperty.baseType;
|
||||
} else {
|
||||
if (cm.complexType != null) {
|
||||
@@ -2326,10 +2341,19 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
op.returnTypeIsPrimitive = true;
|
||||
}
|
||||
}
|
||||
addHeaders(methodResponse, op.responseHeaders);
|
||||
addHeaders(openAPI, methodResponse, op.responseHeaders);
|
||||
}
|
||||
}
|
||||
|
||||
if (operation.getCallbacks() != null && !operation.getCallbacks().isEmpty()) {
|
||||
operation.getCallbacks().forEach((name, callback) -> {
|
||||
CodegenCallback c = fromCallback(name, callback, schemas, openAPI);
|
||||
c.hasMore = true;
|
||||
op.callbacks.add(c);
|
||||
});
|
||||
op.callbacks.get(op.callbacks.size() - 1).hasMore = false;
|
||||
}
|
||||
|
||||
List<Parameter> parameters = operation.getParameters();
|
||||
List<CodegenParameter> allParams = new ArrayList<CodegenParameter>();
|
||||
List<CodegenParameter> bodyParams = new ArrayList<CodegenParameter>();
|
||||
@@ -2366,7 +2390,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
bodyParameterName = (String) op.vendorExtensions.get("x-codegen-request-body-name");
|
||||
}
|
||||
bodyParam = fromRequestBody(requestBody, schemas, imports, bodyParameterName);
|
||||
bodyParam.description = requestBody.getDescription();
|
||||
bodyParam.description = escapeText(requestBody.getDescription());
|
||||
postProcessParameter(bodyParam);
|
||||
|
||||
bodyParams.add(bodyParam);
|
||||
@@ -2443,7 +2467,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
op.bodyParam = bodyParam;
|
||||
op.httpMethod = httpMethod.toUpperCase();
|
||||
op.httpMethod = httpMethod.toUpperCase(Locale.ROOT);
|
||||
|
||||
// move "required" parameters in front of "optional" parameters
|
||||
if (sortParamsByRequiredFlag) {
|
||||
@@ -2503,11 +2527,12 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
/**
|
||||
* Convert OAS Response object to Codegen Response object
|
||||
*
|
||||
* @param openAPI a OAS object representing the spec
|
||||
* @param responseCode HTTP response code
|
||||
* @param response OAS Response object
|
||||
* @return Codegen Response object
|
||||
*/
|
||||
public CodegenResponse fromResponse(String responseCode, ApiResponse response) {
|
||||
public CodegenResponse fromResponse(OpenAPI openAPI, String responseCode, ApiResponse response) {
|
||||
CodegenResponse r = CodegenModelFactory.newInstance(CodegenModelType.RESPONSE);
|
||||
if ("default".equals(responseCode)) {
|
||||
r.code = "0";
|
||||
@@ -2524,7 +2549,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (response.getExtensions() != null && !response.getExtensions().isEmpty()) {
|
||||
r.vendorExtensions.putAll(response.getExtensions());
|
||||
}
|
||||
addHeaders(response, r.headers);
|
||||
addHeaders(openAPI, response, r.headers);
|
||||
r.hasHeaders = !r.headers.isEmpty();
|
||||
|
||||
if (r.schema != null) {
|
||||
@@ -2606,6 +2631,79 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert OAS Callback object to Codegen Callback object
|
||||
*
|
||||
* @param name callback name
|
||||
* @param callback OAS Callback object
|
||||
* @param schemas a map of OAS models
|
||||
* @param openAPI a OAS object representing the spec
|
||||
* @return Codegen Response object
|
||||
*/
|
||||
public CodegenCallback fromCallback(String name, Callback callback, Map<String, Schema> schemas, OpenAPI openAPI) {
|
||||
CodegenCallback c = new CodegenCallback();
|
||||
c.name = name;
|
||||
|
||||
if (callback.getExtensions() != null && !callback.getExtensions().isEmpty()) {
|
||||
c.vendorExtensions.putAll(callback.getExtensions());
|
||||
}
|
||||
|
||||
callback.forEach((expression, pi) -> {
|
||||
CodegenCallback.Url u = new CodegenCallback.Url();
|
||||
u.expression = expression;
|
||||
u.hasMore = true;
|
||||
|
||||
if (pi.getExtensions() != null && !pi.getExtensions().isEmpty()) {
|
||||
u.vendorExtensions.putAll(pi.getExtensions());
|
||||
}
|
||||
|
||||
Stream.of(
|
||||
Pair.of("get", pi.getGet()),
|
||||
Pair.of("head", pi.getHead()),
|
||||
Pair.of("put", pi.getPut()),
|
||||
Pair.of("post", pi.getPost()),
|
||||
Pair.of("delete", pi.getDelete()),
|
||||
Pair.of("patch", pi.getPatch()),
|
||||
Pair.of("options", pi.getOptions()))
|
||||
.filter(p -> p.getValue() != null)
|
||||
.forEach(p -> {
|
||||
String method = p.getKey();
|
||||
Operation op = p.getValue();
|
||||
|
||||
boolean genId = op.getOperationId() == null;
|
||||
if (genId) {
|
||||
op.setOperationId(getOrGenerateOperationId(op, c.name+"_"+expression.replaceAll("\\{\\$.*}", ""), method));
|
||||
}
|
||||
|
||||
if (op.getExtensions() == null) {
|
||||
op.setExtensions(new HashMap<>());
|
||||
}
|
||||
// This extension will be removed later by `fromOperation()` as it is only needed here to
|
||||
// distinguish between normal operations and callback requests
|
||||
op.getExtensions().put("x-callback-request", true);
|
||||
|
||||
CodegenOperation co = fromOperation(expression, method, op, schemas, openAPI);
|
||||
if (genId) {
|
||||
co.operationIdOriginal = null;
|
||||
// legacy (see `fromOperation()`)
|
||||
co.nickname = co.operationId;
|
||||
}
|
||||
u.requests.add(co);
|
||||
});
|
||||
|
||||
if (!u.requests.isEmpty()) {
|
||||
u.requests.get(u.requests.size() - 1).hasMore = false;
|
||||
}
|
||||
c.urls.add(u);
|
||||
});
|
||||
|
||||
if (!c.urls.isEmpty()) {
|
||||
c.urls.get(c.urls.size() - 1).hasMore = false;
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert OAS Parameter object to Codegen Parameter object
|
||||
*
|
||||
@@ -2638,6 +2736,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
LOGGER.warn("warning! Schema not found for parameter \"" + parameter.getName() + "\", using String");
|
||||
parameterSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to missing type definition.");
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(parameterSchema.getNullable())) { // use nullable defined in the spec
|
||||
codegenParameter.isNullable = true;
|
||||
}
|
||||
|
||||
// set default value
|
||||
if (parameterSchema.getDefault() != null) {
|
||||
codegenParameter.defaultValue = toDefaultValue(parameterSchema);
|
||||
@@ -2671,7 +2774,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
} else if (ModelUtils.isMapSchema(parameterSchema)) { // for map parameter
|
||||
CodegenProperty codegenProperty = fromProperty("inner", (Schema) parameterSchema.getAdditionalProperties());
|
||||
CodegenProperty codegenProperty = fromProperty("inner", ModelUtils.getAdditionalProperties(parameterSchema));
|
||||
codegenParameter.items = codegenProperty;
|
||||
codegenParameter.mostInnerItems = codegenProperty.mostInnerItems;
|
||||
codegenParameter.baseType = codegenProperty.dataType;
|
||||
@@ -2896,7 +2999,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// TODO revise below as it should be replaced by ModelUtils.isByteArraySchema(parameterSchema)
|
||||
public boolean isDataTypeBinary(String dataType) {
|
||||
if (dataType != null) {
|
||||
return dataType.toLowerCase().startsWith("byte");
|
||||
return dataType.toLowerCase(Locale.ROOT).startsWith("byte");
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -2905,7 +3008,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// TODO revise below as it should be replaced by ModelUtils.isFileSchema(parameterSchema)
|
||||
public boolean isDataTypeFile(String dataType) {
|
||||
if (dataType != null) {
|
||||
return dataType.toLowerCase().equals("file");
|
||||
return dataType.toLowerCase(Locale.ROOT).equals("file");
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -2993,12 +3096,12 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
protected void setReservedWordsLowerCase(List<String> words) {
|
||||
reservedWords = new HashSet<String>();
|
||||
for (String word : words) {
|
||||
reservedWords.add(word.toLowerCase());
|
||||
reservedWords.add(word.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isReservedWord(String word) {
|
||||
return word != null && reservedWords.contains(word.toLowerCase());
|
||||
return word != null && reservedWords.contains(word.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3070,12 +3173,15 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* @param response API response
|
||||
* @param properties list of codegen property
|
||||
*/
|
||||
private void addHeaders(ApiResponse response, List<CodegenProperty> properties) {
|
||||
private void addHeaders(OpenAPI openAPI, ApiResponse response, List<CodegenProperty> properties) {
|
||||
if (response.getHeaders() != null) {
|
||||
for (Map.Entry<String, Header> headers : response.getHeaders().entrySet()) {
|
||||
CodegenProperty cp = fromProperty(headers.getKey(), headers.getValue().getSchema());
|
||||
cp.setDescription(escapeText(headers.getValue().getDescription()));
|
||||
cp.setUnescapedDescription(headers.getValue().getDescription());
|
||||
String description = headers.getValue().getDescription();
|
||||
// follow the $ref
|
||||
Header header = ModelUtils.getReferencedHeader(openAPI, headers.getValue());
|
||||
CodegenProperty cp = fromProperty(headers.getKey(), header.getSchema());
|
||||
cp.setDescription(escapeText(description));
|
||||
cp.setUnescapedDescription(description);
|
||||
properties.add(cp);
|
||||
}
|
||||
}
|
||||
@@ -3124,9 +3230,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
LOGGER.warn("generated unique operationId `" + uniqueName + "`");
|
||||
}
|
||||
co.operationId = uniqueName;
|
||||
co.operationIdLowerCase = uniqueName.toLowerCase();
|
||||
co.operationIdCamelCase = DefaultCodegen.camelize(uniqueName);
|
||||
co.operationIdSnakeCase = DefaultCodegen.underscore(uniqueName);
|
||||
co.operationIdLowerCase = uniqueName.toLowerCase(Locale.ROOT);
|
||||
co.operationIdCamelCase = org.openapitools.codegen.utils.StringUtils.camelize(uniqueName);
|
||||
co.operationIdSnakeCase = org.openapitools.codegen.utils.StringUtils.underscore(uniqueName);
|
||||
opList.add(co);
|
||||
co.baseName = tag;
|
||||
}
|
||||
@@ -3155,23 +3261,12 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
*
|
||||
* @param word The word
|
||||
* @return The underscored version of the word
|
||||
* @deprecated since version 3.2.3, may be removed with the next major release (4.0)
|
||||
* @see org.openapitools.codegen.utils.StringUtils#underscore
|
||||
*/
|
||||
@Deprecated
|
||||
public static String underscore(String word) {
|
||||
String firstPattern = "([A-Z]+)([A-Z][a-z])";
|
||||
String secondPattern = "([a-z\\d])([A-Z])";
|
||||
String replacementPattern = "$1_$2";
|
||||
// Replace package separator with slash.
|
||||
word = word.replaceAll("\\.", "/"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
// Replace $ with two underscores for inner classes.
|
||||
word = word.replaceAll("\\$", "__");
|
||||
// Replace capital letter with _ plus lowercase letter.
|
||||
word = word.replaceAll(firstPattern, replacementPattern);
|
||||
word = word.replaceAll(secondPattern, replacementPattern);
|
||||
word = word.replace('-', '_');
|
||||
// replace space with underscore
|
||||
word = word.replace(' ', '_');
|
||||
word = word.toLowerCase();
|
||||
return word;
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(word);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3179,10 +3274,13 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
*
|
||||
* @param word The word
|
||||
* @return The dashized version of the word, e.g. "my-name"
|
||||
* @deprecated since version 3.2.3, may be removed with the next major release (4.0)
|
||||
* @see org.openapitools.codegen.utils.StringUtils#dashize
|
||||
*/
|
||||
@SuppressWarnings("static-method")
|
||||
@Deprecated
|
||||
protected String dashize(String word) {
|
||||
return underscore(word).replaceAll("[_ ]", "-");
|
||||
return org.openapitools.codegen.utils.StringUtils.dashize(word);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3334,7 +3432,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* @param schemas The complete set of model definitions (schemas).
|
||||
* @return A mapping from model name to type alias
|
||||
*/
|
||||
private static Map<String, String> getAllAliases(Map<String, Schema> schemas) {
|
||||
static Map<String, String> getAllAliases(Map<String, Schema> schemas) {
|
||||
if (schemas == null || schemas.isEmpty()) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
@@ -3377,11 +3475,12 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
.map(StringUtils::capitalize)
|
||||
.collect(Collectors.joining(""));
|
||||
if (result.length() > 0) {
|
||||
result = result.substring(0, 1).toLowerCase() + result.substring(1);
|
||||
result = result.substring(0, 1).toLowerCase(Locale.ROOT) + result.substring(1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Camelize name (parameter, property, method, etc) with upper case for first letter
|
||||
* copied from Twitter elephant bird
|
||||
@@ -3389,9 +3488,12 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
*
|
||||
* @param word string to be camelize
|
||||
* @return camelized string
|
||||
* @deprecated since version 3.2.3, may be removed with the next major release (4.0)
|
||||
* @see org.openapitools.codegen.utils.StringUtils#camelize(String)
|
||||
*/
|
||||
@Deprecated
|
||||
public static String camelize(String word) {
|
||||
return camelize(word, false);
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(word);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3400,80 +3502,15 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* @param word string to be camelize
|
||||
* @param lowercaseFirstLetter lower case for first letter if set to true
|
||||
* @return camelized string
|
||||
* @deprecated since version 3.2.3, may be removed with the next major release (4.0)
|
||||
* @see org.openapitools.codegen.utils.StringUtils#camelize(String, boolean)
|
||||
*/
|
||||
@Deprecated
|
||||
public static String camelize(String word, boolean lowercaseFirstLetter) {
|
||||
// Replace all slashes with dots (package separator)
|
||||
Pattern p = Pattern.compile("\\/(.?)");
|
||||
Matcher m = p.matcher(word);
|
||||
while (m.find()) {
|
||||
word = m.replaceFirst("." + m.group(1)/*.toUpperCase()*/); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
m = p.matcher(word);
|
||||
}
|
||||
|
||||
// case out dots
|
||||
String[] parts = word.split("\\.");
|
||||
StringBuilder f = new StringBuilder();
|
||||
for (String z : parts) {
|
||||
if (z.length() > 0) {
|
||||
f.append(Character.toUpperCase(z.charAt(0))).append(z.substring(1));
|
||||
}
|
||||
}
|
||||
word = f.toString();
|
||||
|
||||
m = p.matcher(word);
|
||||
while (m.find()) {
|
||||
word = m.replaceFirst("" + Character.toUpperCase(m.group(1).charAt(0)) + m.group(1).substring(1)/*.toUpperCase()*/);
|
||||
m = p.matcher(word);
|
||||
}
|
||||
|
||||
// Uppercase the class name.
|
||||
p = Pattern.compile("(\\.?)(\\w)([^\\.]*)$");
|
||||
m = p.matcher(word);
|
||||
if (m.find()) {
|
||||
String rep = m.group(1) + m.group(2).toUpperCase() + m.group(3);
|
||||
rep = rep.replaceAll("\\$", "\\\\\\$");
|
||||
word = m.replaceAll(rep);
|
||||
}
|
||||
|
||||
// Remove all underscores (underscore_case to camelCase)
|
||||
p = Pattern.compile("(_)(.)");
|
||||
m = p.matcher(word);
|
||||
while (m.find()) {
|
||||
String original = m.group(2);
|
||||
String upperCase = original.toUpperCase();
|
||||
if (original.equals(upperCase)) {
|
||||
word = word.replaceFirst("_", "");
|
||||
} else {
|
||||
word = m.replaceFirst(upperCase);
|
||||
}
|
||||
m = p.matcher(word);
|
||||
}
|
||||
|
||||
// Remove all hyphens (hyphen-case to camelCase)
|
||||
p = Pattern.compile("(-)(.)");
|
||||
m = p.matcher(word);
|
||||
while (m.find()) {
|
||||
word = m.replaceFirst(m.group(2).toUpperCase());
|
||||
m = p.matcher(word);
|
||||
}
|
||||
|
||||
if (lowercaseFirstLetter && word.length() > 0) {
|
||||
int i = 0;
|
||||
char charAt = word.charAt(i);
|
||||
while (i + 1 < word.length() && !((charAt >= 'a' && charAt <= 'z') || (charAt >= 'A' && charAt <= 'Z'))) {
|
||||
i = i + 1;
|
||||
charAt = word.charAt(i);
|
||||
}
|
||||
i = i + 1;
|
||||
word = word.substring(0, i).toLowerCase() + word.substring(i);
|
||||
}
|
||||
|
||||
// remove all underscore
|
||||
word = word.replaceAll("_", "");
|
||||
|
||||
return word;
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(word, lowercaseFirstLetter);
|
||||
}
|
||||
|
||||
|
||||
public String apiFilename(String templateName, String tag) {
|
||||
String suffix = apiTemplateFiles().get(templateName);
|
||||
return apiFileFolder() + File.separator + toApiFilename(tag) + suffix;
|
||||
@@ -3488,7 +3525,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
*/
|
||||
public String apiDocFilename(String templateName, String tag) {
|
||||
String docExtension = getDocExtension();
|
||||
String suffix = docExtension != null ? docExtension: apiDocTemplateFiles().get(templateName);
|
||||
String suffix = docExtension != null ? docExtension : apiDocTemplateFiles().get(templateName);
|
||||
return apiDocFileFolder() + File.separator + toApiDocFilename(tag) + suffix;
|
||||
}
|
||||
|
||||
@@ -3888,6 +3925,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
enumVar.put("isString", isDataTypeString(dataType));
|
||||
enumVars.add(enumVar);
|
||||
}
|
||||
// if "x-enum-varnames" defined, update varnames
|
||||
updateEnumVarsWithExtensions(enumVars, var.getVendorExtensions());
|
||||
allowableValues.put("enumVars", enumVars);
|
||||
|
||||
// handle default value for enum, e.g. available => StatusEnum.AVAILABLE
|
||||
@@ -3905,6 +3944,16 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateEnumVarsWithExtensions(List<Map<String, Object>> enumVars, Map<String, Object> vendorExtensions) {
|
||||
if (vendorExtensions != null && vendorExtensions.containsKey("x-enum-varnames")) {
|
||||
List<String> alias = (List<String>) vendorExtensions.get("x-enum-varnames");
|
||||
int size = Math.min(enumVars.size(), alias.size());
|
||||
for (int i = 0; i < size; i++) {
|
||||
enumVars.get(i).put("name", alias.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If the pattern misses the delimiter, add "/" to the beginning and end
|
||||
* Otherwise, return the original pattern
|
||||
@@ -4239,7 +4288,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
codegenParameter.isPrimitiveType = false;
|
||||
codegenParameter.isContainer = true;
|
||||
codegenParameter.isListContainer = true;
|
||||
codegenParameter.description = s.getDescription();
|
||||
codegenParameter.description = escapeText(s.getDescription());
|
||||
codegenParameter.dataType = getTypeDeclaration(s);
|
||||
if (codegenParameter.baseType != null && codegenParameter.enumName != null) {
|
||||
codegenParameter.datatypeWithEnum = codegenParameter.dataType.replace(codegenParameter.baseType, codegenParameter.enumName);
|
||||
@@ -4251,6 +4300,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// default to csv:
|
||||
codegenParameter.collectionFormat = StringUtils.isEmpty(collectionFormat) ? "csv" : collectionFormat;
|
||||
|
||||
// set nullable
|
||||
setParameterNullable(codegenParameter, codegenProperty);
|
||||
|
||||
// recursively add import
|
||||
while (codegenProperty != null) {
|
||||
imports.add(codegenProperty.baseType);
|
||||
@@ -4279,7 +4331,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
public CodegenParameter fromFormProperty(String name, Schema propertySchema, Set<String> imports) {
|
||||
CodegenParameter codegenParameter = CodegenModelFactory.newInstance(CodegenModelType.PARAMETER);
|
||||
|
||||
LOGGER.debug("Debugging fromFormProperty: " + name);
|
||||
LOGGER.debug("Debugging fromFormProperty {}: {}", name, propertySchema);
|
||||
CodegenProperty codegenProperty = fromProperty(name, propertySchema);
|
||||
|
||||
codegenParameter.isFormParam = Boolean.TRUE;
|
||||
@@ -4293,7 +4345,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
codegenParameter.jsonSchema = Json.pretty(propertySchema);
|
||||
codegenParameter.defaultValue = codegenProperty.getDefaultValue();
|
||||
|
||||
|
||||
if (codegenProperty.getVendorExtensions() != null && !codegenProperty.getVendorExtensions().isEmpty()) {
|
||||
codegenParameter.vendorExtensions = codegenProperty.getVendorExtensions();
|
||||
}
|
||||
@@ -4352,6 +4403,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
setParameterBooleanFlagWithCodegenProperty(codegenParameter, codegenProperty);
|
||||
setParameterExampleValue(codegenParameter);
|
||||
// set nullable
|
||||
setParameterNullable(codegenParameter, codegenProperty);
|
||||
|
||||
//TODO collectionFormat for form parameter not yet supported
|
||||
//codegenParameter.collectionFormat = getCollectionFormat(propertySchema);
|
||||
@@ -4365,7 +4418,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
CodegenParameter codegenParameter = CodegenModelFactory.newInstance(CodegenModelType.PARAMETER);
|
||||
codegenParameter.baseName = "UNKNOWN_BASE_NAME";
|
||||
codegenParameter.paramName = "UNKNOWN_PARAM_NAME";
|
||||
codegenParameter.description = body.getDescription();
|
||||
codegenParameter.description = escapeText(body.getDescription());
|
||||
codegenParameter.required = body.getRequired() != null ? body.getRequired() : Boolean.FALSE;
|
||||
codegenParameter.isBodyParam = Boolean.TRUE;
|
||||
|
||||
@@ -4378,7 +4431,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
if (ModelUtils.isMapSchema(schema)) {
|
||||
Schema inner = (Schema) schema.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(schema);
|
||||
if (inner == null) {
|
||||
inner = new StringSchema().description("//TODO automatically added by openapi-generator");
|
||||
schema.setAdditionalProperties(inner);
|
||||
@@ -4401,6 +4454,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
codegenParameter.isMapContainer = Boolean.TRUE;
|
||||
|
||||
setParameterBooleanFlagWithCodegenProperty(codegenParameter, codegenProperty);
|
||||
|
||||
// set nullable
|
||||
setParameterNullable(codegenParameter, codegenProperty);
|
||||
} else if (ModelUtils.isArraySchema(schema)) {
|
||||
final ArraySchema arraySchema = (ArraySchema) schema;
|
||||
Schema inner = arraySchema.getItems();
|
||||
@@ -4423,7 +4479,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(bodyParameterName)) {
|
||||
if(StringUtils.isEmpty(mostInnerItem.complexType)) {
|
||||
if (StringUtils.isEmpty(mostInnerItem.complexType)) {
|
||||
codegenParameter.baseName = "request_body";
|
||||
} else {
|
||||
codegenParameter.baseName = mostInnerItem.complexType;
|
||||
@@ -4440,6 +4496,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
codegenParameter.isListContainer = Boolean.TRUE;
|
||||
|
||||
setParameterBooleanFlagWithCodegenProperty(codegenParameter, codegenProperty);
|
||||
// set nullable
|
||||
setParameterNullable(codegenParameter, codegenProperty);
|
||||
|
||||
while (codegenProperty != null) {
|
||||
imports.add(codegenProperty.baseType);
|
||||
@@ -4466,7 +4524,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
imports.add(codegenParameter.baseType);
|
||||
} else {
|
||||
CodegenProperty codegenProperty = fromProperty("property", schema);
|
||||
if (schema.getAdditionalProperties() != null) {// http body is map
|
||||
if (ModelUtils.getAdditionalProperties(schema) != null) {// http body is map
|
||||
LOGGER.error("Map should be supported. Please report to openapi-generator github repo about the issue.");
|
||||
} else if (codegenProperty != null) {
|
||||
String codegenModelName, codegenModelDescription;
|
||||
@@ -4502,6 +4560,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
setParameterBooleanFlagWithCodegenProperty(codegenParameter, codegenProperty);
|
||||
// set nullable
|
||||
setParameterNullable(codegenParameter, codegenProperty);
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -4525,6 +4585,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
}
|
||||
setParameterBooleanFlagWithCodegenProperty(codegenParameter, codegenProperty);
|
||||
// set nullable
|
||||
setParameterNullable(codegenParameter, codegenProperty);
|
||||
}
|
||||
|
||||
// set the parameter's example value
|
||||
@@ -4588,4 +4650,42 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
public boolean isDataTypeString(String dataType) {
|
||||
return "String".equals(dataType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CodegenServer> fromServers(List<Server> servers) {
|
||||
if (servers == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<CodegenServer> codegenServers = new LinkedList<>();
|
||||
for (Server server : servers) {
|
||||
CodegenServer cs = new CodegenServer();
|
||||
cs.description = escapeText(server.getDescription());
|
||||
cs.url = server.getUrl();
|
||||
cs.variables = this.fromServerVariables(server.getVariables());
|
||||
codegenServers.add(cs);
|
||||
}
|
||||
return codegenServers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CodegenServerVariable> fromServerVariables(Map<String, ServerVariable> variables) {
|
||||
if (variables == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<CodegenServerVariable> codegenServerVariables = new LinkedList<>();
|
||||
for (Entry<String, ServerVariable> variableEntry : variables.entrySet()) {
|
||||
CodegenServerVariable codegenServerVariable = new CodegenServerVariable();
|
||||
ServerVariable variable = variableEntry.getValue();
|
||||
codegenServerVariable.defaultValue = variable.getDefault();
|
||||
codegenServerVariable.description = escapeText(variable.getDescription());
|
||||
codegenServerVariable.enumValues = variable.getEnum();
|
||||
codegenServerVariable.name = variableEntry.getKey();
|
||||
codegenServerVariables.add(codegenServerVariable);
|
||||
}
|
||||
return codegenServerVariables;
|
||||
}
|
||||
|
||||
private void setParameterNullable(CodegenParameter parameter, CodegenProperty property) {
|
||||
parameter.isNullable = property.isNullable;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
private void generateModelDocumentation(List<File> files, Map<String, Object> models, String modelName) throws IOException {
|
||||
for (String templateName : config.modelDocTemplateFiles().keySet()) {
|
||||
String docExtension = config.getDocExtension();
|
||||
String suffix = docExtension!=null ? docExtension : config.modelDocTemplateFiles().get(templateName);
|
||||
String suffix = docExtension != null ? docExtension : config.modelDocTemplateFiles().get(templateName);
|
||||
String filename = config.modelDocFileFolder() + File.separator + config.toModelDocFilename(modelName) + suffix;
|
||||
if (!config.shouldOverwrite(filename)) {
|
||||
LOGGER.info("Skipped overwriting " + filename);
|
||||
@@ -382,6 +382,10 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
} */
|
||||
});
|
||||
|
||||
Boolean skipFormModel = System.getProperty(CodegenConstants.SKIP_FORM_MODEL) != null ?
|
||||
Boolean.valueOf(System.getProperty(CodegenConstants.SKIP_FORM_MODEL)) :
|
||||
getGeneratorPropertyDefaultSwitch(CodegenConstants.SKIP_FORM_MODEL, false);
|
||||
|
||||
// process models only
|
||||
for (String name : modelKeys) {
|
||||
try {
|
||||
@@ -393,8 +397,13 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
|
||||
// don't generate models that are not used as object (e.g. form parameters)
|
||||
if (unusedModels.contains(name)) {
|
||||
LOGGER.debug("Model " + name + " not generated since it's marked as unused (due to form parameters)");
|
||||
continue;
|
||||
if (Boolean.FALSE.equals(skipFormModel)) {
|
||||
// if skipFormModel sets to true, still generate the model and log the result
|
||||
LOGGER.info("Model " + name + " (marked as unused due to form parameters) is generated due to skipFormModel=false (default)");
|
||||
} else {
|
||||
LOGGER.info("Model " + name + " not generated since it's marked as unused (due to form parameters) and skipFormModel set to true");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Schema schema = schemas.get(name);
|
||||
@@ -753,6 +762,12 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
bundle.put("authMethods", authMethods);
|
||||
bundle.put("hasAuthMethods", true);
|
||||
}
|
||||
|
||||
List<CodegenServer> servers = config.fromServers(openAPI.getServers());
|
||||
if (servers != null && !servers.isEmpty()) {
|
||||
bundle.put("servers", servers);
|
||||
bundle.put("hasServers", true);
|
||||
}
|
||||
|
||||
if (openAPI.getExternalDocs() != null) {
|
||||
bundle.put("externalDocs", openAPI.getExternalDocs());
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
* Copyright 2018 SmartBear Software
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
@@ -18,11 +35,10 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import io.swagger.v3.oas.models.media.Content;
|
||||
import io.swagger.v3.oas.models.media.MediaType;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import io.swagger.v3.oas.models.media.XML;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class InlineModelResolver {
|
||||
private OpenAPI openapi;
|
||||
@@ -68,9 +84,23 @@ public class InlineModelResolver {
|
||||
Schema schema = new Schema();
|
||||
schema.set$ref(modelName);
|
||||
mt.setSchema(schema);
|
||||
// TODO assume JSON, need to support other payload later
|
||||
content.addMediaType("application/json", mt);
|
||||
|
||||
// get "consumes", e.g. application/xml, application/json
|
||||
Set<String> consumes;
|
||||
if (requestBody == null || requestBody.getContent() == null || requestBody.getContent().isEmpty()) {
|
||||
consumes = new HashSet<>();
|
||||
consumes.add("application/json"); // default to application/json
|
||||
LOGGER.info("Default to application/json for inline body schema");
|
||||
} else {
|
||||
consumes = requestBody.getContent().keySet();
|
||||
}
|
||||
|
||||
for (String consume : consumes) {
|
||||
content.addMediaType(consume, mt);
|
||||
}
|
||||
|
||||
rb.setContent(content);
|
||||
|
||||
// add to openapi "components"
|
||||
if (openapi.getComponents().getRequestBodies() == null) {
|
||||
Map<String, RequestBody> requestBodies = new HashMap<String, RequestBody>();
|
||||
@@ -208,7 +238,7 @@ public class InlineModelResolver {
|
||||
}
|
||||
} else if (property instanceof MapSchema) {
|
||||
MapSchema mp = (MapSchema) property;
|
||||
Schema innerProperty = (Schema) mp.getAdditionalProperties();
|
||||
Schema innerProperty = ModelUtils.getAdditionalProperties(mp);
|
||||
if (innerProperty instanceof ObjectSchema) {
|
||||
ObjectSchema op = (ObjectSchema) innerProperty;
|
||||
if (op.getProperties() != null && op.getProperties().size() > 0) {
|
||||
@@ -291,7 +321,7 @@ public class InlineModelResolver {
|
||||
/**
|
||||
* This function fix models that are string (mostly enum). Before this fix, the
|
||||
* example would look something like that in the doc: "\"example from def\""
|
||||
*
|
||||
*
|
||||
* @param m Schema implementation
|
||||
*/
|
||||
private void fixStringModel(Schema m) {
|
||||
@@ -334,10 +364,7 @@ public class InlineModelResolver {
|
||||
int count = 0;
|
||||
boolean done = false;
|
||||
key = key.replaceAll("[^a-z_\\.A-Z0-9 ]", ""); // FIXME: a parameter
|
||||
// should not be
|
||||
// assigned. Also declare
|
||||
// the methods parameters
|
||||
// as 'final'.
|
||||
// should not be assigned. Also declare the methods parameters as 'final'.
|
||||
while (!done) {
|
||||
String name = key;
|
||||
if (count > 0) {
|
||||
@@ -404,7 +431,7 @@ public class InlineModelResolver {
|
||||
}
|
||||
}
|
||||
if (ModelUtils.isMapSchema(property)) {
|
||||
Schema inner = (Schema) property.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(property);
|
||||
if (inner instanceof ObjectSchema) {
|
||||
ObjectSchema op = (ObjectSchema) inner;
|
||||
if (op.getProperties() != null && op.getProperties().size() > 0) {
|
||||
@@ -492,7 +519,7 @@ public class InlineModelResolver {
|
||||
model.setDescription(description);
|
||||
model.setName(object.getName());
|
||||
model.setExample(example);
|
||||
model.setItems((Schema) object.getAdditionalProperties());
|
||||
model.setItems(ModelUtils.getAdditionalProperties(object));
|
||||
return model;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import io.swagger.v3.parser.core.models.AuthorizationValue;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
@@ -39,8 +40,11 @@ public class AuthParser {
|
||||
for (String part : parts) {
|
||||
String[] kvPair = part.split(":");
|
||||
if (kvPair.length == 2) {
|
||||
// FIXME replace the deprecated method by decode(string, encoding). Which encoding is used ? Default UTF-8 ?
|
||||
auths.add(new AuthorizationValue(URLDecoder.decode(kvPair[0]), URLDecoder.decode(kvPair[1]), "header"));
|
||||
try {
|
||||
auths.add(new AuthorizationValue(URLDecoder.decode(kvPair[0], "UTF-8"), URLDecoder.decode(kvPair[1], "UTF-8"), "header"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
LOGGER.warn(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,16 +19,33 @@ package org.openapitools.codegen.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAnyGetter;
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.auth.AuthParser;
|
||||
import io.swagger.parser.OpenAPIParser;
|
||||
import io.swagger.v3.core.util.Json;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.parser.core.models.AuthorizationValue;
|
||||
import io.swagger.v3.parser.core.models.ParseOptions;
|
||||
import io.swagger.v3.parser.core.models.SwaggerParseResult;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.openapitools.codegen.languages.*;
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.ClientOptInput;
|
||||
import org.openapitools.codegen.ClientOpts;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConfigLoader;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.SpecValidationException;
|
||||
import org.openapitools.codegen.auth.AuthParser;
|
||||
import org.openapitools.codegen.languages.CSharpNancyFXServerCodegen;
|
||||
import org.openapitools.codegen.languages.CppQt5ClientCodegen;
|
||||
import org.openapitools.codegen.languages.CppRestSdkClientCodegen;
|
||||
import org.openapitools.codegen.languages.CppTizenClientCodegen;
|
||||
import org.openapitools.codegen.languages.JavaJerseyServerCodegen;
|
||||
import org.openapitools.codegen.languages.PhpLumenServerCodegen;
|
||||
import org.openapitools.codegen.languages.PhpSlimServerCodegen;
|
||||
import org.openapitools.codegen.languages.PhpZendExpressivePathHandlerServerCodegen;
|
||||
import org.openapitools.codegen.languages.RubySinatraServerCodegen;
|
||||
import org.openapitools.codegen.languages.ScalaAkkaClientCodegen;
|
||||
import org.openapitools.codegen.languages.ScalaHttpClientCodegen;
|
||||
import org.openapitools.codegen.languages.SwiftClientCodegen;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -40,6 +57,7 @@ import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -139,7 +157,7 @@ public class CodegenConfigurator implements Serializable {
|
||||
public CodegenConfigurator setGeneratorName(final String generatorName) {
|
||||
if (nameMigrationMap.containsKey(generatorName)) {
|
||||
String newValue = nameMigrationMap.get(generatorName);
|
||||
LOGGER.warn(String.format("The name '%s' is a deprecated. Please update to the new name of '%s'.", generatorName, newValue));
|
||||
LOGGER.warn(String.format(Locale.ROOT, "The name '%s' is a deprecated. Please update to the new name of '%s'.", generatorName, newValue));
|
||||
this.generatorName = newValue;
|
||||
} else {
|
||||
this.generatorName = generatorName;
|
||||
|
||||
@@ -236,10 +236,10 @@ public class ExampleGenerator {
|
||||
Map<String, Object> mp = new HashMap<String, Object>();
|
||||
if (property.getName() != null) {
|
||||
mp.put(property.getName(),
|
||||
resolvePropertyToExample(propertyName, mediaType, (Schema) property.getAdditionalProperties(), processedModels));
|
||||
resolvePropertyToExample(propertyName, mediaType, ModelUtils.getAdditionalProperties(property), processedModels));
|
||||
} else {
|
||||
mp.put("key",
|
||||
resolvePropertyToExample(propertyName, mediaType, (Schema) property.getAdditionalProperties(), processedModels));
|
||||
resolvePropertyToExample(propertyName, mediaType, ModelUtils.getAdditionalProperties(property), processedModels));
|
||||
}
|
||||
return mp;
|
||||
} else if (ModelUtils.isUUIDSchema(property)) {
|
||||
|
||||
@@ -25,9 +25,11 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Presents a processing utility for parsing and evaluating files containing common ignore patterns. (.openapi-generator-ignore)
|
||||
@@ -82,30 +84,30 @@ public class CodegenIgnoreProcessor {
|
||||
loadCodegenRules(targetIgnoreFile);
|
||||
this.ignoreFile = targetIgnoreFile;
|
||||
} catch (IOException e) {
|
||||
LOGGER.error(String.format("Could not process %s.", targetIgnoreFile.getName()), e.getMessage());
|
||||
LOGGER.error(String.format(Locale.ROOT, "Could not process %s.", targetIgnoreFile.getName()), e.getMessage());
|
||||
}
|
||||
} else if (!".swagger-codegen-ignore".equals(targetIgnoreFile.getName())) {
|
||||
final File legacyIgnoreFile = new File(targetIgnoreFile.getParentFile(), ".swagger-codegen-ignore");
|
||||
if (legacyIgnoreFile.exists() && legacyIgnoreFile.isFile()) {
|
||||
LOGGER.info(String.format("Legacy support: '%s' file renamed to '%s'.", legacyIgnoreFile.getName(), targetIgnoreFile.getName()));
|
||||
LOGGER.info(String.format(Locale.ROOT, "Legacy support: '%s' file renamed to '%s'.", legacyIgnoreFile.getName(), targetIgnoreFile.getName()));
|
||||
try {
|
||||
Files.move(legacyIgnoreFile, targetIgnoreFile);
|
||||
loadFromFile(targetIgnoreFile);
|
||||
} catch (IOException e) {
|
||||
LOGGER.error(String.format("Could not rename file: %s", e.getMessage()));
|
||||
LOGGER.error(String.format(Locale.ROOT, "Could not rename file: %s", e.getMessage()));
|
||||
}
|
||||
} else {
|
||||
// log info message
|
||||
LOGGER.info(String.format("No %s file found.", targetIgnoreFile.getName()));
|
||||
LOGGER.info(String.format(Locale.ROOT, "No %s file found.", targetIgnoreFile.getName()));
|
||||
}
|
||||
} else {
|
||||
// log info message
|
||||
LOGGER.info(String.format("No %s file found.", targetIgnoreFile.getName()));
|
||||
LOGGER.info(String.format(Locale.ROOT, "No %s file found.", targetIgnoreFile.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
void loadCodegenRules(final File codegenIgnore) throws IOException {
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(codegenIgnore))) {
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(codegenIgnore), Charset.forName("UTF-8")))) {
|
||||
String line;
|
||||
|
||||
// NOTE: Comments that start with a : (e.g. //:) are pulled from git documentation for .gitignore
|
||||
|
||||
@@ -183,7 +183,6 @@ public abstract class Rule {
|
||||
|
||||
}
|
||||
} catch (ParserException e) {
|
||||
e.printStackTrace();
|
||||
return new InvalidRule(null, definition, e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
@@ -19,13 +19,11 @@ package org.openapitools.codegen.languages;
|
||||
|
||||
import com.samskivert.mustache.Escapers;
|
||||
import com.samskivert.mustache.Mustache;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
@@ -43,8 +41,10 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
abstract public class AbstractAdaCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractAdaCodegen.class);
|
||||
|
||||
@@ -180,7 +180,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
}
|
||||
|
||||
public String toFilename(String name) {
|
||||
return name.replace(".", "-").toLowerCase();
|
||||
return name.replace(".", "-").toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -329,7 +329,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
return getTypeDeclaration(inner) + "_Vectors.Vector";
|
||||
}
|
||||
if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
String name = getTypeDeclaration(inner) + "_Map";
|
||||
if (name.startsWith("Swagger.")) {
|
||||
return name;
|
||||
@@ -391,7 +391,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
String mt = media.get("mediaType");
|
||||
if (mt != null) {
|
||||
mt = mt.replace('/', '_');
|
||||
media.put("adaMediaType", mt.toUpperCase());
|
||||
media.put("adaMediaType", mt.toUpperCase(Locale.ROOT));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@@ -620,7 +620,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
}
|
||||
}
|
||||
}
|
||||
authMethod.name = camelize(sanitizeName(authMethod.name), true);
|
||||
authMethod.name = org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(authMethod.name), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import java.util.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import com.google.common.base.Strings;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenParameter;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.DefaultCodegen;
|
||||
@@ -36,6 +36,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
|
||||
public abstract class AbstractApexCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractApexCodegen.class);
|
||||
|
||||
@@ -90,7 +91,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
// sanitize name
|
||||
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
if (name.toLowerCase().matches("^_*class$")) {
|
||||
if (name.toLowerCase(Locale.ROOT).matches("^_*class$")) {
|
||||
return "propertyClass";
|
||||
}
|
||||
|
||||
@@ -107,12 +108,12 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
|
||||
if (startsWithTwoUppercaseLetters(name)) {
|
||||
name = name.substring(0, 2).toLowerCase() + name.substring(2);
|
||||
name = name.substring(0, 2).toLowerCase(Locale.ROOT) + name.substring(2);
|
||||
}
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// pet_id => petId
|
||||
name = camelize(name, true);
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
@@ -125,7 +126,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
private boolean startsWithTwoUppercaseLetters(String name) {
|
||||
boolean startsWithTwoUppercaseLetters = false;
|
||||
if (name.length() > 1) {
|
||||
startsWithTwoUppercaseLetters = name.substring(0, 2).equals(name.substring(0, 2).toUpperCase());
|
||||
startsWithTwoUppercaseLetters = name.substring(0, 2).equals(name.substring(0, 2).toUpperCase(Locale.ROOT));
|
||||
}
|
||||
return startsWithTwoUppercaseLetters;
|
||||
}
|
||||
@@ -159,7 +160,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
final String camelizedName = camelize(nameWithPrefixSuffix);
|
||||
final String camelizedName = org.openapitools.codegen.utils.StringUtils.camelize(nameWithPrefixSuffix);
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(camelizedName)) {
|
||||
@@ -196,7 +197,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
|
||||
if (inner == null) {
|
||||
LOGGER.warn(p.getName() + "(map property) does not have a proper inner type defined");
|
||||
@@ -225,15 +226,15 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
return null;
|
||||
}
|
||||
|
||||
return String.format(pattern, getTypeDeclaration(ap.getItems()));
|
||||
return String.format(Locale.ROOT, pattern, getTypeDeclaration(ap.getItems()));
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
final MapSchema ap = (MapSchema) p;
|
||||
final String pattern = "new HashMap<%s>()";
|
||||
if (ap.getAdditionalProperties() == null) {
|
||||
if (ModelUtils.getAdditionalProperties(ap) == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return String.format(pattern, String.format("String, %s", getTypeDeclaration((Schema) ap.getAdditionalProperties())));
|
||||
return String.format(Locale.ROOT, pattern, String.format(Locale.ROOT, "String, %s", getTypeDeclaration(ModelUtils.getAdditionalProperties(ap))));
|
||||
} else if (ModelUtils.isLongSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
return p.getDefault().toString() + "l";
|
||||
@@ -297,7 +298,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
p.example = "'" + p.example + "'";
|
||||
} else if ("".equals(p.example) || p.example == null && p.dataType != "Object") {
|
||||
// Get an example object from the generated model
|
||||
if (!isReservedWord(p.dataType.toLowerCase())) {
|
||||
if (!isReservedWord(p.dataType.toLowerCase(Locale.ROOT))) {
|
||||
p.example = p.dataType + ".getExample()";
|
||||
}
|
||||
} else {
|
||||
@@ -332,7 +333,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
} else if (example.isEmpty()) {
|
||||
example = "2000, 1, 23";
|
||||
} else {
|
||||
LOGGER.warn(String.format("The example provided for property '%s' is not a valid RFC3339 date. Defaulting to '2000-01-23'. [%s]", p
|
||||
LOGGER.warn(String.format(Locale.ROOT, "The example provided for property '%s' is not a valid RFC3339 date. Defaulting to '2000-01-23'. [%s]", p
|
||||
.getName(), example));
|
||||
example = "2000, 1, 23";
|
||||
}
|
||||
@@ -343,7 +344,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
} else if (example.isEmpty()) {
|
||||
example = "2000, 1, 23, 4, 56, 7";
|
||||
} else {
|
||||
LOGGER.warn(String.format("The example provided for property '%s' is not a valid RFC3339 datetime. Defaulting to '2000-01-23T04-56-07Z'. [%s]", p
|
||||
LOGGER.warn(String.format(Locale.ROOT, "The example provided for property '%s' is not a valid RFC3339 datetime. Defaulting to '2000-01-23T04-56-07Z'. [%s]", p
|
||||
.getName(), example));
|
||||
example = "2000, 1, 23, 4, 56, 7";
|
||||
}
|
||||
@@ -366,7 +367,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
} else if (ModelUtils.isLongSchema(p)) {
|
||||
example = example.isEmpty() ? "123456789L" : example + "L";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
example = "new " + getTypeDeclaration(p) + "{'key'=>" + toExampleValue((Schema) p.getAdditionalProperties()) + "}";
|
||||
example = "new " + getTypeDeclaration(p) + "{'key'=>" + toExampleValue(ModelUtils.getAdditionalProperties(p)) + "}";
|
||||
|
||||
} else if (ModelUtils.isPasswordSchema(p)) {
|
||||
example = example.isEmpty() ? "password123" : escapeText(example);
|
||||
@@ -422,11 +423,11 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
|
||||
}
|
||||
|
||||
operationId = camelize(sanitizeName(operationId), true);
|
||||
operationId = org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId), true);
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
String newOperationId = camelize("call_" + operationId, true);
|
||||
String newOperationId = org.openapitools.codegen.utils.StringUtils.camelize("call_" + operationId, true);
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
}
|
||||
@@ -515,7 +516,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
return sanitizeName(camelize(property.name)) + "Enum";
|
||||
return sanitizeName(org.openapitools.codegen.utils.StringUtils.camelize(property.name)) + "Enum";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -526,7 +527,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
|
||||
// for symbol, e.g. $, #
|
||||
if (getSymbolName(value) != null) {
|
||||
return getSymbolName(value).toUpperCase();
|
||||
return getSymbolName(value).toUpperCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
// number
|
||||
@@ -540,7 +541,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
|
||||
// string
|
||||
String var = value.replaceAll("\\W+", "_").toUpperCase();
|
||||
String var = value.replaceAll("\\W+", "_").toUpperCase(Locale.ROOT);
|
||||
if (var.matches("\\d.*")) {
|
||||
return "_" + var;
|
||||
} else {
|
||||
@@ -669,7 +670,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
|
||||
@Override
|
||||
public String sanitizeTag(String tag) {
|
||||
return camelize(sanitizeName(tag));
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(tag));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public abstract class AbstractCSharpCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
protected boolean optionalAssemblyInfoFlag = true;
|
||||
@@ -234,7 +235,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
|
||||
LOGGER.warn(String.format("%s is not used by C# generators. Please use %s",
|
||||
LOGGER.warn(String.format(Locale.ROOT, "%s is not used by C# generators. Please use %s",
|
||||
CodegenConstants.INVOKER_PACKAGE, CodegenConstants.PACKAGE_NAME));
|
||||
}
|
||||
|
||||
@@ -313,9 +314,9 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.INTERFACE_PREFIX)) {
|
||||
String useInterfacePrefix = additionalProperties.get(CodegenConstants.INTERFACE_PREFIX).toString();
|
||||
if ("false".equals(useInterfacePrefix.toLowerCase())) {
|
||||
if ("false".equals(useInterfacePrefix.toLowerCase(Locale.ROOT))) {
|
||||
setInterfacePrefix("");
|
||||
} else if (!"true".equals(useInterfacePrefix.toLowerCase())) {
|
||||
} else if (!"true".equals(useInterfacePrefix.toLowerCase(Locale.ROOT))) {
|
||||
// NOTE: if user passes "true" explicitly, we use the default I- prefix. The other supported case here is a custom prefix.
|
||||
setInterfacePrefix(sanitizeName(useInterfacePrefix));
|
||||
}
|
||||
@@ -600,17 +601,17 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName("call_" + operationId)));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
// operationId starts with a number
|
||||
if (operationId.matches("^\\d.*")) {
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName("call_" + operationId)));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
return camelize(sanitizeName(operationId));
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -625,7 +626,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
// camelize the variable name
|
||||
// pet_id => PetId
|
||||
name = camelize(name);
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
@@ -648,9 +649,9 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
return name;
|
||||
}
|
||||
|
||||
// camelize(lower) the variable name
|
||||
// org.openapitools.codegen.utils.StringUtils.camelize(lower) the variable name
|
||||
// pet_id => petId
|
||||
name = camelize(name, true);
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
@@ -768,8 +769,8 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
// NOTE: typeMapping here supports things like string/String, long/Long, datetime/DateTime as lowercase keys.
|
||||
// Should we require explicit casing here (values are not insensitive).
|
||||
// TODO avoid using toLowerCase as typeMapping should be case-sensitive
|
||||
if (typeMapping.containsKey(openAPIType.toLowerCase())) {
|
||||
type = typeMapping.get(openAPIType.toLowerCase());
|
||||
if (typeMapping.containsKey(openAPIType.toLowerCase(Locale.ROOT))) {
|
||||
type = typeMapping.get(openAPIType.toLowerCase(Locale.ROOT));
|
||||
if (languageSpecificPrimitives.contains(type)) {
|
||||
return type;
|
||||
}
|
||||
@@ -811,7 +812,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
return getArrayTypeDeclaration((ArraySchema) p);
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
// Should we also support maps of maps?
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return getSchemaType(p) + "<string, " + getTypeDeclaration(inner) + ">";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
@@ -836,19 +837,19 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (name.matches("^\\d.*")) {
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return camelize(name);
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -936,7 +937,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
// for symbol, e.g. $, #
|
||||
if (getSymbolName(name) != null) {
|
||||
return camelize(getSymbolName(name));
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(getSymbolName(name));
|
||||
}
|
||||
|
||||
String enumName = sanitizeName(name);
|
||||
@@ -944,7 +945,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
enumName = enumName.replaceFirst("^_", "");
|
||||
enumName = enumName.replaceFirst("_$", "");
|
||||
|
||||
enumName = camelize(enumName) + "Enum";
|
||||
enumName = org.openapitools.codegen.utils.StringUtils.camelize(enumName) + "Enum";
|
||||
|
||||
if (enumName.matches("\\d.*")) { // starts with number
|
||||
return "_" + enumName;
|
||||
@@ -955,7 +956,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
return sanitizeName(camelize(property.name)) + "Enum";
|
||||
return sanitizeName(org.openapitools.codegen.utils.StringUtils.camelize(property.name)) + "Enum";
|
||||
}
|
||||
|
||||
public String testPackageName() {
|
||||
|
||||
@@ -21,11 +21,9 @@ import static com.google.common.base.Strings.isNullOrEmpty;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import io.swagger.v3.core.util.Json;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
@@ -46,9 +44,12 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||
|
||||
public abstract class AbstractEiffelCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractEiffelCodegen.class);
|
||||
|
||||
@@ -169,13 +170,13 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// params should be lowercase. E.g. "person: PERSON"
|
||||
return toVarName(name).toLowerCase();
|
||||
return toVarName(name).toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
// phone_number => PHONE_NUMBER
|
||||
return toModelFilename(name).toUpperCase();
|
||||
return toModelFilename(name).toUpperCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -205,7 +206,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
// (after camelize)
|
||||
}
|
||||
|
||||
return underscore(name);
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -216,12 +217,12 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
// methods parameters as 'final'.
|
||||
|
||||
// e.g. PetApi.go => pet_api.go
|
||||
return underscore(name) + "_api";
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name) + "_api";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiTestFilename(String name) {
|
||||
return toApiName(name).toLowerCase() + "_test";
|
||||
return toApiName(name).toLowerCase(Locale.ROOT) + "_test";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -229,7 +230,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
if (name.length() == 0) {
|
||||
return "DEFAULT_API";
|
||||
}
|
||||
return name.toUpperCase() + "_API";
|
||||
return name.toUpperCase(Locale.ROOT) + "_API";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -269,7 +270,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
}
|
||||
if (!isNullOrEmpty(model.parentSchema)) {
|
||||
model.parentSchema = model.parentSchema.toLowerCase();
|
||||
model.parentSchema = model.parentSchema.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,7 +291,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
Schema inner = ap.getItems();
|
||||
return "LIST [" + getTypeDeclaration(inner) + "]";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
|
||||
return getSchemaType(p) + "[" + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
@@ -334,7 +335,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(sanitizedOperationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to "
|
||||
+ camelize("call_" + operationId));
|
||||
+ org.openapitools.codegen.utils.StringUtils.camelize("call_" + operationId));
|
||||
sanitizedOperationId = "call_" + sanitizedOperationId;
|
||||
}
|
||||
// method name from updateSomething to update_Something.
|
||||
@@ -352,7 +353,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
for (CodegenOperation operation : operations) {
|
||||
// http method verb conversion (e.g. PUT => Put)
|
||||
|
||||
operation.httpMethod = camelize(operation.httpMethod.toLowerCase());
|
||||
operation.httpMethod = org.openapitools.codegen.utils.StringUtils.camelize(operation.httpMethod.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
// remove model imports to avoid error
|
||||
@@ -557,7 +558,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
@Override
|
||||
public String toInstantiationType(Schema p) {
|
||||
if (ModelUtils.isMapSchema(p)) {
|
||||
Schema additionalProperties2 = (Schema) p.getAdditionalProperties();
|
||||
Schema additionalProperties2 = ModelUtils.getAdditionalProperties(p);
|
||||
String type = additionalProperties2.getType();
|
||||
if (null == type) {
|
||||
LOGGER.error("No Type defined for Additional Schema " + additionalProperties2 + "\n" //
|
||||
@@ -575,7 +576,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
|
||||
public String unCamelize(String name) {
|
||||
return name.replaceAll("(.)(\\p{Upper})", "$1_$2").toLowerCase();
|
||||
return name.replaceAll("(.)(\\p{Upper})", "$1_$2").toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
public String toEiffelFeatureStyle(String operationId) {
|
||||
|
||||
@@ -17,22 +17,16 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.core.util.Yaml;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public abstract class AbstractGoCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractGoCodegen.class);
|
||||
@@ -140,7 +134,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
if (this.reservedWordsMappings().containsKey(name)) {
|
||||
return this.reservedWordsMappings().get(name);
|
||||
}
|
||||
return camelize(name) + '_';
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name) + '_';
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -155,7 +149,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// pet_id => PetId
|
||||
name = camelize(name);
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
|
||||
// for reserved word append _
|
||||
if (isReservedWord(name)) {
|
||||
@@ -180,7 +174,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
// params should be lowerCamelCase. E.g. "person Person", instead of
|
||||
// "Person Person".
|
||||
//
|
||||
name = camelize(toVarName(name), true);
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(toVarName(name), true);
|
||||
|
||||
// REVISIT: Actually, for idiomatic go, the param name should
|
||||
// really should just be a letter, e.g. "p Person"), but we'll get
|
||||
@@ -197,7 +191,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
public String toModelName(String name) {
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return camelize(toModel(name));
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(toModel(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -234,7 +228,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
return underscore(name);
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -243,7 +237,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// e.g. PetApi.go => pet_api.go
|
||||
name = "api_" + underscore(name);
|
||||
name = "api_" + org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
if (name.endsWith("_test")) {
|
||||
LOGGER.warn(name + ".go with `_test.go` suffix (reserved word) cannot be used as filename. Renamed to " + name + "_.go");
|
||||
name += "_";
|
||||
@@ -258,7 +252,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
Schema inner = ap.getItems();
|
||||
return "[]" + getTypeDeclaration(inner);
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return getSchemaType(p) + "[string]" + getTypeDeclaration(inner);
|
||||
}
|
||||
//return super.getTypeDeclaration(p);
|
||||
@@ -314,17 +308,17 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(sanitizedOperationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to "
|
||||
+ camelize("call_" + sanitizedOperationId));
|
||||
+ org.openapitools.codegen.utils.StringUtils.camelize("call_" + sanitizedOperationId));
|
||||
sanitizedOperationId = "call_" + sanitizedOperationId;
|
||||
}
|
||||
|
||||
// operationId starts with a number
|
||||
if (sanitizedOperationId.matches("^\\d.*")) {
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + camelize("call_" + sanitizedOperationId));
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("call_" + sanitizedOperationId));
|
||||
sanitizedOperationId = "call_" + sanitizedOperationId;
|
||||
}
|
||||
|
||||
return camelize(sanitizedOperationId);
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(sanitizedOperationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -335,7 +329,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||
for (CodegenOperation operation : operations) {
|
||||
// http method verb conversion (e.g. PUT => Put)
|
||||
operation.httpMethod = camelize(operation.httpMethod.toLowerCase());
|
||||
operation.httpMethod = org.openapitools.codegen.utils.StringUtils.camelize(operation.httpMethod.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
// remove model imports to avoid error
|
||||
@@ -389,7 +383,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
} else {
|
||||
// Map optional type to dataType
|
||||
param.vendorExtensions.put("x-optionalDataType",
|
||||
param.dataType.substring(0, 1).toUpperCase() + param.dataType.substring(1));
|
||||
param.dataType.substring(0, 1).toUpperCase(Locale.ROOT) + param.dataType.substring(1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -562,11 +556,11 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
|
||||
// for symbol, e.g. $, #
|
||||
if (getSymbolName(name) != null) {
|
||||
return getSymbolName(name).toUpperCase();
|
||||
return getSymbolName(name).toUpperCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
// string
|
||||
String enumName = sanitizeName(underscore(name).toUpperCase());
|
||||
String enumName = sanitizeName(org.openapitools.codegen.utils.StringUtils.underscore(name).toUpperCase(Locale.ROOT));
|
||||
enumName = enumName.replaceFirst("^_", "");
|
||||
enumName = enumName.replaceFirst("_$", "");
|
||||
|
||||
@@ -581,7 +575,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
String enumName = underscore(toModelName(property.name)).toUpperCase();
|
||||
String enumName = org.openapitools.codegen.utils.StringUtils.underscore(toModelName(property.name)).toUpperCase(Locale.ROOT);
|
||||
|
||||
// remove [] for array or map of enum
|
||||
enumName = enumName.replace("[]", "");
|
||||
|
||||
@@ -49,9 +49,13 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.escape;
|
||||
|
||||
|
||||
public abstract class AbstractJavaCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractJavaCodegen.class);
|
||||
@@ -551,7 +555,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
if (name.length() == 0) {
|
||||
return "DefaultApi";
|
||||
}
|
||||
return camelize(name) + "Api";
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name) + "Api";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -564,7 +568,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
// sanitize name
|
||||
name = sanitizeName(name, "\\W-[\\$]"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
if (name.toLowerCase().matches("^_*class$")) {
|
||||
if (name.toLowerCase(Locale.ROOT).matches("^_*class$")) {
|
||||
return "propertyClass";
|
||||
}
|
||||
|
||||
@@ -578,7 +582,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
|
||||
if (startsWithTwoUppercaseLetters(name)) {
|
||||
name = name.substring(0, 2).toLowerCase() + name.substring(2);
|
||||
name = name.substring(0, 2).toLowerCase(Locale.ROOT) + name.substring(2);
|
||||
}
|
||||
|
||||
// If name contains special chars -> replace them.
|
||||
@@ -586,12 +590,12 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
List<String> allowedCharacters = new ArrayList<>();
|
||||
allowedCharacters.add("_");
|
||||
allowedCharacters.add("$");
|
||||
name = escapeSpecialCharacters(name, allowedCharacters, "_");
|
||||
name = escape(name, specialCharReplacements, allowedCharacters, "_");
|
||||
}
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// pet_id => petId
|
||||
name = camelize(name, true);
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
@@ -604,7 +608,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
private boolean startsWithTwoUppercaseLetters(String name) {
|
||||
boolean startsWithTwoUppercaseLetters = false;
|
||||
if (name.length() > 1) {
|
||||
startsWithTwoUppercaseLetters = name.substring(0, 2).equals(name.substring(0, 2).toUpperCase());
|
||||
startsWithTwoUppercaseLetters = name.substring(0, 2).equals(name.substring(0, 2).toUpperCase(Locale.ROOT));
|
||||
}
|
||||
return startsWithTwoUppercaseLetters;
|
||||
}
|
||||
@@ -643,7 +647,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
final String camelizedName = camelize(nameWithPrefixSuffix);
|
||||
final String camelizedName = org.openapitools.codegen.utils.StringUtils.camelize(nameWithPrefixSuffix);
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(camelizedName)) {
|
||||
@@ -679,7 +683,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
if (inner == null) {
|
||||
LOGGER.warn(p.getName() + "(map property) does not have a proper inner type defined. Default to string");
|
||||
inner = new StringSchema().description("TODO default missing array inner type to string");
|
||||
@@ -720,7 +724,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
}
|
||||
|
||||
return String.format(pattern, typeDeclaration);
|
||||
return String.format(Locale.ROOT, pattern, typeDeclaration);
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
final String pattern;
|
||||
if (fullJavaUtil) {
|
||||
@@ -728,11 +732,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
} else {
|
||||
pattern = "new HashMap<%s>()";
|
||||
}
|
||||
if (p.getAdditionalProperties() == null) {
|
||||
if (ModelUtils.getAdditionalProperties(p) == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String typeDeclaration = String.format("String, %s", getTypeDeclaration((Schema) p.getAdditionalProperties()));
|
||||
String typeDeclaration = String.format(Locale.ROOT, "String, %s", getTypeDeclaration(ModelUtils.getAdditionalProperties(p)));
|
||||
Object java8obj = additionalProperties.get("java8");
|
||||
if (java8obj != null) {
|
||||
Boolean java8 = Boolean.valueOf(java8obj.toString());
|
||||
@@ -741,7 +745,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
}
|
||||
|
||||
return String.format(pattern, typeDeclaration);
|
||||
return String.format(Locale.ROOT, pattern, typeDeclaration);
|
||||
} else if (ModelUtils.isIntegerSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
if (SchemaTypeUtil.INTEGER64_FORMAT.equals(p.getFormat())) {
|
||||
@@ -875,19 +879,19 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
|
||||
}
|
||||
|
||||
operationId = camelize(sanitizeName(operationId), true);
|
||||
operationId = org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId), true);
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
String newOperationId = camelize("call_" + operationId, true);
|
||||
String newOperationId = org.openapitools.codegen.utils.StringUtils.camelize("call_" + operationId, true);
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
}
|
||||
|
||||
// operationId starts with a number
|
||||
if (operationId.matches("^\\d.*")) {
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method sname. Renamed to " + camelize("call_" + operationId), true);
|
||||
operationId = camelize("call_" + operationId, true);
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method sname. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("call_" + operationId), true);
|
||||
operationId = org.openapitools.codegen.utils.StringUtils.camelize("call_" + operationId, true);
|
||||
}
|
||||
|
||||
return operationId;
|
||||
@@ -1038,7 +1042,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
return sanitizeName(camelize(property.name)) + "Enum";
|
||||
return sanitizeName(org.openapitools.codegen.utils.StringUtils.camelize(property.name)) + "Enum";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1049,7 +1053,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
// for symbol, e.g. $, #
|
||||
if (getSymbolName(value) != null) {
|
||||
return getSymbolName(value).toUpperCase();
|
||||
return getSymbolName(value).toUpperCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
// number
|
||||
@@ -1063,7 +1067,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
|
||||
// string
|
||||
String var = value.replaceAll("\\W+", "_").toUpperCase();
|
||||
String var = value.replaceAll("\\W+", "_").toUpperCase(Locale.ROOT);
|
||||
if (var.matches("\\d.*")) {
|
||||
return "_" + var;
|
||||
} else {
|
||||
@@ -1334,7 +1338,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
@Override
|
||||
public String sanitizeTag(String tag) {
|
||||
tag = camelize(underscore(sanitizeName(tag)));
|
||||
tag = org.openapitools.codegen.utils.StringUtils.camelize(org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName(tag)));
|
||||
|
||||
// tag starts with numbers
|
||||
if (tag.matches("^\\d.*")) {
|
||||
|
||||
@@ -40,6 +40,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen implements BeanValidationFeatures {
|
||||
public static final String SERVER_PORT = "serverPort";
|
||||
/**
|
||||
@@ -250,7 +251,7 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen
|
||||
return "DefaultApi";
|
||||
}
|
||||
computed = sanitizeName(computed);
|
||||
return camelize(computed) + "Api";
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(computed) + "Api";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,24 +17,20 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public abstract class AbstractKotlinCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractKotlinCodegen.class);
|
||||
@@ -57,6 +53,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>(Arrays.asList(
|
||||
"kotlin.Byte",
|
||||
"kotlin.ByteArray",
|
||||
"kotlin.Short",
|
||||
"kotlin.Int",
|
||||
"kotlin.Long",
|
||||
@@ -141,6 +138,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
|
||||
defaultIncludes = new HashSet<String>(Arrays.asList(
|
||||
"kotlin.Byte",
|
||||
"kotlin.ByteArray",
|
||||
"kotlin.Short",
|
||||
"kotlin.Int",
|
||||
"kotlin.Long",
|
||||
@@ -161,21 +159,22 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
typeMapping.put("float", "kotlin.Float");
|
||||
typeMapping.put("long", "kotlin.Long");
|
||||
typeMapping.put("double", "kotlin.Double");
|
||||
typeMapping.put("ByteArray", "kotlin.ByteArray");
|
||||
typeMapping.put("number", "java.math.BigDecimal");
|
||||
typeMapping.put("date-time", "java.time.LocalDateTime");
|
||||
typeMapping.put("date", "java.time.LocalDateTime");
|
||||
typeMapping.put("file", "java.io.File");
|
||||
typeMapping.put("array", "kotlin.Array");
|
||||
typeMapping.put("list", "kotlin.Array");
|
||||
typeMapping.put("list", "kotlin.collections.List");
|
||||
typeMapping.put("map", "kotlin.collections.Map");
|
||||
typeMapping.put("object", "kotlin.Any");
|
||||
typeMapping.put("binary", "kotlin.Array<kotlin.Byte>");
|
||||
typeMapping.put("Date", "java.time.LocalDateTime");
|
||||
typeMapping.put("DateTime", "java.time.LocalDateTime");
|
||||
|
||||
instantiationTypes.put("array", "arrayOf");
|
||||
instantiationTypes.put("list", "arrayOf");
|
||||
instantiationTypes.put("map", "mapOf");
|
||||
instantiationTypes.put("array", "kotlin.arrayOf");
|
||||
instantiationTypes.put("list", "kotlin.arrayOf");
|
||||
instantiationTypes.put("map", "kotlin.mapOf");
|
||||
|
||||
importMapping = new HashMap<String, String>();
|
||||
importMapping.put("BigDecimal", "java.math.BigDecimal");
|
||||
@@ -220,7 +219,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
// TODO: Allow enum escaping as an option (e.g. backticks vs append/prepend underscore vs match model property escaping).
|
||||
return String.format("`%s`", name);
|
||||
return String.format(Locale.ROOT, "`%s`", name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -282,7 +281,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
return getArrayTypeDeclaration((ArraySchema) p);
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
|
||||
// Maps will be keyed only by primitive Kotlin string
|
||||
return getSchemaType(p) + "<kotlin.String, " + getTypeDeclaration(inner) + ">";
|
||||
@@ -402,19 +401,19 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
break;
|
||||
case camelCase:
|
||||
// NOTE: Removes hyphens and underscores
|
||||
modified = camelize(modified, true);
|
||||
modified = org.openapitools.codegen.utils.StringUtils.camelize(modified, true);
|
||||
break;
|
||||
case PascalCase:
|
||||
// NOTE: Removes hyphens and underscores
|
||||
String result = camelize(modified);
|
||||
String result = org.openapitools.codegen.utils.StringUtils.camelize(modified);
|
||||
modified = titleCase(result);
|
||||
break;
|
||||
case snake_case:
|
||||
// NOTE: Removes hyphens
|
||||
modified = underscore(modified);
|
||||
modified = org.openapitools.codegen.utils.StringUtils.underscore(modified);
|
||||
break;
|
||||
case UPPERCASE:
|
||||
modified = modified.toUpperCase();
|
||||
modified = modified.toUpperCase(Locale.ROOT);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -473,15 +472,55 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
modifiedName = sanitizeKotlinSpecificNames(modifiedName);
|
||||
|
||||
// Camelize name of nested properties
|
||||
modifiedName = camelize(modifiedName);
|
||||
modifiedName = org.openapitools.codegen.utils.StringUtils.camelize(modifiedName);
|
||||
|
||||
if (reservedWords.contains(modifiedName)) {
|
||||
modifiedName = escapeReservedWord(modifiedName);
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(modifiedName)) {
|
||||
final String modelName = "Model" + modifiedName;
|
||||
LOGGER.warn(modifiedName + " (reserved word) cannot be used as model name. Renamed to " + modelName);
|
||||
return modelName;
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (modifiedName.matches("^\\d.*")) {
|
||||
final String modelName = "Model" + modifiedName; // e.g. 200Response => Model200Response (after camelize)
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
|
||||
return modelName;
|
||||
}
|
||||
|
||||
return titleCase(modifiedName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the operation ID (method name)
|
||||
*
|
||||
* @param operationId operation ID
|
||||
* @return the sanitized method name
|
||||
*/
|
||||
@Override
|
||||
public String toOperationId(String operationId) {
|
||||
// throw exception if method name is empty
|
||||
if (StringUtils.isEmpty(operationId))
|
||||
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
|
||||
|
||||
operationId = camelize(sanitizeName(operationId), true);
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
String newOperationId = camelize("call_" + operationId, true);
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
}
|
||||
|
||||
// operationId starts with a number
|
||||
if (operationId.matches("^\\d.*")) {
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method sname. Renamed to " + camelize("call_" + operationId), true);
|
||||
operationId = camelize("call_" + operationId, true);
|
||||
}
|
||||
|
||||
return operationId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
// Should be the same as the model name
|
||||
@@ -536,7 +575,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
|
||||
private String titleCase(final String input) {
|
||||
return input.substring(0, 1).toUpperCase() + input.substring(1);
|
||||
return input.substring(0, 1).toUpperCase(Locale.ROOT) + input.substring(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -579,4 +618,70 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
public boolean isDataTypeString(final String dataType) {
|
||||
return "String".equals(dataType) || "kotlin.String".equals(dataType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// to avoid conflicts with 'callback' parameter for async call
|
||||
if ("callback".equals(name)) {
|
||||
return "paramCallback";
|
||||
}
|
||||
|
||||
// should be the same as variable name
|
||||
return toVarName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// sanitize name
|
||||
name = sanitizeName(name, "\\W-[\\$]");
|
||||
|
||||
if (name.toLowerCase(Locale.ROOT).matches("^_*class$")) {
|
||||
return "propertyClass";
|
||||
}
|
||||
|
||||
if ("_".equals(name)) {
|
||||
name = "_u";
|
||||
}
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$")) {
|
||||
return name;
|
||||
}
|
||||
|
||||
if (startsWithTwoUppercaseLetters(name)) {
|
||||
name = name.substring(0, 2).toLowerCase(Locale.ROOT) + name.substring(2);
|
||||
}
|
||||
|
||||
// If name contains special chars -> replace them.
|
||||
if ((name.chars().anyMatch(character -> specialCharReplacements.keySet().contains("" + ((char) character))))) {
|
||||
List<String> allowedCharacters = new ArrayList<>();
|
||||
allowedCharacters.add("_");
|
||||
allowedCharacters.add("$");
|
||||
name = escapeSpecialCharacters(name, allowedCharacters, "_");
|
||||
}
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// pet_id => petId
|
||||
name = camelize(name, true);
|
||||
|
||||
// for reserved word or word starting with number or containing dollar symbol, escape it
|
||||
if (isReservedWord(name) || name.matches("(^\\d.*)|(.*[$].*)")) {
|
||||
name = escapeReservedWord(name);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toRegularExpression(String pattern) {
|
||||
return escapeText(pattern);
|
||||
}
|
||||
|
||||
private boolean startsWithTwoUppercaseLetters(String name) {
|
||||
boolean startsWithTwoUppercaseLetters = false;
|
||||
if (name.length() > 1) {
|
||||
startsWithTwoUppercaseLetters = name.substring(0, 2).equals(name.substring(0, 2).toUpperCase(Locale.ROOT));
|
||||
}
|
||||
return startsWithTwoUppercaseLetters;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
/*ap Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
* Copyright 2018 SmartBear Software
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -17,6 +16,9 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
@@ -24,16 +26,18 @@ import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenParameter;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -41,6 +45,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public abstract class AbstractPhpCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractPhpCodegen.class);
|
||||
@@ -238,6 +243,9 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
// apache v2 license
|
||||
// supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));
|
||||
|
||||
// all PHP codegens requires Composer, it means that we need to exclude from SVN at least vendor folder
|
||||
supportingFiles.add(new SupportingFile(".gitignore", "", ".gitignore"));
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
@@ -328,7 +336,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
Schema inner = ap.getItems();
|
||||
return getTypeDeclaration(inner) + "[]";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return getSchemaType(p) + "[string," + getTypeDeclaration(inner) + "]";
|
||||
} else if (StringUtils.isNotBlank(p.get$ref())) { // model
|
||||
String type = super.getTypeDeclaration(p);
|
||||
@@ -406,11 +414,11 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
if ("camelCase".equals(variableNamingConvention)) {
|
||||
// return the name in camelCase style
|
||||
// phone_number => phoneNumber
|
||||
name = camelize(name, true);
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
} else { // default to snake case
|
||||
// return the name in underscore style
|
||||
// PhoneNumber => phone_number
|
||||
name = underscore(name);
|
||||
name = org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
}
|
||||
|
||||
// parameter name starting with number won't compile
|
||||
@@ -441,13 +449,13 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
// model name cannot use reserved keyword
|
||||
if (isReservedWord(name)) {
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (name.matches("^\\d.*")) {
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
@@ -464,7 +472,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return camelize(name);
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -488,17 +496,17 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId), true));
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName("call_" + operationId), true));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
// operationId starts with a number
|
||||
if (operationId.matches("^\\d.*")) {
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId), true));
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName("call_" + operationId), true));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
return camelize(sanitizeName(operationId), true);
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId), true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -623,7 +631,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
// for symbol, e.g. $, #
|
||||
if (getSymbolName(name) != null) {
|
||||
return (getSymbolName(name)).toUpperCase();
|
||||
return (getSymbolName(name)).toUpperCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
// number
|
||||
@@ -636,7 +644,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
}
|
||||
|
||||
// string
|
||||
String enumName = sanitizeName(underscore(name).toUpperCase());
|
||||
String enumName = sanitizeName(org.openapitools.codegen.utils.StringUtils.underscore(name).toUpperCase(Locale.ROOT));
|
||||
enumName = enumName.replaceFirst("^_", "");
|
||||
enumName = enumName.replaceFirst("_$", "");
|
||||
|
||||
@@ -649,7 +657,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
String enumName = underscore(toModelName(property.name)).toUpperCase();
|
||||
String enumName = org.openapitools.codegen.utils.StringUtils.underscore(toModelName(property.name)).toUpperCase(Locale.ROOT);
|
||||
|
||||
// remove [] for array or map of enum
|
||||
enumName = enumName.replace("[]", "");
|
||||
@@ -674,7 +682,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
for (CodegenOperation op : operationList) {
|
||||
// for API test method name
|
||||
// e.g. public function test{{vendorExtensions.x-testOperationId}}()
|
||||
op.vendorExtensions.put("x-testOperationId", camelize(op.operationId));
|
||||
op.vendorExtensions.put("x-testOperationId", org.openapitools.codegen.utils.StringUtils.camelize(op.operationId));
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
@@ -19,12 +19,15 @@ package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
abstract class AbstractRubyCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractRubyCodegen.class);
|
||||
@@ -88,7 +91,7 @@ abstract class AbstractRubyCodegen extends DefaultCodegen implements CodegenConf
|
||||
Schema inner = ((ArraySchema) schema).getItems();
|
||||
return getSchemaType(schema) + "<" + getTypeDeclaration(inner) + ">";
|
||||
} else if (ModelUtils.isMapSchema(schema)) {
|
||||
Schema inner = (Schema) schema.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(schema);
|
||||
return getSchemaType(schema) + "<String, " + getTypeDeclaration(inner) + ">";
|
||||
}
|
||||
|
||||
@@ -116,12 +119,12 @@ abstract class AbstractRubyCodegen extends DefaultCodegen implements CodegenConf
|
||||
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
// if it's all uppper case, convert to lower case
|
||||
if (name.matches("^[A-Z_]*$")) {
|
||||
name = name.toLowerCase();
|
||||
name = name.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// petId => pet_id
|
||||
name = underscore(name);
|
||||
name = org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
@@ -141,12 +144,12 @@ abstract class AbstractRubyCodegen extends DefaultCodegen implements CodegenConf
|
||||
public String toOperationId(String operationId) {
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
String newOperationId = underscore("call_" + operationId);
|
||||
String newOperationId = org.openapitools.codegen.utils.StringUtils.underscore("call_" + operationId);
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
}
|
||||
|
||||
return underscore(operationId);
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(operationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,6 +35,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public abstract class AbstractScalaCodegen extends DefaultCodegen {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractScalaCodegen.class);
|
||||
|
||||
@@ -181,7 +182,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
|
||||
Schema inner = ap.getItems();
|
||||
return getSchemaType(p) + "[" + getTypeDeclaration(inner) + "]";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
|
||||
return getSchemaType(p) + "[String, " + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
@@ -206,7 +207,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
|
||||
@Override
|
||||
public String toInstantiationType(Schema p) {
|
||||
if (ModelUtils.isMapSchema(p)) {
|
||||
String inner = getSchemaType((Schema) p.getAdditionalProperties());
|
||||
String inner = getSchemaType(ModelUtils.getAdditionalProperties(p));
|
||||
return instantiationTypes.get("map") + "[String, " + inner + "]";
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
@@ -235,7 +236,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
|
||||
} else if (ModelUtils.isIntegerSchema(p)) {
|
||||
return null;
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
String inner = getSchemaType((Schema) p.getAdditionalProperties());
|
||||
String inner = getSchemaType(ModelUtils.getAdditionalProperties(p));
|
||||
return "new HashMap[String, " + inner + "]() ";
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
@@ -273,7 +274,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
|
||||
}
|
||||
|
||||
protected String formatIdentifier(String name, boolean capitalized) {
|
||||
String identifier = camelize(sanitizeName(name), true);
|
||||
String identifier = org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(name), true);
|
||||
if (capitalized) {
|
||||
identifier = StringUtils.capitalize(identifier);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractTypeScriptClientCodegen.class);
|
||||
|
||||
@@ -191,27 +192,27 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
String modelName = camelize("model_" + name);
|
||||
String modelName = org.openapitools.codegen.utils.StringUtils.camelize("model_" + name);
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + modelName);
|
||||
return modelName;
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (name.matches("^\\d.*")) {
|
||||
String modelName = camelize("model_" + name); // e.g. 200Response => Model200Response (after camelize)
|
||||
String modelName = org.openapitools.codegen.utils.StringUtils.camelize("model_" + name); // e.g. 200Response => Model200Response (after camelize)
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
|
||||
return modelName;
|
||||
}
|
||||
|
||||
if (languageSpecificPrimitives.contains(name)) {
|
||||
String modelName = camelize("model_" + name);
|
||||
String modelName = org.openapitools.codegen.utils.StringUtils.camelize("model_" + name);
|
||||
LOGGER.warn(name + " (model name matches existing language type) cannot be used as a model name. Renamed to " + modelName);
|
||||
return modelName;
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return camelize(name);
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -227,7 +228,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
Schema inner = ap.getItems();
|
||||
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return "{ [key: string]: " + getTypeDeclaration(inner) + "; }";
|
||||
} else if (ModelUtils.isFileSchema(p)) {
|
||||
return "any";
|
||||
@@ -246,7 +247,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
inner = mp1.getItems();
|
||||
return this.getSchemaType(p) + "<" + this.getParameterDataType(parameter, inner) + ">";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
inner = (Schema) p.getAdditionalProperties();
|
||||
inner = ModelUtils.getAdditionalProperties(p);
|
||||
return "{ [key: string]: " + this.getParameterDataType(parameter, inner) + "; }";
|
||||
} else if (ModelUtils.isStringSchema(p)) {
|
||||
// Handle string enums
|
||||
@@ -375,10 +376,10 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
// append _ at the beginning, e.g. _return
|
||||
if (isReservedWord(operationId)) {
|
||||
return escapeReservedWord(camelize(sanitizeName(operationId), true));
|
||||
return escapeReservedWord(org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId), true));
|
||||
}
|
||||
|
||||
return camelize(sanitizeName(operationId), true);
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId), true);
|
||||
}
|
||||
|
||||
public void setModelPropertyNaming(String naming) {
|
||||
@@ -401,11 +402,11 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
case original:
|
||||
return name;
|
||||
case camelCase:
|
||||
return camelize(name, true);
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
case PascalCase:
|
||||
return camelize(name);
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
case snake_case:
|
||||
return underscore(name);
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid model property naming '" +
|
||||
name + "'. Must be 'original', 'camelCase', " +
|
||||
@@ -436,7 +437,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
|
||||
// for symbol, e.g. $, #
|
||||
if (getSymbolName(name) != null) {
|
||||
return camelize(getSymbolName(name));
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(getSymbolName(name));
|
||||
}
|
||||
|
||||
// number
|
||||
@@ -456,7 +457,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
|
||||
// camelize the enum variable name
|
||||
// ref: https://basarat.gitbooks.io/typescript/content/docs/enums.html
|
||||
enumName = camelize(enumName);
|
||||
enumName = org.openapitools.codegen.utils.StringUtils.camelize(enumName);
|
||||
|
||||
if (enumName.matches("\\d.*")) { // starts with number
|
||||
return "_" + enumName;
|
||||
|
||||
@@ -17,14 +17,18 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import com.samskivert.mustache.Template;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import com.samskivert.mustache.Template;
|
||||
import org.openapitools.codegen.*;
|
||||
import java.util.Locale;
|
||||
|
||||
public class AdaCodegen extends AbstractAdaCodegen implements CodegenConfig {
|
||||
|
||||
@@ -71,7 +75,7 @@ public class AdaCodegen extends AbstractAdaCodegen implements CodegenConfig {
|
||||
// e.g. petstore.api (package name) => petstore_api (project name)
|
||||
projectName = packageName.replaceAll("\\.", "_");
|
||||
}
|
||||
String configBaseName = modelPackage.toLowerCase();
|
||||
String configBaseName = modelPackage.toLowerCase(Locale.ROOT);
|
||||
supportingFiles.add(new SupportingFile("gnat-project.mustache", "", toFilename(projectName) + ".gpr"));
|
||||
// supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("config.gpr", "", "config.gpr"));
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.openapitools.codegen.languages;
|
||||
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import com.samskivert.mustache.Template;
|
||||
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
@@ -28,6 +27,7 @@ import org.openapitools.codegen.SupportingFile;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.Locale;
|
||||
|
||||
public class AdaServerCodegen extends AbstractAdaCodegen implements CodegenConfig {
|
||||
|
||||
@@ -76,7 +76,7 @@ public class AdaServerCodegen extends AbstractAdaCodegen implements CodegenConfi
|
||||
// e.g. petstore.api (package name) => petstore_api (project name)
|
||||
projectName = packageName.replaceAll("\\.", "_");
|
||||
}
|
||||
String configBaseName = modelPackage.toLowerCase();
|
||||
String configBaseName = modelPackage.toLowerCase(Locale.ROOT);
|
||||
supportingFiles.add(new SupportingFile("gnat-project.mustache", "", toFilename(projectName) + ".gpr"));
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("config.gpr", "", "config.gpr"));
|
||||
|
||||
@@ -36,6 +36,7 @@ import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
|
||||
public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AndroidClientCodegen.class);
|
||||
public static final String USE_ANDROID_MAVEN_GRADLE_PLUGIN = "useAndroidMavenGradlePlugin";
|
||||
@@ -189,7 +190,7 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
|
||||
Schema inner = ap.getItems();
|
||||
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
|
||||
return getSchemaType(p) + "<String, " + getTypeDeclaration(inner) + ">";
|
||||
}
|
||||
@@ -228,7 +229,7 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// pet_id => petId
|
||||
name = camelize(name, true);
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
@@ -257,7 +258,7 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
name = camelize(sanitizeName(name));
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(name));
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
@@ -354,11 +355,11 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
|
||||
throw new RuntimeException("Empty method name (operationId) not allowed");
|
||||
}
|
||||
|
||||
operationId = camelize(sanitizeName(operationId), true);
|
||||
operationId = org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId), true);
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
String newOperationId = camelize("call_" + operationId, true);
|
||||
String newOperationId = org.openapitools.codegen.utils.StringUtils.camelize("call_" + operationId, true);
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class ApexClientCodegen extends AbstractApexCodegen {
|
||||
|
||||
private static final String CLASS_PREFIX = "classPrefix";
|
||||
@@ -191,7 +192,7 @@ public class ApexClientCodegen extends AbstractApexCodegen {
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
return camelize(classPrefix + super.toApiName(name));
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(classPrefix + super.toApiName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -217,6 +218,7 @@ public class ApexClientCodegen extends AbstractApexCodegen {
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
Schema inner = ((ArraySchema) p).getItems();
|
||||
out = String.format(
|
||||
Locale.ROOT,
|
||||
"new List<%s>()",
|
||||
inner == null ? "Object" : getTypeDeclaration(inner)
|
||||
);
|
||||
@@ -227,14 +229,14 @@ public class ApexClientCodegen extends AbstractApexCodegen {
|
||||
Long def = (Long) p.getDefault();
|
||||
out = def == null ? out : def.toString() + "L";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
String s = inner == null ? "Object" : getTypeDeclaration(inner);
|
||||
out = String.format("new Map<String, %s>()", s);
|
||||
out = String.format(Locale.ROOT, "new Map<String, %s>()", s);
|
||||
} else if (ModelUtils.isStringSchema(p)) {
|
||||
if (p.getDefault() != null) {
|
||||
String def = p.getDefault().toString();
|
||||
if (def != null) {
|
||||
out = p.getEnum() == null ? String.format("'%s'", escapeText(def)) : def;
|
||||
out = p.getEnum() == null ? String.format(Locale.ROOT, "'%s'", escapeText(def)) : def;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -270,7 +272,7 @@ public class ApexClientCodegen extends AbstractApexCodegen {
|
||||
if (apiVersion.matches("^\\d{2}(\\.0)?$")) {
|
||||
return apiVersion.substring(0, 2) + ".0";
|
||||
} else {
|
||||
LOGGER.warn(String.format("specified API version is invalid: %s - defaulting to %s", apiVersion, this.apiVersion));
|
||||
LOGGER.warn(String.format(Locale.ROOT, "specified API version is invalid: %s - defaulting to %s", apiVersion, this.apiVersion));
|
||||
return this.apiVersion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,21 +17,21 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import com.samskivert.mustache.Mustache;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.utils.URLPathUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.UUID.randomUUID;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
|
||||
public static final String USE_SWASHBUCKLE = "useSwashbuckle";
|
||||
|
||||
private String packageGuid = "{" + randomUUID().toString().toUpperCase() + "}";
|
||||
private String packageGuid = "{" + randomUUID().toString().toUpperCase(Locale.ROOT) + "}";
|
||||
|
||||
@SuppressWarnings("hiding")
|
||||
protected Logger LOGGER = LoggerFactory.getLogger(AspNetCoreServerCodegen.class);
|
||||
@@ -141,7 +141,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
additionalProperties.put(USE_SWASHBUCKLE, useSwashbuckle);
|
||||
}
|
||||
|
||||
additionalProperties.put("dockerTag", packageName.toLowerCase());
|
||||
additionalProperties.put("dockerTag", packageName.toLowerCase(Locale.ROOT));
|
||||
|
||||
apiPackage = packageName + ".Controllers";
|
||||
modelPackage = packageName + ".Models";
|
||||
@@ -211,7 +211,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
}
|
||||
|
||||
// Converts, for example, PUT to HttpPut for controller attributes
|
||||
operation.httpMethod = "Http" + operation.httpMethod.substring(0, 1) + operation.httpMethod.substring(1).toLowerCase();
|
||||
operation.httpMethod = "Http" + operation.httpMethod.substring(0, 1) + operation.httpMethod.substring(1).toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -388,7 +388,7 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
Schema inner = ap.getItems();
|
||||
return getSchemaType(p) + "[" + getTypeDeclaration(inner) + "]";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return getSchemaType(p) + "[String, " + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
@@ -637,7 +637,7 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
mapper.writerWithDefaultPrettyPrinter().writeValueAsString(
|
||||
definitions.get(p.dataType).getExample()));
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.warn(e.getMessage(), e);
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
|
||||
@@ -21,9 +21,7 @@ import static org.apache.commons.lang3.StringUtils.isEmpty;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.samskivert.mustache.Mustache;
|
||||
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
@@ -40,8 +38,11 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
||||
|
||||
public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
@SuppressWarnings({"hiding"})
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class);
|
||||
@@ -57,7 +58,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
// Defines the sdk option for targeted frameworks, which differs from targetFramework and targetFrameworkNuget
|
||||
private static final String MCS_NET_VERSION_KEY = "x-mcs-sdk";
|
||||
|
||||
protected String packageGuid = "{" + java.util.UUID.randomUUID().toString().toUpperCase() + "}";
|
||||
protected String packageGuid = "{" + java.util.UUID.randomUUID().toString().toUpperCase(Locale.ROOT) + "}";
|
||||
protected String clientPackage = "Org.OpenAPITools.Client";
|
||||
protected String localVariablePrefix = "";
|
||||
protected String apiDocPath = "docs/";
|
||||
@@ -703,7 +704,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
|
||||
// for symbol, e.g. $, #
|
||||
if (getSymbolName(value) != null) {
|
||||
return camelize(getSymbolName(value));
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(getSymbolName(value));
|
||||
}
|
||||
|
||||
// number
|
||||
@@ -719,7 +720,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
// string
|
||||
String var = value.replaceAll("_", " ");
|
||||
//var = WordUtils.capitalizeFully(var);
|
||||
var = camelize(var);
|
||||
var = org.openapitools.codegen.utils.StringUtils.camelize(var);
|
||||
var = var.replaceAll("\\W+", "");
|
||||
|
||||
if (var.matches("\\d.*")) {
|
||||
@@ -754,11 +755,11 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
case original:
|
||||
return name;
|
||||
case camelCase:
|
||||
return camelize(name, true);
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
case PascalCase:
|
||||
return camelize(name);
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
case snake_case:
|
||||
return underscore(name);
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid model property naming '" +
|
||||
name + "'. Must be 'original', 'camelCase', " +
|
||||
|
||||
@@ -17,17 +17,25 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||
import static org.apache.commons.lang3.StringUtils.capitalize;
|
||||
import static org.openapitools.codegen.CodegenConstants.*;
|
||||
import static org.openapitools.codegen.CodegenType.SERVER;
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.UUID.randomUUID;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Multimap;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
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.utils.ModelUtils;
|
||||
import org.openapitools.codegen.utils.URLPathUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.utils.*;
|
||||
import io.swagger.v3.oas.models.*;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
@@ -36,20 +44,34 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Multimap;
|
||||
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.UUID.randomUUID;
|
||||
import static org.apache.commons.lang3.StringUtils.capitalize;
|
||||
import static org.openapitools.codegen.CodegenConstants.INTERFACE_PREFIX;
|
||||
import static org.openapitools.codegen.CodegenConstants.INTERFACE_PREFIX_DESC;
|
||||
import static org.openapitools.codegen.CodegenConstants.OPTIONAL_PROJECT_FILE;
|
||||
import static org.openapitools.codegen.CodegenConstants.OPTIONAL_PROJECT_FILE_DESC;
|
||||
import static org.openapitools.codegen.CodegenConstants.OPTIONAL_PROJECT_GUID;
|
||||
import static org.openapitools.codegen.CodegenConstants.OPTIONAL_PROJECT_GUID_DESC;
|
||||
import static org.openapitools.codegen.CodegenConstants.PACKAGE_NAME;
|
||||
import static org.openapitools.codegen.CodegenConstants.PACKAGE_VERSION;
|
||||
import static org.openapitools.codegen.CodegenConstants.RETURN_ICOLLECTION;
|
||||
import static org.openapitools.codegen.CodegenConstants.RETURN_ICOLLECTION_DESC;
|
||||
import static org.openapitools.codegen.CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG;
|
||||
import static org.openapitools.codegen.CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC;
|
||||
import static org.openapitools.codegen.CodegenConstants.SOURCE_FOLDER;
|
||||
import static org.openapitools.codegen.CodegenConstants.SOURCE_FOLDER_DESC;
|
||||
import static org.openapitools.codegen.CodegenConstants.USE_COLLECTION;
|
||||
import static org.openapitools.codegen.CodegenConstants.USE_COLLECTION_DESC;
|
||||
import static org.openapitools.codegen.CodegenConstants.USE_DATETIME_OFFSET;
|
||||
import static org.openapitools.codegen.CodegenConstants.USE_DATETIME_OFFSET_DESC;
|
||||
import static org.openapitools.codegen.CodegenType.SERVER;
|
||||
|
||||
public class CSharpNancyFXServerCodegen extends AbstractCSharpCodegen {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CSharpNancyFXServerCodegen.class);
|
||||
@@ -64,7 +86,7 @@ public class CSharpNancyFXServerCodegen extends AbstractCSharpCodegen {
|
||||
private static final Map<String, Predicate<Schema>> propertyToOpenAPITypeMapping =
|
||||
createPropertyToOpenAPITypeMapping();
|
||||
|
||||
private String packageGuid = "{" + randomUUID().toString().toUpperCase() + "}";
|
||||
private String packageGuid = "{" + randomUUID().toString().toUpperCase(Locale.ROOT) + "}";
|
||||
|
||||
private final Map<String, DependencyInfo> dependencies = new HashMap<>();
|
||||
private final Set<String> parentModels = new HashSet<>();
|
||||
@@ -185,18 +207,18 @@ public class CSharpNancyFXServerCodegen extends AbstractCSharpCodegen {
|
||||
final String assemblyFramework = namespaceInfo.length > 3 ? namespaceInfo[3].trim() : "net45";
|
||||
|
||||
if (isNullOrEmpty(model) || isNullOrEmpty(namespaceName)) {
|
||||
LOGGER.warn(String.format("Could not import: '%s' - invalid namespace: '%s'", model, entry.getValue()));
|
||||
LOGGER.warn(String.format(Locale.ROOT, "Could not import: '%s' - invalid namespace: '%s'", model, entry.getValue()));
|
||||
importMapping.remove(model);
|
||||
} else {
|
||||
LOGGER.info(String.format("Importing: '%s' from '%s' namespace.", model, namespaceName));
|
||||
LOGGER.info(String.format(Locale.ROOT, "Importing: '%s' from '%s' namespace.", model, namespaceName));
|
||||
importMapping.put(model, namespaceName);
|
||||
}
|
||||
if (!isNullOrEmpty(modelClass)) {
|
||||
LOGGER.info(String.format("Mapping: '%s' class to '%s'", model, modelClass));
|
||||
LOGGER.info(String.format(Locale.ROOT, "Mapping: '%s' class to '%s'", model, modelClass));
|
||||
modelNameMapping.put(model, modelClass);
|
||||
}
|
||||
if (assembly != null && assemblyVersion != null) {
|
||||
LOGGER.info(String.format("Adding dependency: '%s', version: '%s', framework: '%s'",
|
||||
LOGGER.info(String.format(Locale.ROOT, "Adding dependency: '%s', version: '%s', framework: '%s'",
|
||||
assembly, assemblyVersion, assemblyVersion));
|
||||
dependencies.put(assembly, new DependencyInfo(assemblyVersion, assemblyFramework));
|
||||
}
|
||||
@@ -248,7 +270,7 @@ public class CSharpNancyFXServerCodegen extends AbstractCSharpCodegen {
|
||||
operation.path = operation.path.replace("?", "/");
|
||||
}
|
||||
if (!isNullOrEmpty(operation.httpMethod)) {
|
||||
operation.httpMethod = capitalize(operation.httpMethod.toLowerCase());
|
||||
operation.httpMethod = capitalize(operation.httpMethod.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,7 +302,7 @@ public class CSharpNancyFXServerCodegen extends AbstractCSharpCodegen {
|
||||
for (final CodegenProperty property : parent.vars) {
|
||||
final CodegenProperty duplicatedByParent = childPropertiesByName.get(property.name);
|
||||
if (duplicatedByParent != null) {
|
||||
LOGGER.info(String.format("Property: '%s' in '%s' model is inherited from '%s'",
|
||||
LOGGER.info(String.format(Locale.ROOT, "Property: '%s' in '%s' model is inherited from '%s'",
|
||||
property.name, child.classname, parent.classname));
|
||||
duplicatedByParent.isInherited = true;
|
||||
final CodegenProperty parentVar = duplicatedByParent.clone();
|
||||
@@ -311,7 +333,7 @@ public class CSharpNancyFXServerCodegen extends AbstractCSharpCodegen {
|
||||
return "Empty";
|
||||
}
|
||||
|
||||
final String enumName = camelize(
|
||||
final String enumName = org.openapitools.codegen.utils.StringUtils.camelize(
|
||||
sanitizeName(name)
|
||||
.replaceFirst("^_", "")
|
||||
.replaceFirst("_$", "")
|
||||
@@ -322,7 +344,7 @@ public class CSharpNancyFXServerCodegen extends AbstractCSharpCodegen {
|
||||
} else {
|
||||
result = enumName;
|
||||
}
|
||||
LOGGER.debug(String.format("toEnumVarName('%s', %s) = '%s'", name, datatype, enumName));
|
||||
LOGGER.debug(String.format(Locale.ROOT, "toEnumVarName('%s', %s) = '%s'", name, datatype, enumName));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -334,7 +356,7 @@ public class CSharpNancyFXServerCodegen extends AbstractCSharpCodegen {
|
||||
} else {
|
||||
apiName = capitalize(name);
|
||||
}
|
||||
LOGGER.debug(String.format("toApiName('%s') = '%s'", name, apiName));
|
||||
LOGGER.debug(String.format(Locale.ROOT, "toApiName('%s') = '%s'", name, apiName));
|
||||
return apiName;
|
||||
}
|
||||
|
||||
@@ -355,7 +377,7 @@ public class CSharpNancyFXServerCodegen extends AbstractCSharpCodegen {
|
||||
} else {
|
||||
result = null;
|
||||
}
|
||||
LOGGER.debug(String.format("toModelImport('%s') = '%s'", name, result));
|
||||
LOGGER.debug(String.format(Locale.ROOT, "toModelImport('%s') = '%s'", name, result));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -378,7 +400,7 @@ public class CSharpNancyFXServerCodegen extends AbstractCSharpCodegen {
|
||||
|
||||
@Override
|
||||
public String toEnumName(final CodegenProperty property) {
|
||||
return sanitizeName(camelize(property.name)) + "Enum";
|
||||
return sanitizeName(org.openapitools.codegen.utils.StringUtils.camelize(property.name)) + "Enum";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Contact;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.info.License;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
@@ -24,16 +29,12 @@ import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.oas.models.info.*;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final String PROJECT_NAME = "projectName";
|
||||
@@ -109,7 +110,7 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi
|
||||
Info info = openAPI.getInfo();
|
||||
if (projectName == null && info.getTitle() != null) {
|
||||
// when projectName is not specified, generate it from info.title
|
||||
projectName = dashize(info.getTitle());
|
||||
projectName = org.openapitools.codegen.utils.StringUtils.dashize(info.getTitle());
|
||||
}
|
||||
if (projectVersion == null) {
|
||||
// when projectVersion is not specified, use info.version
|
||||
@@ -148,7 +149,7 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi
|
||||
projectDescription = "Client library of " + projectName;
|
||||
}
|
||||
if (baseNamespace == null) {
|
||||
baseNamespace = dashize(projectName);
|
||||
baseNamespace = org.openapitools.codegen.utils.StringUtils.dashize(projectName);
|
||||
}
|
||||
apiPackage = baseNamespace + ".api";
|
||||
|
||||
@@ -182,17 +183,17 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi
|
||||
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
|
||||
}
|
||||
|
||||
return dashize(sanitizeName(operationId));
|
||||
return org.openapitools.codegen.utils.StringUtils.dashize(sanitizeName(operationId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiFilename(String name) {
|
||||
return underscore(toApiName(name));
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(toApiName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
return dashize(name);
|
||||
return org.openapitools.codegen.utils.StringUtils.dashize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -203,7 +204,7 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
name = name.replaceAll("[^a-zA-Z0-9_-]+", ""); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
name = dashize(name);
|
||||
name = org.openapitools.codegen.utils.StringUtils.dashize(name);
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -221,7 +222,7 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) objs.get("operation");
|
||||
for (CodegenOperation op : ops) {
|
||||
// Convert httpMethod to lower case, e.g. "get", "post"
|
||||
op.httpMethod = op.httpMethod.toLowerCase();
|
||||
op.httpMethod = op.httpMethod.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
return operations;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
@@ -32,6 +31,7 @@ import org.openapitools.codegen.utils.ModelUtils;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class ConfluenceWikiCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
@@ -99,7 +99,7 @@ public class ConfluenceWikiCodegen extends DefaultCodegen implements CodegenConf
|
||||
Schema inner = ap.getItems();
|
||||
return getSchemaType(p) + "[" + getTypeDeclaration(inner) + "]";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return getSchemaType(p) + "[String, " + getTypeDeclaration(inner) + "]";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
@@ -110,7 +110,7 @@ public class ConfluenceWikiCodegen extends DefaultCodegen implements CodegenConf
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
for (CodegenOperation op : operationList) {
|
||||
op.httpMethod = op.httpMethod.toLowerCase();
|
||||
op.httpMethod = op.httpMethod.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
@@ -38,9 +37,11 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
protected String implFolder = "impl";
|
||||
protected boolean isAddExternalLibs = true;
|
||||
@@ -198,8 +199,8 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
String classname = (String) operations.get("classname");
|
||||
operations.put("classnameSnakeUpperCase", DefaultCodegen.underscore(classname).toUpperCase());
|
||||
operations.put("classnameSnakeLowerCase", DefaultCodegen.underscore(classname).toLowerCase());
|
||||
operations.put("classnameSnakeUpperCase", org.openapitools.codegen.utils.StringUtils.underscore(classname).toUpperCase(Locale.ROOT));
|
||||
operations.put("classnameSnakeLowerCase", org.openapitools.codegen.utils.StringUtils.underscore(classname).toLowerCase(Locale.ROOT));
|
||||
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
for (CodegenOperation op : operationList) {
|
||||
@@ -220,7 +221,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
op.httpMethod = op.httpMethod.substring(0, 1).toUpperCase() + op.httpMethod.substring(1).toLowerCase();
|
||||
op.httpMethod = op.httpMethod.substring(0, 1).toUpperCase(Locale.ROOT) + op.httpMethod.substring(1).toLowerCase(Locale.ROOT);
|
||||
|
||||
for (CodegenParameter param : op.allParams) {
|
||||
if (param.isFormParam) isParsingSupported = false;
|
||||
@@ -246,11 +247,13 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
}
|
||||
op.vendorExtensions.put("x-codegen-pistache-consumesJson", consumeJson);
|
||||
op.vendorExtensions.put("x-codegen-pistache-isParsingSupported", isParsingSupported);
|
||||
|
||||
// Check if any one of the operations needs a model, then at API file level, at least one model has to be included.
|
||||
for(String hdr : op.imports) {
|
||||
if(importMapping.containsKey(hdr)) {
|
||||
continue;
|
||||
}
|
||||
additionalProperties.put("hasModelImport", true);
|
||||
operations.put("hasModelImport", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,7 +308,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
|
||||
}
|
||||
if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return getSchemaType(p) + "<std::string, " + getTypeDeclaration(inner) + ">";
|
||||
}
|
||||
else if (ModelUtils.isByteArraySchema(p)) {
|
||||
@@ -343,7 +346,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
else if (ModelUtils.isByteArraySchema(p)) {
|
||||
return "\"\"";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
String inner = getSchemaType((Schema) p.getAdditionalProperties());
|
||||
String inner = getSchemaType(ModelUtils.getAdditionalProperties(p));
|
||||
return "std::map<std::string, " + inner + ">()";
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
|
||||
@@ -17,12 +17,15 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -30,9 +33,11 @@ import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class CppQt5ClientCodegen extends AbstractCppCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CppQt5ClientCodegen.class);
|
||||
|
||||
@@ -294,7 +299,7 @@ public class CppQt5ClientCodegen extends AbstractCppCodegen implements CodegenCo
|
||||
Schema inner = ap.getItems();
|
||||
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">*";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return getSchemaType(p) + "<QString, " + getTypeDeclaration(inner) + ">*";
|
||||
}
|
||||
if (foundationClasses.contains(openAPIType)) {
|
||||
@@ -325,7 +330,7 @@ public class CppQt5ClientCodegen extends AbstractCppCodegen implements CodegenCo
|
||||
}
|
||||
return "0";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return "new QMap<QString, " + getTypeDeclaration(inner) + ">()";
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
@@ -371,12 +376,12 @@ public class CppQt5ClientCodegen extends AbstractCppCodegen implements CodegenCo
|
||||
|
||||
// if it's all uppper case, convert to lower case
|
||||
if (varName.matches("^[A-Z_]*$")) {
|
||||
varName = varName.toLowerCase();
|
||||
varName = varName.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// petId => pet_id
|
||||
varName = underscore(varName);
|
||||
varName = org.openapitools.codegen.utils.StringUtils.underscore(varName);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(varName) || varName.matches("^\\d.*")) {
|
||||
|
||||
@@ -17,22 +17,30 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenParameter;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class CppQt5QHttpEngineServerCodegen extends AbstractCppCodegen implements CodegenConfig {
|
||||
@SuppressWarnings("unused")
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CppQt5QHttpEngineServerCodegen.class);
|
||||
@@ -52,7 +60,7 @@ public class CppQt5QHttpEngineServerCodegen extends AbstractCppCodegen implement
|
||||
protected Map<String, String> namespaces = new HashMap<String, String>();
|
||||
protected Set<String> systemIncludes = new HashSet<String>();
|
||||
protected String cppNamespace = "OpenAPI";
|
||||
|
||||
protected Set<String> nonFrameworkPrimitives = new HashSet<String>();
|
||||
public CppQt5QHttpEngineServerCodegen() {
|
||||
super();
|
||||
|
||||
@@ -132,7 +140,17 @@ public class CppQt5QHttpEngineServerCodegen extends AbstractCppCodegen implement
|
||||
"float",
|
||||
"double")
|
||||
);
|
||||
|
||||
nonFrameworkPrimitives.addAll(languageSpecificPrimitives);
|
||||
|
||||
foundationClasses.addAll(
|
||||
Arrays.asList(
|
||||
"QString",
|
||||
"QDate",
|
||||
"QDateTime",
|
||||
"QByteArray")
|
||||
);
|
||||
languageSpecificPrimitives.addAll(foundationClasses);
|
||||
|
||||
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder + MODEL_DIR, PREFIX + "Helpers.h"));
|
||||
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder + MODEL_DIR, PREFIX + "Helpers.cpp"));
|
||||
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder + MODEL_DIR, PREFIX + "Object.h"));
|
||||
@@ -171,7 +189,7 @@ public class CppQt5QHttpEngineServerCodegen extends AbstractCppCodegen implement
|
||||
importMapping = new HashMap<String, String>();
|
||||
namespaces = new HashMap<String, String>();
|
||||
|
||||
foundationClasses.add("QString");
|
||||
|
||||
|
||||
systemIncludes.add("QString");
|
||||
systemIncludes.add("QList");
|
||||
@@ -323,7 +341,7 @@ public class CppQt5QHttpEngineServerCodegen extends AbstractCppCodegen implement
|
||||
Schema inner = ap.getItems();
|
||||
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return getSchemaType(p) + "<QString, " + getTypeDeclaration(inner) + ">";
|
||||
} else if (ModelUtils.isBinarySchema(p)) {
|
||||
return getSchemaType(p) + "*";
|
||||
@@ -359,7 +377,7 @@ public class CppQt5QHttpEngineServerCodegen extends AbstractCppCodegen implement
|
||||
}
|
||||
return "0";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return "QMap<QString, " + getTypeDeclaration(inner) + ">()";
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
@@ -407,12 +425,12 @@ public class CppQt5QHttpEngineServerCodegen extends AbstractCppCodegen implement
|
||||
|
||||
// if it's all uppper case, convert to lower case
|
||||
if (varName.matches("^[A-Z_]*$")) {
|
||||
varName = varName.toLowerCase();
|
||||
varName = varName.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// petId => pet_id
|
||||
varName = underscore(varName);
|
||||
varName = org.openapitools.codegen.utils.StringUtils.underscore(varName);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(varName) || varName.matches("^\\d.*")) {
|
||||
@@ -431,4 +449,71 @@ public class CppQt5QHttpEngineServerCodegen extends AbstractCppCodegen implement
|
||||
public String getTypeDeclaration(String str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean needToImport(String type) {
|
||||
return StringUtils.isNotBlank(type) && !defaultIncludes.contains(type)
|
||||
&& !nonFrameworkPrimitives.contains(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
||||
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||
|
||||
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
||||
for (CodegenOperation operation : operations) {
|
||||
// Check all return parameter baseType if there is a necessity to include, include it if not
|
||||
// already done
|
||||
if (operation.returnBaseType != null && needToImport(operation.returnBaseType)) {
|
||||
if(!isIncluded(operation.returnBaseType, imports)) {
|
||||
imports.add(createMapping("import", operation.returnBaseType));
|
||||
}
|
||||
}
|
||||
List<CodegenParameter> params = new ArrayList<CodegenParameter>();
|
||||
if (operation.allParams != null)params.addAll(operation.allParams);
|
||||
|
||||
// Check all parameter baseType if there is a necessity to include, include it if not
|
||||
// already done
|
||||
for(CodegenParameter param : params) {
|
||||
if(param.isPrimitiveType && needToImport(param.baseType)) {
|
||||
if(!isIncluded(param.baseType, imports)) {
|
||||
imports.add(createMapping("import", param.baseType));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (operation.pathParams != null) {
|
||||
// We use QString to pass path params, add it to include
|
||||
if(!isIncluded("QString", imports)) {
|
||||
imports.add(createMapping("import", "QString"));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isIncluded("QMap", imports)) {
|
||||
// Maps uses QString as key
|
||||
if(!isIncluded("QString", imports)) {
|
||||
imports.add(createMapping("import", "QString"));
|
||||
}
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
public Map<String, String> createMapping(String key, String value) {
|
||||
Map<String, String> customImport = new HashMap<String, String>();
|
||||
customImport.put(key, toModelImport(value));
|
||||
return customImport;
|
||||
}
|
||||
|
||||
private boolean isIncluded(String type, List<Map<String, String>> imports) {
|
||||
boolean included = false;
|
||||
String inclStr = toModelImport(type);
|
||||
for (Map<String, String> importItem : imports) {
|
||||
if(importItem.containsValue(inclStr)) {
|
||||
included = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return included;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,17 +17,13 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
@@ -42,9 +38,12 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||
|
||||
public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
||||
|
||||
public static final String DECLSPEC = "declspec";
|
||||
@@ -139,6 +138,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
||||
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
|
||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||
supportingFiles.add(new SupportingFile("cmake-lists.mustache", "", "CMakeLists.txt"));
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList("int", "char", "bool", "long", "float", "double", "int32_t", "int64_t"));
|
||||
@@ -188,10 +188,10 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
||||
|
||||
additionalProperties.put("modelNamespaceDeclarations", modelPackage.split("\\."));
|
||||
additionalProperties.put("modelNamespace", modelPackage.replaceAll("\\.", "::"));
|
||||
additionalProperties.put("modelHeaderGuardPrefix", modelPackage.replaceAll("\\.", "_").toUpperCase());
|
||||
additionalProperties.put("modelHeaderGuardPrefix", modelPackage.replaceAll("\\.", "_").toUpperCase(Locale.ROOT));
|
||||
additionalProperties.put("apiNamespaceDeclarations", apiPackage.split("\\."));
|
||||
additionalProperties.put("apiNamespace", apiPackage.replaceAll("\\.", "::"));
|
||||
additionalProperties.put("apiHeaderGuardPrefix", apiPackage.replaceAll("\\.", "_").toUpperCase());
|
||||
additionalProperties.put("apiHeaderGuardPrefix", apiPackage.replaceAll("\\.", "_").toUpperCase(Locale.ROOT));
|
||||
additionalProperties.put("declspec", declspec);
|
||||
additionalProperties.put("defaultInclude", defaultInclude);
|
||||
}
|
||||
@@ -307,7 +307,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
||||
Schema inner = ap.getItems();
|
||||
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return getSchemaType(p) + "<utility::string_t, " + getTypeDeclaration(inner) + ">";
|
||||
} else if (ModelUtils.isStringSchema(p)
|
||||
|| ModelUtils.isDateSchema(p) || ModelUtils.isDateTimeSchema(p)
|
||||
@@ -338,7 +338,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
||||
}
|
||||
return "0";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
String inner = getSchemaType((Schema) p.getAdditionalProperties());
|
||||
String inner = getSchemaType(ModelUtils.getAdditionalProperties(p));
|
||||
return "std::map<utility::string_t, " + inner + ">()";
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
|
||||
@@ -270,7 +270,7 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
||||
Schema inner = ap.getItems();
|
||||
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return getSchemaType(p) + "<std::string, " + getTypeDeclaration(inner) + ">";
|
||||
} else if (ModelUtils.isByteArraySchema(p)) {
|
||||
return "std::string";
|
||||
@@ -307,7 +307,7 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
||||
} else if (ModelUtils.isByteArraySchema(p)) {
|
||||
return "\"\"";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
String inner = getSchemaType((Schema) p.getAdditionalProperties());
|
||||
String inner = getSchemaType(ModelUtils.getAdditionalProperties(p));
|
||||
return "std::map<std::string, " + inner + ">()";
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
|
||||
public class CppTizenClientCodegen extends AbstractCppCodegen implements CodegenConfig {
|
||||
protected static String PREFIX = "ArtikCloud";
|
||||
protected String sourceFolder = "src";
|
||||
@@ -283,7 +284,7 @@ public class CppTizenClientCodegen extends AbstractCppCodegen implements Codegen
|
||||
}
|
||||
|
||||
// add_pet_by_id => addPetById
|
||||
return camelize(operationId, true);
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(operationId, true);
|
||||
}
|
||||
/**
|
||||
* Output the Getter name for boolean property, e.g. getActive
|
||||
|
||||
@@ -39,6 +39,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(DartClientCodegen.class);
|
||||
|
||||
@@ -243,7 +244,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// pet_id => petId
|
||||
name = camelize(name, true);
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
|
||||
if (name.matches("^\\d.*")) {
|
||||
name = "n" + name;
|
||||
@@ -266,23 +267,23 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public String toModelName(String name) {
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model filename. Renamed to " + camelize("model_" + name));
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model filename. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return camelize(name);
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
return underscore(toModelName(name));
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(toModelName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiFilename(String name) {
|
||||
return underscore(toApiName(name));
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(toApiName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -307,7 +308,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
Schema inner = ap.getItems();
|
||||
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
|
||||
return getSchemaType(p) + "<String, " + getTypeDeclaration(inner) + ">";
|
||||
}
|
||||
@@ -401,7 +402,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
new ArrayList<Map<String, String>>();
|
||||
for (Map<String, Object> value : values) {
|
||||
Map<String, String> enumVar = new HashMap<String, String>();
|
||||
String name = camelize((String) value.get("identifier"), true);
|
||||
String name = org.openapitools.codegen.utils.StringUtils.camelize((String) value.get("identifier"), true);
|
||||
if (isReservedWord(name)) {
|
||||
name = escapeReservedWord(name);
|
||||
}
|
||||
@@ -427,7 +428,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
"int".equalsIgnoreCase(datatype)) {
|
||||
var = "Number" + var;
|
||||
}
|
||||
return escapeReservedWord(camelize(var, true));
|
||||
return escapeReservedWord(org.openapitools.codegen.utils.StringUtils.camelize(var, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -444,12 +445,12 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public String toOperationId(String operationId) {
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
String newOperationId = camelize("call_" + operationId, true);
|
||||
String newOperationId = org.openapitools.codegen.utils.StringUtils.camelize("call_" + operationId, true);
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
}
|
||||
|
||||
return camelize(operationId, true);
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(operationId, true);
|
||||
}
|
||||
|
||||
public void setBrowserClient(boolean browserClient) {
|
||||
|
||||
@@ -17,13 +17,16 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.openapitools.codegen.*;
|
||||
import java.io.File;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
public class EiffelClientCodegen extends AbstractEiffelCodegen {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(EiffelClientCodegen.class);
|
||||
@@ -168,7 +171,7 @@ public class EiffelClientCodegen extends AbstractEiffelCodegen {
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
return sanitizeName(property.name).toUpperCase() + "_ENUM";
|
||||
return sanitizeName(property.name).toUpperCase(Locale.ROOT) + "_ENUM";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -179,7 +182,7 @@ public class EiffelClientCodegen extends AbstractEiffelCodegen {
|
||||
|
||||
// for symbol, e.g. $, #
|
||||
if (getSymbolName(value) != null) {
|
||||
return getSymbolName(value).toUpperCase();
|
||||
return getSymbolName(value).toUpperCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
// number
|
||||
@@ -193,7 +196,7 @@ public class EiffelClientCodegen extends AbstractEiffelCodegen {
|
||||
}
|
||||
|
||||
// string
|
||||
String var = value.replaceAll("\\W+", "_").toLowerCase();
|
||||
String var = value.replaceAll("\\W+", "_").toLowerCase(Locale.ROOT);
|
||||
if (var.matches("\\d.*")) {
|
||||
return "val_" + var;
|
||||
} else if (var.startsWith("_")) {
|
||||
|
||||
@@ -38,6 +38,7 @@ import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ElixirClientCodegen.class);
|
||||
|
||||
@@ -276,7 +277,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
while (matcher.find()) {
|
||||
String pathTemplateName = matcher.group(1);
|
||||
matcher.appendReplacement(buffer, "#{" + underscore(pathTemplateName) + "}" + "$2");
|
||||
matcher.appendReplacement(buffer, "#{" + org.openapitools.codegen.utils.StringUtils.underscore(pathTemplateName) + "}" + "$2");
|
||||
pathTemplateNames.add(pathTemplateName);
|
||||
}
|
||||
ExtendedCodegenOperation eco = new ExtendedCodegenOperation(o);
|
||||
@@ -324,7 +325,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
String underscored(String words) {
|
||||
ArrayList<String> underscoredWords = new ArrayList<String>();
|
||||
for (String word : words.split(" ")) {
|
||||
underscoredWords.add(underscore(word));
|
||||
underscoredWords.add(org.openapitools.codegen.utils.StringUtils.underscore(word));
|
||||
}
|
||||
return join("_", underscoredWords);
|
||||
}
|
||||
@@ -332,7 +333,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
String modulized(String words) {
|
||||
ArrayList<String> modulizedWords = new ArrayList<String>();
|
||||
for (String word : words.split(" ")) {
|
||||
modulizedWords.add(camelize(word));
|
||||
modulizedWords.add(org.openapitools.codegen.utils.StringUtils.camelize(word));
|
||||
}
|
||||
return join("", modulizedWords);
|
||||
}
|
||||
@@ -351,7 +352,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
private String sourceFolder() {
|
||||
ArrayList<String> underscoredWords = new ArrayList<String>();
|
||||
for (String word : moduleName.split("\\.")) {
|
||||
underscoredWords.add(underscore(word));
|
||||
underscoredWords.add(org.openapitools.codegen.utils.StringUtils.underscore(word));
|
||||
}
|
||||
return ("lib/" + join("/", underscoredWords)).replace('/', File.separatorChar);
|
||||
}
|
||||
@@ -378,7 +379,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
if (name.length() == 0) {
|
||||
return "Default";
|
||||
}
|
||||
return camelize(name);
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -387,14 +388,14 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
name = name.replaceAll("-", "_");
|
||||
|
||||
// e.g. PetApi.go => pet_api.go
|
||||
return underscore(name);
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return camelize(toModelFilename(name));
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(toModelFilename(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -421,7 +422,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
return underscore(name);
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -431,7 +432,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
throw new RuntimeException("Empty method name (operationId) not allowed");
|
||||
}
|
||||
|
||||
return camelize(sanitizeName(operationId));
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -447,7 +448,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
Schema inner = ap.getItems();
|
||||
return "[" + getTypeDeclaration(inner) + "]";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return "%{optional(String.t) => " + getTypeDeclaration(inner) + "}";
|
||||
} else if (ModelUtils.isPasswordSchema(p)) {
|
||||
return "String.t";
|
||||
@@ -584,7 +585,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
public String typespec() {
|
||||
StringBuilder sb = new StringBuilder("@spec ");
|
||||
sb.append(underscore(operationId));
|
||||
sb.append(org.openapitools.codegen.utils.StringUtils.underscore(operationId));
|
||||
sb.append("(Tesla.Env.client, ");
|
||||
|
||||
for (CodegenParameter param : allParams) {
|
||||
|
||||
@@ -17,15 +17,21 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import org.openapitools.codegen.*;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.NumberSchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenParameter;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.CodegenResponse;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.openapitools.codegen.languages.features.BeanValidationFeatures;
|
||||
import org.openapitools.codegen.languages.features.JbossFeature;
|
||||
import org.openapitools.codegen.languages.features.SwaggerFeatures;
|
||||
import io.swagger.v3.oas.models.*;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.oas.models.parameters.*;
|
||||
import io.swagger.v3.oas.models.responses.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.Collator;
|
||||
@@ -36,10 +42,12 @@ import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
|
||||
public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final String X_ENCODER = "x-encoder";
|
||||
private static final String X_DECODER = "x-decoder";
|
||||
@@ -165,7 +173,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
final String modelName = camelize(name);
|
||||
final String modelName = org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return defaultIncludes.contains(modelName) ? modelName + "_" : modelName;
|
||||
}
|
||||
|
||||
@@ -181,13 +189,13 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
final String varName = camelize(name, true);
|
||||
final String varName = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
return isReservedWord(varName) ? escapeReservedWord(name) : varName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumVarName(String value, String datatype) {
|
||||
final String camelized = camelize(value.replace(" ", "_").replace("(", "_").replace(")", "")); // TODO FIXME escape properly
|
||||
final String camelized = org.openapitools.codegen.utils.StringUtils.camelize(value.replace(" ", "_").replace("(", "_").replace(")", "")); // TODO FIXME escape properly
|
||||
if (!Character.isUpperCase(camelized.charAt(0))) {
|
||||
return "N" + camelized;
|
||||
}
|
||||
@@ -259,7 +267,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
Collections.sort(parent.children, new Comparator<CodegenModel>() {
|
||||
@Override
|
||||
public int compare(CodegenModel cm1, CodegenModel cm2) {
|
||||
return Collator.getInstance().compare(cm1.classname, cm2.classname);
|
||||
return Collator.getInstance(Locale.ROOT).compare(cm1.classname, cm2.classname);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -290,8 +298,8 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
elmImport.moduleName = modulePrefix + cm.arrayModelType;
|
||||
elmImport.exposures = new TreeSet<>();
|
||||
elmImport.exposures.add(cm.arrayModelType);
|
||||
elmImport.exposures.add(camelize(cm.arrayModelType, true) + "Decoder");
|
||||
elmImport.exposures.add(camelize(cm.arrayModelType, true) + "Encoder");
|
||||
elmImport.exposures.add(org.openapitools.codegen.utils.StringUtils.camelize(cm.arrayModelType, true) + "Decoder");
|
||||
elmImport.exposures.add(org.openapitools.codegen.utils.StringUtils.camelize(cm.arrayModelType, true) + "Encoder");
|
||||
elmImport.hasExposures = true;
|
||||
elmImports.add(elmImport);
|
||||
}
|
||||
@@ -486,7 +494,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
Schema inner = ap.getItems();
|
||||
return getTypeDeclaration(inner);
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = (Schema) p.getAdditionalProperties();
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return getTypeDeclaration(inner);
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
@@ -506,8 +514,8 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenResponse fromResponse(String responseCode, ApiResponse resp) {
|
||||
final CodegenResponse response = super.fromResponse(responseCode, resp);
|
||||
public CodegenResponse fromResponse(OpenAPI openAPI, String responseCode, ApiResponse resp) {
|
||||
final CodegenResponse response = super.fromResponse(openAPI, responseCode, resp);
|
||||
if (response.dataType != null) {
|
||||
addEncoderAndDecoder(response.vendorExtensions, response.dataType, response.isMapContainer, response.primitiveType);
|
||||
}
|
||||
@@ -527,7 +535,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
if (isMapContainer) {
|
||||
isPrimitiveType = isPrimitiveDataType(dataType);
|
||||
}
|
||||
final String baseName = camelize(dataType, true);
|
||||
final String baseName = org.openapitools.codegen.utils.StringUtils.camelize(dataType, true);
|
||||
String encoderName;
|
||||
String decoderName;
|
||||
if (isPrimitiveType) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user