Skip to content

Commit 6ddc8b3

Browse files
authored
Add section on type and import mappings with samples (#14576)
1 parent 32499a1 commit 6ddc8b3

File tree

1 file changed

+29
-0
lines changed
  • modules/openapi-generator-maven-plugin

1 file changed

+29
-0
lines changed

modules/openapi-generator-maven-plugin/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,35 @@ Notice that some of these environment variable options may overwrite or conflict
138138

139139
The difference here is that you may define `generateModels` and `modelsToGenerate` as properties, while `globalProperties` may only be configured as a configuration node.
140140

141+
### Type and import mappings
142+
143+
To override the mappings between OpenAPI spec types and the types used in the generated code, set `typeMappings`.
144+
145+
```xml
146+
<configuration>
147+
<typeMappings>
148+
<!-- convert Double to BigDecimal -->
149+
<typeMapping>Double=java.math.BigDecimal</typeMapping>
150+
</typeMappings>
151+
</configuration>
152+
```
153+
154+
For types that are not already included in the generator configuration, you may need to add a corresponding `importMapping` too.
155+
156+
```xml
157+
<configuration>
158+
<!-- convert file/binary to JAX-RS StreamingOutput -->
159+
<typeMappings>
160+
<typeMapping>binary=StreamingOutput</typeMapping>
161+
<typeMapping>file=StreamingOutput</typeMapping>
162+
</typeMappings>
163+
<importMappings>
164+
<importMapping>StreamingOutput=javax.ws.rs.core.StreamingOutput</importMapping>
165+
</importMappings>
166+
</configuration>
167+
```
168+
169+
141170
### Custom Generator
142171

143172
Specifying a custom generator is a bit different. It doesn't support the classpath:/ syntax, but it does support the fully qualified name of the package. You can also specify your custom templates, which also get pulled in. Notice the dependency on a project, in the plugin scope. That would be your generator/template jar.

0 commit comments

Comments
 (0)