Skip to content

Commit

Permalink
docs: update indentation and code snippet in the type providers section
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony133 committed May 26, 2024
1 parent 24af949 commit f81539b
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions docs/Reference/Type-Providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,20 @@ import { JsonSchemaToTsProvider } from '@fastify/type-provider-json-schema-to-ts
const server = fastify().withTypeProvider<JsonSchemaToTsProvider>()

server.get('/route', {
schema: {
querystring: {
type: 'object',
properties: {
foo: { type: 'number' },
bar: { type: 'string' },
},
required: ['foo', 'bar']
}
schema: {
querystring: {
type: 'object',
properties: {
foo: { type: 'number' },
bar: { type: 'string' },
},
required: ['foo', 'bar']
}

}
}, (request, reply) => {

// type Query = { foo: number, bar: string }

const { foo, bar } = request.query // type safe!
// type Query = { foo: number, bar: string }
const { foo, bar } = request.query // type safe!
})
```

Expand All @@ -78,17 +76,16 @@ import { Type } from '@sinclair/typebox'
const server = fastify().withTypeProvider<TypeBoxTypeProvider>()

server.get('/route', {
schema: {
querystring: Type.Object({
foo: Type.Number(),
bar: Type.String()
})
}
schema: {
querystring: Type.Object({
foo: Type.Number(),
bar: Type.String()
})
}
}, (request, reply) => {

// type Query = { foo: number, bar: string }

const { foo, bar } = request.query // type safe!
// type Query = { foo: number, bar: string }
const { foo, bar } = request.query // type safe!
})
```

Expand Down

0 comments on commit f81539b

Please sign in to comment.