-
Notifications
You must be signed in to change notification settings - Fork 416
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
Upgrade to OpenApi 3.0 gives issues with multipart/form-data #348
Comments
What if you change |
@oblakeerickson I'm having this issue as well and that does not fix it. For me it always assumes the first parameter and uses it to populate requestBody. i.e. If my first parameter is EDIT It seems to be related to
It only finds the first value from the parameters array to corresponds to that check |
@BookOfGreg any idea? |
if works for me if I write with schema
The yml is generated correctly, but my spec does not pass, because it adds a And it seems that it's only like this when it is consumes "multipart/form-data", when it's "application/json", I have to put it in schema with a name too, but the name itself is not added to my parameters. Any ideas? |
By looking into the code, it seems that for construct the yml (for form_data and json), you want us to write out only once the in: :body params, and list the properties inside the schema But when constructing the payload for the test, for json it's ok, you also consider it to be written out once, but for form_data, you consider it to be written out as many times as your params
I think we should standardize the behavior, and simply change
What do you guys think? happy to open a PR if necessary |
I am currently doing the workaround as @yao0204. By adding a wrapper object
the expected json is generated:
But, this additional wrapper object in params is breaking the integration specs. |
this workaround works for me and my integration spec still pass |
I'm also running into issues documenting our uploads endpoint with multipart/form-data. I'm not able to get the tests to pass though with the above workarounds, so I'm just skipping this test for now with This for sure will be on my list of things that will go into the 2.4.0 release.
@yao0204 if you are still up for it, yes, a PR would very much be welcome here. |
I ran into the same issue, but with
and in my controller file are defined as:
My integration test pass with this but request from Swagger returns Downgrading to Swagger 2.0 solved it for me 🤔 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If the issue is still relevant to you, please leave a comment stating so to keep the issue from being closed. Thank you for your contributions. |
This is still an issue for me. I can either get the documentation to display correctly, but the tests won't pass, or I can write tests that pass but the documentation is incorrect. |
Still an issue for me as well |
Same here. we should have a fix for that... |
same, still an issue |
I am running into this as well |
I think I found a workaround that works with rswag 2.8, although it's probably the most unusual code I've ever written! Using a parameter whose name is the empty string, the test passes and the docs are generated correctly: parameter name: :'', in: :formData, schema: {
type: :object,
properties: {
file: { type: :file },
kind: { type: :string },
},
}
let(:'') { { file: a_file, kind: 'pdf' } } |
Hi everyone!
While trying to upgrade my swagger definition from Swagger 2 to OpenApi 3.0, I found the following issue with
multipart/form-data
input parameter:These params in my spec file:
is expected to generate (https://swagger.io/docs/specification/describing-request-body/multipart-requests):
but it generates:
Even the test-app (https://github.com/rswag/rswag/blob/master/test-app/swagger/v1/swagger.json) generated similar
swagger.json
for/blogs/{id}/upload
which goes against the OpenApi 3 multipart requests specification.The text was updated successfully, but these errors were encountered: