Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/swagger-codegen-maven-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ mvn clean compile
- `generateSupportingFiles` - generate the supporting files (`true` by default)
- `supportingFilesToGenerate` - A comma separated list of supporting files to generate. All files is the default.
- `skip` - skip code generation (`false` by default. Can also be set globally through the `codegen.skip` property)
- `skipInlineModelMatches` - when processing inline models, generate unique classes for models with the same content (`false` by default, causes reusing)

### Custom Generator

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,12 @@ public class CodeGenMojo extends AbstractMojo {
@Parameter(name = "skip", property = "codegen.skip", required = false, defaultValue = "false")
private Boolean skip;

/**
* Skip matches
*/
@Parameter(name = "skipInlineModelMatches", required = false)
private Boolean skipInlineModelMatches = false;

/**
* Add the output directory to the project as a source root, so that the generated java types
* are compiled and included in the project artifact.
Expand Down Expand Up @@ -368,6 +374,8 @@ protected void execute_() throws MojoExecutionException {

configurator.setOutputDir(output.getAbsolutePath());

configurator.setSkipInlineModelMatches(skipInlineModelMatches);

if (isNotEmpty(auth)) {
configurator.setAuth(auth);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class CodegenConfigurator implements Serializable {
private boolean verbose;
private boolean skipOverwrite;
private boolean removeOperationIdPrefix;
private boolean skipInlineModelMatches;
private String templateDir;
private String templateVersion;
private String auth;
Expand Down Expand Up @@ -175,6 +176,15 @@ public CodegenConfigurator setRemoveOperationIdPrefix(boolean removeOperationIdP
return this;
}

public boolean getSkipInlineModelMatches() {
return skipInlineModelMatches;
}

public CodegenConfigurator setSkipInlineModelMatches(boolean skipInlineModelMatches) {
this.skipInlineModelMatches = skipInlineModelMatches;
return this;
}

public String getModelNameSuffix() {
return modelNameSuffix;
}
Expand Down Expand Up @@ -561,11 +571,10 @@ public ClientOptInput toClientOptInput() {

if (!StringUtils.isBlank(inputSpec)) {
config.setInputSpec(inputSpec);
ParseOptions options = new ParseOptions();
options.setResolve(true);
options.setResolveFully(resolveFully);
options.setFlatten(true);
options.setFlattenComposedSchemas(flattenInlineSchema);

ParseOptions options = buildParseOptions();


SwaggerParseResult result = new OpenAPIParser().readContents(inputSpec, authorizationValues, options);
OpenAPI openAPI = result.getOpenAPI();
if (config.needsUnflattenedSpec()) {
Expand Down Expand Up @@ -597,13 +606,11 @@ public ClientOptInput toClientOptInput() {
throw new IllegalArgumentException(msg);
}
config.setInputSpec(specContent);

config.setInputURL(sanitizedSpecificationUrl);
ParseOptions options = new ParseOptions();
options.setResolve(true);
options.setResolveFully(resolveFully);
options.setFlatten(true);
options.setFlattenComposedSchemas(flattenInlineSchema);
ParseOptions options = buildParseOptions();
SwaggerParseResult result = new OpenAPIParser().readLocation(sanitizedSpecificationUrl, authorizationValues, options);

OpenAPI openAPI = result.getOpenAPI();
LOGGER.debug("getClientOptInput - parsed inputSpecURL " + sanitizedSpecificationUrl);
input.opts(new ClientOpts())
Expand Down Expand Up @@ -660,6 +667,16 @@ public ClientOptInput toClientOptInput() {
return input;
}

private ParseOptions buildParseOptions() {
ParseOptions options = new ParseOptions();
options.setResolve(true);
options.setResolveFully(resolveFully);
options.setFlatten(true);
options.setFlattenComposedSchemas(flattenInlineSchema);
options.setSkipMatches(this.skipInlineModelMatches);
return options;
}

@JsonAnySetter
public CodegenConfigurator addDynamicProperty(String name, Object value) {
dynamicProperties.put(name, value);
Expand Down