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
151 stars 29 forks source link

Generates incorrect code for array parameter with uniqueItems set to true #92

Closed dalewking closed 3 years ago

dalewking commented 3 years ago

We have a parameter defined as follows where it takes a set of UUIDs:

    {
      "name" : "timeOffRequestIds",
      "in" : "body",
      "required" : true,
      "schema" : {
        "type" : "array",
        "items" : {
          "type" : "string",
          "format" : "uuid"
        },
        "uniqueItems" : true
      }
    }

The parameter to the API is declared as a Set due to the uniqueItems:

 timeOffRequestIds: kotlin.collections.Set<kotlin.String>

But the code to serialize is trying to use ListSerializer:

 _json.encodeToString(ListSerializer(kotlin.String.serializer()), timeOffRequestIds)

That should be using SetSerializer, not ListSerializer

Alex009 commented 3 years ago

will be available in 0.11.0