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

checkJSONBodyContentType failed to tolerate multipart/form-data with boundary #115

Closed
dikac opened this issue Jun 6, 2024 · 2 comments
Closed

Comments

@dikac
Copy link

dikac commented Jun 6, 2024

Describe the bug
Content-Type: multipart/form-data; boundary=SOME-BOUNDARY
would fail to parse when request tag contain formData and json

type UserList struct {
	Page      string       `formData:"page" json:"page"`
}

To Reproduce
create a request struct with formData and json

type UserList struct {
	Page      string       `formData:"page" json:"page"`
}

send request with content type multipart/form-data with boundary

POST /users HTTP/1.1
Host: localhost:8234
User-Agent: insomnia/2023.3.0
Content-Type: multipart/form-data; boundary=X-INSOMNIA-BOUNDARY
Accept: */*
Content-Length: 98

--X-INSOMNIA-BOUNDARY
Content-Disposition: form-data; name="page"
A
--X-INSOMNIA-BOUNDARY--

would give Response

< HTTP/1.1 400 Bad Request
< Content-Length: 168
< Content-Type: application/json
< Date: Thu, 06 Jun 2024 14:17:45 GMT

Expected behavior
Data decoded successfully without error

Additional context
problem seems to came from function checkJSONBodyContentType

@vearutop
Copy link
Member

Hello, swaggest/openapi-go library does not provide any request decoding facilities, could you clarify your use case? How do you decode request and how openapi-go is related?

@vearutop
Copy link
Member

I'm closing this issue as likely not directly related to the lib, but feel free to reopen with more details.

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