Hi,
I am playing with the framework to know if I should keep using it and this crashes the server when I npm server. Not sure why and I couldn't find anything in the docs. Thanks for your insight!
const userSchema = {
schema: {
response: {
200: {
type: 'object',
properties: {
users: { type: 'array' }
}
}
}
}
TypeError: Cannot read property '$ref' of undefined
at buildArray (/Users/om/Documents/projects/ch/node-api/node_modules/fast-json-stringify/index.js:401:19)
at nested (/Users/m/Documents/projects/ch/node-api/node_modules/fast-json-stringify/index.js:518:19)
at Object.keys.forEach (/Users/m/Documents/projects/ch/node-api/node_modules/fast-json-stringify/index.js:365:18)
at Array.forEach (native)
at buildObject (/Users/m/Documents/projects/ch/node-api/node_modules/fast-json-stringify/index.js:352:40)
at build (/Users/m/Documents/projects/crowdhub/node-api/node_modules/fast-json-stringify/index.js:56:14)
at getValidatorForStatusCodeSchema (/Users/m/Documents/projects/ch/node-api/node_modules/fastify/lib/validation.js:15:10)
at /Users/m/Documents/projects/ch/node-api/node_modules/fastify/lib/validation.js:21:21
at Array.reduce (native)
at getResponseSchema (/Users/m/Documents/projects/ch/node-api/node_modules/fastify/lib/validation.js:20:22)
at build (/Users/m/Documents/projects/ch/node-api/node_modules/fastify/lib/validation.js:44:28)
at _fastify.after (/Users/m/Documents/projects/ch/node-api/node_modules/fastify/fastify.js:400:7)
at Function._encapsulateThreeParam (/Users/m/Documents/projects/ch/node-api/node_modules/avvio/boot.js:271:7)
at Boot.callWithCbOrNextTick (/Users/m/Documents/projects/ch/node-api/node_modules/avvio/boot.js:223:5)
at Boot._after (/Users/m/Documents/projects/ch/node-api/node_modules/avvio/boot.js:180:26)
at process.nextTick (/Users/m/Documents/projects/ch/node-api/node_modules/avvio/plugin.js:30:5)
Done. Thanks!
I just ran into the same issue and found the solution in this issue.
Just want to put this here for somebody else who might be asking this question...
type : 'array' requires items in a similar fashion as the type object requires properties.
type: 'array',
items: {
type: 'object',
properties : {
name: { type: 'string' },
nickname: { type: 'string' },
age: { type: 'integer' }
}
}
Most helpful comment
I just ran into the same issue and found the solution in this issue.
Just want to put this here for somebody else who might be asking this question...
type : 'array'requires items in a similar fashion as the type object requires properties.