Manweill / swagger-axios-codegen

swagger client to use axios and typescript
MIT License
306 stars 83 forks source link

fix: Multipart Formdata bodies are ignored #191

Closed arkraft closed 7 months ago

arkraft commented 7 months ago

Hi,

switching from 0.16.8 to 0.16.9 the generated client ignores file uploads. We have this request in swagger:

"requestBody": {
    "required": true,
    "content": {
        "multipart/form-data": {
            "schema": {
                "type": "object",
                "properties": {
                    "file": {
                        "type": "string",
                        "format": "binary"
                    }
                }
            }
        }
    }
}

which worked fine and generated the upload code:

image

Since 0.16.9 it is broken and generated nothing in this place. This breaks the file uploads for us.

We identified the change which broke the generation. It seems that the if statement is to harsh and in our case it will be skipped. We made a PR to revert this if statement change, bur we are open for other solutions.

https://github.com/Manweill/swagger-axios-codegen/compare/v0.16.8...v0.16.9

Manweill commented 7 months ago

@arkraft I'm really sorry for not conducting rigorous testing. Can you verify that in v0.16.11 version? I seem to have fixed this problem in v0.16.11

arkraft commented 7 months ago

Hi @Manweill. No worries, that can happen.

We found the problem in v0.16.11 and went back the versions until the version where it did not happen.

We believe the if statement already blocks because in our case, bodyParameter is an empty string. So maybe the problem lies somewhere else, where the bodyParameter is parsed. Right now version 0.16.8 is working for us and also the fix generates the correct client.

Manweill commented 7 months ago

嗨 .不用担心,这可能会发生。

我们在 v0.16.11 中发现了问题,并返回了版本,直到没有发生问题的版本。

我们相信 if 语句已经阻塞,因为在我们的例子中,是一个空字符串。所以也许问题出在其他地方,bodyParameter 被解析的地方。现在版本 0.16.8 正在为我们工作,并且修复程序也会生成正确的客户端。bodyParameter

OK,rebase it and push agian

arkraft commented 7 months ago

The branch is already up to date, or am I missing something?

@arkraft ➜ /workspaces/swagger-axios-codegen (fix/multipart-form-data) $ git rebase 'upstream/main'
Current branch fix/multipart-form-data is up to date.
Manweill commented 7 months ago

The branch is already up to date, or am I missing something?

@arkraft ➜ /workspaces/swagger-axios-codegen (fix/multipart-form-data) $ git rebase 'upstream/main'
Current branch fix/multipart-form-data is up to date.

fix in 0.16.13