You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
regarding to Fastify docs you can use @fastify/type-provider-json-schema-to-ts to convert the schema into a TS type, like this:
import { JsonSchemaToTsProvider } from '@fastify/type-provider-json-schema-to-ts'
import fastify from 'fastify'
const server = fastify().withTypeProvider<JsonSchemaToTsProvider>()
server.get('/', {schema: /* your schema*/}, (req, res)=>{
// now req.body has the right type
})
but, if I want to separate the route logic,.
unfortunately, there is no working example
server.get('/', {schema: /* your schema*/}, route)
function route(req, res){
// I want to use the generated type here
let { invalidProp } = req.body
}
The text was updated successfully, but these errors were encountered:
regarding to Fastify docs you can use
@fastify/type-provider-json-schema-to-ts
to convert the schema into a TS type, like this:but, if I want to separate the route logic,.
unfortunately, there is no working example
The text was updated successfully, but these errors were encountered: