krakenjs / swaggerize-express

Design-driven apis with swagger 2.0 and express.
Other
354 stars 81 forks source link

Validations on numbers #120

Closed gonenduk closed 7 years ago

gonenduk commented 7 years ago

Hi, I have a question about validations. I have defined a parameter as an integer with a minimum of 1. It fails if I pass a string and pass on a number. That's ok. However, it also pass if I pass -1. The same definition fails on the editor.swagger.io so I guess I did write it as required.

Any ideas what is wrong? attached is the definition of the parameter.

"parameters": [ { "name": "id", "in": "path", "description": "ID of user to get", "required": true, "type": "integer", "format": "int64", "minimum": 1 } ]

gonenduk commented 7 years ago

It seems the problem is in enjoi. The schema doesn't include the minimum and maximum values, so the joi object created doesn't have the required tests added. I will continue to investigate it.

gonenduk commented 7 years ago

Found the issue in swaggerize-routes. Create a pull request to fix it (including new unit tests): https://github.com/krakenjs/swaggerize-routes/pull/74

Closing this issue.