fsbahman / apidoc-swagger

apidoc and swagger are two nice projects which are focusing on documentation of APIs. This project is a middle tier which tries to bring them together in a sense that it uses apidoc to convert inline documentation to json schema and later convert it to swagger json schmea.
Other
252 stars 129 forks source link

Apidoc-swagger crashes on apidoc specifications with custom parameter group names #14

Closed brownstein closed 5 years ago

brownstein commented 8 years ago

I'm using apidoc-swagger against a project which annotates URL parameters using a group named "URL Parameters" instead of the default, and I ran across some unsafe access patterns to the Parameters array.

Specifically,var required = verbs.parameter && verbs.parameter.fields && verbs.parameter.fields.Parameter.length > 0; on line 83 of apidocToSwagger.js makes an unsafe check, which causes an unhandled exception if "Parameter" is not defined.

PR incoming.

bermi commented 8 years ago

Any chance of getting this merged? It seems to be the root cause for #19 as well.

Vaxter commented 7 years ago

Fix proposed just skips handling everything if Parameters are not available resulting in not having parameters added in Swagger. There was a proper fix for older version that was able to handle custom grouping, submitted by my friend and I, but pull request was not merged due to rewrite.

To fix this issue the right way, parameter grouping should be handled.

brownstein commented 7 years ago

@Vaxter The alternative (current approach) seems to be to just crash, which also results in not having parameters added in Swagger. Not sure why this isn't a step in the right direction.

Vaxter commented 7 years ago

@brownstein https://github.com/fsbahman/apidoc-swagger/pull/25/commits/2d332e39a1a0847e1f39a1c6cc9c1b6f320fe9f1

Here, this is a step in the right direction. Now fields are generated, but needs additional work to handle mixing groups and handling form data cases. Also, apiDoc allows free form grouping, so better default group should also be handled. This was a quick fix, but should do the trick.