z0mt3c / node-restify-swagger

Swagger generation for REST-Services built with node-restify and node.js based on validation schemas of node-restify-validation.
MIT License
29 stars 16 forks source link

Allow for creation of different models for resources with same url but different method #19

Closed rochal closed 9 years ago

rochal commented 9 years ago

Fix issue causing models getting overriden by model definitions from routes with same paths.

Introduced allowMethodInModelNames: true flag to enable this as it might be breaking change in some cases.

Here's the issue:

Create new resource with POST: POST /animals - accepts: { name: "string", age: "integer" }

Update reasource with PUT, but only allow name to be updated: PUT /animals - accepts: { name: "string" }

At the moment, POST Model which should have both name and age props will get overridden by PUT Model because they use same "Animals" model.

coveralls commented 9 years ago

Coverage Status

Coverage increased (+0.11%) to 89.47% when pulling cdcd25347e1981781e6915fee8a412332b969546 on rochal:master into b405bcae11f8dc01a8201c4ada28cc1db9ab5e17 on z0mt3c:master.

rochal commented 9 years ago

@z0mt3c please let me know if you have any questions regarding this pull request.

I'm particularly interested if you think models should be created with unique names by default or is my new allowMethodInModelNames config flag a preferred way.

z0mt3c commented 9 years ago

Thank you!

May we could generate the model names based on it's schema instead of the path. Same schema could/should result in the same model... or at least offer the possibility to specify a name?