Skip to content

Commit

Permalink
Merge pull request #9817 from swagger-api/resolved-spec-not-flatten
Browse files Browse the repository at this point in the history
[openapi, openapi-yaml] - option not to flatten resolved spec, refactor
  • Loading branch information
frantuma committed Oct 30, 2019
2 parents 1ca09f4 + 8de0b58 commit 4c0558e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,8 @@ public interface CodegenConfig {
List<CodegenArgument> getLanguageArguments();

void setLanguageArguments(List<CodegenArgument> codegenArguments);

boolean needsUnflattenedSpec();

void setUnflattenedOpenAPI(OpenAPI unflattenedOpenAPI);
}
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,14 @@ public ClientOptInput toClientOptInput() {
SwaggerParseResult result = new OpenAPIParser().readContents(inputSpec, authorizationValues, options);
OpenAPI openAPI = result.getOpenAPI();

if (config.needsUnflattenedSpec()) {
ParseOptions optionsUnflattened = new ParseOptions();
optionsUnflattened.setResolve(true);
SwaggerParseResult resultUnflattened = new OpenAPIParser().readContents(inputSpec, authorizationValues, optionsUnflattened);
OpenAPI openAPIUnflattened = resultUnflattened.getOpenAPI();
config.setUnflattenedOpenAPI(openAPIUnflattened);
}

input.opts(new ClientOpts())
.openAPI(openAPI);

Expand Down Expand Up @@ -497,6 +505,15 @@ public ClientOptInput toClientOptInput() {
LOGGER.debug("getClientOptInput - parsed inputSpecURL " + inputSpecURL);
input.opts(new ClientOpts())
.openAPI(openAPI);

if (config.needsUnflattenedSpec()) {
ParseOptions optionsUnflattened = new ParseOptions();
optionsUnflattened.setResolve(true);
SwaggerParseResult resultUnflattened = new OpenAPIParser().readLocation(inputSpecURL, authorizationValues, optionsUnflattened);
OpenAPI openAPIUnflattened = resultUnflattened.getOpenAPI();
config.setUnflattenedOpenAPI(openAPIUnflattened);
}

}

config.setOutputDir(outputDir);
Expand Down

0 comments on commit 4c0558e

Please sign in to comment.