mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2026-03-18 05:39:21 +00:00
Add CodegenProperty.nameInSnakeCase (#42)
This commit is contained in:
@@ -68,6 +68,7 @@ public class CodegenProperty implements Cloneable {
|
||||
public boolean isInherited;
|
||||
public String discriminatorValue;
|
||||
public String nameInCamelCase; // property name in camel case
|
||||
public String nameInSnakeCase; // property name in upper snake case
|
||||
// enum name based on the property name, usually use as a prefix (e.g. VAR_NAME) for enum name (e.g. VAR_NAME_VALUE1)
|
||||
public String enumName;
|
||||
public Integer maxItems;
|
||||
@@ -344,6 +345,10 @@ public class CodegenProperty implements Cloneable {
|
||||
this.nameInCamelCase = nameInCamelCase;
|
||||
}
|
||||
|
||||
public String getNameInSnakeCase() {
|
||||
return nameInSnakeCase;
|
||||
}
|
||||
|
||||
public String getEnumName() {
|
||||
return enumName;
|
||||
}
|
||||
@@ -456,6 +461,7 @@ public class CodegenProperty implements Cloneable {
|
||||
result = prime * result + Objects.hashCode(isInherited);
|
||||
result = prime * result + Objects.hashCode(discriminatorValue);
|
||||
result = prime * result + Objects.hashCode(nameInCamelCase);
|
||||
result = prime * result + Objects.hashCode(nameInSnakeCase);
|
||||
result = prime * result + Objects.hashCode(enumName);
|
||||
result = prime * result + ((maxItems == null) ? 0 : maxItems.hashCode());
|
||||
result = prime * result + ((minItems == null) ? 0 : minItems.hashCode());
|
||||
@@ -642,6 +648,9 @@ public class CodegenProperty implements Cloneable {
|
||||
if (!Objects.equals(this.nameInCamelCase, other.nameInCamelCase)) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(this.nameInSnakeCase, other.nameInSnakeCase)) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(this.enumName, other.enumName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package org.openapitools.codegen;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.samskivert.mustache.Mustache.Compiler;
|
||||
|
||||
import io.swagger.v3.core.util.Json;
|
||||
@@ -1636,6 +1637,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
property.name = toVarName(name);
|
||||
property.baseName = name;
|
||||
property.nameInCamelCase = camelize(property.name, false);
|
||||
property.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, property.nameInCamelCase);
|
||||
property.description = escapeText(p.getDescription());
|
||||
property.unescapedDescription = p.getDescription();
|
||||
property.title = p.getTitle();
|
||||
|
||||
Reference in New Issue
Block a user