Skip to content

[BUG][Kotlin Client] API using case other than camelCase not generated properly #2391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{#hasEnums}}
import com.squareup.moshi.Json
{{/hasEnums}}
{{#parcelizeModels}}
import android.os.Parcelable
import kotlinx.android.parcel.Parcelize
Expand Down Expand Up @@ -29,7 +27,8 @@ data class {{classname}} (
*/
enum class {{nameInCamelCase}}(val value: {{dataType}}){
{{#allowableValues}}{{#enumVars}}
@Json(name = {{{value}}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
@Json(name = {{{value}}})
{{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
{{/enumVars}}{{/allowableValues}}
}
{{/isEnum}}{{/vars}}{{/hasEnums}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{#description}}
/* {{{description}}} */
{{/description}}
@Json(name = "{{{baseName}}}")
val {{{name}}}: {{#isEnum}}{{classname}}.{{nameInCamelCase}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = {{#defaultvalue}}{{defaultvalue}}{{/defaultvalue}}{{^defaultvalue}}null{{/defaultvalue}}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{#description}}
/* {{{description}}} */
{{/description}}
@Json(name = "{{{baseName}}}")
val {{{name}}}: {{#isEnum}}{{classname}}.{{nameInCamelCase}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.squareup.moshi.Json
*/
enum class {{classname}}(val value: {{dataType}}){
{{#allowableValues}}{{#enumVars}}
@Json(name = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
@Json(name = {{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}})
{{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
{{/enumVars}}{{/allowableValues}}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@
package org.openapitools.client.models


import com.squareup.moshi.Json
/**
* Describes the result of uploading an image resource
* @param code
* @param type
* @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
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: kotlin.String? = null,
/* Order Status */
@Json(name = "status")
val status: Order.Status? = null,
@Json(name = "complete")
val complete: kotlin.Boolean? = null
) {

Expand All @@ -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");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {

Expand All @@ -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");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@ package org.openapitools.client.models

import org.threeten.bp.LocalDateTime

import com.squareup.moshi.Json
/**
* Describes the result of uploading an image resource
* @param code
* @param type
* @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
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ package org.openapitools.client.models

import org.threeten.bp.LocalDateTime

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
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,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: org.threeten.bp.LocalDateTime? = null,
/* Order Status */
@Json(name = "status")
val status: Order.Status? = null,
@Json(name = "complete")
val complete: kotlin.Boolean? = null
) {

Expand All @@ -39,11 +45,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");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,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
) {

Expand All @@ -41,11 +47,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");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ package org.openapitools.client.models

import org.threeten.bp.LocalDateTime

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
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ package org.openapitools.client.models

import org.threeten.bp.LocalDateTime

import com.squareup.moshi.Json
/**
* A User who is purchasing from the pet store
* @param id
Expand All @@ -25,14 +26,22 @@ import org.threeten.bp.LocalDateTime
* @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
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@
package org.openapitools.client.models


import com.squareup.moshi.Json
/**
* Describes the result of uploading an image resource
* @param code
* @param type
* @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
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {

Expand Down
Loading