Plugin not working with JOI
See original GitHub issueHere is schema example for route:
import * as Joi from 'joi';
export const PING_CREATE_VALIDATOR = {
schema: {
body: Joi.object({
example: Joi.string().required(),
}).required(),
},
schemaCompiler: (schema: any) => (data: any) => Joi.validate(data, schema),
};
Error:
TypeError: Cannot read property 'description' of null
at Object.keys.forEach.p (node_modules/fastify-swagger/index.js:217:34)
at Array.forEach (native)
at getPathParams (node_modules/fastify-swagger/index.js:212:23)
at Object.swagger (node_modules/fastify-swagger/index.js:121:11)
at fastify.ready (src/app.ts:49:20)
at Object._encapsulateThreeParam (node_modules/avvio/boot.js:345:7)
at Boot.callWithCbOrNextTick (node_modules/avvio/boot.js:300:5)
at Object.push (node_modules/fastq/queue.js:88:14)
at Boot.ready (node_modules/avvio/boot.js:255:18)
at Object.server.(anonymous function) [as ready] (node_modules/avvio/boot.js:46:21)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Joi alternatives not working as per required for validation of ...
Simple solution using when , got from github. const Joi = require('joi'); const foo = Joi.object({ city: Joi.string().required(), ...
Read more >Joi — awesome code validation for Node.js and Express
This describes how you can use Joi to validate your data. We also learn how to build a middleware for Express that validates...
Read more >How to use the joi.ref function in joi - Snyk
Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues...
Read more >6 Validation with Joi - hapi.js in Action - liveBook · Manning
Working with Joi ; Adding validation to hapi apps; Customising validation errors; Consuming and presenting validation errors;
Read more >Joi — awesome code validation for Node.js and Express
I suggest to have a look and see if there is a helper function that can solve whatever case you have that I'm...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
As soon as I get a chance. Lots of works right now 👍.
Guys I think this is fixed by https://github.com/fastify/fastify-swagger/pull/144. 😄 Only thing you have to do is code a short
transform
method to map Joi schema back to standard JSON schema for Swagger documentation generation.Have a working sample on this repo.
Only schema property you can’t use with Joi is
response
as I ended up reporting to @mcollina here.