diff --git a/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java b/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java index 4b25c10c98..31c5073275 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java +++ b/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java @@ -3590,9 +3590,7 @@ public List readLanguageArguments() { String shortOption = argument.findValue("shortOption") != null ? argument.findValue("shortOption").textValue() : null; String type = argument.findValue("type") != null ? argument.findValue("type").textValue() : "string"; boolean isArray = argument.findValue("isArray") != null ? argument.findValue("isArray").booleanValue() : false; - if (StringUtils.isBlank(option)) { - continue; - } + languageArguments.add(new CodegenArgument() .option(option) .shortOption(shortOption) diff --git a/src/main/java/io/swagger/codegen/v3/generators/dotnet/AspNetCoreServerCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/dotnet/AspNetCoreServerCodegen.java index 1c4a9e53fc..0254fcf77c 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/dotnet/AspNetCoreServerCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/dotnet/AspNetCoreServerCodegen.java @@ -92,6 +92,19 @@ public AspNetCoreServerCodegen() { this.returnICollection); this.aspNetCoreVersion = DEFAULT_ASP_NET_CORE_VERSION; + + addSwitch(INTERFACE_ONLY_OPTION.substring(2), + "Only generate interfaces for controllers", + false); + + addSwitch(INTERFACE_CONTROLLER_OPTION.substring(2), + "Generate interfaces for controllers, implemented by a default controller implementation", + false); + + addOption(ASP_NET_CORE_VERSION_OPTION.substring(2), + "ASP.NET Core version", + DEFAULT_ASP_NET_CORE_VERSION); + } @Override @@ -299,8 +312,25 @@ public List fromSecurity(Map securitySc } private void addInterfaceControllerTemplate() { - boolean interfaceOnly = Boolean.valueOf(getOptionValue(INTERFACE_ONLY_OPTION)); - boolean interfaceController = Boolean.valueOf(getOptionValue(INTERFACE_CONTROLLER_OPTION)); + String interfaceOnlyOption = getOptionValue(INTERFACE_ONLY_OPTION); + boolean interfaceOnly = false; + if (StringUtils.isNotBlank(interfaceOnlyOption)) { + interfaceOnly = Boolean.valueOf(getOptionValue(INTERFACE_ONLY_OPTION)); + } else { + if (additionalProperties.get(INTERFACE_ONLY_OPTION.substring(2)) != null) { + interfaceOnly = Boolean.valueOf(additionalProperties.get(INTERFACE_ONLY_OPTION.substring(2)).toString()); + } + } + + String interfaceControllerOption = getOptionValue(INTERFACE_CONTROLLER_OPTION); + boolean interfaceController = false; + if (StringUtils.isNotBlank(interfaceControllerOption)) { + interfaceController = Boolean.valueOf(getOptionValue(INTERFACE_CONTROLLER_OPTION)); + } else { + if (additionalProperties.get(INTERFACE_CONTROLLER_OPTION.substring(2)) != null) { + interfaceController = Boolean.valueOf(additionalProperties.get(INTERFACE_CONTROLLER_OPTION.substring(2)).toString()); + } + } if (interfaceController) { apiTemplateFiles.put("icontroller.mustache", ".cs"); @@ -321,9 +351,14 @@ public String getArgumentsLocation() { private void setAspNetCoreVersion() { String optionValue = getOptionValue(ASP_NET_CORE_VERSION_OPTION); if (StringUtils.isBlank(optionValue)) { - return; + if (additionalProperties.get(ASP_NET_CORE_VERSION_OPTION.substring(2)) != null) { + this.aspNetCoreVersion = additionalProperties.get(ASP_NET_CORE_VERSION_OPTION.substring(2)).toString(); + } else { + return; + } + } else { + this.aspNetCoreVersion = optionValue; } - this.aspNetCoreVersion = optionValue; if (!this.aspNetCoreVersion.equals("2.0") && !this.aspNetCoreVersion.equals("2.1") && !this.aspNetCoreVersion.equals("2.2")) { LOGGER.error("version '" + this.aspNetCoreVersion + "' is not supported, switching to default version: '" + DEFAULT_ASP_NET_CORE_VERSION + "'"); this.aspNetCoreVersion = DEFAULT_ASP_NET_CORE_VERSION; diff --git a/src/main/resources/arguments/inflector.yaml b/src/main/resources/arguments/inflector.yaml index e0b4321709..f3ad5daf80 100644 --- a/src/main/resources/arguments/inflector.yaml +++ b/src/main/resources/arguments/inflector.yaml @@ -13,4 +13,4 @@ arguments: type: "boolean" - option: "--use-oas2" description: "use OpenAPI v2.0 (Swagger 1.5.x) annotations (by default, OpenAPI v3.0 is used)." - type: "boolean" \ No newline at end of file + type: "boolean" diff --git a/src/main/resources/arguments/java.yaml b/src/main/resources/arguments/java.yaml index 9ef0bd1472..2531bd0b12 100644 --- a/src/main/resources/arguments/java.yaml +++ b/src/main/resources/arguments/java.yaml @@ -4,4 +4,4 @@ arguments: type: "string" - option: "--use-oas2" description: "use OpenAPI v2.0 (Swagger 1.5.x) annotations (by default, OpenAPI v3.0 is used)." - type: "boolean" \ No newline at end of file + type: "boolean"