Skip to content

Commit

Permalink
[e2e] fixes e2e tests and ads documentation for [plugins/openapi-cont…
Browse files Browse the repository at this point in the history
…rollers]
  • Loading branch information
ivangsa committed Sep 18, 2024
1 parent 7dfdab8 commit b996e0b
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.4</version>
<version>3.3.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>io.zenwave360.example</groupId>
Expand Down Expand Up @@ -148,7 +148,7 @@
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>6.6.0</version>
<version>7.8.0</version>
<executions>
<execution>
<goals>
Expand All @@ -162,9 +162,7 @@
<modelPackage>io.zenwave360.example.adapters.web.model</modelPackage>
<modelNameSuffix>DTO</modelNameSuffix>
<addCompileSourceRoot>true</addCompileSourceRoot>
<supportingFilesToGenerate>
ApiUtil.java
</supportingFilesToGenerate>
<generateSupportingFiles>false</generateSupportingFiles>
<typeMappings>
<typeMapping>Double=java.math.BigDecimal</typeMapping>
</typeMappings>
Expand All @@ -175,7 +173,9 @@
<useOptional>true</useOptional>
<useTags>true</useTags>
<interfaceOnly>true</interfaceOnly>
<skipDefaultInterface>true</skipDefaultInterface>
<delegatePattern>false</delegatePattern>
<sortParamsByRequiredFlag>false</sortParamsByRequiredFlag>
</configOptions>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.4</version>
<version>3.3.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>io.zenwave360.example</groupId>
Expand Down Expand Up @@ -144,7 +144,7 @@
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>6.6.0</version>
<version>7.8.0</version>
<executions>
<execution>
<goals>
Expand All @@ -158,9 +158,7 @@
<modelPackage>io.zenwave360.example.adapters.web.model</modelPackage>
<modelNameSuffix>DTO</modelNameSuffix>
<addCompileSourceRoot>true</addCompileSourceRoot>
<supportingFilesToGenerate>
ApiUtil.java
</supportingFilesToGenerate>
<generateSupportingFiles>false</generateSupportingFiles>
<typeMappings>
<typeMapping>Double=java.math.BigDecimal</typeMapping>
</typeMappings>
Expand All @@ -171,7 +169,9 @@
<useOptional>true</useOptional>
<useTags>true</useTags>
<interfaceOnly>true</interfaceOnly>
<skipDefaultInterface>true</skipDefaultInterface>
<delegatePattern>false</delegatePattern>
<sortParamsByRequiredFlag>false</sortParamsByRequiredFlag>
</configOptions>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.1</version>
<version>3.3.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<packaging>pom</packaging>
Expand Down Expand Up @@ -134,7 +134,7 @@
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>6.6.0</version>
<version>7.8.0</version>
<executions>
<execution>
<id>openapi-generator-server</id>
Expand All @@ -149,9 +149,7 @@
<modelPackage>${basePackage}.adapters.web.model</modelPackage>
<modelNameSuffix>DTO</modelNameSuffix>
<addCompileSourceRoot>true</addCompileSourceRoot>
<supportingFilesToGenerate>
ApiUtil.java
</supportingFilesToGenerate>
<generateSupportingFiles>false</generateSupportingFiles>
<typeMappings>
<typeMapping>Double=java.math.BigDecimal</typeMapping>
</typeMappings>
Expand All @@ -162,7 +160,9 @@
<useOptional>true</useOptional>
<useTags>true</useTags>
<interfaceOnly>true</interfaceOnly>
<skipDefaultInterface>true</skipDefaultInterface>
<delegatePattern>false</delegatePattern>
<sortParamsByRequiredFlag>false</sortParamsByRequiredFlag>
</configOptions>
</configuration>
</execution>
Expand Down
10 changes: 5 additions & 5 deletions e2e/src/test/resources/projects/simple-domain-packaging/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.4</version>
<version>3.3.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>io.zenwave360.example</groupId>
Expand Down Expand Up @@ -144,7 +144,7 @@
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>6.6.0</version>
<version>7.8.0</version>
<executions>
<execution>
<goals>
Expand All @@ -158,9 +158,7 @@
<modelPackage>io.zenwave360.example.customer.dtos</modelPackage>
<modelNameSuffix>DTO</modelNameSuffix>
<addCompileSourceRoot>true</addCompileSourceRoot>
<supportingFilesToGenerate>
ApiUtil.java
</supportingFilesToGenerate>
<generateSupportingFiles>false</generateSupportingFiles>
<typeMappings>
<typeMapping>Double=java.math.BigDecimal</typeMapping>
</typeMappings>
Expand All @@ -171,7 +169,9 @@
<useOptional>true</useOptional>
<useTags>true</useTags>
<interfaceOnly>true</interfaceOnly>
<skipDefaultInterface>true</skipDefaultInterface>
<delegatePattern>false</delegatePattern>
<sortParamsByRequiredFlag>false</sortParamsByRequiredFlag>
</configOptions>
</configuration>
</execution>
Expand Down
58 changes: 56 additions & 2 deletions plugins/openapi-controllers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,62 @@ jbang zw -p io.zenwave360.sdk.plugins.OpenAPIControllersPlugin
targetFolder=.
```

## Options
## Configuring OpenAPI Generator for Compatibility

Default options for https://openapi-generator.tech/docs/generators/spring/ have changes over time and different versions. Here is a sample configuration that works with this version of ZenWave360 SDK.

```xml
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>7.8.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/public/apis/openapi.yml</inputSpec>
<skipIfSpecIsUnchanged>true</skipIfSpecIsUnchanged>
<generatorName>spring</generatorName>
<apiPackage>${openApiApiPackage}</apiPackage>
<modelPackage>${openApiModelPackage}</modelPackage>
<modelNameSuffix>DTO</modelNameSuffix>
<addCompileSourceRoot>true</addCompileSourceRoot>
<generateSupportingFiles>false</generateSupportingFiles>
<typeMappings>
<typeMapping>Double=java.math.BigDecimal</typeMapping>
</typeMappings>
<configOptions>
<useSpringBoot3>true</useSpringBoot3>
<documentationProvider>none</documentationProvider>
<openApiNullable>false</openApiNullable>
<useOptional>true</useOptional>
<useTags>true</useTags>
<interfaceOnly>true</interfaceOnly>
<skipDefaultInterface>true</skipDefaultInterface>
<delegatePattern>false</delegatePattern>
<sortParamsByRequiredFlag>false</sortParamsByRequiredFlag><!-- this is important -->
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
```

Also, make sure you set `required: true` for `requestBody` in your OpenAPI definition for post, put, patch...

```yaml
requestBody:
required: true # this is important
content:
application/json:
schema:
$ref: "#/components/schemas/Customer"
```
## Plugin Options
| **Option** | **Description** | **Type** | **Default** | **Values** |
|-----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------|---------------------------------------|-----------------------------------|
Expand All @@ -42,7 +97,6 @@ jbang zw -p io.zenwave360.sdk.plugins.OpenAPIControllersPlugin
| `haltOnFailFormatting` | Halt on formatting errors | boolean | true | |
| `continueOnZdlError` | Continue even when ZDL contains fatal errors | boolean | true | |


## Getting Help

```shell
Expand Down

0 comments on commit b996e0b

Please sign in to comment.