@@ -18,6 +18,7 @@ package com.github.hauner.openapi.spring.generatr
1818
1919import com.github.hauner.openapi.api.OpenApiGeneratr
2020import com.github.hauner.openapi.spring.converter.ApiConverter
21+ import com.github.hauner.openapi.spring.converter.ApiOptions
2122import com.github.hauner.openapi.spring.writer.ApiWriter
2223import com.github.hauner.openapi.spring.writer.HeaderWriter
2324import com.github.hauner.openapi.spring.writer.InterfaceWriter
@@ -31,33 +32,34 @@ import io.swagger.v3.parser.core.models.SwaggerParseResult
3132 *
3233 * @author Martin Hauner
3334 */
34- class SpringGeneratr implements OpenApiGeneratr<ApiOptions > {
35+ class SpringGeneratr implements OpenApiGeneratr<SpringGeneratrOptions > {
3536
3637 @Override
3738 String getName () {
3839 return ' spring'
3940 }
4041
4142 @Override
42- Class<ApiOptions > getOptionsType () {
43- return ApiOptions
43+ Class<SpringGeneratrOptions > getOptionsType () {
44+ return SpringGeneratrOptions
4445 }
4546
4647 @Override
47- void run (ApiOptions options ) {
48+ void run (SpringGeneratrOptions generatrOptions ) {
4849 ParseOptions opts = new ParseOptions (
4950 // loads $refs to other files into #/components/schema and replaces the $refs to the
5051 // external files with $refs to #/components/schema.
5152 resolve : true
5253 )
5354
5455 SwaggerParseResult result = new OpenAPIV3Parser ()
55- .readLocation (options . apiPath, null , opts)
56+ .readLocation (generatrOptions . apiPath, null , opts)
5657
57- if (options . showWarnings) {
58+ if (generatrOptions . showWarnings) {
5859 printWarnings(result. messages)
5960 }
6061
62+ def options = convertOptions (generatrOptions)
6163 def cv = new ApiConverter (options)
6264 def api = cv. convert (result. openAPI)
6365
@@ -70,6 +72,16 @@ class SpringGeneratr implements OpenApiGeneratr<ApiOptions> {
7072 writer. write (api)
7173 }
7274
75+ private ApiOptions convertOptions (SpringGeneratrOptions generatrOptions ) {
76+ def options = new ApiOptions ()
77+ def reader = new TypeMappingReader ()
78+ options. apiPath = generatrOptions. apiPath
79+ options. targetDir = generatrOptions. targetDir
80+ options. packageName = generatrOptions. packageName
81+ options. typeMappings = reader. read (generatrOptions. typeMappings)
82+ options
83+ }
84+
7385 private static printWarnings (List<String > warnings ) {
7486 if (warnings. empty) {
7587 return
0 commit comments