You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using kotlinx.serialization strings with format: uuid are converted to String in models, while Jackson serialization generates UUID. I think it would be a good addition if kotlinx.serialization is also able to produce UUID. Directly having UUID would eliminate the need to convert UUID <> String when working with e.g. Exposed.
Is this something that could be done? I'd be happy to open a pull request for it.
I found the following code in kotlin/com/cjbooms/fabrikt/model/KotlinTypeInfo.kt:
OasType.Uuid-> {
if (MutableSettings.serializationLibrary() ==KOTLINX_SERIALIZATION) Text// could possibly be Kotlin native UUID once that becomes stableelseUuid
}
As far as I'm aware Kotlin's Uuid is not stable yet. Maybe this feature could be added as Type Override so users can choose whether it will be UUID / String (Uuid in future)?
Since kotlinx.serialization does not have a built in serializer for UUID it was decided to ignore the format and fall back to string. The same applies for format: uri (and actually also for format: number which currently maps to BigDecimal, which will not compile and needs to be fixed).
Serializer has not been found for type 'UUID'.
To use context serializer as fallback, explicitly annotate type or property with @Contextual
It is possible to provide a custom serializer for these types using the @Contextual (docs) annotation.
We could probably add an option to make fabrikt generate add @Contextual to the fields in question instead of falling back to string.
Hello,
When using kotlinx.serialization strings with
format: uuid
are converted toString
in models, while Jackson serialization generatesUUID
. I think it would be a good addition if kotlinx.serialization is also able to produceUUID
. Directly havingUUID
would eliminate the need to convertUUID <> String
when working with e.g. Exposed.Is this something that could be done? I'd be happy to open a pull request for it.
I found the following code in
kotlin/com/cjbooms/fabrikt/model/KotlinTypeInfo.kt
:As far as I'm aware Kotlin's Uuid is not stable yet. Maybe this feature could be added as Type Override so users can choose whether it will be UUID / String (Uuid in future)?
Examples
The text was updated successfully, but these errors were encountered: