mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-06 18:45:23 +00:00
Merge remote-tracking branch 'origin/master' into 3.1.x
This commit is contained in:
commit
66b73e906e
@ -128,4 +128,4 @@ after_success:
|
||||
- if [ $DOCKER_HUB_USERNAME ]; then echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin && docker build -t $DOCKER_CODEGEN_CLI_IMAGE_NAME ./modules/openapi-generator-cli && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest $DOCKER_CODEGEN_CLI_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME && echo "Pushed to $DOCKER_CODEGEN_CLI_IMAGE_NAME"; fi; fi
|
||||
|
||||
env:
|
||||
- DOCKER_GENERATOR_IMAGE_NAME=openapitools/openapi-generator-online DOCKER_CODEGEN_CLI_IMAGE_NAME=openapitools/openapi-generator-cli
|
||||
- DOCKER_GENERATOR_IMAGE_NAME=openapitools/openapi-generator-online DOCKER_CODEGEN_CLI_IMAGE_NAME=openapitools/openapi-generator-cli NODE_ENV=test
|
||||
|
@ -836,8 +836,8 @@
|
||||
<!-- test non-java projects -->
|
||||
<module>samples/client/petstore/go</module>
|
||||
<!-- test java-related projects -->
|
||||
<module>samples/client/petstore/akka-scala</module>
|
||||
<module>samples/client/petstore/scala</module>
|
||||
<module>samples/client/petstore/scala-akka</module>
|
||||
<module>samples/client/petstore/scala-httpclient</module>
|
||||
<module>samples/client/petstore/scalaz</module>
|
||||
<module>samples/client/petstore/clojure</module>
|
||||
<module>samples/client/petstore/java/feign</module>
|
||||
|
@ -834,8 +834,8 @@
|
||||
<modules>
|
||||
<!-- clients -->
|
||||
<!-- test java-related projects -->
|
||||
<module>samples/client/petstore/akka-scala</module>
|
||||
<module>samples/client/petstore/scala</module>
|
||||
<module>samples/client/petstore/scala-akka</module>
|
||||
<module>samples/client/petstore/scala-httpclient</module>
|
||||
<module>samples/client/petstore/scalaz</module>
|
||||
<module>samples/client/petstore/clojure</module>
|
||||
<module>samples/client/petstore/java/feign</module>
|
||||
|
@ -36,6 +36,9 @@
|
||||
|
||||
:warning: If the OpenAPI spec is obtained from an untrusted source, please make sure you've reviewed the spec before using OpenAPI Generator to generate the API client, server stub or documentation as [code injection](https://en.wikipedia.org/wiki/Code_injection) may occur :warning:
|
||||
|
||||
:bangbang: Both "OpenAPI Tools" (https://OpenAPITools.org - the parent organization of OpenAPI Generator) and "OpenAPI Generator" are not affiliated with OpenAPI Initiative (OAI) :bangbang:
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
## Overview
|
||||
@ -43,7 +46,7 @@ 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) **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)
|
||||
**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 documentation generators** | **HTML**, **Confluence Wiki**
|
||||
**Configuration files** | [**Apache2**](https://httpd.apache.org/)
|
||||
@ -474,6 +477,7 @@ Here is a list of template creators:
|
||||
* Java (Rest-assured): @viclovsky
|
||||
* Javascript/NodeJS: @jfiala
|
||||
* Javascript (Closure-annotated Angular) @achew22
|
||||
* Javascript (Flow types) @jaypea
|
||||
* JMeter: @davidkiss
|
||||
* Kotlin: @jimschubert
|
||||
* Lua: @daurnimator
|
||||
|
32
bin/javascript-flowtyped-petstore.sh
Executable file
32
bin/javascript-flowtyped-petstore.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#!/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 -t modules/openapi-generator/src/main/resources/Javascript-Flowtyped -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g javascript-flowtyped -o samples/client/petstore/javascript-flowtyped -DappName=PetstoreClient $@"
|
||||
|
||||
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 --artifact-id "scala-akka-petstore-client" -t modules/openapi-generator/src/main/resources/akka-scala -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g akka-scala -o samples/client/petstore/akka-scala $@"
|
||||
ags="generate --artifact-id "scala-akka-petstore-client" -t modules/openapi-generator/src/main/resources/scala-akka-client -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g akka-scala -o samples/client/petstore/scala-akka $@"
|
||||
|
||||
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/scala -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala -o samples/client/petstore/scala $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/scala-httpclient -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala -o samples/client/petstore/scala-httpclient $@"
|
||||
|
||||
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/slim -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g php-slim -o samples/server/petstore/php-slim $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/slim -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g php-slim -o samples/server/petstore/php-slim $@"
|
||||
|
||||
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 --artifact-id "scala-akka-petstore-client" -t modules/openapi-generator/src/main/resources/akka-scala -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g scala-akka -o samples/client/petstore/akka-scala $@"
|
||||
ags="generate --artifact-id "scala-akka-petstore-client" -t modules/openapi-generator/src/main/resources/scala-akka-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g scala-akka -o samples/client/petstore/scala-akka $@"
|
||||
|
||||
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/scala -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g scala-httpclient -o samples/client/petstore/scala $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/scala-httpclient -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g scala-httpclient -o samples/client/petstore/scala-httpclient $@"
|
||||
|
||||
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/scala -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g scala-httpclient -o samples/client/petstore-security-test/scala $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/scala-httpclient -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g scala-httpclient -o samples/client/petstore-security-test/scala-httpclient $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
@ -4,3 +4,4 @@
|
||||
./bin/swift4-petstore-promisekit.sh
|
||||
./bin/swift4-petstore-rxswift.sh
|
||||
./bin/swift4-petstore-objcCompatible.sh
|
||||
./bin/swift4-petstore-unwrapRequired.sh
|
||||
|
7
bin/swift4-petstore-unwrapRequired.json
Normal file
7
bin/swift4-petstore-unwrapRequired.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"podSummary": "PetstoreClient",
|
||||
"podHomepage": "https://github.com/openapitools/openapi-generator",
|
||||
"podAuthors": "",
|
||||
"projectName": "PetstoreClient",
|
||||
"unwrapRequired": true
|
||||
}
|
32
bin/swift4-petstore-unwrapRequired.sh
Executable file
32
bin/swift4-petstore-unwrapRequired.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#!/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 -t modules/openapi-generator/src/main/resources/swift4 -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g swift4 -c ./bin/swift4-petstore-unwrapRequired.json -o samples/client/petstore/swift4/unwrapRequired $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
@ -5,6 +5,6 @@ If Not Exist %executable% (
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g php-slim -o samples\server\petstore\php-slim
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -g php-slim -o samples\server\petstore\php-slim
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
@ -5,6 +5,6 @@ If Not Exist %executable% (
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||
set ags=generate --artifact-id "scala-akka-petstore-client" -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g scala-akka -o samples\client\petstore\akka-scala
|
||||
set ags=generate --artifact-id "scala-akka-petstore-client" -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g scala-akka -o samples\client\petstore\scala-akka
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
@ -5,6 +5,6 @@ If Not Exist %executable% (
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g scala-httpclient -o samples\client\petstore\scala
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g scala-httpclient -o samples\client\petstore\scala-httpclient
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
@ -16,6 +16,8 @@ There are several reasons:
|
||||
1. According to SmartBear, [Swagger Codegen 2.x and 3.x should be supported in parallel for a while](https://github.com/swagger-api/swagger-codegen/issues/7754#issuecomment-375039048) without the possibility to work with git branches to merge the fixes from one branch to the next. Having to implement everything twice is not a good idea and the best use of the Swagger Codegen community resources.
|
||||
1. Having a community-driven version can bring the project to the next level.
|
||||
|
||||
UPDATE: After the public launch of OpenAPI Generator, some of the core team members were contacted by Ron (SmartBear) and we explained to him the reasons of the fork as explained above. We also asked him to contact team@openapitools.org if he wants to discuss further but so far we don't see any email from him to team@openapitools.org.
|
||||
|
||||
#### Has anything been done in attempt to address the issues before deciding to fork Swagger Codegen and maintain a community-driven version?
|
||||
|
||||
There were several conversations with SmartBear (Ron, Hugo) via emails, gitter, Skype call and GitHub issues.
|
||||
|
@ -13,6 +13,9 @@
|
||||
<name>openapi-generator-gradle-plugin (maven wrapper)</name>
|
||||
<description>This is a maven wrapper to call gradle during installation phase</description>
|
||||
|
||||
<properties>
|
||||
<skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@ -23,19 +26,28 @@
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- NOTE: Consider this temporary, as a way to cleanly hook into our pipeline.
|
||||
We've discussed moving the entire project to gradle https://github.com/OpenAPITools/openapi-generator/issues/200, which would avoid this fitting. -->
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<!-- 1) disable maven install. This wrapper is not needed. (gradle will install a jar and a pom into the local maven repo) -->
|
||||
<plugin>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- 3) disable maven deploy. This wrapper is not needed. -->
|
||||
<plugin>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
|
||||
<!-- NOTE: Consider this temporary, as a way to cleanly hook into our pipeline.
|
||||
We've discussed moving the entire project to gradle https://github.com/OpenAPITools/openapi-generator/issues/200, which would avoid this fitting. -->
|
||||
<!-- 1) disable maven install. This wrapper is not needed. (gradle will install a jar and a pom into the local maven repo) -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<version>2.5.2</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugins>
|
||||
<!-- 2) run gradle -->
|
||||
<plugin>
|
||||
<groupId>org.fortasoft</groupId>
|
||||
@ -65,15 +77,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- 3) disable maven deploy. This wrapper is not needed. -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>2.8.2</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
@ -1 +1 @@
|
||||
3.0.0-SNAPSHOT
|
||||
3.0.1-SNAPSHOT
|
@ -4245,7 +4245,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
codegenProperty = codegenProperty.items;
|
||||
}
|
||||
|
||||
} else if (ModelUtils.isObjectSchema(schema)) {
|
||||
} else if (ModelUtils.isObjectSchema(schema) || ModelUtils.isComposedSchema(schema)) {
|
||||
CodegenModel codegenModel = null;
|
||||
if (StringUtils.isNotBlank(name)) {
|
||||
schema.setName(name);
|
||||
|
@ -105,7 +105,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
typeMapping.put("file", "*os.File");
|
||||
typeMapping.put("binary", "*os.File");
|
||||
typeMapping.put("ByteArray", "string");
|
||||
typeMapping.put("object", "interface{}");
|
||||
typeMapping.put("object", "map[string]interface{}");
|
||||
|
||||
importMapping = new HashMap<String, String>();
|
||||
|
||||
|
@ -48,7 +48,9 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
importMapping.clear();
|
||||
|
||||
supportsInheritance = true;
|
||||
setReservedWordsLowerCase(Arrays.asList(
|
||||
|
||||
// NOTE: TypeScript uses camel cased reserved words, while models are title cased. We don't want lowercase comparisons.
|
||||
reservedWords.addAll(Arrays.asList(
|
||||
// local variable names used in API methods (endpoints)
|
||||
"varLocalPath", "queryParameters", "headerParams", "formParams", "useFormData", "varLocalDeferred",
|
||||
"requestOptions",
|
||||
@ -344,6 +346,12 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isReservedWord(String word) {
|
||||
// NOTE: This differs from super's implementation in that TypeScript does _not_ want case insensitive matching.
|
||||
return reservedWords.contains(word);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchemaType(Schema p) {
|
||||
|
@ -219,14 +219,14 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
|
||||
//TODO: This changes the info about the real type but it is needed to parse the header params
|
||||
if (param.isHeaderParam) {
|
||||
param.dataType = "Optional<Net::Http::Header::Raw>";
|
||||
param.baseType = "Optional<Net::Http::Header::Raw>";
|
||||
param.dataType = "Pistache::Optional<Pistache::Http::Header::Raw>";
|
||||
param.baseType = "Pistache::Optional<Pistache::Http::Header::Raw>";
|
||||
} else if (param.isQueryParam) {
|
||||
if (param.isPrimitiveType) {
|
||||
param.dataType = "Optional<" + param.dataType + ">";
|
||||
param.dataType = "Pistache::Optional<" + param.dataType + ">";
|
||||
} else {
|
||||
param.dataType = "Optional<" + param.baseType + ">";
|
||||
param.baseType = "Optional<" + param.baseType + ">";
|
||||
param.dataType = "Pistache::Optional<" + param.baseType + ">";
|
||||
param.baseType = "Pistache::Optional<" + param.baseType + ">";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -299,7 +299,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
return toModelName(openAPIType);
|
||||
}
|
||||
|
||||
return "std::shared_ptr<" + openAPIType + ">";
|
||||
return openAPIType;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -326,30 +326,14 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
String inner = getSchemaType(ap.getItems());
|
||||
if (!languageSpecificPrimitives.contains(inner)) {
|
||||
inner = "std::shared_ptr<" + inner + ">";
|
||||
}
|
||||
return "std::vector<" + inner + ">()";
|
||||
} else if (!StringUtils.isEmpty(p.get$ref())) { // model
|
||||
return "new " + toModelName(ModelUtils.getSimpleRef(p.get$ref())) + "()";
|
||||
return toModelName(ModelUtils.getSimpleRef(p.get$ref())) + "()";
|
||||
} else if (ModelUtils.isStringSchema(p)) {
|
||||
return "\"\"";
|
||||
}
|
||||
|
||||
return "nullptr";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessParameter(CodegenParameter parameter) {
|
||||
super.postProcessParameter(parameter);
|
||||
|
||||
boolean isPrimitiveType = parameter.isPrimitiveType == Boolean.TRUE;
|
||||
boolean isListContainer = parameter.isListContainer == Boolean.TRUE;
|
||||
boolean isString = parameter.isString == Boolean.TRUE;
|
||||
|
||||
if (!isPrimitiveType && !isListContainer && !isString && !parameter.dataType.startsWith("std::shared_ptr")) {
|
||||
parameter.dataType = "std::shared_ptr<" + parameter.dataType + ">";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -248,7 +248,7 @@ public class CppQt5ClientCodegen extends AbstractCppCodegen implements CodegenCo
|
||||
if (!folder.isEmpty())
|
||||
folder += File.separator;
|
||||
|
||||
return "#include \"" + folder + name + ".h\"";
|
||||
return "#include \"" + folder + toModelName(name) + ".h\"";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -285,7 +285,7 @@ public class CppQt5ClientCodegen extends AbstractCppCodegen implements CodegenCo
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
return modelNamePrefix + initialCaps(name);
|
||||
return initialCaps(toModelName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -381,7 +381,7 @@ public class CppQt5ClientCodegen extends AbstractCppCodegen implements CodegenCo
|
||||
@Override
|
||||
public String toModelName(String type) {
|
||||
if (type == null) {
|
||||
LOGGER.warn("Model name can't be null. Defaul to 'UnknownModel'.");
|
||||
LOGGER.warn("Model name can't be null. Default to 'UnknownModel'.");
|
||||
type = "UnknownModel";
|
||||
}
|
||||
|
||||
@ -392,30 +392,31 @@ public class CppQt5ClientCodegen extends AbstractCppCodegen implements CodegenCo
|
||||
languageSpecificPrimitives.contains(type)) {
|
||||
return type;
|
||||
} else {
|
||||
return modelNamePrefix + Character.toUpperCase(type.charAt(0)) + type.substring(1);
|
||||
String typeName = sanitizeName(type);
|
||||
return modelNamePrefix + Character.toUpperCase(typeName.charAt(0)) + typeName.substring(1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// sanitize name
|
||||
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
String varName = sanitizeName(name);
|
||||
|
||||
// if it's all uppper case, convert to lower case
|
||||
if (name.matches("^[A-Z_]*$")) {
|
||||
name = name.toLowerCase();
|
||||
if (varName.matches("^[A-Z_]*$")) {
|
||||
varName = varName.toLowerCase();
|
||||
}
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// petId => pet_id
|
||||
name = underscore(name);
|
||||
varName = underscore(varName);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
name = escapeReservedWord(name);
|
||||
if (isReservedWord(varName) || varName.matches("^\\d.*")) {
|
||||
varName = escapeReservedWord(varName);
|
||||
}
|
||||
|
||||
return name;
|
||||
return varName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,18 +19,13 @@ package org.openapitools.codegen.languages;
|
||||
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.utils.*;
|
||||
import org.openapitools.codegen.mustache.*;
|
||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||
import io.swagger.v3.oas.models.*;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.models.parameters.*;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
|
||||
public class JMeterCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public class JMeterClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// source folder where to write the files
|
||||
protected String sourceFolder = "";
|
||||
@ -69,11 +64,11 @@ public class JMeterCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
return "Generates a JMeter .jmx file.";
|
||||
}
|
||||
|
||||
public JMeterCodegen() {
|
||||
public JMeterClientCodegen() {
|
||||
super();
|
||||
|
||||
// set the output folder here
|
||||
outputFolder = "generated-code/JMeterCodegen";
|
||||
outputFolder = "generated-code/JMeterClientCodegen";
|
||||
|
||||
/*
|
||||
* Api classes. You can write classes for each Api file with the apiTemplateFiles map.
|
||||
@ -90,7 +85,7 @@ public class JMeterCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
* Template Location. This is the location which templates will be read from. The generator
|
||||
* will use the resource stream to attempt to read the templates.
|
||||
*/
|
||||
embeddedTemplateDir = templateDir = "JMeter";
|
||||
embeddedTemplateDir = templateDir = "jmeter-client";
|
||||
|
||||
/*
|
||||
* Api Package. Optional, if needed, this can be used in templates
|
@ -0,0 +1,281 @@
|
||||
/*
|
||||
* 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.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class JavascriptFlowtypedClientCodegen extends AbstractTypeScriptClientCodegen {
|
||||
private static final SimpleDateFormat SNAPSHOT_SUFFIX_FORMAT = new SimpleDateFormat("yyyyMMddHHmm");
|
||||
|
||||
public static final String NPM_NAME = "npmName";
|
||||
public static final String NPM_VERSION = "npmVersion";
|
||||
public static final String NPM_REPOSITORY = "npmRepository";
|
||||
public static final String SNAPSHOT = "snapshot";
|
||||
|
||||
protected String npmName = null;
|
||||
protected String npmVersion = "1.0.0";
|
||||
protected String npmRepository = null;
|
||||
|
||||
public JavascriptFlowtypedClientCodegen() {
|
||||
super();
|
||||
|
||||
// clear import mapping (from default generator) as TS does not use it
|
||||
// at the moment
|
||||
importMapping.clear();
|
||||
|
||||
setReservedWordsLowerCase(Arrays.asList(
|
||||
// local variable names used in API methods (endpoints)
|
||||
"varLocalPath", "queryParameters", "headerParams", "formParams", "useFormData", "varLocalDeferred",
|
||||
"requestOptions",
|
||||
// Typescript reserved words
|
||||
"abstract", "arguments", "boolean", "break", "byte",
|
||||
"case", "catch", "char", "class", "const",
|
||||
"continue", "debugger", "default", "delete", "do",
|
||||
"double", "else", "enum", "eval", "export",
|
||||
"extends", "false", "final", "finally", "float",
|
||||
"for", "function", "goto", "if", "implements",
|
||||
"import", "in", "instanceof", "int", "interface",
|
||||
"let", "long", "native", "new", "null",
|
||||
"package", "private", "protected", "public", "return",
|
||||
"short", "static", "super", "switch", "synchronized",
|
||||
"this", "throw", "throws", "transient", "true",
|
||||
"try", "typeof", "var", "void", "volatile",
|
||||
"while", "with", "yield",
|
||||
"Array", "Date", "eval", "function", "hasOwnProperty",
|
||||
"Infinity", "isFinite", "isNaN", "isPrototypeOf",
|
||||
"Math", "NaN", "Number", "Object",
|
||||
"prototype", "String", "toString", "undefined", "valueOf"));
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList("string", "boolean", "number", "Array", "Object", "Date", "File", "Blob")
|
||||
);
|
||||
|
||||
instantiationTypes.put("array", "Array");
|
||||
instantiationTypes.put("list", "Array");
|
||||
instantiationTypes.put("map", "Object");
|
||||
typeMapping.clear();
|
||||
typeMapping.put("array", "Array");
|
||||
typeMapping.put("map", "Object");
|
||||
typeMapping.put("List", "Array");
|
||||
typeMapping.put("boolean", "boolean");
|
||||
typeMapping.put("string", "string");
|
||||
typeMapping.put("int", "number");
|
||||
typeMapping.put("float", "number");
|
||||
typeMapping.put("number", "number");
|
||||
typeMapping.put("DateTime", "Date");
|
||||
typeMapping.put("date", "Date");
|
||||
typeMapping.put("long", "number");
|
||||
typeMapping.put("short", "number");
|
||||
typeMapping.put("char", "string");
|
||||
typeMapping.put("double", "number");
|
||||
typeMapping.put("object", "Object");
|
||||
typeMapping.put("integer", "number");
|
||||
// file, binary not supported in JS client right now, using String as a workaround
|
||||
typeMapping.put("file", "string");
|
||||
typeMapping.put("binary", "string");
|
||||
typeMapping.put("ByteArray", "string");
|
||||
typeMapping.put("UUID", "string");
|
||||
|
||||
defaultIncludes = new HashSet<String>(languageSpecificPrimitives);
|
||||
outputFolder = "generated-code/javascript-flowtyped";
|
||||
embeddedTemplateDir = templateDir = "Javascript-Flowtyped";
|
||||
|
||||
this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package"));
|
||||
this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package"));
|
||||
this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json"));
|
||||
this.cliOptions.add(new CliOption(SNAPSHOT, "When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, Schema schema) {
|
||||
codegenModel.additionalPropertiesType = getTypeDeclaration((Schema) schema.getAdditionalProperties());
|
||||
addImport(codegenModel, codegenModel.additionalPropertiesType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
supportingFiles.add(new SupportingFile("index.mustache", "src", "index.js"));
|
||||
supportingFiles.add(new SupportingFile("api.mustache", "src", "api.js"));
|
||||
supportingFiles.add(new SupportingFile("configuration.mustache", "src", "configuration.js"));
|
||||
supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));
|
||||
|
||||
addNpmPackageGeneration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
Schema inner;
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
inner = ((ArraySchema) p).getItems();
|
||||
return this.getSchemaType(p) + "<" + this.getTypeDeclaration(inner) + ">";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
inner = (Schema) p.getAdditionalProperties();
|
||||
return "{ [key: string]: " + this.getTypeDeclaration(inner) + "; }";
|
||||
} else if (ModelUtils.isFileSchema(p)) {
|
||||
return "any";
|
||||
} else if (ModelUtils.isBinarySchema(p)) {
|
||||
return "any";
|
||||
} else {
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
}
|
||||
|
||||
private void addNpmPackageGeneration() {
|
||||
if (additionalProperties.containsKey(NPM_NAME)) {
|
||||
this.setNpmName(additionalProperties.get(NPM_NAME).toString());
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(NPM_VERSION)) {
|
||||
this.setNpmVersion(additionalProperties.get(NPM_VERSION).toString());
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(SNAPSHOT) && Boolean.valueOf(additionalProperties.get(SNAPSHOT).toString())) {
|
||||
this.setNpmVersion(npmVersion + "-SNAPSHOT." + SNAPSHOT_SUFFIX_FORMAT.format(new Date()));
|
||||
}
|
||||
additionalProperties.put(NPM_VERSION, npmVersion);
|
||||
|
||||
if (additionalProperties.containsKey(NPM_REPOSITORY)) {
|
||||
this.setNpmRepository(additionalProperties.get(NPM_REPOSITORY).toString());
|
||||
}
|
||||
|
||||
//Files for building our lib
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json"));
|
||||
supportingFiles.add(new SupportingFile("flowconfig.mustache", "", ".flowconfig"));
|
||||
supportingFiles.add(new SupportingFile("babelrc", "", ".babelrc"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||
super.preprocessOpenAPI(openAPI);
|
||||
|
||||
if (openAPI.getInfo() != null) {
|
||||
Info info = openAPI.getInfo();
|
||||
if (StringUtils.isBlank(npmName) && info.getTitle() != null) {
|
||||
// when projectName is not specified, generate it from info.title
|
||||
npmName = sanitizeName(dashize(info.getTitle()));
|
||||
}
|
||||
if (StringUtils.isBlank(npmVersion)) {
|
||||
// when projectVersion is not specified, use info.version
|
||||
npmVersion = escapeUnsafeCharacters(escapeQuotationMark(info.getVersion()));
|
||||
}
|
||||
}
|
||||
|
||||
// default values
|
||||
if (StringUtils.isBlank(npmName)) {
|
||||
npmName = "openapi-js-client";
|
||||
}
|
||||
if (StringUtils.isBlank(npmVersion)) {
|
||||
npmVersion = "1.0.0";
|
||||
}
|
||||
|
||||
additionalProperties.put(NPM_NAME, npmName);
|
||||
additionalProperties.put(NPM_VERSION, npmVersion);
|
||||
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||
// process enum in models
|
||||
List<Object> models = (List<Object>) postProcessModelsEnum(objs).get("models");
|
||||
for (Object _mo : models) {
|
||||
Map<String, Object> mo = (Map<String, Object>) _mo;
|
||||
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||
cm.imports = new TreeSet(cm.imports);
|
||||
// name enum with model name, e.g. StatusEnum => Pet.StatusEnum
|
||||
for (CodegenProperty var : cm.vars) {
|
||||
if (Boolean.TRUE.equals(var.isEnum)) {
|
||||
var.datatypeWithEnum = var.datatypeWithEnum.replace(var.enumName, cm.classname + "" + var.enumName);
|
||||
}
|
||||
}
|
||||
if (cm.parent != null) {
|
||||
for (CodegenProperty var : cm.allVars) {
|
||||
if (Boolean.TRUE.equals(var.isEnum)) {
|
||||
var.datatypeWithEnum = var.datatypeWithEnum
|
||||
.replace(var.enumName, cm.classname + "" + var.enumName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeQuotationMark(String input) {
|
||||
// remove ', " to avoid code injection
|
||||
return input.replace("\"", "").replace("'", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
return input.replace("*/", "*_/").replace("/*", "/_*");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "javascript-flowtyped";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a Javascript client library (beta) using Flow types and Fetch API.";
|
||||
}
|
||||
|
||||
public String getNpmName() {
|
||||
return npmName;
|
||||
}
|
||||
|
||||
public void setNpmName(String npmName) {
|
||||
this.npmName = npmName;
|
||||
}
|
||||
|
||||
public String getNpmVersion() {
|
||||
return npmVersion;
|
||||
}
|
||||
|
||||
public void setNpmVersion(String npmVersion) {
|
||||
this.npmVersion = npmVersion;
|
||||
}
|
||||
|
||||
public String getNpmRepository() {
|
||||
return npmRepository;
|
||||
}
|
||||
|
||||
public void setNpmRepository(String npmRepository) {
|
||||
this.npmRepository = npmRepository;
|
||||
}
|
||||
|
||||
}
|
@ -18,22 +18,31 @@
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.Comparator;
|
||||
import java.util.Collections;
|
||||
|
||||
public class PhpSlimServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PhpSlimServerCodegen.class);
|
||||
|
||||
protected String invokerPackage;
|
||||
protected String srcBasePath = "lib";
|
||||
protected String groupId = "org.openapitools";
|
||||
@ -112,6 +121,7 @@ public class PhpSlimServerCodegen extends DefaultCodegen implements CodegenConfi
|
||||
supportingFiles.add(new SupportingFile("composer.json", packagePath.replace('/', File.separatorChar), "composer.json"));
|
||||
supportingFiles.add(new SupportingFile("index.mustache", packagePath.replace('/', File.separatorChar), "index.php"));
|
||||
supportingFiles.add(new SupportingFile(".htaccess", packagePath.replace('/', File.separatorChar), ".htaccess"));
|
||||
supportingFiles.add(new SupportingFile(".gitignore", packagePath.replace('/', File.separatorChar), ".gitignore"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -232,9 +242,36 @@ public class PhpSlimServerCodegen extends DefaultCodegen implements CodegenConfi
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
// remove [
|
||||
name = name.replaceAll("\\]", "");
|
||||
|
||||
// Note: backslash ("\\") is allowed for e.g. "\\DateTime"
|
||||
name = name.replaceAll("[^\\w\\\\]+", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// remove dollar sign
|
||||
name = name.replaceAll("$", "");
|
||||
|
||||
// model name cannot use reserved keyword
|
||||
if (isReservedWord(name)) {
|
||||
escapeReservedWord(name); // e.g. return => _return
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + 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));
|
||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
// add prefix and/or suffic only if name does not start wth \ (e.g. \DateTime)
|
||||
if (!name.matches("^\\\\.*")) {
|
||||
if (!StringUtils.isEmpty(modelNamePrefix)) {
|
||||
name = modelNamePrefix + "_" + name;
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(modelNameSuffix)) {
|
||||
name = name + "_" + modelNameSuffix;
|
||||
}
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
@ -248,6 +285,22 @@ public class PhpSlimServerCodegen extends DefaultCodegen implements CodegenConfi
|
||||
return toModelName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toOperationId(String operationId) {
|
||||
// throw exception if method name is empty
|
||||
if (StringUtils.isEmpty(operationId)) {
|
||||
throw new RuntimeException("Empty method name (operationId) not allowed");
|
||||
}
|
||||
|
||||
// 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));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
return camelize(sanitizeName(operationId), true);
|
||||
}
|
||||
|
||||
public String toPackagePath(String packageName, String basePath) {
|
||||
packageName = packageName.replace(invokerPackage, ""); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
if (basePath != null && basePath.length() > 0) {
|
||||
@ -292,4 +345,44 @@ public class PhpSlimServerCodegen extends DefaultCodegen implements CodegenConfi
|
||||
return input.replace("*/", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
for (CodegenOperation op : operationList) {
|
||||
if (op.hasProduces) {
|
||||
// need to escape */* values because they breakes current mustaches
|
||||
List<Map<String, String>> c = op.produces;
|
||||
for (Map<String, String> mediaType : c) {
|
||||
if ("*/*".equals(mediaType.get("mediaType"))) {
|
||||
mediaType.put("mediaType", "*_/_*");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
||||
Map<String, Object> apiInfo = (Map<String, Object>) objs.get("apiInfo");
|
||||
List<HashMap<String, Object>> apiList = (List<HashMap<String, Object>>) apiInfo.get("apis");
|
||||
for (HashMap<String, Object> api : apiList) {
|
||||
HashMap<String, Object> operations = (HashMap<String, Object>) api.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
|
||||
// Sort operations to avoid static routes shadowing
|
||||
// ref: https://github.com/nikic/FastRoute/blob/master/src/DataGenerator/RegexBasedAbstract.php#L92-L101
|
||||
Collections.sort(operationList, new Comparator<CodegenOperation>() {
|
||||
@Override
|
||||
public int compare(CodegenOperation one, CodegenOperation another) {
|
||||
if (one.getHasPathParams() && !another.getHasPathParams()) return 1;
|
||||
if (!one.getHasPathParams() && another.getHasPathParams()) return -1;
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class ScalaAkkaClientCodegen extends AbstractScalaCodegen implements Code
|
||||
outputFolder = "generated-code/scala-akka";
|
||||
modelTemplateFiles.put("model.mustache", ".scala");
|
||||
apiTemplateFiles.put("api.mustache", ".scala");
|
||||
embeddedTemplateDir = templateDir = "akka-scala";
|
||||
embeddedTemplateDir = templateDir = "scala-akka-client";
|
||||
apiPackage = mainPackage + ".api";
|
||||
modelPackage = mainPackage + ".model";
|
||||
invokerPackage = mainPackage + ".core";
|
||||
|
@ -43,7 +43,7 @@ public class ScalaHttpClientCodegen extends AbstractScalaCodegen implements Code
|
||||
outputFolder = "generated-code/scala-http-client";
|
||||
modelTemplateFiles.put("model.mustache", ".scala");
|
||||
apiTemplateFiles.put("api.mustache", ".scala");
|
||||
embeddedTemplateDir = templateDir = "scala";
|
||||
embeddedTemplateDir = templateDir = "scala-httpclient";
|
||||
apiPackage = "org.openapitools.client.api";
|
||||
modelPackage = "org.openapitools.client.model";
|
||||
|
||||
|
@ -43,11 +43,14 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
public static final String TAGGED_UNIONS = "taggedUnions";
|
||||
public static final String NG_VERSION = "ngVersion";
|
||||
public static final String PROVIDED_IN_ROOT ="providedInRoot";
|
||||
|
||||
public static final String SERVICE_SUFFIX = "serviceSuffix";
|
||||
public static final String SERVICE_FILE_SUFFIX = "serviceFileSuffix";
|
||||
|
||||
protected String npmName = null;
|
||||
protected String npmVersion = "1.0.0";
|
||||
protected String npmRepository = null;
|
||||
protected String serviceSuffix = "Service";
|
||||
protected String serviceFileSuffix = ".service";
|
||||
|
||||
private boolean taggedUnions = false;
|
||||
|
||||
@ -81,6 +84,8 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
"Use this property to provide Injectables in root (it is only valid in angular version greater or equal to 6.0.0).",
|
||||
SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
|
||||
this.cliOptions.add(new CliOption(NG_VERSION, "The version of Angular. Default is '4.3'"));
|
||||
this.cliOptions.add(new CliOption(SERVICE_SUFFIX, "The suffix of the generated service. Default is 'Service'."));
|
||||
this.cliOptions.add(new CliOption(SERVICE_FILE_SUFFIX, "The suffix of the file of the generated service (service<suffix>.ts). Default is '.service'."));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -159,6 +164,12 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
if (!ngVersion.atLeast("4.3.0")) {
|
||||
supportingFiles.add(new SupportingFile("rxjs-operators.mustache", getIndexDirectory(), "rxjs-operators.ts"));
|
||||
}
|
||||
if (additionalProperties.containsKey(SERVICE_SUFFIX)) {
|
||||
serviceSuffix = additionalProperties.get(SERVICE_SUFFIX).toString();
|
||||
}
|
||||
if (additionalProperties.containsKey(SERVICE_FILE_SUFFIX)) {
|
||||
serviceFileSuffix = additionalProperties.get(SERVICE_FILE_SUFFIX).toString();
|
||||
}
|
||||
}
|
||||
|
||||
private void addNpmPackageGeneration(SemVer ngVersion) {
|
||||
@ -418,7 +429,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
if (name.length() == 0) {
|
||||
return "DefaultService";
|
||||
}
|
||||
return initialCaps(name) + "Service";
|
||||
return initialCaps(name) + serviceSuffix;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -426,7 +437,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
if (name.length() == 0) {
|
||||
return "default.service";
|
||||
}
|
||||
return camelize(name, true) + ".service";
|
||||
return camelize(name, true) + serviceFileSuffix;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -469,7 +480,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
}
|
||||
|
||||
private String getApiFilenameFromClassname(String classname) {
|
||||
String name = classname.substring(0, classname.length() - "Service".length());
|
||||
String name = classname.substring(0, classname.length() - serviceSuffix.length());
|
||||
return toApiFilename(name);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,41 @@
|
||||
## {{npmName}}@{{npmVersion}}
|
||||
|
||||
This generator creates Flow typed JavaScript client that utilizes [Fetch API](https://fetch.spec.whatwg.org/). The generated Node module can be used in the following environments:
|
||||
|
||||
Environment
|
||||
* Node.js
|
||||
* Webpack
|
||||
* Browserify
|
||||
|
||||
Language level
|
||||
* ES6
|
||||
|
||||
Module system
|
||||
* ES6 module system
|
||||
|
||||
### Building
|
||||
|
||||
To build an compile the flow typed sources to javascript use:
|
||||
```
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
### Publishing
|
||||
|
||||
First build the package then run ```npm publish```
|
||||
|
||||
### Consuming
|
||||
|
||||
navigate to the folder of your consuming project and run one of the following commands.
|
||||
|
||||
_published:_
|
||||
|
||||
```
|
||||
npm install {{npmName}}@{{npmVersion}} --save
|
||||
```
|
||||
|
||||
_unPublished (not recommended):_
|
||||
|
||||
```
|
||||
npm install PATH_TO_GENERATED_PACKAGE --save
|
@ -0,0 +1,266 @@
|
||||
// @flow
|
||||
/* eslint-disable no-use-before-define */
|
||||
{{>licenseInfo}}
|
||||
|
||||
import * as url from "url";
|
||||
import * as portableFetch from "portable-fetch";
|
||||
import { Configuration } from "./configuration";
|
||||
|
||||
const BASE_PATH: string = "{{{basePath}}}".replace(/\/+$/, "");
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const COLLECTION_FORMATS = {
|
||||
csv: ",",
|
||||
ssv: " ",
|
||||
tsv: "\t",
|
||||
pipes: "|",
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export type FetchAPI = {
|
||||
(url: string, init?: any): Promise<Response>;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export type FetchArgs = {
|
||||
url: string;
|
||||
options: {};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export type RequestOptions = {
|
||||
headers?: {};
|
||||
query?: {};
|
||||
body?: string | FormData;
|
||||
}
|
||||
|
||||
/**
|
||||
* * @export
|
||||
* @class RequiredError
|
||||
* @extends {Error}
|
||||
*/
|
||||
export class RequiredError extends Error {
|
||||
name:string = "RequiredError"
|
||||
constructor(field: string, msg?: string) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
|
||||
{{#models}}
|
||||
{{#model}}{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>modelGeneric}}{{/isEnum}}{{/model}}
|
||||
{{/models}}
|
||||
|
||||
{{#apiInfo}}{{#apis}}{{#operations}}
|
||||
/**
|
||||
* {{classname}} - fetch parameter creator{{#description}}
|
||||
* {{&description}}{{/description}}
|
||||
* @export
|
||||
*/
|
||||
export const {{classname}}FetchParamCreator = function (configuration?: Configuration) {
|
||||
return {
|
||||
{{#operation}}
|
||||
/**
|
||||
* {{¬es}}
|
||||
{{#summary}}
|
||||
* @summary {{&summary}}
|
||||
{{/summary}}
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options: RequestOptions): FetchArgs {
|
||||
{{#allParams}}
|
||||
{{#required}}
|
||||
// verify required parameter '{{paramName}}' is not null or undefined
|
||||
if ({{paramName}} === null || {{paramName}} === undefined) {
|
||||
throw new RequiredError('{{paramName}}','Required parameter {{paramName}} was null or undefined when calling {{nickname}}.');
|
||||
}
|
||||
{{/required}}
|
||||
{{/allParams}}
|
||||
const localVarPath = `{{{path}}}`{{#pathParams}}
|
||||
.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String({{paramName}}))){{/pathParams}};
|
||||
const localVarUrlObj = url.parse(localVarPath, true);
|
||||
const localVarRequestOptions: RequestOptions = Object.assign({}, { method: '{{httpMethod}}' }, options);
|
||||
const localVarHeaderParameter = {};
|
||||
const localVarQueryParameter = {};
|
||||
{{#hasFormParams}}
|
||||
const localVarFormParams = new FormData();
|
||||
{{/hasFormParams}}
|
||||
|
||||
{{#authMethods}}
|
||||
// authentication {{name}} required
|
||||
{{#isApiKey}}
|
||||
{{#isKeyInHeader}}
|
||||
if (configuration && configuration.apiKey) {
|
||||
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
|
||||
? configuration.apiKey("{{keyParamName}}")
|
||||
: configuration.apiKey;
|
||||
localVarHeaderParameter["{{keyParamName}}"] = localVarApiKeyValue;
|
||||
}
|
||||
{{/isKeyInHeader}}
|
||||
{{#isKeyInQuery}}
|
||||
if (configuration && configuration.apiKey) {
|
||||
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
|
||||
? configuration.apiKey("{{keyParamName}}")
|
||||
: configuration.apiKey;
|
||||
localVarQueryParameter["{{keyParamName}}"] = localVarApiKeyValue;
|
||||
}
|
||||
{{/isKeyInQuery}}
|
||||
{{/isApiKey}}
|
||||
{{#isBasic}}
|
||||
// http basic authentication required
|
||||
if (configuration && (configuration.username || configuration.password)) {
|
||||
localVarHeaderParameter["Authorization"] = "Basic " + btoa(configuration.username + ":" + configuration.password);
|
||||
}
|
||||
{{/isBasic}}
|
||||
{{#isOAuth}}
|
||||
// oauth required
|
||||
if (configuration && configuration.accessToken) {
|
||||
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
|
||||
? configuration.accessToken("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}])
|
||||
: configuration.accessToken;
|
||||
localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue;
|
||||
}
|
||||
{{/isOAuth}}
|
||||
|
||||
{{/authMethods}}
|
||||
{{#queryParams}}
|
||||
{{#isListContainer}}
|
||||
if ({{paramName}}) {
|
||||
{{#isCollectionFormatMulti}}
|
||||
localVarQueryParameter['{{baseName}}'] = {{paramName}};
|
||||
{{/isCollectionFormatMulti}}
|
||||
{{^isCollectionFormatMulti}}
|
||||
localVarQueryParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]);
|
||||
{{/isCollectionFormatMulti}}
|
||||
}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
if ({{paramName}} !== undefined) {
|
||||
{{#isDateTime}}
|
||||
localVarQueryParameter['{{baseName}}'] = (({{paramName}}:any):Date).toISOString();
|
||||
{{/isDateTime}}
|
||||
{{^isDateTime}}
|
||||
{{#isDate}}
|
||||
localVarQueryParameter['{{baseName}}'] = (({{paramName}}:any):Date).toISOString();
|
||||
{{/isDate}}
|
||||
{{^isDate}}
|
||||
localVarQueryParameter['{{baseName}}'] = (({{paramName}}:any):string);
|
||||
{{/isDate}}
|
||||
{{/isDateTime}}
|
||||
}
|
||||
{{/isListContainer}}
|
||||
|
||||
{{/queryParams}}
|
||||
{{#headerParams}}
|
||||
{{#isListContainer}}
|
||||
if ({{paramName}}) {
|
||||
localVarHeaderParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]);
|
||||
}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
if ({{paramName}} !== undefined && {{paramName}} !== null) {
|
||||
localVarHeaderParameter['{{baseName}}'] = (({{paramName}}:any):string);
|
||||
}
|
||||
{{/isListContainer}}
|
||||
|
||||
{{/headerParams}}
|
||||
{{#formParams}}
|
||||
{{#isListContainer}}
|
||||
if ({{paramName}}) {
|
||||
{{#isCollectionFormatMulti}}
|
||||
{{paramName}}.forEach((element) => {
|
||||
localVarFormParams.append('{{baseName}}', element);
|
||||
})
|
||||
{{/isCollectionFormatMulti}}
|
||||
{{^isCollectionFormatMulti}}
|
||||
localVarFormParams.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS["{{collectionFormat}}"]));
|
||||
{{/isCollectionFormatMulti}}
|
||||
}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
if ({{paramName}} !== undefined) {
|
||||
localVarFormParams.set('{{baseName}}', (({{paramName}}:any):string));
|
||||
}
|
||||
{{/isListContainer}}
|
||||
|
||||
{{/formParams}}
|
||||
{{#bodyParam}}
|
||||
{{^consumes}}
|
||||
localVarHeaderParameter['Content-Type'] = 'application/json';
|
||||
{{/consumes}}
|
||||
{{#consumes.0}}
|
||||
localVarHeaderParameter['Content-Type'] = '{{{mediaType}}}';
|
||||
{{/consumes.0}}
|
||||
|
||||
{{/bodyParam}}
|
||||
localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query);
|
||||
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
|
||||
delete localVarUrlObj.search;
|
||||
localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
|
||||
{{#hasFormParams}}
|
||||
localVarRequestOptions.body = localVarFormParams;
|
||||
{{/hasFormParams}}
|
||||
{{#bodyParam}}
|
||||
const needsSerialization = (typeof {{paramName}} !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
|
||||
localVarRequestOptions.body = needsSerialization ? JSON.stringify({{paramName}} || {}) : ((({{paramName}}:any):string) || "");
|
||||
{{/bodyParam}}
|
||||
|
||||
return {
|
||||
url: url.format(localVarUrlObj),
|
||||
options: localVarRequestOptions,
|
||||
};
|
||||
},
|
||||
{{/operation}}
|
||||
}
|
||||
};
|
||||
|
||||
export type {{classname}}Type = { {{#operation}}
|
||||
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: RequestOptions): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}>,
|
||||
{{/operation}}
|
||||
}
|
||||
|
||||
/**
|
||||
* {{classname}} - factory function to inject configuration {{#description}}
|
||||
* {{{description}}}{{/description}}
|
||||
* @export
|
||||
*/
|
||||
export const {{classname}} = function(configuration?: Configuration, fetch: FetchAPI = portableFetch): {{classname}}Type {
|
||||
const basePath: string = (configuration && configuration.basePath) || BASE_PATH;
|
||||
return {
|
||||
{{#operation}}
|
||||
/**
|
||||
* {{¬es}}
|
||||
{{#summary}}
|
||||
* @summary {{&summary}}
|
||||
{{/summary}}
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: RequestOptions = {}): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}> {
|
||||
const localVarFetchArgs = {{classname}}FetchParamCreator(configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options);
|
||||
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
return response{{#returnType}}.json(){{/returnType}};
|
||||
} else {
|
||||
throw response;
|
||||
}
|
||||
});
|
||||
},
|
||||
{{/operation}}
|
||||
}
|
||||
};
|
||||
{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
export type ApiTypes = { {{#apiInfo}}{{#apis}}{{#operations}}
|
||||
{{classname}}: {{classname}}Type,
|
||||
{{/operations}}{{/apis}}{{/apiInfo}} }
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"presets": ["react-app"],
|
||||
"plugins": ["transform-flow-strip-types"]
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
// @flow
|
||||
{{>licenseInfo}}
|
||||
|
||||
export type ConfigurationParameters = {
|
||||
apiKey?: string | (name: string) => string;
|
||||
username?: string;
|
||||
password?: string;
|
||||
accessToken?: string | (name: string, scopes?: string[]) => string;
|
||||
basePath?: string;
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
/**
|
||||
* parameter for apiKey security
|
||||
* @param name security name
|
||||
* @memberof Configuration
|
||||
*/
|
||||
apiKey: string | (name: string) => string;
|
||||
/**
|
||||
* parameter for basic security
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
username: string;
|
||||
/**
|
||||
* parameter for basic security
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
password: string;
|
||||
/**
|
||||
* parameter for oauth2 security
|
||||
* @param name security name
|
||||
* @param scopes oauth2 scope
|
||||
* @memberof Configuration
|
||||
*/
|
||||
accessToken: string | ((name: string, scopes?: string[]) => string);
|
||||
/**
|
||||
* override base path
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
basePath: string;
|
||||
|
||||
constructor(param: ConfigurationParameters = {}) {
|
||||
if (param.apiKey) {
|
||||
this.apiKey = param.apiKey;
|
||||
}
|
||||
if (param.username) {
|
||||
this.username = param.username;
|
||||
}
|
||||
if (param.password) {
|
||||
this.password = param.password;
|
||||
}
|
||||
if (param.accessToken) {
|
||||
this.accessToken = param.accessToken;
|
||||
}
|
||||
if (param.basePath) {
|
||||
this.basePath = param.basePath;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
[ignore]
|
||||
|
||||
[include]
|
||||
|
||||
[libs]
|
||||
|
||||
[lints]
|
||||
|
||||
[options]
|
||||
|
||||
[strict]
|
@ -0,0 +1 @@
|
||||
node_modules
|
@ -0,0 +1,5 @@
|
||||
// @flow
|
||||
{{>licenseInfo}}
|
||||
|
||||
export * from "./api";
|
||||
export * from "./configuration";
|
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* {{{appName}}}
|
||||
* {{{appDescription}}}
|
||||
*
|
||||
* {{#version}}OpenAPI spec version: {{{version}}}{{/version}}
|
||||
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
@ -0,0 +1,6 @@
|
||||
/**
|
||||
* {{{description}}}
|
||||
* @export
|
||||
* @enum {string}
|
||||
*/
|
||||
export type {{classname}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}} | {{/-last}}{{/enumVars}}{{/allowableValues}};
|
@ -0,0 +1,27 @@
|
||||
{{#hasEnums}}
|
||||
{{#vars}}
|
||||
{{#isEnum}}
|
||||
|
||||
export type {{classname}}{{enumName}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}} | {{/-last}}{{/enumVars}}{{/allowableValues}};
|
||||
{{/isEnum}}
|
||||
{{/vars}}
|
||||
{{/hasEnums}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
* @export
|
||||
*/
|
||||
export type {{classname}} = {
|
||||
{{#additionalPropertiesType}}
|
||||
[key: string]: {{{additionalPropertiesType}}}{{#hasVars}} | any{{/hasVars}};
|
||||
|
||||
{{/additionalPropertiesType}}
|
||||
{{#vars}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
* @type {{=<% %>=}}{<%&datatype%>}<%={{ }}=%>
|
||||
* @memberof {{classname}}
|
||||
*/
|
||||
{{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}};
|
||||
{{/vars}}
|
||||
}
|
||||
|
@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "{{npmName}}",
|
||||
"version": "{{npmVersion}}",
|
||||
"description": "swagger client for {{npmName}}",
|
||||
"author": "Swagger Codegen Contributors",
|
||||
"keywords": [
|
||||
"fetch",
|
||||
"flow",
|
||||
"swagger-client",
|
||||
"{{npmName}}"
|
||||
],
|
||||
"license": "Unlicense",
|
||||
"main": "./lib/index.js",
|
||||
"scripts": {
|
||||
"build": "npm run build:clean && npm run build:lib && npm run build:flow",
|
||||
"build:clean": "rimraf lib",
|
||||
"build:lib": "node_modules/.bin/babel -d lib src --ignore '**/__tests__/**'",
|
||||
"build:flow": "flow-copy-source -v -i '**/__tests__/**' src lib"
|
||||
},
|
||||
"dependencies": {
|
||||
"portable-fetch": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.26.0",
|
||||
"babel-core": "^6.26.3",
|
||||
"babel-plugin-transform-flow-strip-types": "^6.22.0",
|
||||
"babel-preset-react-app": "^3.1.1",
|
||||
"flow-copy-source": "^1.3.0",
|
||||
"rimraf": "^2.6.2"
|
||||
}{{#npmRepository}},{{/npmRepository}}
|
||||
{{#npmRepository}}
|
||||
"publishConfig":{
|
||||
"registry":"{{npmRepository}}"
|
||||
}
|
||||
{{/npmRepository}}
|
||||
}
|
@ -45,8 +45,9 @@ org.openapitools.codegen.languages.JavaResteasyServerCodegen
|
||||
org.openapitools.codegen.languages.JavaResteasyEapServerCodegen
|
||||
org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen
|
||||
org.openapitools.codegen.languages.JavascriptClientCodegen
|
||||
org.openapitools.codegen.languages.JavascriptFlowtypedClientCodegen
|
||||
org.openapitools.codegen.languages.JavascriptClosureAngularClientCodegen
|
||||
org.openapitools.codegen.languages.JMeterCodegen
|
||||
org.openapitools.codegen.languages.JMeterClientCodegen
|
||||
org.openapitools.codegen.languages.LuaClientCodegen
|
||||
org.openapitools.codegen.languages.NodeJSServerCodegen
|
||||
org.openapitools.codegen.languages.ObjcClientCodegen
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include <pistache/router.h>
|
||||
#include <pistache/http_headers.h>
|
||||
|
||||
#include <pistache/optional.h>
|
||||
|
||||
{{#imports}}{{{import}}}
|
||||
{{/imports}}
|
||||
|
||||
@ -41,7 +43,7 @@ private:
|
||||
{{/operation}}
|
||||
void {{classnameSnakeLowerCase}}_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
|
||||
|
||||
std::shared_ptr<Pistache::Http::Endpoint> httpEndpoint;
|
||||
Pistache::Http::Endpoint httpEndpoint;
|
||||
Pistache::Rest::Router router;
|
||||
|
||||
{{#operation}}
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
#include <{{classname}}.h>
|
||||
|
||||
#include <pistache/optional.h>
|
||||
|
||||
{{#imports}}{{{import}}}
|
||||
{{/imports}}
|
||||
|
||||
|
@ -10,24 +10,24 @@ namespace {{this}} {
|
||||
using namespace {{modelNamespace}};
|
||||
|
||||
{{classname}}::{{classname}}(Pistache::Address addr)
|
||||
: httpEndpoint(std::make_shared<Pistache::Http::Endpoint>(addr))
|
||||
: httpEndpoint(addr)
|
||||
{ };
|
||||
|
||||
void {{classname}}::init(size_t thr = 2) {
|
||||
auto opts = Pistache::Http::Endpoint::options()
|
||||
.threads(thr)
|
||||
.flags(Pistache::Tcp::Options::InstallSignalHandler);
|
||||
httpEndpoint->init(opts);
|
||||
httpEndpoint.init(opts);
|
||||
setupRoutes();
|
||||
}
|
||||
|
||||
void {{classname}}::start() {
|
||||
httpEndpoint->setHandler(router.handler());
|
||||
httpEndpoint->serve();
|
||||
httpEndpoint.setHandler(router.handler());
|
||||
httpEndpoint.serve();
|
||||
}
|
||||
|
||||
void {{classname}}::shutdown() {
|
||||
httpEndpoint->shutdown();
|
||||
httpEndpoint.shutdown();
|
||||
}
|
||||
|
||||
void {{classname}}::setupRoutes() {
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
/// </summary>
|
||||
{{^isNotContainer}}{{{dataType}}}& {{getter}}();
|
||||
{{/isNotContainer}}{{#isNotContainer}}{{{dataType}}} {{getter}}() const;
|
||||
void {{setter}}({{{dataType}}} value);
|
||||
void {{setter}}({{{dataType}}} const{{^isPrimitiveType}}&{{/isPrimitiveType}} value);
|
||||
{{/isNotContainer}}{{^required}}bool {{nameInCamelCase}}IsSet() const;
|
||||
void unset{{name}}();
|
||||
{{/required}}
|
||||
|
@ -84,7 +84,7 @@ void {{classname}}::fromJson(nlohmann::json& val)
|
||||
else
|
||||
{
|
||||
{{{items.datatype}}} newItem({{{items.defaultValue}}});
|
||||
newItem->fromJson(item);
|
||||
newItem.fromJson(item);
|
||||
m_{{name}}.push_back( newItem );
|
||||
}
|
||||
{{/items.isDateTime}}{{/items.isString}}{{/isPrimitiveType}}
|
||||
@ -100,7 +100,7 @@ void {{classname}}::fromJson(nlohmann::json& val)
|
||||
{{/isDateTime}}{{^isDateTime}}if(!val["{{baseName}}"].is_null())
|
||||
{
|
||||
{{{dataType}}} newItem({{{defaultValue}}});
|
||||
newItem->fromJson(val["{{baseName}}"]);
|
||||
newItem.fromJson(val["{{baseName}}"]);
|
||||
{{setter}}( newItem );
|
||||
}
|
||||
{{/isDateTime}}{{/isString}}
|
||||
@ -119,7 +119,7 @@ void {{classname}}::fromJson(nlohmann::json& val)
|
||||
{
|
||||
return m_{{name}};
|
||||
}
|
||||
void {{classname}}::{{setter}}({{{dataType}}} value)
|
||||
void {{classname}}::{{setter}}({{{dataType}}} const{{^isPrimitiveType}}&{{/isPrimitiveType}} value)
|
||||
{
|
||||
m_{{name}} = value;
|
||||
{{^required}}m_{{name}}IsSet = true;{{/required}}
|
||||
|
@ -28,13 +28,13 @@ public:
|
||||
virtual nlohmann::json toJson() const = 0;
|
||||
virtual void fromJson(nlohmann::json& json) = 0;
|
||||
|
||||
static std::string toJson( const std::string& value );
|
||||
static std::string toJson( const std::time_t& value );
|
||||
static int32_t toJson( int32_t value );
|
||||
static int64_t toJson( int64_t value );
|
||||
static double toJson( double value );
|
||||
static bool toJson( bool value );
|
||||
static nlohmann::json toJson( std::shared_ptr<ModelBase> content );
|
||||
static std::string toJson( std::string const& value );
|
||||
static std::string toJson( std::time_t const& value );
|
||||
static int32_t toJson( int32_t const value );
|
||||
static int64_t toJson( int64_t const value );
|
||||
static double toJson( double const value );
|
||||
static bool toJson( bool const value );
|
||||
static nlohmann::json toJson(ModelBase const& content );
|
||||
|
||||
};
|
||||
|
||||
|
@ -12,41 +12,41 @@ ModelBase::~ModelBase()
|
||||
{
|
||||
}
|
||||
|
||||
std::string ModelBase::toJson( const std::string& value )
|
||||
std::string ModelBase::toJson( std::string const& value )
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
std::string ModelBase::toJson( const std::time_t& value )
|
||||
std::string ModelBase::toJson( std::time_t const& value )
|
||||
{
|
||||
char buf[sizeof "2011-10-08T07:07:09Z"];
|
||||
strftime(buf, sizeof buf, "%FT%TZ", gmtime(&value));
|
||||
return buf;
|
||||
}
|
||||
|
||||
int32_t ModelBase::toJson( int32_t value )
|
||||
int32_t ModelBase::toJson( int32_t const value )
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
int64_t ModelBase::toJson( int64_t value )
|
||||
int64_t ModelBase::toJson( int64_t const value )
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
double ModelBase::toJson( double value )
|
||||
double ModelBase::toJson( double const value )
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
bool ModelBase::toJson( bool value )
|
||||
bool ModelBase::toJson( bool const value )
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
nlohmann::json ModelBase::toJson( std::shared_ptr<ModelBase> content )
|
||||
nlohmann::json ModelBase::toJson(ModelBase content )
|
||||
{
|
||||
return content.get() ? content->toJson() : nlohmann::json();
|
||||
return content.toJson();
|
||||
}
|
||||
|
||||
{{#modelNamespaceDeclarations}}
|
||||
|
@ -35,9 +35,9 @@ type {{classname}} struct {
|
||||
{{#description}}
|
||||
// {{{description}}}
|
||||
{{/description}}
|
||||
{{name}} {{^isEnum}}{{^isPrimitiveType}}{{^isContainer}}{{^isDateTime}}*{{/isDateTime}}{{/isContainer}}{{/isPrimitiveType}}{{/isEnum}}{{{dataType}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"{{#withXml}} xml:"{{baseName}}"{{/withXml}}`
|
||||
{{name}} {{{dataType}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"{{#withXml}} xml:"{{baseName}}"{{/withXml}}`
|
||||
{{/vars}}
|
||||
}
|
||||
{{/isEnum}}
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
{{/models}}
|
||||
|
@ -3,7 +3,7 @@
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{^isContainer}}{{^isDateTime}}*{{/isDateTime}}{{/isContainer}}{{{dataType}}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
|
||||
{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{{dataType}}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
|
||||
{{/vars}}
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -47,4 +47,4 @@ uuid = {version = "0.5", optional = true, features = ["serde", "v4"]}
|
||||
|
||||
[dev-dependencies]
|
||||
clap = "2.25"
|
||||
error-chain = "0.11"
|
||||
error-chain = "0.12"
|
||||
|
6
modules/openapi-generator/src/main/resources/slim/.gitignore
vendored
Normal file
6
modules/openapi-generator/src/main/resources/slim/.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
composer.phar
|
||||
/vendor/
|
||||
|
||||
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
|
||||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
|
||||
composer.lock
|
@ -13,17 +13,44 @@ $app = new Slim\App();
|
||||
* {{httpMethod}} {{nickname}}
|
||||
* Summary: {{summary}}
|
||||
* Notes: {{notes}}
|
||||
{{#hasProduces}} * Output-Formats: [{{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}]{{/hasProduces}}
|
||||
{{#hasProduces}}
|
||||
* Output-Formats: [{{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}]
|
||||
{{/hasProduces}}
|
||||
*/
|
||||
$app->{{httpMethod}}('{{{basePathWithoutHost}}}{{{path}}}', function($request, $response, $args) {
|
||||
{{#hasHeaderParams}}$headers = $request->getHeaders();{{/hasHeaderParams}}
|
||||
{{#hasQueryParams}}$queryParams = $request->getQueryParams();
|
||||
{{#queryParams}}${{paramName}} = $queryParams['{{paramName}}'];{{newline}} {{/queryParams}}{{/hasQueryParams}}
|
||||
{{#hasFormParams}}{{#formParams}}${{paramName}} = $args['{{paramName}}'];{{newline}} {{/formParams}}{{/hasFormParams}}
|
||||
{{#hasBodyParam}}$body = $request->getParsedBody();{{/hasBodyParam}}
|
||||
$response->write('How about implementing {{nickname}} as a {{httpMethod}} method ?');
|
||||
return $response;
|
||||
});
|
||||
{{#hasHeaderParams}}
|
||||
$headers = $request->getHeaders();
|
||||
{{#headerParams}}
|
||||
${{paramName}} = $request->hasHeader('{{baseName}}') ? $headers['{{baseName}}'] : null;
|
||||
{{/headerParams}}
|
||||
{{/hasHeaderParams}}
|
||||
{{#hasPathParams}}
|
||||
{{#pathParams}}
|
||||
${{paramName}} = $args['{{baseName}}'];
|
||||
{{/pathParams}}
|
||||
{{/hasPathParams}}
|
||||
{{#hasQueryParams}}
|
||||
$queryParams = $request->getQueryParams();
|
||||
{{#queryParams}}
|
||||
${{paramName}} = $request->getQueryParam('{{baseName}}');
|
||||
{{/queryParams}}
|
||||
{{/hasQueryParams}}
|
||||
{{#hasFormParams}}
|
||||
{{#formParams}}
|
||||
{{^isFile}}
|
||||
${{paramName}} = $request->getParsedBodyParam('{{baseName}}');
|
||||
{{/isFile}}
|
||||
{{#isFile}}
|
||||
${{paramName}} = (key_exists('{{baseName}}', $request->getUploadedFiles())) ? $request->getUploadedFiles()['{{baseName}}'] : null;
|
||||
{{/isFile}}
|
||||
{{/formParams}}
|
||||
{{/hasFormParams}}
|
||||
{{#hasBodyParam}}
|
||||
$body = $request->getParsedBody();
|
||||
{{/hasBodyParam}}
|
||||
$response->write('How about implementing {{nickname}} as a {{httpMethod}} method ?');
|
||||
return $response;
|
||||
});
|
||||
|
||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
|
||||
|
@ -9,11 +9,11 @@ public struct {{classname}}: Codable {
|
||||
{{#allVars}}
|
||||
{{#isEnum}}
|
||||
{{#description}}/** {{description}} */
|
||||
{{/description}}public var {{name}}: {{{datatypeWithEnum}}}{{^required}}?{{/required}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}
|
||||
{{/description}}public var {{name}}: {{{datatypeWithEnum}}}{{#unwrapRequired}}?{{/unwrapRequired}}{{^unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}
|
||||
{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
{{#description}}/** {{description}} */
|
||||
{{/description}}public var {{name}}: {{{dataType}}}{{^required}}?{{/required}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}{{#objcCompatible}}{{#vendorExtensions.x-swift-optional-scalar}}
|
||||
{{/description}}public var {{name}}: {{{datatype}}}{{#unwrapRequired}}?{{/unwrapRequired}}{{^unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}{{#objcCompatible}}{{#vendorExtensions.x-swift-optional-scalar}}
|
||||
public var {{name}}Num: NSNumber? {
|
||||
get {
|
||||
return {{name}}.map({ return NSNumber(value: $0) })
|
||||
@ -23,7 +23,7 @@ public struct {{classname}}: Codable {
|
||||
{{/allVars}}
|
||||
|
||||
{{#hasVars}}
|
||||
public init({{#allVars}}{{name}}: {{{datatypeWithEnum}}}{{^required}}?{{/required}}{{#hasMore}}, {{/hasMore}}{{/allVars}}) {
|
||||
public init({{#allVars}}{{name}}: {{{datatypeWithEnum}}}{{#unwrapRequired}}?{{/unwrapRequired}}{{^unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}{{#hasMore}}, {{/hasMore}}{{/allVars}}) {
|
||||
{{#allVars}}
|
||||
self.{{name}} = {{name}}
|
||||
{{/allVars}}
|
||||
@ -52,7 +52,7 @@ public struct {{classname}}: Codable {
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
{{#allVars}}
|
||||
try container.encode{{^required}}IfPresent{{/required}}({{{name}}}, forKey: "{{{baseName}}}")
|
||||
try container.encode{{#unwrapRequired}}IfPresent{{/unwrapRequired}}{{^unwrapRequired}}{{^required}}IfPresent{{/required}}{{/unwrapRequired}}({{{name}}}, forKey: "{{{baseName}}}")
|
||||
{{/allVars}}
|
||||
try container.encodeMap(additionalProperties)
|
||||
}
|
||||
@ -63,7 +63,7 @@ public struct {{classname}}: Codable {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
{{#allVars}}
|
||||
{{name}} = try container.decode{{^required}}IfPresent{{/required}}({{{datatypeWithEnum}}}.self, forKey: "{{{baseName}}}")
|
||||
{{name}} = try container.decode{{#unwrapRequired}}IfPresent{{/unwrapRequired}}{{^unwrapRequired}}{{^required}}IfPresent{{/required}}{{/unwrapRequired}}({{{datatypeWithEnum}}}.self, forKey: "{{{baseName}}}")
|
||||
{{/allVars}}
|
||||
var nonAdditionalPropertyKeys = Set<String>()
|
||||
{{#allVars}}
|
||||
|
@ -19,6 +19,9 @@ package org.openapitools.codegen.java;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import io.swagger.parser.OpenAPIParser;
|
||||
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.ComposedSchema;
|
||||
import io.swagger.v3.oas.models.media.Content;
|
||||
@ -28,6 +31,7 @@ import io.swagger.v3.oas.models.media.ObjectSchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.media.StringSchema;
|
||||
import io.swagger.v3.oas.models.parameters.RequestBody;
|
||||
import io.swagger.v3.parser.core.models.ParseOptions;
|
||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
@ -37,6 +41,7 @@ import org.openapitools.codegen.CodegenModelType;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenParameter;
|
||||
import org.openapitools.codegen.languages.JavaClientCodegen;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -305,6 +310,17 @@ public class JavaClientCodegenTest {
|
||||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "xyz.yyyyy.zzzzzzz.mmmmm");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSchemaTypeWithComposedSchemaWithAllOf() {
|
||||
final OpenAPI openAPI = new OpenAPIParser().readLocation("src/test/resources/2_0/composed-allof.yaml", null, new ParseOptions()).getOpenAPI();
|
||||
final JavaClientCodegen codegen = new JavaClientCodegen();
|
||||
|
||||
Operation operation = openAPI.getPaths().get("/ping").getPost();
|
||||
CodegenOperation co = codegen.fromOperation("/ping", "POST", operation, ModelUtils.getSchemas(openAPI), openAPI);
|
||||
Assert.assertEquals(co.allParams.size(), 1);
|
||||
Assert.assertEquals(co.allParams.get(0).baseType, "MessageEventCoreWithTimeListEntries");
|
||||
}
|
||||
|
||||
private CodegenParameter createPathParam(String name) {
|
||||
CodegenParameter codegenParameter = createStringParam(name);
|
||||
codegenParameter.isPathParam = true;
|
||||
|
@ -35,6 +35,8 @@ public class TypeScriptAngularClientOptionsProvider implements OptionsProvider {
|
||||
public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false";
|
||||
public static final String NG_VERSION = "2";
|
||||
public static final String PREPEND_FORM_OR_BODY_PARAMETERS_VALUE = "true";
|
||||
public static String SERVICE_SUFFIX = "Service";
|
||||
public static String SERVICE_FILE_SUFFIX = ".service";
|
||||
|
||||
@Override
|
||||
public String getLanguage() {
|
||||
@ -56,6 +58,8 @@ public class TypeScriptAngularClientOptionsProvider implements OptionsProvider {
|
||||
.put(TypeScriptAngularClientCodegen.TAGGED_UNIONS, Boolean.FALSE.toString())
|
||||
.put(TypeScriptAngularClientCodegen.NPM_REPOSITORY, NPM_REPOSITORY)
|
||||
.put(TypeScriptAngularClientCodegen.NG_VERSION, NG_VERSION)
|
||||
.put(TypeScriptAngularClientCodegen.SERVICE_SUFFIX, SERVICE_SUFFIX)
|
||||
.put(TypeScriptAngularClientCodegen.SERVICE_FILE_SUFFIX, SERVICE_FILE_SUFFIX)
|
||||
.put(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE)
|
||||
.put(CodegenConstants.PREPEND_FORM_OR_BODY_PARAMETERS, PREPEND_FORM_OR_BODY_PARAMETERS_VALUE)
|
||||
.build();
|
||||
|
@ -0,0 +1,53 @@
|
||||
swagger: "2.0"
|
||||
info:
|
||||
version: "2"
|
||||
title: "Test API"
|
||||
basePath: "/xx2"
|
||||
consumes:
|
||||
- "application/json"
|
||||
produces:
|
||||
- "application/json"
|
||||
paths:
|
||||
/ping:
|
||||
post:
|
||||
tags:
|
||||
- Messaging
|
||||
summary: Add a message event to the given message calendar
|
||||
operationId: addMessageEventToMessageCalendar
|
||||
parameters:
|
||||
- in: body
|
||||
name: new-message-event
|
||||
required: true
|
||||
schema:
|
||||
$ref: "#/definitions/MessageEventCoreWithTimeListEntries"
|
||||
responses:
|
||||
200:
|
||||
description: OK
|
||||
definitions:
|
||||
MessageEventCoreWithTimeListEntries:
|
||||
type: object
|
||||
description: "Base of a message event with Time List entries"
|
||||
allOf:
|
||||
- $ref: "#/definitions/MessageEventCore"
|
||||
- type: object
|
||||
required:
|
||||
- timeListEntries
|
||||
properties:
|
||||
timeListEntries:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/definitions/TimeListEntry"
|
||||
MessageEventCore:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
message:
|
||||
type: string
|
||||
TimeListEntry:
|
||||
type: object
|
||||
properties:
|
||||
p1:
|
||||
type: string
|
||||
p2:
|
||||
type: string
|
10
pom.xml
10
pom.xml
@ -608,7 +608,7 @@
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>scala-client</id>
|
||||
<id>scala-httpclient</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
@ -616,7 +616,7 @@
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>samples/client/petstore/scala</module>
|
||||
<module>samples/client/petstore/scala-httpclient</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
@ -937,12 +937,11 @@
|
||||
<!--<module>samples/client/petstore/perl</module>-->
|
||||
<module>samples/client/petstore/php/OpenAPIClient-php</module>
|
||||
<module>samples/openapi3/client/petstore/php/OpenAPIClient-php</module>
|
||||
<module>samples/client/petstore/scala</module>
|
||||
<module>samples/client/petstore/akka-scala</module>
|
||||
<module>samples/client/petstore/javascript</module>
|
||||
<module>samples/client/petstore/javascript-es6</module>
|
||||
<module>samples/client/petstore/javascript-promise</module>
|
||||
<module>samples/client/petstore/javascript-promise-es6</module>
|
||||
<module>samples/client/petstore/javascript-flowtyped</module>
|
||||
<module>samples/client/petstore/python</module>
|
||||
<module>samples/client/petstore/python-tornado</module>
|
||||
<module>samples/client/petstore/python-asyncio</module>
|
||||
@ -976,7 +975,8 @@
|
||||
<module>samples/client/petstore/elixir</module>
|
||||
<module>samples/client/petstore/erlang-client</module>
|
||||
<!-- servers -->
|
||||
<module>samples/server/petstore/erlang-server</module>
|
||||
<!-- disable erlang server test due to dependency issues
|
||||
<module>samples/server/petstore/erlang-server</module> -->
|
||||
<module>samples/server/petstore/jaxrs/jersey2</module>
|
||||
<module>samples/server/petstore/jaxrs/jersey2-useTags</module>
|
||||
<module>samples/server/petstore/spring-mvc</module>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user