Swag: Setting parameters in FormData mode only supports files and is modified to support all types of parameters.

Created on 19 May 2018  路  14Comments  路  Source: swaggo/swag

Describe the bug
Setting parameters in FormData mode only supports files and is modified to support all types of parameters.

To Reproduce
github.comswaggoswagoperation.go : 131 line

case "formData":
param = createParameter(paramType, description, name, "file", required)

Expected behavior

case "formData":
param = createParameter(paramType, description, name, TransToValidSchemeType(schemaType), required)

Screenshots
image

Additional context
I hope the author will fix it as soon as possible.

bug question

All 14 comments

I'll check.

I also met this issue.

By the way, what specific swagger.json do you want?

            "post": {
                "description": "user signup",
                "consumes": [
                    "application/x-www-form-urlencoded"
                ],
                "produces": [
                    "application/json"
                ],
                "summary": "user signup",
                "parameters": [
                    {
                        "type": "file",
                        "description": "username",
                        "name": "username",
                        "in": "formData",
                        "required": true
                    },

I think the param type should be ~formData~string, not file.

@xwjdsh @pei0804
I think it should be "type":"string", not "type":"file"

@BlueSimle Yes, you are right, there is no formData type at all, I don't know what I was thinking at that time...

Do you want use application/x-www-form-urlencoded?

I think you should use string.
FormData is for file upload.

https://swagger.io/docs/specification/2-0/describing-parameters/#form-parameters

I refer to this document. Is there any misunderstandings?

In this case, post requests only support file parameter types.

absolutely is a big problem after formData if we use string everything should be ok ! but its not working !
@pei0804 FormData is just not about uploading file .

Sorry for the misunderstandings. I will take care of it.

@BlueSimle @xwjdsh @iraniamir fixed by #146 Thank you all you guy 馃槂

Please reopen it if you have any concerns.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

padurean picture padurean  路  6Comments

hoangtuan151 picture hoangtuan151  路  4Comments

Ashtonian picture Ashtonian  路  6Comments

chiragg6 picture chiragg6  路  7Comments

dz0ny picture dz0ny  路  5Comments