Skip to content

Commit

Permalink
Merge branch 'master' into rienafairefr-templating
Browse files Browse the repository at this point in the history
* master: (47 commits)
  [Slim] Fix AbstractAuthenticator constructor TypeError (#2641)
  Fix issue 1340 - StaticHtmlGenerator to allow snake_case property names (#2612)
  Test Gradle plugin in Appveyor CI (#2651)
  Add Camptocamp to company list (#2652)
  Use percent encoding for path parameters (#2649)
  Unescape HTML characters in JS docstring (#2636)
  [ONLINE] Minor links fix (#2644)
  better handling of undefined inner property in array (#2635)
  Fix regexp error on php-slim (#2604)
  [TypeScript-Fetch] Generate oneOf schemas as type unions (#2617)
  Add Namsor as the sponsor (#2639)
  fix classname in website (#2638)
  Code review fixes (#2633)
  Move Ruby module/gem to codegen constant (#2621)
  Add sponsor section to the website (#2634)
  [Spring] Spotbugs static class and default encoding (#2609)
  Add @Zomzog (2019/04) to Java, Kotlin tech comm (#2630)
  [maven] remove validateSpec (#2614)
  Clean up the license field in various templates to ensure it's unlicense by default. (#2627)
  Fix NPE when server url is null (#2628)
  ...
  • Loading branch information
jimschubert committed Apr 13, 2019
2 parents f95715f + c88b0a1 commit fb2346c
Show file tree
Hide file tree
Showing 217 changed files with 2,417 additions and 1,715 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ packages/
/generated-files
nbactions.xml

# website
website/build/
website/package-lock.json

# scalatra
samples/server-generator/scalatra/output
samples/server-generator/scalatra/target
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@

</div>

## Sponsors

If you find OpenAPI Generator useful for work, please consider asking your company to support this Open Source project by [becoming a sponsor](https://opencollective.com/openapi_generator). You can also individually sponsor the project by [becoming a backer](https://opencollective.com/openapi_generator).

#### Thank you to our bronze sponsors!

[![NamSor](https://openapi-generator.tech/img/companies/namsor.png)](https://www.namsor.com/?utm_source=openapi_generator&utm_medium=github_webpage&utm_campaign=sponsor)


## Overview
OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an [OpenAPI Spec](https://github.com/OAI/OpenAPI-Specification) (both 2.0 and 3.0 are supported). Currently, the following languages/frameworks are supported:

Expand Down Expand Up @@ -509,6 +518,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- [BIMData.io](https://bimdata.io)
- [Bithost GmbH](https://www.bithost.ch)
- [Boxever](https://www.boxever.com/)
- [Camptocamp](https://www.camptocamp.com/en)
- [codecentric AG](https://www.codecentric.de/)
- [Cupix](https://www.cupix.com/)
- [FormAPI](https://formapi.io/)
Expand Down Expand Up @@ -558,7 +568,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- 2019-03-07 - [OpenAPI Generator で Spring Boot と Angular をタイプセーフに繋ぐ](https://qiita.com/chibato/items/e4a748db12409b40c02f) by [Tomofumi Chiba](https://github.com/chibat)
- 2019-03-25 - [Access any REST service with the SAP S/4HANA Cloud SDK](https://blogs.sap.com/2019/03/25/integrate-sap-s4hana-cloud-sdk-with-open-api/) by [Alexander Duemont](https://people.sap.com/alexander.duemont)
- 2019-03-25 - [OpenAPI generatorを試してみる](https://qiita.com/amuyikam/items/e8a45daae59c68be0fc8) by [@amuyikam](https://twitter.com/amuyikam)

- 2019-03-27 - [OpenAPI3を使ってみよう!Go言語でクライアントとスタブの自動生成まで!](https://techblog.zozo.com/entry/openapi3/go) by [@gold_kou](https://twitter.com/gold_kou)

## [6 - About Us](#table-of-contents)

Expand Down Expand Up @@ -734,8 +744,8 @@ If you want to join the committee, please kindly apply by sending an email to te
| GraphQL | @renepardon (2018/12) |
| Groovy | |
| Haskell | |
| Java | @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) |
| Kotlin | @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert), @dr4ke616 (2018/08) @karismann (2019/03) |
| Java | @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) |
| Kotlin | @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert), @dr4ke616 (2018/08) @karismann (2019/03) @Zomzog (2019/04) |
| Lua | @daurnimator (2017/08) |
| NodeJS/Javascript | @CodeNinjai (2017/07) @frol (2017/07) @cliffano (2017/07) |
| ObjC | |
Expand Down
15 changes: 14 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,23 @@ install:
)
[System.IO.Compression.ZipFile]::ExtractToDirectory("C:\maven-bin.zip", "C:\maven")
}
- cmd: SET PATH=C:\maven\apache-maven-3.2.5\bin;%JAVA_HOME%\bin;%PATH%
# install gradle
- ps: |
Add-Type -AssemblyName System.IO.Compression.FileSystem
if (!(Test-Path -Path "C:\gradle" )) {
(new-object System.Net.WebClient).DownloadFile(
'https://services.gradle.org/distributions/gradle-5.3.1-bin.zip',
'C:\gradle-bin.zip'
)
[System.IO.Compression.ZipFile]::ExtractToDirectory("C:\gradle-bin.zip", "C:\gradle")
}
- cmd: SET PATH=C:\maven\apache-maven-3.2.5\bin;C:\gradle\gradle-5.3.1\bin;%JAVA_HOME%\bin;%PATH%
- cmd: SET MAVEN_OPTS=-XX:MaxPermSize=2g -Xmx4g
- cmd: SET JAVA_OPTS=-XX:MaxPermSize=2g -Xmx4g
- cmd: SET M2_HOME=C:\maven\apache-maven-3.2.5
- cmd: java -version
- cmd: gradle -v
- cmd: gradle -b modules\openapi-generator-gradle-plugin\samples\local-spec\build.gradle buildGoSdk --info
- cmd: dir/w
- git clone https://github.com/wing328/swagger-samples
- ps: Start-Process -FilePath 'C:\maven\apache-maven-3.2.5\bin\mvn' -ArgumentList 'jetty:run' -WorkingDirectory "$env:appveyor_build_folder\swagger-samples\java\java-jersey-jaxrs-ci"
Expand Down Expand Up @@ -57,4 +69,5 @@ test_script:

cache:
- C:\maven\
- C:\gradle\
- C:\Users\appveyor\.m2
2 changes: 2 additions & 0 deletions bin/java-jaxrs-petstore-server-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@
./bin/jaxrs-spec-petstore-server.sh
./bin/jaxrs-usetags-petstore-server.sh

./bin/openapi3/jaxrs-jersey-petstore.sh

echo " Please run ./bin/jaxrs-cxf-petstore-server-test-data.sh manually instead"
1 change: 1 addition & 0 deletions bin/windows/typescript-axios-petstore-all.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ call bin\windows\typescript-axios-petstore.bat
call bin\windows\typescript-axios-petstore-target-es6.bat
call bin\windows\typescript-axios-petstore-with-npm-version.bat
call bin\windows\typescript-axios-petstore-interfaces.bat
call bin\windows\typescript-axios-petstore-with-npm-version-and-separate-models-and-api.bat
2 changes: 1 addition & 1 deletion docs/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ CONFIG OPTIONS
retrofit - HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1 (Retrofit 1.9.0)
retrofit2 - HTTP client: OkHttp 2.5.0. JSON processing: Gson 2.4 (Retrofit 2.0.0-beta2)
google-api-client - HTTP client: google-api-client 1.23.0. JSON processing: Jackson 2.8.9
rest-assured - HTTP client: rest-assured : 3.1.0. JSON processing: Gson 2.6.1. Only for Java8
rest-assured - HTTP client: rest-assured : 3.3.0. JSON processing: Gson 2.8.5. Only for Java8
```
Your config file for Java can look like
Expand Down
9 changes: 5 additions & 4 deletions docs/generators/aspnetcore.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ sidebar_label: aspnetcore
|packageVersion|C# package version.| |1.0.0|
|packageGuid|The GUID that will be associated with the C# project| |null|
|sourceFolder|source folder for generated code| |src|
|aspnetCoreVersion|ASP.NET Core version: 2.1 (default), 2.0 (deprecated)| |2.1|
|compatibilityVersion|ASP.Net Core CompatibilityVersion| |Version_2_1|
|aspnetCoreVersion|ASP.NET Core version: 2.2 (default), 2.1, 2.0 (deprecated)| |2.2|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|useDateTimeOffset|Use DateTimeOffset to model date-time properties| |false|
|useCollection|Deserialize array types to Collection&lt;T&gt; instead of List&lt;T&gt;.| |false|
|returnICollection|Return ICollection&lt;T&gt; instead of the concrete type.| |false|
|useSwashbuckle|Uses the Swashbuckle.AspNetCore NuGet package for documentation.| |true|
|classModifier|Class modifiers such as abstract or partial| ||
|operationModifier|Operation modifiers such as virtual or abstract.| |virtual|
|classModifier|Class Modifier can be empty, abstract| ||
|operationModifier|Operation Modifier can be virtual, abstract or partial| |virtual|
|buildTarget|Target to build an application or library| |program|
|generateBody|Generates method body.| |true|
|buildTarget|Target the build for a program or library.| |program|
1 change: 1 addition & 0 deletions docs/generators/php-symfony.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ sidebar_label: php-symfony
|artifactVersion|The version to use in the composer package version field. e.g. 1.2.3| |null|
|composerVendorName|The vendor name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. yaypets| |null|
|bundleName|The name of the Symfony bundle. The template uses {{bundleName}}| |null|
|bundleAlias|The alias of the Symfony bundle. The template uses {{aliasName}}| |null|
|composerProjectName|The project name used in the composer package name. The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. petstore-client| |null|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|phpLegacySupport|Should the generated code be compatible with PHP 5.x?| |true|
2 changes: 1 addition & 1 deletion docs/generators/ruby.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sidebar_label: ruby
|gemName|gem name (convention: underscore_case).| |openapi_client|
|moduleName|top module name (convention: CamelCase, usually corresponding to gem name).| |OpenAPIClient|
|gemVersion|gem version.| |1.0.0|
|gemLicense|gem license. | |proprietary|
|gemLicense|gem license. | |unlicense|
|gemRequiredRubyVersion|gem required Ruby version. | |&gt;= 1.9|
|gemHomepage|gem homepage. | |http://org.openapitools|
|gemSummary|gem summary. | |A ruby wrapper for the REST APIs|
Expand Down
2 changes: 1 addition & 1 deletion docs/generators/spring.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ sidebar_label: spring
|useTags|use tags for creating interface and controller classnames| |false|
|useBeanValidation|Use BeanValidation API annotations| |true|
|performBeanValidation|Use Bean Validation Impl. to perform BeanValidation| |false|
|implicitHeaders|Use of @ApiImplicitParams for headers.| |false|
|implicitHeaders|Skip header parameters in the generated API methods using @ApiImplicitParams annotation.| |false|
|swaggerDocketConfig|Generate Spring OpenAPI Docket configuration class.| |false|
|apiFirst|Generate the API from the OAI spec at server compile time (API first approach)| |false|
|useOptional|Use Optional container for optional parameters| |false|
Expand Down
1 change: 1 addition & 0 deletions docs/generators/typescript-axios.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ sidebar_label: typescript-axios
|snapshot|When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm| |false|
|withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false|
|withSeparateModelsAndApi|Put the model and api in separate folders and in separate classes| |false|
|withoutPrefixEnums|Dont prefix enum names with class names| |false|
2 changes: 2 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ To pass more than one generator property, these can be combined via comma:
--additional-properties=key1=value1,key2=value2
```
For the full list of generator-specified parameters, refer to [generators docs](./generators.md).
#### Type Mappings and Import Mappings
Most generators allow for types bound to the OpenAPI Specification's types to be remapped to a user's desired types. Not _all_ type mappings can be reassigned, as some generators define mappings which are tightly coupled to the built-in templates.
Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator-gradle-plugin/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ The gradle plugin is not currently published to https://plugins.gradle.org/m2/.
|configOptions
|Map(String,String)
|None
|A map of options specific to a generator.
|A map of options specific to a generator. To see the full list of generator-specified parameters, please refer to [generators docs](https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators.md)

|logToStderr
|Boolean
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
openApiGeneratorVersion=3.3.4
openApiGeneratorVersion=4.0.0-beta3
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ open class GenerateTask : DefaultTask() {
}

skipValidateSpec.ifNotEmpty { value ->
configurator.setValidateSpec(value)
configurator.setValidateSpec(!value)
}

generateAliasAsModel.ifNotEmpty { value ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,64 @@ class GenerateTaskDslTest : TestBase() {
assertEquals(TaskOutcome.SUCCESS, result.task(":openApiGenerate")?.outcome,
"Expected a successful run, but found ${result.task(":openApiGenerate")?.outcome}")
}

@Test
fun `openApiValidate should fail on invalid spec`() {
// Arrange
val projectFiles = mapOf(
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid.yaml")
)

withProject(defaultBuildGradle, projectFiles)

// Act
val result = GradleRunner.create()
.withProjectDir(temp)
.withArguments("openApiGenerate")
.withPluginClasspath()
.buildAndFail()

// Assert
assertTrue(result.output.contains("issues with the specification"), "Unexpected/no message presented to the user for an invalid spec.")
assertEquals(TaskOutcome.FAILED, result.task(":openApiGenerate")?.outcome,
"Expected a failed run, but found ${result.task(":openApiValidate")?.outcome}")
}

@Test
fun `openApiValidate should ok skip spec validation`() {
// Arrange
val projectFiles = mapOf(
"spec.yaml" to javaClass.classLoader.getResourceAsStream("specs/petstore-v3.0-invalid.yaml")
)

withProject("""
plugins {
id 'org.openapi.generator'
}
openApiGenerate {
generatorName = "kotlin"
inputSpec = file("spec.yaml").absolutePath
outputDir = file("build/kotlin").absolutePath
apiPackage = "org.openapitools.example.api"
invokerPackage = "org.openapitools.example.invoker"
modelPackage = "org.openapitools.example.model"
skipValidateSpec = true
configOptions = [
dateLibrary: "java8"
]
}
""".trimIndent(), projectFiles)

// Act
val result = GradleRunner.create()
.withProjectDir(temp)
.withArguments("openApiGenerate")
.withPluginClasspath()
.build()

// Assert
assertTrue(result.output.contains("validation has been explicitly disabled"), "Unexpected/no message presented to the user for an invalid spec.")
assertEquals(TaskOutcome.SUCCESS, result.task(":openApiGenerate")?.outcome,
"Expected a successful run, but found ${result.task(":openApiGenerate")?.outcome}")
}
}
3 changes: 1 addition & 2 deletions modules/openapi-generator-maven-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ mvn clean compile
:bulb: These **general** configurations should be in the same level

- `inputSpec` - OpenAPI Spec file path
- `validateSpec` - Whether or not to validate the input spec prior to generation. Invalid specifications will result in an error.
- `language` - target generation language (deprecated, replaced by `generatorName` as values here don't represent only 'language' any longer)
- `generatorName` - target generator name
- `output` - target output path (default is `${project.build.directory}/generated-sources/openapi`. Can also be set globally through the `openapi.generator.maven.plugin.output` property)
Expand All @@ -57,7 +56,7 @@ mvn clean compile
- `removeOperationIdPrefix` - remove operationId prefix (e.g. user_getName => getName)
- `logToStderr` - write all log messages (not just errors) to STDOUT
- `enablePostProcessFile` - enable file post-processing hook
- `skipValidateSpec` - skip spec validation
- `skipValidateSpec` - Whether or not to skip validating the input spec prior to generation. By default, invalid specifications will result in an error.
- `generateAliasAsModel` - generate alias (array, map) as model
- `generateApis` - generate the apis (`true` by default)
- `generateApiTests` - generate the api tests (`true` by default. Only available if `generateApis` is `true`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ public class CodeGenMojo extends AbstractMojo {
@Component
private BuildContext buildContext = new DefaultBuildContext();

@Parameter(name="validateSpec", required = false, defaultValue = "true")
private Boolean validateSpec;

@Parameter(name = "verbose", required = false, defaultValue = "false")
private boolean verbose;

Expand Down Expand Up @@ -434,11 +431,6 @@ public void execute() throws MojoExecutionException {

configurator.setVerbose(verbose);

// now override with any specified parameters
if (validateSpec != null) {
configurator.setValidateSpec(validateSpec);
}

if (skipOverwrite != null) {
configurator.setSkipOverwrite(skipOverwrite);
}
Expand All @@ -464,7 +456,7 @@ public void execute() throws MojoExecutionException {
}

if (skipValidateSpec != null) {
configurator.setSkipOverwrite(skipValidateSpec);
configurator.setValidateSpec(!skipValidateSpec);
}

if (logToStderr != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class CliOption {
private String description;
private String type;
private String defaultValue;
private String optValue;
private Map<String, String> enumValues;

public CliOption(String opt, String description) {
Expand Down Expand Up @@ -73,6 +74,18 @@ public CliOption defaultValue(String defaultValue) {
return this;
}

public String getOptValue() {
return this.optValue;
}

public void setOptValue(String optValue) {
if (this.enumValues!=null && this.enumValues.containsKey(optValue)) {
this.optValue = optValue;
} else {
this.optValue = null;
}
}

public CliOption addEnum(String value, String description) {
if (this.enumValues == null) {
this.enumValues = new LinkedHashMap<String, String>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ public class CodegenConstants {
public static final String PERL_MODULE_NAME = "perlModuleName";
public static final String PERL_MODULE_NAME_DESC = "root module name for generated perl code";

public static final String MODULE_NAME = "moduleName";
public static final String MODULE_NAME_DESC = "top module name (convention: CamelCase, usually corresponding to gem name).";

public static final String GEM_NAME = "gemName";
public static final String GEM_NAME_DESC = "gem name (convention: underscore_case).";

public static final String PYTHON_PACKAGE_NAME = "pythonPackageName";
public static final String PYTHON_PACKAGE_NAME_DESC = "package name for generated python code";

Expand Down Expand Up @@ -280,13 +286,13 @@ public static enum ENUM_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case,
public static final String ENABLE_POST_PROCESS_FILE_DESC = "Enable post-processing file using environment variables.";

public static final String OPEN_API_SPEC_NAME = "openAPISpecName";

public static final String GENERATE_ALIAS_AS_MODEL = "generateAliasAsModel";
public static final String GENERATE_ALIAS_AS_MODEL_DESC = "Generate alias to map, array as models";

public static final String USE_COMPARE_NET_OBJECTS = "useCompareNetObjects";
public static final String USE_COMPARE_NET_OBJECTS_DESC = "Use KellermanSoftware.CompareNetObjects for deep recursive object comparison. WARNING: this option incurs potential performance impact.";

public static final String SNAPSHOT_VERSION = "snapshotVersion";
public static final String SNAPSHOT_VERSION_DESC = "Uses a SNAPSHOT version.";

Expand Down
Loading

0 comments on commit fb2346c

Please sign in to comment.