krakenjs / swaggerize-routes

Swagger document driven route builder.
Other
58 stars 57 forks source link

Consider number types on coercion #75

Closed delaguilaluis closed 7 years ago

delaguilaluis commented 7 years ago

Currently if a string parameter is validated against a schema specifying it as 'number', it would not be coerced.

When validating the input string '0', the result from validation (the number 0) would be taken as a "falsy" value and the original string '0' would be returned.

So, the type 'number', which is part of the Swagger specification was added to the cases to consider on coercion to avoid this behavior.

gonenduk commented 7 years ago

Looks good. Do you have a connection to the owners of the repo and can find out when will they check this request?

tlivings commented 7 years ago

Looks good to me :+1:

gonenduk commented 7 years ago

@tlivings , Can you also check the pull request to fix the min/max issues?

subeeshcbabu-zz commented 7 years ago

@delaguilaluis Hi Luis, can you check the CI failure. I can merge this, if we get green build.

delaguilaluis commented 7 years ago

Hi @subeeshcbabu ! The CI failure is because the lint command is failing. The output shows this error:

lib/buildroutes.js: line 27, col 38, This function's cyclomatic complexity is too high. (17)

I didn't modified that file, but let me know if I could help on a refactor to fix it.

delaguilaluis commented 7 years ago

Closing this since #80 fixed it. Now more options are passed to enjoi, so joi converts the string values to the schema type.