-
Notifications
You must be signed in to change notification settings - Fork 49
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
Support for file uploads? #6
Comments
Actually i never really managed to get the swagger file-upload stuff working. But i have to admit - i didn't try much ;-) Feel free to try and contribute if you are successful! I just updated the module with some changes which might bring you a bit closer (swagger-ui has been updated as well in the demo project). You can start here ;-) server.post({url: '/upload',
swagger: {
summary: 'x',
notes: 'y',
nickname: 'z'
},
validation: {
uploadFile: {
swaggerType: "file",
isRequired: false,
scope: "body",
description: "Video File"
}
}}, function (req, res, next) {
res.send(req.params);
}); |
Yea, I'm stuck around here... server.post
url: "/upload"
swagger:
summary: "Upload a video and thumbnail"
notes: ""
nickname: ""
consumes: [ # which of these do we need?
"multipart/form-data"
"application/json"
"image/jpeg"
"video/x-m4v"
"application/x-www-form-urlencoded"
]
validation:
video:
swaggerType: "file"
parameterType: "form"
scope: "body"
isRequired: false
description: "Video"
thumbnail:
swaggerType: "file"
parameterType: "form"
scope: "body"
isRequired: false
description: "Video Thumbnail"
title:
isString: true
isRequired: true
scope: "body"
description: "Video Title" If I select multipart/form for the fields in the swagger ui, then I get "bad content-type header, no multipart boundary." If I try to set each field to it's correct type, not all of them come through... Not sure if this is an issue with Swagger or restify-validation. Thoughts? |
Hmm, i see the issue... you can simply unload restify-validation. restify-swagger doesnt depend on the usage of the validation module. But it doesnt change anything. From my point of view the requests which is generated by swagger/swagger-ui itself looks strange. Hm, anything wrong in here? {
"notes": null,
"nickname": "Upload",
"produces": ["application/json"],
"consumes": ["multipart/form-data", "application/json", "image/jpeg", "video/x-m4v", "application/x-www-form-urlencoded"],
"responseMessages": [{
"code": 500,
"message": "Internal Server Error"
}],
"parameters": [{
"type": "file",
"dataType": "file",
"name": "video",
"description": "Video",
"paramType": "body"
}, {
"type": "file",
"dataType": "file",
"name": "thumbnail",
"description": "Video Thumbnail",
"paramType": "body"
}, {
"name": "Body",
"description": "Upload a video and thumbnail",
"required": true,
"dataType": "Upload",
"paramType": "body"
}],
"summary": "Upload a video and thumbnail",
"httpMethod": "POST",
"method": "POST"
} |
First off, this and restify-swagger are awesome - thanks!
I'm trying to add a file upload to a post request, but can't seem to figure it out. Is this supported?
The text was updated successfully, but these errors were encountered: