OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.86k stars 6.59k forks source link

[BUG][Kotlin][Multiplatform] byte[] is represented as List<Base64ByteArray> instead of Base64ByteArray #12660

Open krzema12 opened 2 years ago

krzema12 commented 2 years ago

Bug Report Checklist

Description

I have a field in my Java DTO that is of type byte[]. Swagger spec generated for it looks like this:

          "responseBody": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "byte"
            }
          }
openapi-generator version

6.0.1-SNAPSHOT

OpenAPI declaration file content or url
          "responseBody": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "byte"
            }
          }
Generation Details
generate -g kotlin --library multiplatform ...
Related issues/PRs

None found.

Suggest a fix

It looks straightforward - an array of bytes should be mapped to just Base64ByteArray, not List<Base64ByteArray>. Regarding place in the code, probably something around this place: https://github.com/OpenAPITools/openapi-generator/blob/b02fd28ba638a606785c952d1227f15dfd8660bf/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java#L701

837 commented 8 months ago

It looks correct to me.

     "responseBody": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "byte"
            }
          }

This should generate a List<Base64ByteArray >

if you just want a byte[]

     "responseBody": {
            "type": "string",
             "format": "byte"     
      }