mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 02:55:19 +00:00
Merge pull request #3244 from wing328/java_fix_2d_array_enum
[Java] better default value for variable declaration (with inner enum type)
This commit is contained in:
commit
acc28495e8
@ -1595,14 +1595,10 @@ public class DefaultCodegen {
|
|||||||
// inner item is Enum
|
// inner item is Enum
|
||||||
if (isPropertyInnerMostEnum(property)) {
|
if (isPropertyInnerMostEnum(property)) {
|
||||||
property.isEnum = true;
|
property.isEnum = true;
|
||||||
// update datatypeWithEnum for array
|
// update datatypeWithEnum and default value for array
|
||||||
// e.g. List<string> => List<StatusEnum>
|
// e.g. List<string> => List<StatusEnum>
|
||||||
updateDataTypeWithEnumForArray(property);
|
updateDataTypeWithEnumForArray(property);
|
||||||
|
|
||||||
// TOOD need to revise the default value for enum
|
|
||||||
if (property.defaultValue != null) {
|
|
||||||
property.defaultValue = property.defaultValue.replace(property.items.baseType, property.items.datatypeWithEnum);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1626,15 +1622,9 @@ public class DefaultCodegen {
|
|||||||
// inner item is Enum
|
// inner item is Enum
|
||||||
if (isPropertyInnerMostEnum(property)) {
|
if (isPropertyInnerMostEnum(property)) {
|
||||||
property.isEnum = true;
|
property.isEnum = true;
|
||||||
// update datatypeWithEnum for map
|
// update datatypeWithEnum and default value for map
|
||||||
// e.g. Dictionary<string, string> => Dictionary<string, StatusEnum>
|
// e.g. Dictionary<string, string> => Dictionary<string, StatusEnum>
|
||||||
updateDataTypeWithEnumForMap(property);
|
updateDataTypeWithEnumForMap(property);
|
||||||
|
|
||||||
// TOOD need to revise the default value for enum
|
|
||||||
// set default value
|
|
||||||
if (property.defaultValue != null) {
|
|
||||||
property.defaultValue = property.defaultValue.replace(property.items.baseType, property.items.datatypeWithEnum);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1667,7 +1657,11 @@ public class DefaultCodegen {
|
|||||||
}
|
}
|
||||||
// set both datatype and datetypeWithEnum as only the inner type is enum
|
// set both datatype and datetypeWithEnum as only the inner type is enum
|
||||||
property.datatypeWithEnum = property.datatypeWithEnum.replace(baseItem.baseType, toEnumName(baseItem));
|
property.datatypeWithEnum = property.datatypeWithEnum.replace(baseItem.baseType, toEnumName(baseItem));
|
||||||
//property.datatype = property.datatypeWithEnum;
|
|
||||||
|
// set default value for variable with inner enum
|
||||||
|
if (property.defaultValue != null) {
|
||||||
|
property.defaultValue = property.defaultValue.replace(property.items.baseType, toEnumName(property.items));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1682,7 +1676,11 @@ public class DefaultCodegen {
|
|||||||
}
|
}
|
||||||
// set both datatype and datetypeWithEnum as only the inner type is enum
|
// set both datatype and datetypeWithEnum as only the inner type is enum
|
||||||
property.datatypeWithEnum = property.datatypeWithEnum.replace(", " + baseItem.baseType, ", " + toEnumName(baseItem));
|
property.datatypeWithEnum = property.datatypeWithEnum.replace(", " + baseItem.baseType, ", " + toEnumName(baseItem));
|
||||||
//property.datatype = property.datatypeWithEnum;
|
|
||||||
|
// set default value for variable with inner enum
|
||||||
|
if (property.defaultValue != null) {
|
||||||
|
property.defaultValue = property.defaultValue.replace(", " + property.items.baseType, ", " + toEnumName(property.items));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setNonArrayMapProperty(CodegenProperty property, String type) {
|
protected void setNonArrayMapProperty(CodegenProperty property, String type) {
|
||||||
|
@ -1064,15 +1064,16 @@ definitions:
|
|||||||
type: object
|
type: object
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
type: string
|
type: string
|
||||||
map_map_of_enum:
|
# comment out the following (map of map of enum) as many language not yet support this
|
||||||
type: object
|
#map_map_of_enum:
|
||||||
additionalProperties:
|
# type: object
|
||||||
type: object
|
# additionalProperties:
|
||||||
additionalProperties:
|
# type: object
|
||||||
type: string
|
# additionalProperties:
|
||||||
enum:
|
# type: string
|
||||||
- UPPER
|
# enum:
|
||||||
- lower
|
# - UPPER
|
||||||
|
# - lower
|
||||||
map_of_enum_string:
|
map_of_enum_string:
|
||||||
type: object
|
type: object
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
|
@ -5,16 +5,9 @@
|
|||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
**mapMapOfString** | [**Map<String, Map<String, String>>**](Map.md) | | [optional]
|
**mapMapOfString** | [**Map<String, Map<String, String>>**](Map.md) | | [optional]
|
||||||
**mapMapOfEnum** | [**Map<String, Map<String, InnerEnum>>**](#Map<String, Map<String, InnerEnum>>) | | [optional]
|
|
||||||
**mapOfEnumString** | [**Map<String, InnerEnum>**](#Map<String, InnerEnum>) | | [optional]
|
**mapOfEnumString** | [**Map<String, InnerEnum>**](#Map<String, InnerEnum>) | | [optional]
|
||||||
|
|
||||||
|
|
||||||
<a name="Map<String, Map<String, InnerEnum>>"></a>
|
|
||||||
## Enum: Map<String, Map<String, InnerEnum>>
|
|
||||||
Name | Value
|
|
||||||
---- | -----
|
|
||||||
|
|
||||||
|
|
||||||
<a name="Map<String, InnerEnum>"></a>
|
<a name="Map<String, InnerEnum>"></a>
|
||||||
## Enum: Map<String, InnerEnum>
|
## Enum: Map<String, InnerEnum>
|
||||||
Name | Value
|
Name | Value
|
||||||
|
@ -1 +0,0 @@
|
|||||||
Hello world!
|
|
@ -42,9 +42,6 @@ public class MapTest {
|
|||||||
@SerializedName("map_map_of_string")
|
@SerializedName("map_map_of_string")
|
||||||
private Map<String, Map<String, String>> mapMapOfString = new HashMap<String, Map<String, String>>();
|
private Map<String, Map<String, String>> mapMapOfString = new HashMap<String, Map<String, String>>();
|
||||||
|
|
||||||
@SerializedName("map_map_of_enum")
|
|
||||||
private Map<String, Map<String, InnerEnum>> mapMapOfEnum = new HashMap<String, Map<String, InnerEnum>>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets or Sets inner
|
* Gets or Sets inner
|
||||||
*/
|
*/
|
||||||
@ -88,24 +85,6 @@ public class MapTest {
|
|||||||
this.mapMapOfString = mapMapOfString;
|
this.mapMapOfString = mapMapOfString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapTest mapMapOfEnum(Map<String, Map<String, InnerEnum>> mapMapOfEnum) {
|
|
||||||
this.mapMapOfEnum = mapMapOfEnum;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get mapMapOfEnum
|
|
||||||
* @return mapMapOfEnum
|
|
||||||
**/
|
|
||||||
@ApiModelProperty(example = "null", value = "")
|
|
||||||
public Map<String, Map<String, InnerEnum>> getMapMapOfEnum() {
|
|
||||||
return mapMapOfEnum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMapMapOfEnum(Map<String, Map<String, InnerEnum>> mapMapOfEnum) {
|
|
||||||
this.mapMapOfEnum = mapMapOfEnum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MapTest mapOfEnumString(Map<String, InnerEnum> mapOfEnumString) {
|
public MapTest mapOfEnumString(Map<String, InnerEnum> mapOfEnumString) {
|
||||||
this.mapOfEnumString = mapOfEnumString;
|
this.mapOfEnumString = mapOfEnumString;
|
||||||
return this;
|
return this;
|
||||||
@ -135,13 +114,12 @@ public class MapTest {
|
|||||||
}
|
}
|
||||||
MapTest mapTest = (MapTest) o;
|
MapTest mapTest = (MapTest) o;
|
||||||
return Objects.equals(this.mapMapOfString, mapTest.mapMapOfString) &&
|
return Objects.equals(this.mapMapOfString, mapTest.mapMapOfString) &&
|
||||||
Objects.equals(this.mapMapOfEnum, mapTest.mapMapOfEnum) &&
|
|
||||||
Objects.equals(this.mapOfEnumString, mapTest.mapOfEnumString);
|
Objects.equals(this.mapOfEnumString, mapTest.mapOfEnumString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(mapMapOfString, mapMapOfEnum, mapOfEnumString);
|
return Objects.hash(mapMapOfString, mapOfEnumString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -150,7 +128,6 @@ public class MapTest {
|
|||||||
sb.append("class MapTest {\n");
|
sb.append("class MapTest {\n");
|
||||||
|
|
||||||
sb.append(" mapMapOfString: ").append(toIndentedString(mapMapOfString)).append("\n");
|
sb.append(" mapMapOfString: ").append(toIndentedString(mapMapOfString)).append("\n");
|
||||||
sb.append(" mapMapOfEnum: ").append(toIndentedString(mapMapOfEnum)).append("\n");
|
|
||||||
sb.append(" mapOfEnumString: ").append(toIndentedString(mapOfEnumString)).append("\n");
|
sb.append(" mapOfEnumString: ").append(toIndentedString(mapOfEnumString)).append("\n");
|
||||||
sb.append("}");
|
sb.append("}");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
Loading…
Reference in New Issue
Block a user