Twipped / joi-to-swagger

A library to convert Joi schema objects into Swagger schema definitions
Other
164 stars 63 forks source link

False default values for boolean not passing #71

Closed nelsongomes closed 3 years ago

nelsongomes commented 3 years ago

@Mairu please copy this code, this is fix to allow to pass false boolean in defaultValue.

Code changes: const defaultValue = get(schema, '_flags.default'); if ((defaultValue || typeof defaultValue === 'boolean') && typeof defaultValue !== 'function') { swagger.default = defaultValue; }

test code: simpleTest( 'boolean', joi.boolean().default(false), { default: false, type: 'boolean', }, );

tried to open a PR, but was not possible.

Mairu commented 3 years ago

I applied the changes and released a new version 5.1.0. Thx for the fix.

nelsongomes commented 3 years ago

Thank you

A sábado, 17/10/2020, 17:13, Sebastian Große notifications@github.com escreveu:

I applied the changes and released a new version 5.1.0. Thx for the fix.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Twipped/joi-to-swagger/issues/71#issuecomment-711037354, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAITSRD62BS4T3PW5KDCWQ3SLG7DHANCNFSM4SRYKOWQ .