forked from loafle/openapi-generator-original
[kotlin][client] Add Jackson to interface properties and remove extra line feed (#5459)
* [kotlin][client] Ensure Jackson annotations are consistent with interface vars * [kotlin][client] Rebuild samples * [kotlin][client] Some kotlin client enhancements - Don't use JsonFormat for Date objects, this should be controlled via a custom serializer/deserializer or a turning on and off serialization features of Jackson. I've updated the jacksonObjectMapper config to write the dates as strings, which I think was intended in the original commit. https://fasterxml.github.io/jackson-databind/javadoc/2.6/com/fasterxml/jackson/databind/SerializationFeature.html#WRITE_DATES_AS_TIMESTAMPS https://fasterxml.github.io/jackson-databind/javadoc/2.6/com/fasterxml/jackson/databind/cfg/MapperConfig.html#getDateFormat-- - Dont' use @JsonFormat(shape = JsonFormat.Shape.OBJECT) for enums. This causes Enums to be formatted as objects with an internal "value" field. In reality, OpenAPI enums are just strings without properties and should be treated as a string. https://www.baeldung.com/jackson-serialize-enums#2-enum-as-json-object - Add's Kotlin use site annotation @get: to JsonProperty for parent interface properties. Otherwise Kotlin will warn: "This annotation is not applicable to target 'member property without backing field or delegate'" - Add's JsonTypeInfo annotations to interfaces for inheritance. This was copied verbatim from the kotlin-spring generator. https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/kotlin-spring/typeInfoAnnotation.mustache * [kotlin][client] Rebuild kotlin samples
This commit is contained in:
@@ -23,14 +23,11 @@ import java.io.Serializable
|
||||
|
||||
data class ApiResponse (
|
||||
@Json(name = "code")
|
||||
val code: kotlin.Int? = null
|
||||
,
|
||||
val code: kotlin.Int? = null,
|
||||
@Json(name = "type")
|
||||
val type: kotlin.String? = null
|
||||
,
|
||||
val type: kotlin.String? = null,
|
||||
@Json(name = "message")
|
||||
val message: kotlin.String? = null
|
||||
|
||||
) : Serializable {
|
||||
companion object {
|
||||
private const val serialVersionUID: Long = 123
|
||||
|
||||
@@ -22,11 +22,9 @@ import java.io.Serializable
|
||||
|
||||
data class Category (
|
||||
@Json(name = "id")
|
||||
val id: kotlin.Long? = null
|
||||
,
|
||||
val id: kotlin.Long? = null,
|
||||
@Json(name = "name")
|
||||
val name: kotlin.String? = null
|
||||
|
||||
) : Serializable {
|
||||
companion object {
|
||||
private const val serialVersionUID: Long = 123
|
||||
|
||||
@@ -26,24 +26,18 @@ import java.io.Serializable
|
||||
|
||||
data class Order (
|
||||
@Json(name = "id")
|
||||
val id: kotlin.Long? = null
|
||||
,
|
||||
val id: kotlin.Long? = null,
|
||||
@Json(name = "petId")
|
||||
val petId: kotlin.Long? = null
|
||||
,
|
||||
val petId: kotlin.Long? = null,
|
||||
@Json(name = "quantity")
|
||||
val quantity: kotlin.Int? = null
|
||||
,
|
||||
val quantity: kotlin.Int? = null,
|
||||
@Json(name = "shipDate")
|
||||
val shipDate: kotlin.String? = null
|
||||
,
|
||||
val shipDate: kotlin.String? = null,
|
||||
/* Order Status */
|
||||
@Json(name = "status")
|
||||
val status: Order.Status? = null
|
||||
,
|
||||
val status: Order.Status? = null,
|
||||
@Json(name = "complete")
|
||||
val complete: kotlin.Boolean? = null
|
||||
|
||||
) : Serializable {
|
||||
companion object {
|
||||
private const val serialVersionUID: Long = 123
|
||||
@@ -54,7 +48,6 @@ data class Order (
|
||||
* Values: placed,approved,delivered
|
||||
*/
|
||||
|
||||
|
||||
enum class Status(val value: kotlin.String){
|
||||
@Json(name = "placed") placed("placed"),
|
||||
@Json(name = "approved") approved("approved"),
|
||||
|
||||
@@ -28,24 +28,18 @@ import java.io.Serializable
|
||||
|
||||
data class Pet (
|
||||
@Json(name = "id")
|
||||
val id: kotlin.Long? = null
|
||||
,
|
||||
val id: kotlin.Long? = null,
|
||||
@Json(name = "category")
|
||||
val category: Category? = null
|
||||
,
|
||||
val category: Category? = null,
|
||||
@Json(name = "name")
|
||||
val name: kotlin.String
|
||||
,
|
||||
val name: kotlin.String,
|
||||
@Json(name = "photoUrls")
|
||||
val photoUrls: kotlin.Array<kotlin.String>
|
||||
,
|
||||
val photoUrls: kotlin.Array<kotlin.String>,
|
||||
@Json(name = "tags")
|
||||
val tags: kotlin.Array<Tag>? = null
|
||||
,
|
||||
val tags: kotlin.Array<Tag>? = null,
|
||||
/* pet status in the store */
|
||||
@Json(name = "status")
|
||||
val status: Pet.Status? = null
|
||||
|
||||
) : Serializable {
|
||||
companion object {
|
||||
private const val serialVersionUID: Long = 123
|
||||
@@ -56,7 +50,6 @@ data class Pet (
|
||||
* Values: available,pending,sold
|
||||
*/
|
||||
|
||||
|
||||
enum class Status(val value: kotlin.String){
|
||||
@Json(name = "available") available("available"),
|
||||
@Json(name = "pending") pending("pending"),
|
||||
|
||||
@@ -22,11 +22,9 @@ import java.io.Serializable
|
||||
|
||||
data class Tag (
|
||||
@Json(name = "id")
|
||||
val id: kotlin.Long? = null
|
||||
,
|
||||
val id: kotlin.Long? = null,
|
||||
@Json(name = "name")
|
||||
val name: kotlin.String? = null
|
||||
|
||||
) : Serializable {
|
||||
companion object {
|
||||
private const val serialVersionUID: Long = 123
|
||||
|
||||
@@ -28,30 +28,22 @@ import java.io.Serializable
|
||||
|
||||
data class User (
|
||||
@Json(name = "id")
|
||||
val id: kotlin.Long? = null
|
||||
,
|
||||
val id: kotlin.Long? = null,
|
||||
@Json(name = "username")
|
||||
val username: kotlin.String? = null
|
||||
,
|
||||
val username: kotlin.String? = null,
|
||||
@Json(name = "firstName")
|
||||
val firstName: kotlin.String? = null
|
||||
,
|
||||
val firstName: kotlin.String? = null,
|
||||
@Json(name = "lastName")
|
||||
val lastName: kotlin.String? = null
|
||||
,
|
||||
val lastName: kotlin.String? = null,
|
||||
@Json(name = "email")
|
||||
val email: kotlin.String? = null
|
||||
,
|
||||
val email: kotlin.String? = null,
|
||||
@Json(name = "password")
|
||||
val password: kotlin.String? = null
|
||||
,
|
||||
val password: kotlin.String? = null,
|
||||
@Json(name = "phone")
|
||||
val phone: kotlin.String? = null
|
||||
,
|
||||
val phone: kotlin.String? = null,
|
||||
/* User Status */
|
||||
@Json(name = "userStatus")
|
||||
val userStatus: kotlin.Int? = null
|
||||
|
||||
) : Serializable {
|
||||
companion object {
|
||||
private const val serialVersionUID: Long = 123
|
||||
|
||||
Reference in New Issue
Block a user