forked from loafle/openapi-generator-original
Ensure enum classes toString() returns kotlin.String (#16247)
When creating an enum where a valid value is `String`, the override of toString() will be the wrong type. Simply using `*kotlin*.String` will allow using `String` as a value in an enum.
This commit is contained in:
parent
6a8039c672
commit
75b04bb965
@ -74,7 +74,7 @@ import kotlinx.serialization.*
|
|||||||
* This solves a problem when the variable name and its value are different, and ensures that
|
* This solves a problem when the variable name and its value are different, and ensures that
|
||||||
* the client sends the correct enum values to the server always.
|
* the client sends the correct enum values to the server always.
|
||||||
*/
|
*/
|
||||||
override fun toString(): String = value{{^isString}}.toString(){{/isString}}
|
override fun toString(): kotlin.String = value{{^isString}}.toString(){{/isString}}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
/**
|
/**
|
||||||
|
@ -48,7 +48,7 @@ enum class PetEnum(val value: kotlin.String) {
|
|||||||
* This solves a problem when the variable name and its value are different, and ensures that
|
* This solves a problem when the variable name and its value are different, and ensures that
|
||||||
* the client sends the correct enum values to the server always.
|
* the client sends the correct enum values to the server always.
|
||||||
*/
|
*/
|
||||||
override fun toString(): String = value
|
override fun toString(): kotlin.String = value
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user