-
Notifications
You must be signed in to change notification settings - Fork 9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Generated CURL seems wrong for mime/multipart uploads that have JSON parts - missing 'type=' option, wrong quotes. #4826
Comments
Same issue here with both "multipart/mixed" and "multipart/form-data". Both generate incorrect cURL command. Any progress on correcting this ?? |
Hi everybody, Related to second point from the
curl -X 'POST' \
'https://foo/v1/api/upload/' \
-H 'accept: application/json' \
-H 'Content-Type: multipart/form-data' \
-F 'file=@file.pdf;type=application/pdf' \
-F 'options={
"some_array": [
"string"
],
"max_bar": 300
}' Provided test case in #9096 |
This change is specific to OpenAPI 3.x.y. Refs swagger-api/swagger-ui#4826
Hi everybody, Related to first point - missing mime type for individual boundaries:
This issue needs to be addressed both in SwaggerUI (here) and in SwaggerClient. OpenAPI 3.x.y specification allows to fully influence this by using encoding field of Media Type Object. For SwaggerClient, PR has been issued to address this and respect the DescriptionOpenAPI 3.x.y definition: {
"openapi": "3.0.0",
"paths": {
"/upload/": {
"post": {
"tags": [
"upload"
],
"operationId": "upload",
"requestBody": {
"required": true,
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"properties": {
"options": {
"type": "object",
"properties": {
"some_array": {
"type": "array",
"items": {
"type": "string"
}
},
"max_bar": {
"type": "integer",
"default": 300
}
}
}
}
},
"encoding": {
"options": {
"contentType": "application/json; charset=utf-8"
}
}
}
}
}
}
}
}
} Here is how the POST / HTTP/1.1
Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266
-----------------------------9051914041544843365972754266
Content-Disposition: form-data; name="options"
{"some_array":["string"],"max_bar":300} Here is how the POST / HTTP/1.1
Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266
-----------------------------9051914041544843365972754266
Content-Disposition: form-data; name="options"; filename="blob"
Content-Type: application/json
{"some_array":["string"],"max_bar":300} Every boundary now contains specific For SwaggerUI this issue has been addressed in #9105 CURL command correctly generated by assigning additional |
This change affects building requests from OpenAPI 3.x.y definitions. Refs swagger-api/swagger-ui#5356 Refs swagger-api/swagger-ui#4826 Refs #2954
Addressed by #9105 |
This is not fixed. The PR #9105 added support only if you add an schema:
type: object
properties: # Request parts
file:
type: string
format: binary
options:
type: object
properties:
some_array:
type: array
items:
type: string
max_bar:
type: integer
default: 300
encoding:
options: # Property name
contentType: application/json But it should be content type
|
From @dvelitchkov on August 21, 2018 0:15
Running swagger editor from docker container, no customizations.
Q&A (please complete the following information)
Content & configuration
Example Swagger/OpenAPI definition:
Describe the bug you're encountering
The generated CURL looks like this:
Expected behavior
I think there are two issues here:
The "type=" option tha specifies the content-type for the "options" part is missing - I feel it should be "application/json", since that is the default for "objects". The "type=" option is actually present for the "myfile" part, which is great.
The quotes for the "options" part need to be single quotes, e.g.
-F 'options={ "some_array": [ "string" ], "max_bar": 0 }'
, not-F "options={ "some_array": [ "string" ], "max_bar": 0 }"
, as having double-quotes everywhere will just cause the shell to strip them.Additional context or thoughts
The full correct curl should be:
Copied from original issue: swagger-api/swagger-editor#1871
The text was updated successfully, but these errors were encountered: