swaggerize-express
swaggerize-express copied to clipboard
Swagger 2.0 File Type is Unsupported
You cannot use the type file in your swagger spec, because Enjoi doens't know how to parse the type, this creates a failure to be 2.0 spec compliant. Despite using all these fancy words, I am so not the guy to know how to fix it.
This is interesting because it is not in JSON schema spec, so it's not appropriate to handle it generically (and indeed any JSON schema validator should fail here).
It seems to me that it will require custom handling within this module.
I've opened an issue against Swagger for this: https://github.com/swagger-api/swagger-spec/issues/340
@tlivings Thanks for fighting the good fight, I saw the resolution for this, and I appreciate your efforts on the matter. IT sounds like for now I should just make a comment in my spec that we support a file, and then add the handling to the handler, but leave it out of the spec files.
Does this sound like the correct course of action?
I will be manually adding support for validating this in swaggerize-express.
Keep this issue open, I will address it.
Will do, thanks!
Any news on this, it has come up in my office again on a separate project.
Are there any work-arounds we could use while waiting for a bug fix here?
Unfortunately not that I know of. I'm targeting this week to get it done. Thanks for your patience - sorry this has taken so long.
No worries thanks!
Ok, I finally got some work into enjoi
- which is how this is going to trickle down to swaggerize-express
.
This PR https://github.com/tlivings/enjoi/pull/9 will allow for adding this new primitive as part of JSON schema...
Whew - this would be easier with another validator, which is something I am considering as well.
Making the final changes to enable this. Should be out this week!
Should be fixed now!
@tlivings I'm trying to use this, but I'm having difficulty with the validation portion. I'm taking in the file as a stream, and it's spitting out an error: child "file" fails because ["value" must be a string]
. This error comes from swaggerize-routes because of how the data is being set here. The data it take in (in my case) is a stream, and down the pipeline, it expects data to be a string. Do you know of a way to lighten the validation from my side? or is this something that would need to change in swaggerize-routes or another module?
Or perhaps this is an enjoi validation issue
It's not an enjoi validation issue, but rather an expectation that you've used some multipart body parser middleware to parse files.
That being said, this is probably making an oversimplified assumption and should be potentially reworked for flexibility.
Reopening this for now to track.
Is it possible to force disable the validation of a parameter, that would help folks having issues like the above.