-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Allow different Content Types in File type parameters #222
Comments
I'll just add and say that for now vendor extensions can be used to extend this functionality, but we should consider it for the next version. Technically, the |
Could you elaborate on this please. |
@christopheblin - of course. If you take the file definition from above as an example: {
"name": "file",
"description": "The base64 encoded multipart file attachment. ",
"required": true,
"paramType": "form",
"type": "file",
"x-mimetype": "image/jpeg"
} This could indicate that the specific file parameter needs to be of an |
Parent: #565 |
This is a very common pattern on REST APIs when you have to upload some binary content and its related metadata in JSON. In those cases, it is desirable to be able to define:
|
You can do that now! |
For multipart uploads that contain a file and some other part, like a JSON object, it would be very useful to be able to specify a content type on the File parts other than the actual binary file. This is critical for Java applications that need the content type of the part in order to know how to deserialize the json or xml into a Java object.
For what its worth, I was able to get this working by modifying swagger-ui,js to use a Blob as the FormData. I had to add a "contentType" field to the Parameter object. I know this violates the spec, but this worked for my project.
swagger-ui.js line 1797:
In the swagger doc, I can define the file and the json object parameters like so:
Refer to this discussion / issue in swagger-core for more detail - swagger-api/swagger-core#636
The text was updated successfully, but these errors were encountered: