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
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ public String toEnumValue(String value, String datatype) {
* @return the sanitized variable name for enum
*/
public String toEnumVarName(String value, String datatype) {
if (value.length() == 0) {
return "EMPTY";
}

String var = value.replaceAll("\\W+", "_").toUpperCase();
if (var.matches("\\d.*")) {
return "_" + var;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,10 @@ public void setSourceFolder(String sourceFolder) {

@Override
public String toEnumVarName(String name, String datatype) {
if (name.length() == 0) {
return "Empty";
}

// for symbol, e.g. $, #
if (getSymbolName(name) != null) {
return camelize(getSymbolName(name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,10 @@ public String toEnumName(CodegenProperty property) {

@Override
public String toEnumVarName(String value, String datatype) {
if (value.length() == 0) {
return "EMPTY";
}

// for symbol, e.g. $, #
if (getSymbolName(value) != null) {
return getSymbolName(value).toUpperCase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,10 @@ public String toEnumDefaultValue(String value, String datatype) {

@Override
public String toEnumVarName(String name, String datatype) {
if (name.length() == 0) {
return "EMPTY";
}

// for symbol, e.g. $, #
if (getSymbolName(name) != null) {
return (getSymbolName(name)).toUpperCase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ public String toEnumDefaultValue(String value, String datatype) {

@Override
public String toEnumVarName(String name, String datatype) {
if (name.length() == 0) {
return "Empty";
}

// for symbol, e.g. $, #
if (getSymbolName(name) != null) {
return camelize(getSymbolName(name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,10 @@ public String toEnumValue(String value, String datatype) {

@Override
public String toEnumVarName(String value, String datatype) {
if (value.length() == 0) {
return "Empty";
}

// for symbol, e.g. $, #
if (getSymbolName(value) != null) {
return camelize(getSymbolName(value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,10 @@ public String toEnumName(CodegenProperty property) {

@Override
public String toEnumVarName(String value, String datatype) {
if (value.length() == 0) {
return "empty";
}

// for symbol, e.g. $, #
if (getSymbolName(value) != null) {
return (getSymbolName(value)).toUpperCase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ public void postProcessModelProperty(final CodegenModel model, final CodegenProp

@Override
public String toEnumVarName(final String name, final String datatype) {
if (name.length() == 0) {
return "Empty";
}

final String enumName = camelize(
sanitizeName(name)
.replaceFirst("^_", "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,10 @@ public String toEnumDefaultValue(String value, String datatype) {

@Override
public String toEnumVarName(String name, String datatype) {
if (name.length() == 0) {
return "EMPTY";
}

// number
if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
String varName = name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,10 @@ public String toEnumValue(String value, String datatype) {

@Override
public String toEnumVarName(String name, String datatype) {
if (name.length() == 0) {
return "EMPTY";
}

// number
if ("Integer".equals(datatype) || "Float".equals(datatype)) {
String varName = name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,10 @@ public String toEnumDefaultValue(String value, String datatype) {

@Override
public String toEnumVarName(String name, String datatype) {
if (name.length() == 0) {
return "empty";
}

// for symbol, e.g. $, #
if (getSymbolName(name) != null) {
return camelize(WordUtils.capitalizeFully(getSymbolName(name).toUpperCase()), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,10 @@ public CodegenProperty fromProperty(String name, Property p) {

@SuppressWarnings("static-method")
public String toSwiftyEnumName(String value) {
if (value.length() == 0) {
return "Empty";
}

if (value.matches("^-?\\d*\\.{0,1}\\d+.*")) { // starts with number
value = "Number" + value;
value = value.replaceAll("-", "Minus");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,7 @@ definitions:
enum:
- UPPER
- lower
- ''
enum_integer:
type: integer
format: int32
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ public enum EnumStringEnum
/// Enum Lower for "lower"
/// </summary>
[EnumMember(Value = "lower")]
Lower
Lower,

/// <summary>
/// Enum Empty for ""
/// </summary>
[EnumMember(Value = "")]
Empty
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ public enum EnumStringEnum
/// Enum Lower for "lower"
/// </summary>
[EnumMember(Value = "lower")]
Lower
Lower,

/// <summary>
/// Enum Empty for ""
/// </summary>
[EnumMember(Value = "")]
Empty
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public class EnumTest {
public enum EnumStringEnum {
UPPER("UPPER"),

LOWER("lower");
LOWER("lower"),

EMPTY("");

private String value;

Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/java/jersey1/docs/EnumTest.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Name | Value
---- | -----
UPPER | &quot;UPPER&quot;
LOWER | &quot;lower&quot;
EMPTY | &quot;&quot;


<a name="EnumIntegerEnum"></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public class EnumTest {
public enum EnumStringEnum {
UPPER("UPPER"),

LOWER("lower");
LOWER("lower"),

EMPTY("");

private String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Name | Value
---- | -----
UPPER | &quot;UPPER&quot;
LOWER | &quot;lower&quot;
EMPTY | &quot;&quot;


<a name="EnumIntegerEnum"></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public class EnumTest {
public enum EnumStringEnum {
UPPER("UPPER"),

LOWER("lower");
LOWER("lower"),

EMPTY("");

private String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Name | Value
---- | -----
UPPER | &quot;UPPER&quot;
LOWER | &quot;lower&quot;
EMPTY | &quot;&quot;


<a name="EnumIntegerEnum"></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public class EnumTest {
public enum EnumStringEnum {
UPPER("UPPER"),

LOWER("lower");
LOWER("lower"),

EMPTY("");

private String value;

Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/java/jersey2/docs/EnumTest.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Name | Value
---- | -----
UPPER | &quot;UPPER&quot;
LOWER | &quot;lower&quot;
EMPTY | &quot;&quot;


<a name="EnumIntegerEnum"></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public class EnumTest {
public enum EnumStringEnum {
UPPER("UPPER"),

LOWER("lower");
LOWER("lower"),

EMPTY("");

private String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Name | Value
---- | -----
UPPER | &quot;UPPER&quot;
LOWER | &quot;lower&quot;
EMPTY | &quot;&quot;


<a name="EnumIntegerEnum"></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ public enum EnumStringEnum {
UPPER("UPPER"),

@SerializedName("lower")
LOWER("lower");
LOWER("lower"),

@SerializedName("")
EMPTY("");

private String value;

Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/java/okhttp-gson/docs/EnumTest.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Name | Value
---- | -----
UPPER | &quot;UPPER&quot;
LOWER | &quot;lower&quot;
EMPTY | &quot;&quot;


<a name="EnumIntegerEnum"></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ public enum EnumStringEnum {
UPPER("UPPER"),

@SerializedName("lower")
LOWER("lower");
LOWER("lower"),

@SerializedName("")
EMPTY("");

private String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ public enum EnumStringEnum {
UPPER("UPPER"),

@SerializedName("lower")
LOWER("lower");
LOWER("lower"),

@SerializedName("")
EMPTY("");

private String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Name | Value
---- | -----
UPPER | &quot;UPPER&quot;
LOWER | &quot;lower&quot;
EMPTY | &quot;&quot;


<a name="EnumIntegerEnum"></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ public class EnumTest {
public enum EnumStringEnum {
UPPER("UPPER"),

LOWER("lower");
LOWER("lower"),

EMPTY("");

private String value;

Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/java/retrofit2/docs/EnumTest.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Name | Value
---- | -----
UPPER | &quot;UPPER&quot;
LOWER | &quot;lower&quot;
EMPTY | &quot;&quot;


<a name="EnumIntegerEnum"></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ public enum EnumStringEnum {
UPPER("UPPER"),

@SerializedName("lower")
LOWER("lower");
LOWER("lower"),

@SerializedName("")
EMPTY("");

private String value;

Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/java/retrofit2rx/docs/EnumTest.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Name | Value
---- | -----
UPPER | &quot;UPPER&quot;
LOWER | &quot;lower&quot;
EMPTY | &quot;&quot;


<a name="EnumIntegerEnum"></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ public enum EnumStringEnum {
UPPER("UPPER"),

@SerializedName("lower")
LOWER("lower");
LOWER("lower"),

@SerializedName("")
EMPTY("");

private String value;

Expand Down
2 changes: 2 additions & 0 deletions samples/client/petstore/javascript-promise/docs/EnumTest.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Name | Type | Description | Notes

* `lower` (value: `"lower"`)

* `empty` (value: `""`)




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,12 @@
* value: "lower"
* @const
*/
"lower": "lower" };
"lower": "lower",
/**
* value: ""
* @const
*/
"empty": "" };

/**
* Allowed values for the <code>enum_integer</code> property.
Expand Down
2 changes: 2 additions & 0 deletions samples/client/petstore/javascript/docs/EnumTest.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Name | Type | Description | Notes

* `lower` (value: `"lower"`)

* `empty` (value: `""`)




Expand Down
Loading