mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-04 06:30:52 +00:00
CliOption hah been change to allow enum values
This commit is contained in:
parent
dadc85b6fd
commit
5d8c23dd09
@ -20,7 +20,7 @@ public class ConfigHelp implements Runnable {
|
||||
System.out.println("CONFIG OPTIONS");
|
||||
for (CliOption langCliOption : config.cliOptions()) {
|
||||
System.out.println("\t" + langCliOption.getOpt());
|
||||
System.out.println("\t " + langCliOption.getDescription().replaceAll("\n", "\n\t "));
|
||||
System.out.println("\t " + langCliOption.getOptionHelp().replaceAll("\n", "\n\t "));
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,25 @@
|
||||
package io.swagger.codegen;
|
||||
|
||||
import io.swagger.models.properties.StringProperty;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CliOption {
|
||||
private final String opt;
|
||||
private String description;
|
||||
private String type;
|
||||
private String defaultValue;
|
||||
private Map<String, String> enumValues;
|
||||
|
||||
public CliOption(String opt, String description) {
|
||||
this(opt, description, StringProperty.TYPE);
|
||||
}
|
||||
|
||||
public CliOption(String opt, String description, String type) {
|
||||
this.opt = opt;
|
||||
this.description = description;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getOpt() {
|
||||
@ -20,4 +33,49 @@ public class CliOption {
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getDefault() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public void setDefault(String defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public CliOption addEnum(String value, String description) {
|
||||
if (this.enumValues == null) {
|
||||
this.enumValues = new LinkedHashMap<String, String>();
|
||||
}
|
||||
if (!enumValues.containsKey(value)) {
|
||||
enumValues.put(value, description);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Map<String, String> getEnum() {
|
||||
return enumValues;
|
||||
}
|
||||
|
||||
public void setEnum(Map<String, String> enumValues) {
|
||||
this.enumValues = enumValues;
|
||||
this.type = "enum";
|
||||
}
|
||||
|
||||
public String getOptionHelp() {
|
||||
StringBuilder sb = new StringBuilder(description);
|
||||
if (enumValues != null) {
|
||||
for (Map.Entry<String, String> entry : enumValues.entrySet()) {
|
||||
sb.append("\n").append(entry.getKey()).append(" - ").append(entry.getValue());
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +96,9 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
supportedLibraries.put("jersey2", "HTTP client: Jersey client 2.6");
|
||||
supportedLibraries.put("okhttp-gson", "HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1");
|
||||
supportedLibraries.put("retrofit", "HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1 (Retrofit 1.9.0)");
|
||||
cliOptions.add(buildLibraryCliOption(supportedLibraries));
|
||||
CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use:");
|
||||
library.setEnum(supportedLibraries);
|
||||
cliOptions.add(library);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user