epam-cross-platform-lab / swagger-dart-code-generator

Swagger/OpenAPI code generator based on Chopper and JsonAnnotation for Flutter
Apache License 2.0
268 stars 124 forks source link

Multipart binary sections does not get created correctly #760

Open RoarGronmo opened 4 months ago

RoarGronmo commented 4 months ago

Describe the bug When dealing with swaggers containing mulitpart, it will not generate files correctly

image It seems to omit parts of the text to be created, like parameters.

Even supplying the missing element, here 'File', will not help.

Section of swagger resulting in this error:

      "put": {
        "tags": [
          "Order"
        ],
        "summary": "Last opp ordrevedlegg",
        "parameters": [
          {
            "name": "frmNo",
            "in": "path",
            "description": "Klientnr",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "ordNo",
            "in": "path",
            "description": "Ordrenr til ordren",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "descr",
            "in": "query",
            "description": "Kort beskrivelse (250)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "ordHash",
            "in": "header",
            "description": "Hash-verdi til ordren",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "File",
                  "FileName"
                ],
                "type": "object",
                "properties": {
                  "FileName": {
                    "type": "string"
                  },
                  "File": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              },
              "encoding": {
                "FileName": {
                  "style": "form"
                },
                "File": {
                  "style": "form"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/OrdAtt"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrdAtt"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrdAtt"
                }
              }
            }
          }
        }
      }

When calling, the "File" section of "Form Data" will not be present:

image


I see there are little activity here the last 3 months, I hope someone picks it up...

Vovanella95 commented 4 months ago

Hello @RoarGronmo ! Unfortunately, I don't have experience working with multipart data. I will be happy if you will create a PR with fix of this issue :)