swaggerize-express icon indicating copy to clipboard operation
swaggerize-express copied to clipboard

Swagger 2.0 File Type is Unsupported

Open jamesblack opened this issue 9 years ago • 17 comments

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.

jamesblack avatar Apr 16 '15 18:04 jamesblack

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.

tlivings avatar Apr 25 '15 13:04 tlivings

I've opened an issue against Swagger for this: https://github.com/swagger-api/swagger-spec/issues/340

tlivings avatar Apr 25 '15 13:04 tlivings

@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?

jamesblack avatar Apr 27 '15 17:04 jamesblack

I will be manually adding support for validating this in swaggerize-express.

tlivings avatar Apr 27 '15 17:04 tlivings

Keep this issue open, I will address it.

tlivings avatar Apr 27 '15 19:04 tlivings

Will do, thanks!

jamesblack avatar Apr 27 '15 19:04 jamesblack

Any news on this, it has come up in my office again on a separate project.

jamesblack avatar Jul 17 '15 15:07 jamesblack

Are there any work-arounds we could use while waiting for a bug fix here?

fiannaca avatar Jul 21 '15 02:07 fiannaca

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.

tlivings avatar Jul 21 '15 02:07 tlivings

No worries thanks!

jamesblack avatar Jul 22 '15 20:07 jamesblack

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.

tlivings avatar Jul 25 '15 03:07 tlivings

Making the final changes to enable this. Should be out this week!

tlivings avatar Aug 05 '15 02:08 tlivings

Should be fixed now!

tlivings avatar Aug 09 '15 01:08 tlivings

@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?

ksmithut avatar Aug 19 '15 15:08 ksmithut

Or perhaps this is an enjoi validation issue

ksmithut avatar Aug 19 '15 15:08 ksmithut

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.

tlivings avatar Aug 19 '15 16:08 tlivings

Is it possible to force disable the validation of a parameter, that would help folks having issues like the above.

dcolens avatar Feb 03 '16 12:02 dcolens