mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 20:50:55 +00:00
Factorize addOption/addSwitch method (#7814)
This commit is contained in:
parent
73bd24db7d
commit
fedfb0cda7
@ -3779,4 +3779,22 @@ public class DefaultCodegen {
|
||||
public void writePropertyBack(String propertyKey, boolean value) {
|
||||
additionalProperties.put(propertyKey, value);
|
||||
}
|
||||
|
||||
protected void addOption(String key, String description) {
|
||||
addOption(key, description, null);
|
||||
}
|
||||
|
||||
protected void addOption(String key, String description, String defaultValue) {
|
||||
CliOption option = new CliOption(key, description);
|
||||
if (defaultValue != null)
|
||||
option.defaultValue(defaultValue);
|
||||
cliOptions.add(option);
|
||||
}
|
||||
|
||||
protected void addSwitch(String key, String description, Boolean defaultValue) {
|
||||
CliOption option = CliOption.newBoolean(key, description);
|
||||
if (defaultValue != null)
|
||||
option.defaultValue(defaultValue.toString());
|
||||
cliOptions.add(option);
|
||||
}
|
||||
}
|
||||
|
@ -144,13 +144,6 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
Arrays.asList("integer", "boolean", "Integer", "Character", "Boolean", "long", "float", "double"));
|
||||
}
|
||||
|
||||
protected void addOption(String key, String description, String defaultValue) {
|
||||
CliOption option = new CliOption(key, description);
|
||||
if (defaultValue != null)
|
||||
option.defaultValue(defaultValue);
|
||||
cliOptions.add(option);
|
||||
}
|
||||
|
||||
public String toFilename(String name) {
|
||||
return name.replace(".", "-").toLowerCase();
|
||||
}
|
||||
|
@ -176,18 +176,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
this.netCoreProjectFileFlag = flag;
|
||||
}
|
||||
|
||||
protected void addOption(String key, String description, String defaultValue) {
|
||||
CliOption option = new CliOption(key, description);
|
||||
if (defaultValue != null) option.defaultValue(defaultValue);
|
||||
cliOptions.add(option);
|
||||
}
|
||||
|
||||
protected void addSwitch(String key, String description, Boolean defaultValue) {
|
||||
CliOption option = CliOption.newBoolean(key, description);
|
||||
if (defaultValue != null) option.defaultValue(defaultValue.toString());
|
||||
cliOptions.add(option);
|
||||
}
|
||||
|
||||
public void useDateTimeOffset(boolean flag) {
|
||||
this.useDateTimeOffsetFlag = flag;
|
||||
if (flag) typeMapping.put("datetime", "DateTimeOffset?");
|
||||
|
@ -181,22 +181,6 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
cliOptions.add(enumPropertyNamingOpt.defaultValue(enumPropertyNaming.name()));
|
||||
}
|
||||
|
||||
protected void addOption(String key, String description) {
|
||||
addOption(key, description, null);
|
||||
}
|
||||
|
||||
protected void addOption(String key, String description, String defaultValue) {
|
||||
CliOption option = new CliOption(key, description);
|
||||
if (defaultValue != null) option.defaultValue(defaultValue);
|
||||
cliOptions.add(option);
|
||||
}
|
||||
|
||||
protected void addSwitch(String key, String description, Boolean defaultValue) {
|
||||
CliOption option = CliOption.newBoolean(key, description);
|
||||
if (defaultValue != null) option.defaultValue(defaultValue.toString());
|
||||
cliOptions.add(option);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiDocFileFolder() {
|
||||
return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar);
|
||||
|
@ -160,13 +160,6 @@ public class CppRestClientCodegen extends AbstractCppCodegen {
|
||||
importMapping.put("utility::datetime", "#include <cpprest/details/basic_types.h>");
|
||||
}
|
||||
|
||||
protected void addOption(String key, String description, String defaultValue) {
|
||||
CliOption option = new CliOption(key, description);
|
||||
if (defaultValue != null)
|
||||
option.defaultValue(defaultValue);
|
||||
cliOptions.add(option);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
@ -159,21 +159,6 @@ public class Qt5CPPGenerator extends AbstractCppCodegen implements CodegenConfig
|
||||
systemIncludes.add("QByteArray");
|
||||
}
|
||||
|
||||
protected void addOption(String key, String description, String defaultValue) {
|
||||
CliOption option = new CliOption(key, description);
|
||||
if (defaultValue != null)
|
||||
option.defaultValue(defaultValue);
|
||||
cliOptions.add(option);
|
||||
}
|
||||
|
||||
protected void addSwitch(String key, String description, Boolean defaultValue) {
|
||||
CliOption option = CliOption.newBoolean(key, description);
|
||||
if (defaultValue != null)
|
||||
option.defaultValue(defaultValue.toString());
|
||||
cliOptions.add(option);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
@ -130,13 +130,6 @@ public class RestbedCodegen extends AbstractCppCodegen {
|
||||
importMapping.put("restbed::Bytes", "#include <corvusoft/restbed/byte.hpp>");
|
||||
}
|
||||
|
||||
protected void addOption(String key, String description, String defaultValue) {
|
||||
CliOption option = new CliOption(key, description);
|
||||
if (defaultValue != null)
|
||||
option.defaultValue(defaultValue);
|
||||
cliOptions.add(option);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
Loading…
x
Reference in New Issue
Block a user