-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Having a nested object structure in formData and get the same reflected on swagger-ui #4041
Comments
Is the request body supposed to be sent as |
I have a similar problem: The swagger config Version 2.0: The swagger UI: As you can see the ncElement is rendered as type formData which is a string instead type "createNCElementProperties" In addition the request part for the ncElement doesn't have a Content-Type. The correct Content-Type would be application/json |
@dalbrx-forcam In OpenAPI/Swagger 2.0, Multipart requests with JSON+file are supported in OpenAPI 3.0: openapi: 3.0.0
...
paths:
/something:
post:
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
properties:
ncElement:
$ref: '#/components/schemas/createNcElementProperties'
file:
type: string
format: binary
required:
- ncElement
- file
responses:
... More examples of OpenAPI 3.0 multipart request definitions: However, "try it out" support for multipart requests and file upload for OpenAPI 3.0 definitions is not yet available in Swagger UI. I believe this is being tracked in the OAS 3.0 Support Backlog. |
As @hkosova mentioned, Swagger 2.0 does not support it, but OAS3 does. We recently added support for it in swagger-ui, so I'm going to go ahead and close the ticket. |
Why is this issue closed? This issue is still not fixed. This is actually a very serious issue - it means that you cannot upload both an object and a file. |
And Swagger UI definitely still doesn't support this. |
@Cloudmersive Uploading objects + files is supported in OpenAPI 3.0 and should work in latest Swagger UI. Check out the examples in my comment above. If something does not work for you, open a new issue and provide the steps to reproduce and other details. |
Currently, swagger accepts properties in formData directly. What I intend to do is, formData should be able to accept a nested object and the file will be present somewhere inside. (See example below).
I am not sure if this is a bug or a whole new feature to be added.
Current Behavior
I tried to do the same like:
But this doesn't work.
The output is like this:
I want to represent formData as a nested object itself and represent it in swagger appropriately.
Is there a way to do so?
Thanks in advance!
The text was updated successfully, but these errors were encountered: