mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-21 02:47:08 +00:00
kotlin-spring: fix exception thrown in enum.forValue (#21622)
* kotlin-spring: fix exception thrown in enum.forValue * update samples
This commit is contained in:
@@ -59,7 +59,8 @@ data class Order(
|
||||
@JvmStatic
|
||||
@JsonCreator
|
||||
fun forValue(value: kotlin.String): Status {
|
||||
return values().first{it -> it.value == value}
|
||||
return values().firstOrNull{it -> it.value == value}
|
||||
?: throw IllegalArgumentException("Unexpected value '$value' for enum 'Order'")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,8 @@ data class Pet(
|
||||
@JvmStatic
|
||||
@JsonCreator
|
||||
fun forValue(value: kotlin.String): Status {
|
||||
return values().first{it -> it.value == value}
|
||||
return values().firstOrNull{it -> it.value == value}
|
||||
?: throw IllegalArgumentException("Unexpected value '$value' for enum 'Pet'")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user