-
-
Notifications
You must be signed in to change notification settings - Fork 28
Closed
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the issue has not already been raised
Issue
Hi. Just a heads up. I've recently published a new version of TypeBox that should mitigate the need to configure AJV for the kind
and modifier
keywords. As of @sinclair/typebox@0.24.0
, the kind
and modifier
keywords have been replaced as symbol property keys. This seems to sidestep the AJV strict
checks allowing TypeBox schemas to be used without any explicit configuration.
Before
const StringKind = Symbol('StringKind')
const T = {
kind: StringKind
type: 'string'
}
After
const Kind = Symbol('TypeBox.Kind')
const T = {
[Kind]: 'String' // AJV should ignore properties defined as symbols
type: 'string'
}
The TypeBox type provider will continue to function with this existing kind
and modifier
configuration, however it may be good to remove the ajvTypeBoxPlugin
export and update the documentation accordingly.
Current
import Fastify from 'fastify'
import { ajvTypeBoxPlugin, TypeBoxTypeProvider } from '@fastify/type-provider-typebox'
const fastify = Fastify({
ajv: {
plugins: [ajvTypeBoxPlugin]
}
}).withTypeProvider<TypeBoxTypeProvider>()
Update
import Fastify from 'fastify'
import { TypeBoxTypeProvider } from '@fastify/type-provider-typebox'
const fastify = Fastify().withTypeProvider<TypeBoxTypeProvider>()
Metadata
Metadata
Assignees
Labels
No labels