Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Describing POST handler for multipart/form-data #5

Open
ainvaltin opened this issue May 2, 2017 · 1 comment
Open

Describing POST handler for multipart/form-data #5

ainvaltin opened this issue May 2, 2017 · 1 comment

Comments

@ainvaltin
Copy link

How one is supposed to describe endpoint for a html form which posts multipart/form-data? It seems that the endpoint.Body() func is meant to be used to describe the fields but I can't figure out what the first parameter should be. Say I have a form which posts an file and a string field...

As a workaround, following seems to work:

api.AddEndpoint(endpoint.New(http.MethodPost, "/foo", "handle posted data",
	endpoint.Handler(handle_post),
	parameter(swagger.Parameter{In: "formData", Type: "file", Name: "file", Description: "file to process", Required: true}),
	parameter(swagger.Parameter{In: "formData", Type: "string", Name: "op", Description: "name of the operation", Required: true}),
	endpoint.Consumes("multipart/form-data"),
	endpoint.Produces("text/xml; charset=utf-8"),
	endpoint.Response(http.StatusOK, struct{}{}, "desc response"),
))

the parameter func is one from endpoint/buider.go.

If there is better way please document it (in some example or as a code snippet in readme).

@MarkSonghurst
Copy link

I think #4 does what you need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants