icerockdev / moko-network

Network components with codegeneration of rest api for mobile (android & ios) Kotlin Multiplatform development
https://moko.icerock.dev
Apache License 2.0
152 stars 28 forks source link

Is the way to change property type from Int to Long? #188

Closed rovkinmax closed 1 year ago

rovkinmax commented 1 year ago

Motivation: In swagger or openApi we have only integer and number, and in generated models uses Int type. But It is not valid in all cases, because sometimes backend can send number value from Long as integer and client can't deserialise this values.

So, I wanna change all generated type as Int to Long. Could you help me with that? If generator doesn't have this option, may be you can show me were I can change it by myself in fork? Because I already use this lib to generate network SDK from swagger.json and have problem described above

Dorofeev commented 1 year ago

Hello! There is a way to do it without fork. You can set the int64 format for the property you want to make Long. Example for yaml:

properties:
  id:
    type: integer
    format: int64

result:

    @SerialName("id")
    val id: kotlin.Long,