Open menesty opened 11 months ago
Use "generatorName": "java-micronaut-server", "serializationLibrary": "micronaut_serde_jackson", "modelPropertyNaming": "original"
Have a model:
Battery: type: object properties: battery_id: type: string slot_id: type: integer format: int32 lock_status: type: integer format: int32 battery_capacity: type: integer format: int32 battery_abnormal: type: integer format: int32 cable_abnormal: type: integer format: int3
openapi: 3.0.1
@io.micronaut.serde.annotation.Serdeable @Generated(value="org.openapitools.codegen.languages.JavaMicronautServerCodegen") @Introspected public class Battery { public static final String JSON_PROPERTY_BATTERY_ID = "battery_id"; private String batteryId; public static final String JSON_PROPERTY_SLOT_ID = "slot_id"; private Integer slotId; public static final String JSON_PROPERTY_LOCK_STATUS = "lock_status"; private Integer lockStatus; public static final String JSON_PROPERTY_BATTERY_CAPACITY = "battery_capacity"; private Integer batteryCapacity; public static final String JSON_PROPERTY_BATTERY_ABNORMAL = "battery_abnormal"; private Integer batteryAbnormal; public static final String JSON_PROPERTY_CABLE_ABNORMAL = "cable_abnormal"; private Integer cableAbnormal; public Battery() { } public Battery batteryId(String batteryId) { this.batteryId = batteryId; return this; } /** * Get batteryId * @return batteryId **/ @Nullable @Schema(name = "battery_id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public String getBatteryId() { return batteryId; } public void setBatteryId(String batteryId) { this.batteryId = batteryId; } public Battery slotId(Integer slotId) { this.slotId = slotId; return this; } /** * Get slotId * @return slotId **/ @Nullable @Schema(name = "slot_id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public Integer getSlotId() { return slotId; } public void setSlotId(Integer slotId) { this.slotId = slotId; } public Battery lockStatus(Integer lockStatus) { this.lockStatus = lockStatus; return this; } /** * Get lockStatus * @return lockStatus **/ @Nullable @Schema(name = "lock_status", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public Integer getLockStatus() { return lockStatus; } public void setLockStatus(Integer lockStatus) { this.lockStatus = lockStatus; } public Battery batteryCapacity(Integer batteryCapacity) { this.batteryCapacity = batteryCapacity; return this; } /** * Get batteryCapacity * @return batteryCapacity **/ @Nullable @Schema(name = "battery_capacity", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public Integer getBatteryCapacity() { return batteryCapacity; } public void setBatteryCapacity(Integer batteryCapacity) { this.batteryCapacity = batteryCapacity; } public Battery batteryAbnormal(Integer batteryAbnormal) { this.batteryAbnormal = batteryAbnormal; return this; } /** * Get batteryAbnormal * @return batteryAbnormal **/ @Nullable @Schema(name = "battery_abnormal", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public Integer getBatteryAbnormal() { return batteryAbnormal; } public void setBatteryAbnormal(Integer batteryAbnormal) { this.batteryAbnormal = batteryAbnormal; } public Battery cableAbnormal(Integer cableAbnormal) { this.cableAbnormal = cableAbnormal; return this; } /** * Get cableAbnormal * @return cableAbnormal **/ @Nullable @Schema(name = "cable_abnormal", requiredMode = Schema.RequiredMode.NOT_REQUIRED) public Integer getCableAbnormal() { return cableAbnormal; } public void setCableAbnormal(Integer cableAbnormal) { this.cableAbnormal = cableAbnormal; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Battery battery = (Battery) o; return Objects.equals(this.batteryId, battery.batteryId) && Objects.equals(this.slotId, battery.slotId) && Objects.equals(this.lockStatus, battery.lockStatus) && Objects.equals(this.batteryCapacity, battery.batteryCapacity) && Objects.equals(this.batteryAbnormal, battery.batteryAbnormal) && Objects.equals(this.cableAbnormal, battery.cableAbnormal); } @Override public int hashCode() { return Objects.hash(batteryId, slotId, lockStatus, batteryCapacity, batteryAbnormal, cableAbnormal); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Battery {\n"); sb.append(" batteryId: ").append(toIndentedString(batteryId)).append("\n"); sb.append(" slotId: ").append(toIndentedString(slotId)).append("\n"); sb.append(" lockStatus: ").append(toIndentedString(lockStatus)).append("\n"); sb.append(" batteryCapacity: ").append(toIndentedString(batteryCapacity)).append("\n"); sb.append(" batteryAbnormal: ").append(toIndentedString(batteryAbnormal)).append("\n"); sb.append(" cableAbnormal: ").append(toIndentedString(cableAbnormal)).append("\n"); sb.append("}"); return sb.toString(); } /** * Convert the given object to string with each line indented by 4 spaces * (except the first line). */ private String toIndentedString(Object o) { if (o == null) { return "null"; } return o.toString().replace("\n", "\n "); } }
Input json
{ "battery_id": "F30001E622", "slot_id": "1", "lock_status": "1", "battery_capacity": "0", "battery_abnormal": "0", "cable_abnormal": "0" }
not de serialize only camel case property batteryId
it is possible add to property add @JsonProperty("battery_id")
@menesty Already fixed. Just use official micronaut generator from here: https://github.com/micronaut-projects/micronaut-openapi
Use "generatorName": "java-micronaut-server", "serializationLibrary": "micronaut_serde_jackson", "modelPropertyNaming": "original"
Description
Have a model:
openapi-generator version
openapi: 3.0.1
generated model look
Input json
not de serialize only camel case property batteryId
it is possible add to property add @JsonProperty("battery_id")