Reputation: 6822
We are using openapi-generator's openapi-generator-maven-plugin to automate an integration with a swagger which uses Numeric datatypes that are not int64. Our codebase tries to standardize around using Long values, but openapi generates artifacts which use int. Is it possible to configure the plugin to generate POJOs which use Long instead of Integer?
We could modify the swagger definition to specify the int64 format but prefer to do this via configuration outside of the swagger.
Upvotes: 9
Views: 16661
Reputation: 6822
I used the typeMappings parameter for this. Using a maven plugin configuration it looks like this:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.1.0</version>
<configuration>
<typeMappings>integer=Long,int=Long</typeMappings>
</configuration>
<executions>
<execution>
...
</execution>
</executions>
</plugin>
Note that this configuration, as of this writing, does not work inside of the execution as it did with swagger-codegen. the typemappings parameter can also be used when calling the openapi-generator directly
Upvotes: 3
Reputation: 2748
Use the format
keyword to specify int64
.
example:
type: integer
format: int64
Upvotes: 24