-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Parsing exception with swagger interface generated with grape-swagger gem #27
Comments
Looks like you are missing the responseClass. The error reporting is not good right now but the trace points here: |
Thanks for the response. That's what I figured. So I guess my question is as follows. Is there a reason why certain fields are required in swagger-codegen but are not required in swagger-ui? Again, I am simply feeding the output from grape-swagger into both, and it works in swagger-ui, but not in swagger-codegen. |
Yes, the code generator is more strict with structure that the ui. Valid swagger specs are best, of course. |
Thanks again for the explanation. I was able to get this to work by monkey-patching the swagger-grape gem to add the responseClass and errorResponses keys to Operations, and added the models key to the ApiListing (all of which are missing in the most recent version of the gem). I'll submit a pull request to the grape-swagger project that will implement these missing keys. |
Thank you. And we will improve the validator messages as well as make a javascript version that's bundled with Swagger-ui. |
bfreeman123, did you ever submit that pull request? I'm running into the same issues .. |
No, I did not. While my patch got the code generator over that hurdle, it merely spit out un-usable code (at least for objective-c). As I recall, it wasn't mapping attributes correctly. I have since moved onto another project and abandoned the swagger codegen, but if you'd like to give it a try, you can simply add the responseClass key to the Operations hash on the grape-swagger gem. If you look at https://github.com/tim-vandecasteele/grape-swagger/blob/master/lib/grape-swagger.rb starting on line 91, you essentially want to change:
to
|
I have a Ruby project that defines a REST API using the grape gem. I am generating the swagger definition with the grape-swagger gem. The swagger definition grape-swagger generates works fine with swagger-ui. It's able to parse the display the API with no errors.
However, when I try to run the same swagger definition through the swagger-codegen validate.sh script, it throws the following exception:
Tracing through the scala code, it appears that the OperationSerializer is expecting a list of keys to be in the json document it's parsing. Specifically, the stack trace seems to be pointing to the missing "responseClass" key in the json document.
Unfortunately, the grape-swagger gem doesn't generate this key. When I curl the api that swagger-codegen is trying to parse (http://localhost:3000/swagger_doc/users.json), it only contains the following keys (notes, summary, nickname, httpMethod, parameters). See below:
Since I am new to scala, it's difficult for me to understand exactly what is going on in the code. So it's possible I'm mis-reading this stack-trace. It's also possible the grape-swagger gem isn't fully implementing the swagger definition, in which case this is an issue for grape-swagger and not swagger-codegen (however that seems odd since swagger-ui can still parse it).
The text was updated successfully, but these errors were encountered: