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

Incorrect generation for array property #80

Closed dalewking closed 3 years ago

dalewking commented 3 years ago

Our API has an entity defined like this in the swagger:

"IgnoredActivityCategories" : {
  "type" : "object",
  "properties" : {
    "values" : {
      "type" : "array",
      "description" : "Activity categories list",
      "items" : {
        "type" : "string",
        "enum" : [ "OnQueueWork", "Break", "Meal", "Meeting", "OffQueueWork", "TimeOff", "Training", "Unavailable", "Unscheduled" ],
        "x-genesys-enum-members" : [ {
          "name" : "OnQueueWork"
        }, {
          "name" : "Break"
        }, {
          "name" : "Meal"
        }, {
          "name" : "Meeting"
        }, {
          "name" : "OffQueueWork"
        }, {
          "name" : "TimeOff"
        }, {
          "name" : "Training"
        }, {
          "name" : "Unavailable"
        }, {
          "name" : "Unscheduled"
        } ]
      }
    }
  }
},

and here is the code that is generated:

@Serializable
public data class IgnoredActivityCategories (
    /* Activity categories list */
    @SerialName("values")
    val values: IgnoredActivityCategories.Values? = null
) {

    /**
    * Activity categories list
    * Values: "OnQueueWork","Break","Meal","Meeting","OffQueueWork","TimeOff","Training","Unavailable","Unscheduled"
    */
    @Serializable
    enum class Values {

        @SerialName("OnQueueWork")
        ON_QUEUE_WORK,

        @SerialName("Break")
        BREAK,

        @SerialName("Meal")
        MEAL,

        @SerialName("Meeting")
        MEETING,

        @SerialName("OffQueueWork")
        OFF_QUEUE_WORK,

        @SerialName("TimeOff")
        TIME_OFF,

        @SerialName("Training")
        TRAINING,

        @SerialName("Unavailable")
        UNAVAILABLE,

        @SerialName("Unscheduled")
        UNSCHEDULED;

    }

}

The problem is that the values parameter to this object should be a collection of values, not just a single value

Alex009 commented 3 years ago

will be available 0.11.0