question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Plugin not working with JOI

See original GitHub issue

Here 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
gaboesquivelcommented, Jul 30, 2018

As soon as I get a chance. Lots of works right now 👍.

0reactions
Roms1383commented, Jan 21, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found