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.27k stars 6.44k forks source link

[BUG] Typescript-fetch generator cannot handle Java FileUploads? #19280

Open klabast opened 1 month ago

klabast commented 1 month ago
Description

When creating a typescript-fetch API client, it seems OpenAPI Generator cannot handle Java FileUploads correctly. The generated code contains an objectToJSON function that does not exist and therefore the client code fails. When using a List, the generated code does not contain a missing function, but fails nonetheless

openapi-generator version

latest, happens on older ones as well.

OpenAPI declaration file content or url

Here is a minimal reproducer:

https://github.com/klabast/openapi-reproducer

{
  "openapi" : "3.0.3",
  "info" : {
    "title" : "backend API",
    "version" : "1.0-SNAPSHOT"
  },
  "paths" : {
    "/api/something/upload" : {
      "post" : {
        "tags" : [ "Some Api" ],
        "requestBody" : {
          "content" : {
            "multipart/form-data" : {
              "schema" : {
                "type" : "object",
                "properties" : {
                  "uploadFile" : {
                    "$ref" : "#/components/schemas/FileUpload"
                  }
                }
              }
            }
          }
        },
        "responses" : {
          "200" : {
            "description" : "OK",
            "content" : {
              "text/plain" : {
                "schema" : {
                  "type" : "string"
                }
              }
            }
          }
        }
      }
    }
  },
  "components" : {
    "schemas" : {
      "FileUpload" : {
        "type" : "object"
      }
    }
  }
}
Generation Details
openapi-generator-cli generate -i http://localhost:8080/q/openapi.json -g typescript-fetch -o ./src/api/generated/
Steps to reproduce

All documented in the reproducer.

Related issues/PRs

Perhaps https://github.com/OpenAPITools/openapi-generator/issues/17731

wsdt commented 1 month ago

Yes having the same issue..

klabast commented 1 month ago

@wsdt did you manage to resolve this issue? sadly, i wasn't yet. not really in the mood to mess with post-processing or so...

Edit: Seems to be related to https://github.com/OpenAPITools/openapi-generator/issues/4119

wsdt commented 4 weeks ago

@wsdt did you manage to resolve this issue? sadly, i wasn't yet. not really in the mood to mess with post-processing or so...

Edit: Seems to be related to #4119

not yet unfortunately!