Closed Skn0tt closed 3 years ago
@Ethan-Arrowood asked if it works without the Schema: Yes, it does.
It seems to me that in this line, context.preParsing
is undefined in my case.
As a workaround, I was able to fix this issue by adding this.preParsing = null
in context.js
.
So I think this is an issue with the import. Why are you using import * as thatSchema from './that.json'
? I'd debug and make sure this is importing as expected.
I've added console.log({ EndpointJobIDParamsSchema })
to queues.ts
and it logged the following:
{
EndpointJobIDParamsSchema: {
'$schema': 'http://json-schema.org/draft-07/schema#',
title: '/queues/:endpoint/:id params',
type: 'object',
properties: { id: [Object], endpoint: [Object] },
required: [ 'id', 'endpoint' ],
additionalProperties: false
}
}
That seems correct to me. What do you think?
@Skn0tt I have tried and I cannot reproduce based on the provided instructions. Could you include a simplified example in a single file? Thanks
Yes this is what I suspected @Skn0tt - you might need to pass thatSchema.EndpointJobIDParamsSchema
to the route. But also a more simplified example can help us narrow down the issue you're facing
That hasn't been the problem, apparently. It was that I specified my response schema like so in another route:
fastify.get("/anything", { schema: { response: thatSchema } }, ...)
instead of
fastify.get("/anything", { schema: { response: { 200: thatSchema } } }, ...)
It makes sense in hindsight, but I wasn't able to find the error by looking at the error messages.
I'll provide a minimal repro nonetheless and check if I can provide a PR that makes the developer mistake easier to spot :D
🐛 Bug Report
I'm trying to get the Schema validation working, but Fastify throws whenever I make a request:
To Reproduce
/api
and runnpm test
(the tests require Redis running onlocalhost:6379
, you can start one usingdocker run -d --name redis -p 6379:6379 redis
)Expected behavior
I expect Fastify to successfully answer my requests.
Your Environment