mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-18 22:17:05 +00:00
[BUG][Kotlin Client] API using case other than camelCase not generated properly (#2391)
* Add Json import for all data classes * Add `@Json` annotation for data class required variables * Add `@json` annotation for data class optional variables * Update samples code (petstore, strings, threetenbp) * Fix annotation to match Kotlin coding style
This commit is contained in:
committed by
William Cheng
parent
6e7c621629
commit
81c57eefd5
@@ -12,6 +12,7 @@
|
||||
package org.openapitools.client.models
|
||||
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
/**
|
||||
* Describes the result of uploading an image resource
|
||||
* @param code
|
||||
@@ -19,8 +20,11 @@ package org.openapitools.client.models
|
||||
* @param message
|
||||
*/
|
||||
data class ApiResponse (
|
||||
@Json(name = "code")
|
||||
val code: kotlin.Int? = null,
|
||||
@Json(name = "type")
|
||||
val type: kotlin.String? = null,
|
||||
@Json(name = "message")
|
||||
val message: kotlin.String? = null
|
||||
) {
|
||||
|
||||
|
||||
@@ -12,13 +12,16 @@
|
||||
package org.openapitools.client.models
|
||||
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
/**
|
||||
* A category for a pet
|
||||
* @param id
|
||||
* @param name
|
||||
*/
|
||||
data class Category (
|
||||
@Json(name = "id")
|
||||
val id: kotlin.Long? = null,
|
||||
@Json(name = "name")
|
||||
val name: kotlin.String? = null
|
||||
) {
|
||||
|
||||
|
||||
@@ -23,12 +23,18 @@ import com.squareup.moshi.Json
|
||||
* @param complete
|
||||
*/
|
||||
data class Order (
|
||||
@Json(name = "id")
|
||||
val id: kotlin.Long? = null,
|
||||
@Json(name = "petId")
|
||||
val petId: kotlin.Long? = null,
|
||||
@Json(name = "quantity")
|
||||
val quantity: kotlin.Int? = null,
|
||||
@Json(name = "shipDate")
|
||||
val shipDate: java.time.LocalDateTime? = null,
|
||||
/* Order Status */
|
||||
@Json(name = "status")
|
||||
val status: Order.Status? = null,
|
||||
@Json(name = "complete")
|
||||
val complete: kotlin.Boolean? = null
|
||||
) {
|
||||
|
||||
@@ -38,11 +44,14 @@ data class Order (
|
||||
*/
|
||||
enum class Status(val value: kotlin.String){
|
||||
|
||||
@Json(name = "placed") placed("placed"),
|
||||
@Json(name = "placed")
|
||||
placed("placed"),
|
||||
|
||||
@Json(name = "approved") approved("approved"),
|
||||
@Json(name = "approved")
|
||||
approved("approved"),
|
||||
|
||||
@Json(name = "delivered") delivered("delivered");
|
||||
@Json(name = "delivered")
|
||||
delivered("delivered");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -25,12 +25,18 @@ import com.squareup.moshi.Json
|
||||
* @param status pet status in the store
|
||||
*/
|
||||
data class Pet (
|
||||
@Json(name = "name")
|
||||
val name: kotlin.String,
|
||||
@Json(name = "photoUrls")
|
||||
val photoUrls: kotlin.Array<kotlin.String>,
|
||||
@Json(name = "id")
|
||||
val id: kotlin.Long? = null,
|
||||
@Json(name = "category")
|
||||
val category: Category? = null,
|
||||
@Json(name = "tags")
|
||||
val tags: kotlin.Array<Tag>? = null,
|
||||
/* pet status in the store */
|
||||
@Json(name = "status")
|
||||
val status: Pet.Status? = null
|
||||
) {
|
||||
|
||||
@@ -40,11 +46,14 @@ data class Pet (
|
||||
*/
|
||||
enum class Status(val value: kotlin.String){
|
||||
|
||||
@Json(name = "available") available("available"),
|
||||
@Json(name = "available")
|
||||
available("available"),
|
||||
|
||||
@Json(name = "pending") pending("pending"),
|
||||
@Json(name = "pending")
|
||||
pending("pending"),
|
||||
|
||||
@Json(name = "sold") sold("sold");
|
||||
@Json(name = "sold")
|
||||
sold("sold");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -12,13 +12,16 @@
|
||||
package org.openapitools.client.models
|
||||
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
/**
|
||||
* A tag for a pet
|
||||
* @param id
|
||||
* @param name
|
||||
*/
|
||||
data class Tag (
|
||||
@Json(name = "id")
|
||||
val id: kotlin.Long? = null,
|
||||
@Json(name = "name")
|
||||
val name: kotlin.String? = null
|
||||
) {
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
package org.openapitools.client.models
|
||||
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
/**
|
||||
* A User who is purchasing from the pet store
|
||||
* @param id
|
||||
@@ -24,14 +25,22 @@ package org.openapitools.client.models
|
||||
* @param userStatus User Status
|
||||
*/
|
||||
data class User (
|
||||
@Json(name = "id")
|
||||
val id: kotlin.Long? = null,
|
||||
@Json(name = "username")
|
||||
val username: kotlin.String? = null,
|
||||
@Json(name = "firstName")
|
||||
val firstName: kotlin.String? = null,
|
||||
@Json(name = "lastName")
|
||||
val lastName: kotlin.String? = null,
|
||||
@Json(name = "email")
|
||||
val email: kotlin.String? = null,
|
||||
@Json(name = "password")
|
||||
val password: kotlin.String? = null,
|
||||
@Json(name = "phone")
|
||||
val phone: kotlin.String? = null,
|
||||
/* User Status */
|
||||
@Json(name = "userStatus")
|
||||
val userStatus: kotlin.Int? = null
|
||||
) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user