Skip to content

TypeBox no longer requires explicit configuration of kind and modifier keywords #19

@sinclairzx81

Description

@sinclairzx81

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions