12
12
import io .swagger .models .Swagger ;
13
13
import io .swagger .models .auth .UrlMatcher ;
14
14
import io .swagger .parser .SwaggerParser ;
15
+ import io .swagger .parser .util .ParseOptions ;
15
16
import io .swagger .v3 .core .util .Json ;
16
17
import org .apache .commons .lang3 .StringUtils ;
17
18
import org .apache .commons .lang3 .Validate ;
@@ -108,15 +109,26 @@ public static io.swagger.codegen.ClientOptInput getClientOptInputV2(GenerationRe
108
109
}
109
110
LOGGER .debug ("getClientOptInputV2 - processed auth" );
110
111
112
+ CodegenConfig codegenConfig =null ;
113
+ try {
114
+ codegenConfig = CodegenConfigLoader .forName (lang );
115
+ } catch (RuntimeException e ) {
116
+ throw new BadRequestException ("Unsupported target " + lang + " supplied" );
117
+ }
118
+ ParseOptions parseOptions = new ParseOptions ();
119
+ parseOptions .setResolve (true );
120
+ if (codegenConfig .isUsingFlattenSpec () && !Boolean .FALSE .equals (generationRequest .getOptions ().isUsingFlattenSpecForV2 ())) {
121
+ parseOptions .setFlatten (true );
122
+ }
111
123
Swagger swagger ;
112
124
if (StringUtils .isBlank (inputSpec )) {
113
125
if (inputSpecURL != null ) {
114
126
if (!authorizationValues .isEmpty ()) {
115
127
swagger =
116
128
new SwaggerParser ().read (inputSpecURL , authorizationValues ,
117
- true );
129
+ parseOptions );
118
130
} else {
119
- swagger = new SwaggerParser ().read (inputSpecURL );
131
+ swagger = new SwaggerParser ().read (inputSpecURL , null , parseOptions );
120
132
}
121
133
} else {
122
134
throw new BadRequestException ("No swagger specification was supplied" );
@@ -126,9 +138,9 @@ public static io.swagger.codegen.ClientOptInput getClientOptInputV2(GenerationRe
126
138
try {
127
139
JsonNode node = io .swagger .util .Json .mapper ().readTree (inputSpec );
128
140
if (!authorizationValues .isEmpty ()) {
129
- swagger = new SwaggerParser ().read (node , authorizationValues , true );
141
+ swagger = new SwaggerParser ().read (node , authorizationValues , parseOptions );
130
142
} else {
131
- swagger = new SwaggerParser ().read (node , true );
143
+ swagger = new SwaggerParser ().read (node , null , parseOptions );
132
144
}
133
145
} catch (Exception e ) {
134
146
LOGGER .error ("Exception parsing input spec" , e );
@@ -144,12 +156,6 @@ public static io.swagger.codegen.ClientOptInput getClientOptInputV2(GenerationRe
144
156
io .swagger .codegen .ClientOptInput clientOptInput = new io .swagger .codegen .ClientOptInput ();
145
157
ClientOpts clientOpts = new ClientOpts ();
146
158
147
- CodegenConfig codegenConfig =null ;
148
- try {
149
- codegenConfig = CodegenConfigLoader .forName (lang );
150
- } catch (RuntimeException e ) {
151
- throw new BadRequestException ("Unsupported target " + lang + " supplied" );
152
- }
153
159
codegenConfig .setOutputDir (generationRequest .getOptions ().getOutputDir ());
154
160
codegenConfig .setInputSpec (inputSpec );
155
161
if (isNotEmpty (options .getApiPackage ())) {
0 commit comments