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 list of nullable objects #131

Closed Tetraquark closed 3 years ago

Tetraquark commented 3 years ago

I got schema like this:

    BlogPermissionsRoles:
      type: object
      additionalProperties:
        type: array
        items:
          type: string
          nullable: true

And the generator makes the wrong type for this scheme:

kotlin.collections.Map<kotlin.String, kotlin.collections.List<kotlin.String>>

Should be nullable kotlin.String inside List.

Tetraquark commented 3 years ago

It looks like there are no ways to fix it inside moko-network-generator. So, the way to work around this problem is to declare a schema in the specification using oneOf operator:

BlogPermissionsRoles:
  type: object
  additionalProperties:
    type: array
    items:
      oneOf:
        - type: null
        - type: string

Check issue from OpenAPITools project for more info: https://github.com/OpenAPITools/openapi-generator/issues/5180