forked from loafle/openapi-generator-original
Co-authored-by: Renato Mameli <renato.mameli@teamviewer.com>
This commit is contained in:
parent
9398c6444a
commit
bfa26ea6be
@ -2055,7 +2055,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
|
||||
// string
|
||||
String var = value.replaceAll("\\W+", "_").toUpperCase(Locale.ROOT);
|
||||
String var = underscore(value.replaceAll("\\W+", "_")).toUpperCase(Locale.ROOT);
|
||||
if (var.matches("\\d.*")) {
|
||||
var = "_" + var;
|
||||
}
|
||||
|
@ -61,6 +61,13 @@ public class AbstractJavaCodegenTest {
|
||||
Assert.assertEquals(fakeJavaCodegen.toEnumVarName("==", "String"), "u");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toEnumVarNameAddUnderscoresIfValueIsPascalCase() {
|
||||
Assert.assertEquals(fakeJavaCodegen.toEnumVarName("OnlyCamelCase", "String"), "ONLY_CAMEL_CASE");
|
||||
Assert.assertEquals(fakeJavaCodegen.toEnumVarName("WithNumber1", "String"), "WITH_NUMBER1");
|
||||
Assert.assertEquals(fakeJavaCodegen.toEnumVarName("_LeadingUnderscore", "String"), "_LEADING_UNDERSCORE");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toVarNameShouldAvoidOverloadingGetClassMethod() throws Exception {
|
||||
Assert.assertEquals(fakeJavaCodegen.toVarName("class"), "propertyClass");
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
| SOMEOBJIDENTIFIER | "SomeObjIdentifier" |
|
||||
| SOME_OBJ_IDENTIFIER | "SomeObjIdentifier" |
|
||||
|
||||
|
||||
## Implemented Interfaces
|
||||
|
@ -59,7 +59,7 @@ public class SomeObj implements Serializable {
|
||||
*/
|
||||
@JsonAdapter(TypeEnum.Adapter.class)
|
||||
public enum TypeEnum {
|
||||
SOMEOBJIDENTIFIER("SomeObjIdentifier");
|
||||
SOME_OBJ_IDENTIFIER("SomeObjIdentifier");
|
||||
|
||||
private String value;
|
||||
|
||||
@ -106,7 +106,7 @@ public class SomeObj implements Serializable {
|
||||
|
||||
public static final String SERIALIZED_NAME_$_TYPE = "$_type";
|
||||
@SerializedName(SERIALIZED_NAME_$_TYPE)
|
||||
private TypeEnum $type = TypeEnum.SOMEOBJIDENTIFIER;
|
||||
private TypeEnum $type = TypeEnum.SOME_OBJ_IDENTIFIER;
|
||||
|
||||
public static final String SERIALIZED_NAME_ID = "id";
|
||||
@SerializedName(SERIALIZED_NAME_ID)
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
| CHILDWITHNULLABLE | "ChildWithNullable" |
|
||||
| CHILD_WITH_NULLABLE | "ChildWithNullable" |
|
||||
|
||||
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class ParentWithNullable {
|
||||
|
||||
public enum TypeEnum {
|
||||
|
||||
CHILDWITHNULLABLE(String.valueOf("ChildWithNullable"));
|
||||
CHILD_WITH_NULLABLE(String.valueOf("ChildWithNullable"));
|
||||
|
||||
String value;
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
| CHILDWITHNULLABLE | "ChildWithNullable" |
|
||||
| CHILD_WITH_NULLABLE | "ChildWithNullable" |
|
||||
|
||||
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class ParentWithNullable {
|
||||
|
||||
public enum TypeEnum {
|
||||
|
||||
CHILDWITHNULLABLE(String.valueOf("ChildWithNullable"));
|
||||
CHILD_WITH_NULLABLE(String.valueOf("ChildWithNullable"));
|
||||
|
||||
String value;
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
| CHILDWITHNULLABLE | "ChildWithNullable" |
|
||||
| CHILD_WITH_NULLABLE | "ChildWithNullable" |
|
||||
|
||||
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class ParentWithNullable {
|
||||
|
||||
public enum TypeEnum {
|
||||
|
||||
CHILDWITHNULLABLE(String.valueOf("ChildWithNullable"));
|
||||
CHILD_WITH_NULLABLE(String.valueOf("ChildWithNullable"));
|
||||
|
||||
String value;
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
| CHILDWITHNULLABLE | "ChildWithNullable" |
|
||||
| CHILD_WITH_NULLABLE | "ChildWithNullable" |
|
||||
|
||||
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
| CHILDCAT | "ChildCat" |
|
||||
| CHILD_CAT | "ChildCat" |
|
||||
|
||||
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
| CHILDCAT | "ChildCat" |
|
||||
| CHILD_CAT | "ChildCat" |
|
||||
|
||||
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
| CHILDCAT | "ChildCat" |
|
||||
| CHILD_CAT | "ChildCat" |
|
||||
|
||||
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
| CHILDWITHNULLABLE | "ChildWithNullable" |
|
||||
| CHILD_WITH_NULLABLE | "ChildWithNullable" |
|
||||
|
||||
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
| CHILDWITHNULLABLE | "ChildWithNullable" |
|
||||
| CHILD_WITH_NULLABLE | "ChildWithNullable" |
|
||||
|
||||
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
| CHILDWITHNULLABLE | "ChildWithNullable" |
|
||||
| CHILD_WITH_NULLABLE | "ChildWithNullable" |
|
||||
|
||||
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
| CHILDWITHNULLABLE | "ChildWithNullable" |
|
||||
| CHILD_WITH_NULLABLE | "ChildWithNullable" |
|
||||
|
||||
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class ParentWithNullable {
|
||||
@XmlEnum(String.class)
|
||||
public enum TypeEnum {
|
||||
@XmlEnumValue("ChildWithNullable")
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
| CHILDWITHNULLABLE | "ChildWithNullable" |
|
||||
| CHILD_WITH_NULLABLE | "ChildWithNullable" |
|
||||
|
||||
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
| CHILDWITHNULLABLE | "ChildWithNullable" |
|
||||
| CHILD_WITH_NULLABLE | "ChildWithNullable" |
|
||||
|
||||
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
| CHILDWITHNULLABLE | "ChildWithNullable" |
|
||||
| CHILD_WITH_NULLABLE | "ChildWithNullable" |
|
||||
|
||||
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
| CHILDWITHNULLABLE | "ChildWithNullable" |
|
||||
| CHILD_WITH_NULLABLE | "ChildWithNullable" |
|
||||
|
||||
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
| CHILDWITHNULLABLE | "ChildWithNullable" |
|
||||
| CHILD_WITH_NULLABLE | "ChildWithNullable" |
|
||||
|
||||
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class ParentWithNullableDto {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
| CHILDCAT | "ChildCat" |
|
||||
| CHILD_CAT | "ChildCat" |
|
||||
|
||||
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class ParentWithNullable {
|
||||
|
||||
public enum TypeEnum {
|
||||
|
||||
CHILDWITHNULLABLE(String.valueOf("ChildWithNullable"));
|
||||
CHILD_WITH_NULLABLE(String.valueOf("ChildWithNullable"));
|
||||
|
||||
|
||||
private String value;
|
||||
|
@ -18,7 +18,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class ParentWithNullable {
|
||||
|
||||
public enum TypeEnum {
|
||||
|
||||
CHILDWITHNULLABLE(String.valueOf("ChildWithNullable"));
|
||||
CHILD_WITH_NULLABLE(String.valueOf("ChildWithNullable"));
|
||||
|
||||
|
||||
private String value;
|
||||
|
@ -43,7 +43,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -26,7 +26,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
public class ParentWithNullable implements Serializable {
|
||||
public enum TypeEnum {
|
||||
|
||||
CHILDWITHNULLABLE(String.valueOf("ChildWithNullable"));
|
||||
CHILD_WITH_NULLABLE(String.valueOf("ChildWithNullable"));
|
||||
|
||||
|
||||
private String value;
|
||||
|
@ -28,7 +28,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
public class ParentWithNullable implements Serializable {
|
||||
public enum TypeEnum {
|
||||
|
||||
CHILDWITHNULLABLE(String.valueOf("ChildWithNullable"));
|
||||
CHILD_WITH_NULLABLE(String.valueOf("ChildWithNullable"));
|
||||
|
||||
|
||||
private String value;
|
||||
|
@ -42,7 +42,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class ParentWithNullable {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class ParentWithNullableDto {
|
||||
* Gets or Sets type
|
||||
*/
|
||||
public enum TypeEnum {
|
||||
CHILDWITHNULLABLE("ChildWithNullable");
|
||||
CHILD_WITH_NULLABLE("ChildWithNullable");
|
||||
|
||||
private String value;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user