Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added capability to work with language argument options on service #9532

Merged
merged 1 commit into from
Jun 28, 2019
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
added capability to work with language argument options on generator …
…service.
  • Loading branch information
HugoMario authored and frantuma committed Jun 28, 2019
commit d799225333d192c54f6984c085d3c9d5b55cdcf3
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.swagger.codegen.CodegenConfigLoader;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.v3.ClientOptInput;
import io.swagger.codegen.v3.CodegenArgument;
import io.swagger.codegen.v3.config.CodegenConfigurator;
import io.swagger.codegen.v3.service.exception.BadRequestException;
import io.swagger.models.Swagger;
Expand Down Expand Up @@ -198,6 +199,7 @@ public static ClientOptInput getClientOptInput(GenerationRequest generationReque

if (isNotEmpty(lang)) {
configurator.setLang(lang);
readCodegenArguments(configurator, options);
}
if (isNotEmpty(options.getAuth())) {
configurator.setAuth(options.getAuth());
Expand Down Expand Up @@ -286,4 +288,26 @@ public static ClientOptInput getClientOptInput(GenerationRequest generationReque
LOGGER.debug("getClientOptInput - end");
return configurator.toClientOptInput();
}

private static void readCodegenArguments(CodegenConfigurator configurator, Options options) {
if (options == null) {
return;
}
io.swagger.codegen.v3.CodegenConfig config = io.swagger.codegen.v3.CodegenConfigLoader.forName(configurator.getLang());
if (config == null) {
return;
}
final List<CodegenArgument> arguments = config.readLanguageArguments();
if (arguments == null || arguments.isEmpty()) {
return;
}
for (CodegenArgument codegenArgument : arguments) {
final String value = options.getCodegenArguments().get(codegenArgument.getOption().substring(2));
if (value == null) {
continue;
}
codegenArgument.setValue(value);
}
configurator.setCodegenArguments(arguments);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public class Options {
private Boolean skipOverride;
private String outputDir = "";

private Map<String, String> codegenArguments = new LinkedHashMap<>();

public Options authorizationValue(AuthorizationValue authorizationValue) {
this.authorizationValue = authorizationValue;
return this;
Expand Down Expand Up @@ -211,6 +213,25 @@ public Options addImportMapping(String key, String value) {
return this;
}

public Options codegenArguments(Map<String, String> codegenArguments) {
this.codegenArguments = codegenArguments;
return this;
}

public Map<String, String> getCodegenArguments() {
return codegenArguments;
}

public void setCodegenArguments(Map<String, String> codegenArguments) {
this.codegenArguments = codegenArguments;
}

public Options addCodegenArgument(String key, String value) {
this.codegenArguments.put(key, value);
return this;
}


public Options invokerPackage(String invokerPackage) {
this.invokerPackage = invokerPackage;
return this;
Expand Down