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 of a composed anyof serializer with an array in the schema #137

Open Tetraquark opened 3 years ago

Tetraquark commented 3 years ago

For scheme like this:

schema:
  anyOf:
    - type: object
      properties:
        meta:
          $ref: '#/components/schemas/PaginationMeta'
        items:
          type: array
          items:
            $ref: '#/components/schemas/NotificationCustomised'
    - type: array
      items:
        $ref: '#/components/schemas/NotificationCustomised'

Generates incorrect composed serializer with code like this:

val item1 = runCatching { json.decodeFromJsonElement(kotlin.collections.List<NotificationCustomised>.serializer(), element) }

Where wrong part is

kotlin.collections.List<NotificationCustomised>.serializer()

Should be:

ListSerializer(NotificationCustomized.serializer())
H4kt commented 3 months ago

Facing the same issue here Any chance of this being fixed?