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

[BUG] aspnetcore generation multipart/form-data error #3086

Open cbaurand opened 5 years ago

cbaurand commented 5 years ago

Bug Report Checklist

Description

When generating aspnetcore skeletton for json interface containing an element of "multipart/form-data:" with object type, the result controller file contains an unexpected method signature with UNKNOWN_BASE_TYPE as parameter Type and parameter name.

openapi-generator version

openapi-generator .3.3.4 openapi-generator .4.01

OpenAPI declaration file content or url
"post": {
"requestBody": {   
"content": {
    "multipart/form-data:": {
        "schema": {
            "type" : "object",
            "properties": {
                "memo": {
                   "type": "string",
                 },
                 "fileToUpload": {
                     "type": "string",
                     "format": "binary"
                  }
              }
          }
      }
}
}
}

The one which works:



"post": {
"requestBody": {   
content": {
      "multipart/form-data:": {
        "schema": {
          "type": "string",
          "format": "binary"
        }
      }
}
}
"

##### Command line used for generation

java -jar openapi-generator-cli.jar generate -i  file1.openapi.json --generator-name  aspnetcore -c file1.aspnetcore.config.json -o tmp/

##### Steps to reproduce

launch the generation, the generated controller file will have "UNKNOWN_BASE_TYPE"
as variable type and name.

##### Related issues/PRs
no

##### Suggest a fix
InfoSec812 commented 4 years ago

@cbaurand Could you try using the latest 5.0.0-beta and see if this issue has been resolved?

cbaurand commented 4 years ago

@InfoSec812: Hi,

I don't work with openAPI anymore and i'm not able to do the test since my environment is fully different.

wing328 commented 3 years ago

Looks like issue in Swagger Parser. A workaround it to define the schema inline.

Related issue: https://github.com/OpenAPITools/openapi-generator/issues/7922

BeDaut commented 3 years ago

@wing328 This problem still exists. I had it working in 4.2.1 openapi generator version, generator type spring Decided to upgrade to 5.0.1 (to support angular 11) but classes with multipart/form-data that has objects or references in them doesn't generate, any help?

MarioVolarevic commented 3 years ago

Is there any update on this issue? It can also be easily reproducible on the latest version with the petstore example from: https://editor.swagger.io/ If you generate the server for aspnetcore you will see that call for POST /pet/{petId}/uploadImage is completely missing from C# code.

wing328 commented 2 years ago

Please give v6.0.0 a try as we've made a of improvements to the inline model resolver.

konradmalik commented 1 year ago

FYI this is still an issue with:

openapi-generator-cli 6.6.0
  commit : 7f8b853