Closed dschenkelman closed 10 years ago
Another alternative would be to define the file format for some type instead of using the description.
Thoughts?
It probably makes sense to allow for extended types that swagger cares about, but would not be validated against JSON schema, and just document the additional types that can be used in your schema definition. I'm starting to look at the swagger 2.0 spec as well, and seeing how much work it'd be to transition to that.
You mean to use this mechanism (i.e. description
) for all potential types supported by swagger? Cool :). This will be fairly useful.
I was thinking of just allowing the use of "file" in the type
property, and then just checking this before schema validation to see if it's set to "file", and if so, skip the validation.
Oh, that is cool. I did not know you could skip validation for a particular property.
Would you be able to point your package.json at the "pr_11" branch that I just uploaded and see if you can get the swagger documentation that you expect for "file" type payloads?
In other words, use something similar to this for your route config:
plugins: {
ratify: {
payload: {
type: 'file'
}
}
}
and see if you get the swagger docs that you expect?
If not, no big deal. I'll try it out later.
I'm currently swamped trying to solve an nginx issue with something else, but will definely give it a try either later today or tomorrow.
Thanks @mac-
Just tried it out. It worked correctly and also all my tests are still passing so :+1: from my side :)
Sweet! I'm going to close this pull request and merge the pr_11 branch in and publish a new version.
That is great :) Will be able to automatically generate correct swagger for our file uploads
I pushed a new version for this: 0.6.3
Great! Just updated our dependencies to it.
Thanks a lot for the fast update
On Fri, Oct 3, 2014 at 12:27 PM, Mac Angell notifications@github.com wrote:
I pushed a new version for this: 0.6.3
— Reply to this email directly or view it on GitHub https://github.com/mac-/ratify/pull/11#issuecomment-57811571.
It is fairly common for POST endpoints to be able to receive a file as the body parameter. Since JSON schema does not support the
'file'
type, it is not possible to specify it when defining the schema.This PR implements a hack that allows people to specify the
'file'
type through the description field.I don't think it is nice, but I can't think of any other way to support this.