{"_id":"@aeolun/fastify-zod-openapi","_rev":"4-a63d02d8ee6433fa8f0d8acb8b3fdde2","name":"@aeolun/fastify-zod-openapi","dist-tags":{"latest":"4.1.4"},"versions":{"4.1.2":{"name":"@aeolun/fastify-zod-openapi","version":"4.1.2","keywords":["typescript","json-schema","swagger","openapi","openapi3","zod","zod-openapi","fastify","plugin","type","provider"],"license":"MIT","_id":"@aeolun/fastify-zod-openapi@4.1.2","maintainers":[{"name":"aeolun","email":"bart@serial-experiments.com"}],"homepage":"https://github.com/samchungy/fastify-zod-openapi#readme","bugs":{"url":"https://github.com/samchungy/fastify-zod-openapi/issues"},"dist":{"shasum":"f7e024542bd22c5fb9a187ccd3db7af9fa927b57","tarball":"https://registry.npmjs.org/@aeolun/fastify-zod-openapi/-/fastify-zod-openapi-4.1.2.tgz","fileCount":7,"integrity":"sha512-laCudtFyuX9Ljrhnwkv/XroDk5ou9IUOwuUF4tBwivkB6Tr+Pk/awgse2eE+rQNbja3TzI/BmhbFBU6f75z7HA==","signatures":[{"sig":"MEQCIE8ZUx3EiTnE06OAycctd1MzlkojkgejOFbvcPN1vEehAiAKFNR1bRFvgtFqMjROep/JnWqsavXMwlrTDGtbIQgtGw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":47541},"main":"./dist/index.cjs","_from":"file:aeolun-fastify-zod-openapi-4.1.2.tgz","skuba":{"type":"package","version":"9.0.1","template":"oss-npm-package","entryPoint":"src/index.ts"},"types":"./dist/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=20"},"exports":{".":{"types":{"import":"./dist/index.d.mts","require":"./dist/index.d.ts"},"import":"./dist/index.mjs","require":"./dist/index.cjs"},"./package.json":"./package.json"},"scripts":{"lint":"skuba lint","test":"skuba test","build":"crackle package","start":"skuba node --port=5000 examples/openapi.ts","format":"skuba format","test:ci":"skuba test --coverage","test:watch":"skuba test --watch"},"_npmUser":{"name":"aeolun","email":"bart@serial-experiments.com"},"_resolved":"/tmp/fdf6cc1df86b10d588bfe9db2dfaf723/aeolun-fastify-zod-openapi-4.1.2.tgz","_integrity":"sha512-laCudtFyuX9Ljrhnwkv/XroDk5ou9IUOwuUF4tBwivkB6Tr+Pk/awgse2eE+rQNbja3TzI/BmhbFBU6f75z7HA==","repository":{"url":"git+ssh://git@github.com/samchungy/fastify-zod-openapi.git","type":"git"},"_npmVersion":"10.9.2","description":"Fastify plugin for zod-openapi","directories":{},"sideEffects":false,"_nodeVersion":"22.14.0","dependencies":{"@fastify/error":"^4.0.0","fastify-plugin":"^5.0.0","fast-json-stringify":"^6.0.0"},"publishConfig":{"registry":"https://registry.npmjs.org/","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"zod":"3.24.1","skuba":"9.1.0","fastify":"5.2.1","@types/node":"22.13.1","zod-openapi":"4.2.3","@crackle/cli":"0.15.5","@fastify/swagger":"9.4.2","@fastify/swagger-ui":"5.2.1","@fastify/under-pressure":"9.0.3","eslint-plugin-zod-openapi":"1.0.0"},"peerDependencies":{"zod":"^3.21.4","fastify":"5","zod-openapi":"^4.2.0","@fastify/swagger":"^9.0.0","@fastify/swagger-ui":"^5.0.1"},"peerDependenciesMeta":{"@fastify/swagger":{"optional":true},"@fastify/swagger-ui":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/fastify-zod-openapi_4.1.2_1747465325458_0.9410960460210294","host":"s3://npm-registry-packages-npm-production"}},"4.1.3":{"name":"@aeolun/fastify-zod-openapi","version":"4.1.3","keywords":["typescript","json-schema","swagger","openapi","openapi3","zod","zod-openapi","fastify","plugin","type","provider"],"license":"MIT","_id":"@aeolun/fastify-zod-openapi@4.1.3","maintainers":[{"name":"aeolun","email":"bart@serial-experiments.com"}],"homepage":"https://github.com/samchungy/fastify-zod-openapi#readme","bugs":{"url":"https://github.com/samchungy/fastify-zod-openapi/issues"},"dist":{"shasum":"3c75ec10f14f6ca76bc95b8d4d8596fed0c44dfa","tarball":"https://registry.npmjs.org/@aeolun/fastify-zod-openapi/-/fastify-zod-openapi-4.1.3.tgz","fileCount":7,"integrity":"sha512-1woIadoh67tbGuUvJDjbNIN57RRPtgrv6pObB+KSDoEnyUu421c8HMxnqoUjXK31TYrfrEviMlP/9M6WCbsc3Q==","signatures":[{"sig":"MEUCIGl4sUTcJ4TnzRvY3w98gb6TIFU5KyrZ1EWLytfq1xM1AiEA37syNBnpLJLRhP3vvdX3a1akPEpTPHkBb3Yyx4r1VQ8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":49089},"main":"./dist/index.cjs","_from":"file:aeolun-fastify-zod-openapi-4.1.3.tgz","skuba":{"type":"package","version":"9.0.1","template":"oss-npm-package","entryPoint":"src/index.ts"},"types":"./dist/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=20"},"exports":{".":{"types":{"import":"./dist/index.d.mts","require":"./dist/index.d.ts"},"import":"./dist/index.mjs","require":"./dist/index.cjs"},"./package.json":"./package.json"},"scripts":{"lint":"skuba lint","test":"skuba test","build":"crackle package","start":"skuba node --port=5000 examples/openapi.ts","format":"skuba format","test:ci":"skuba test --coverage","test:watch":"skuba test --watch"},"_npmUser":{"name":"aeolun","email":"bart@serial-experiments.com"},"_resolved":"/tmp/0676952d27c4bf4d7debf99d581e880f/aeolun-fastify-zod-openapi-4.1.3.tgz","_integrity":"sha512-1woIadoh67tbGuUvJDjbNIN57RRPtgrv6pObB+KSDoEnyUu421c8HMxnqoUjXK31TYrfrEviMlP/9M6WCbsc3Q==","repository":{"url":"git+ssh://git@github.com/samchungy/fastify-zod-openapi.git","type":"git"},"_npmVersion":"10.9.2","description":"Fastify plugin for zod-openapi","directories":{},"sideEffects":false,"_nodeVersion":"22.14.0","dependencies":{"@fastify/error":"^4.0.0","fastify-plugin":"^5.0.0","fast-json-stringify":"^6.0.0"},"publishConfig":{"registry":"https://registry.npmjs.org/","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"zod":"3.24.1","skuba":"9.1.0","fastify":"5.2.1","@types/node":"22.13.1","zod-openapi":"4.2.3","@crackle/cli":"0.15.5","@fastify/swagger":"9.4.2","@fastify/swagger-ui":"5.2.1","@fastify/under-pressure":"9.0.3","eslint-plugin-zod-openapi":"1.0.0"},"peerDependencies":{"zod":"^3.21.4","fastify":"5","zod-openapi":"^4.2.0","@fastify/swagger":"^9.0.0","@fastify/swagger-ui":"^5.0.1"},"peerDependenciesMeta":{"@fastify/swagger":{"optional":true},"@fastify/swagger-ui":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/fastify-zod-openapi_4.1.3_1747470929722_0.8493828289856968","host":"s3://npm-registry-packages-npm-production"}},"4.1.4":{"name":"@aeolun/fastify-zod-openapi","version":"4.1.4","description":"Fastify plugin for zod-openapi","keywords":["typescript","json-schema","swagger","openapi","openapi3","zod","zod-openapi","fastify","plugin","type","provider"],"homepage":"https://github.com/samchungy/fastify-zod-openapi#readme","bugs":{"url":"https://github.com/samchungy/fastify-zod-openapi/issues"},"repository":{"type":"git","url":"git+ssh://git@github.com/samchungy/fastify-zod-openapi.git"},"license":"MIT","sideEffects":false,"exports":{".":{"types":{"import":"./dist/index.d.mts","require":"./dist/index.d.ts"},"import":"./dist/index.mjs","require":"./dist/index.cjs"},"./package.json":"./package.json"},"main":"./dist/index.cjs","module":"./dist/index.mjs","types":"./dist/index.d.ts","dependencies":{"@fastify/error":"^4.0.0","fast-json-stringify":"^6.0.0","fastify-plugin":"^5.0.0"},"devDependencies":{"@crackle/cli":"0.15.5","@fastify/swagger":"9.4.2","@fastify/swagger-ui":"5.2.1","@fastify/under-pressure":"9.0.3","@types/node":"22.13.1","eslint-plugin-zod-openapi":"1.0.0","fastify":"5.2.1","skuba":"9.1.0","zod":"3.24.1","zod-openapi":"4.2.3"},"peerDependencies":{"@fastify/swagger":"^9.0.0","@fastify/swagger-ui":"^5.0.1","fastify":"5","zod":"^3.21.4","zod-openapi":"^4.2.0"},"peerDependenciesMeta":{"@fastify/swagger":{"optional":true},"@fastify/swagger-ui":{"optional":true}},"engines":{"node":">=20"},"publishConfig":{"provenance":true,"registry":"https://registry.npmjs.org/"},"skuba":{"entryPoint":"src/index.ts","template":"oss-npm-package","type":"package","version":"9.0.1"},"scripts":{"build":"crackle package","format":"skuba format","lint":"skuba lint","start":"skuba node --port=5000 examples/openapi.ts","test":"skuba test","test:ci":"skuba test --coverage","test:watch":"skuba test --watch"},"_id":"@aeolun/fastify-zod-openapi@4.1.4","_integrity":"sha512-GE8YK7u9foEDSNiVqlcDJ4sV8ElUqWts+ZE57wgOcM4faAUH9RM6LULe9uRJnZracHnhkkvwyS6kTnEiQbli7g==","_resolved":"/tmp/cb0a39cd3ea6b3d619f6ab2e3cc67a49/aeolun-fastify-zod-openapi-4.1.4.tgz","_from":"file:aeolun-fastify-zod-openapi-4.1.4.tgz","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-GE8YK7u9foEDSNiVqlcDJ4sV8ElUqWts+ZE57wgOcM4faAUH9RM6LULe9uRJnZracHnhkkvwyS6kTnEiQbli7g==","shasum":"a84aa5ec76d2d39be1b102d8f460298ba07ee0d9","tarball":"https://registry.npmjs.org/@aeolun/fastify-zod-openapi/-/fastify-zod-openapi-4.1.4.tgz","fileCount":7,"unpackedSize":49089,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQC49F+qcZSuu383TAMUrhJ3fmhiN6EVWnZupOGEEJeYGgIhAI8PrYyNHJpZbJANhoIdpb8qtDfxgk7/DP86+LpHeu1Z"}]},"_npmUser":{"name":"aeolun","email":"bart@serial-experiments.com"},"directories":{},"maintainers":[{"name":"aeolun","email":"bart@serial-experiments.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/fastify-zod-openapi_4.1.4_1747471552061_0.9712884470739118"},"_hasShrinkwrap":false}},"time":{"created":"2025-05-17T07:02:05.456Z","modified":"2025-05-17T08:45:52.443Z","4.1.2":"2025-05-17T07:02:05.632Z","4.1.3":"2025-05-17T08:35:29.897Z","4.1.4":"2025-05-17T08:45:52.277Z"},"bugs":{"url":"https://github.com/samchungy/fastify-zod-openapi/issues"},"license":"MIT","homepage":"https://github.com/samchungy/fastify-zod-openapi#readme","keywords":["typescript","json-schema","swagger","openapi","openapi3","zod","zod-openapi","fastify","plugin","type","provider"],"repository":{"type":"git","url":"git+ssh://git@github.com/samchungy/fastify-zod-openapi.git"},"description":"Fastify plugin for zod-openapi","maintainers":[{"name":"aeolun","email":"bart@serial-experiments.com"}],"readme":"<p align=\"center\">\n  <h1 align=\"center\">fastify-zod-openapi</h1>\n</p>\n<p align=\"center\">\nFastify <a href=\"https://fastify.dev/docs/latest/Reference/Type-Providers/\">type provider</a>, <a href=\"https://fastify.dev/docs/latest/Reference/Validation-and-Serialization/\">validation, serialization</a> and <a href=\"https://github.com/fastify/fastify-swagger\">@fastify/swagger</a> support for <a href=\"https://github.com/samchungy/zod-openapi\">zod-openapi</a>.\n</p>\n<div align=\"center\">\n<a href=\"https://www.npmjs.com/package/fastify-zod-openapi\"><img src=\"https://img.shields.io/npm/v/fastify-zod-openapi\"/><a>\n<a href=\"https://www.npmjs.com/package/fastify-zod-openapi\"><img src=\"https://img.shields.io/npm/dm/fastify-zod-openapi\"/><a>\n<a href=\"https://nodejs.org/en/\"><img src=\"https://img.shields.io/badge/node-%3E%3D%2020-brightgreen\"/><a>\n<a href=\"https://github.com/samchungy/fastify-zod-openapi/actions/workflows/test.yml\"><img src=\"https://github.com/samchungy/fastify-zod-openapi/actions/workflows/test.yml/badge.svg\"/><a>\n<a href=\"https://github.com/samchungy/fastify-zod-openapi/actions/workflows/release.yml\"><img src=\"https://github.com/samchungy/fastify-zod-openapi/actions/workflows/release.yml/badge.svg\"/><a>\n<a href=\"https://github.com/seek-oss/skuba\"><img src=\"https://img.shields.io/badge/🤿%20skuba-powered-009DC4\"/><a>\n</div>\n<br>\n\n## Install\n\nInstall via `npm`, `pnpm` or `pnpm`:\n\n```bash\nnpm install zod zod-openapi fastify-zod-openapi\n## or\npnpm add zod zod-openapi fastify-zod-openapi\n## or\npnpm install zod-openapi fastify-zod-openapi\n```\n\n## Usage\n\n```ts\nimport 'zod-openapi/extend';\nimport fastify from 'fastify';\nimport {\n  type FastifyZodOpenApiSchema,\n  type FastifyZodOpenApiTypeProvider,\n  serializerCompiler,\n  validatorCompiler,\n} from 'fastify-zod-openapi';\nimport { z } from 'zod';\n\nconst app = fastify();\n\napp.setValidatorCompiler(validatorCompiler);\napp.setSerializerCompiler(serializerCompiler);\n\napp.withTypeProvider<FastifyZodOpenApiTypeProvider>().route({\n  method: 'POST',\n  url: '/:jobId',\n  schema: {\n    body: z.object({\n      jobId: z.string().openapi({\n        description: 'Job ID',\n        example: '60002023',\n      }),\n    }),\n    response: {\n      201: z.object({\n        jobId: z.string().openapi({\n          description: 'Job ID',\n          example: '60002023',\n        }),\n      }),\n    },\n  } satisfies FastifyZodOpenApiSchema,\n  handler: async (req, res) => {\n    await res.send({ jobId: req.body.jobId });\n  },\n});\n\nawait app.ready();\nawait app.listen({ port: 5000 });\n```\n\n## Usage with plugins\n\n```ts\nimport 'zod-openapi/extend';\nimport fastify from 'fastify';\nimport {\n  type FastifyPluginAsyncZodOpenApi,\n  type FastifyZodOpenApiSchema,\n  serializerCompiler,\n  validatorCompiler,\n} from 'fastify-zod-openapi';\nimport { z } from 'zod';\n\nconst app = fastify();\n\napp.setValidatorCompiler(validatorCompiler);\napp.setSerializerCompiler(serializerCompiler);\n\nconst plugin: FastifyPluginAsyncZodOpenApi = async (fastify, _opts) => {\n  fastify.route({\n    method: 'POST',\n    url: '/',\n    // Define your schema\n    schema: {\n      body: z.object({\n        jobId: z.string().openapi({\n          description: 'Job ID',\n          example: '60002023',\n        }),\n      }),\n      response: {\n        201: z.object({\n          jobId: z.string().openapi({\n            description: 'Job ID',\n            example: '60002023',\n          }),\n        }),\n      },\n    } satisfies FastifyZodOpenApiSchema,\n    handler: async (req, res) => {\n      await res.send({ jobId: req.body.jobId });\n    },\n  });\n};\n\napp.register(plugin);\n```\n\n## Usage with @fastify/swagger\n\n```ts\nimport 'zod-openapi/extend';\nimport fastifySwagger from '@fastify/swagger';\nimport fastifySwaggerUI from '@fastify/swagger-ui';\nimport fastify from 'fastify';\nimport {\n  type FastifyZodOpenApiSchema,\n  type FastifyZodOpenApiTypeProvider,\n  fastifyZodOpenApiPlugin,\n  fastifyZodOpenApiTransform,\n  fastifyZodOpenApiTransformObject,\n  serializerCompiler,\n  validatorCompiler,\n} from 'fastify-zod-openapi';\nimport { z } from 'zod';\nimport { type ZodOpenApiVersion } from 'zod-openapi';\n\nconst app = fastify();\n\napp.setValidatorCompiler(validatorCompiler);\napp.setSerializerCompiler(serializerCompiler);\n\nawait app.register(fastifyZodOpenApiPlugin);\nawait app.register(fastifySwagger, {\n  openapi: {\n    info: {\n      title: 'hello world',\n      version: '1.0.0',\n    },\n    openapi: '3.0.3' satisfies ZodOpenApiVersion, // If this is not specified, it will default to 3.1.0\n  },\n  transform: fastifyZodOpenApiTransform,\n  transformObject: fastifyZodOpenApiTransformObject,\n});\nawait app.register(fastifySwaggerUI, {\n  routePrefix: '/documentation',\n});\n\napp.withTypeProvider<FastifyZodOpenApiTypeProvider>().route({\n  method: 'POST',\n  url: '/',\n  schema: {\n    body: z.object({\n      jobId: z.string().openapi({\n        description: 'Job ID',\n        example: '60002023',\n      }),\n    }),\n    response: {\n      201: {\n        content: {\n          'application/json': {\n            schema: z.object({\n              jobId: z.string().openapi({\n                description: 'Job ID',\n                example: '60002023',\n              }),\n            }),\n          },\n        },\n      },\n    },\n  } satisfies FastifyZodOpenApiSchema,\n  handler: async (_req, res) =>\n    res.send({\n      jobId: '60002023',\n    }),\n});\nawait app.ready();\nawait app.listen({ port: 5000 });\n```\n\n### Declaring Components\n\nThis library allows you to easily declare components. As an example:\n\n```typescript\nconst title = z.string().openapi({\n  description: 'Job title',\n  example: 'My job',\n  ref: 'jobTitle', // <- new field\n});\n```\n\nWherever `title` is used in your request/response schemas across your application, it will instead be created as a reference.\n\n```json\n{ \"$ref\": \"#/components/schemas/jobTitle\" }\n```\n\nFor a further dive please follow the documentation [here](https://github.com/samchungy/zod-openapi#creating-components).\n\nIf you wish to declare the components manually you will need to do so via the plugin's options. You will also need\nto create a custom SerializerCompiler to make use of [fast-json-stringify](https://github.com/fastify/fast-json-stringify).\n\n```ts\nconst components: ZodOpenApiComponentsObject = { schemas: { mySchema } };\nawait app.register(fastifyZodOpenApiPlugin, {\n  components,\n});\n\nconst customSerializerCompiler = createSerializerCompiler({\n  components,\n});\n```\n\nAlternatively, you can use `JSON.stringify` instead.\n\n```ts\nconst customSerializerCompiler = createSerializerCompiler({\n  stringify: JSON.stringify,\n});\n```\n\nBy default, this library assumes that if a response schema provided is not a Zod Schema, it is a JSON Schema and will naively pass it straight into `fast-json-stringify`. This will not work in conjunction with Fastify's schema registration.\n\nIf you have other routes with response schemas which are not Zod Schemas, you can supply a `fallbackSerializer` to `createSerializerCompiler`.\n\n```ts\nconst customSerializerCompiler = createSerializerCompiler({\n  fallbackSerializer: ({ schema, url, method }) => customSerializer(schema),\n});\n```\n\nPlease note: the `responses`, `parameters` components do not appear to be supported by the `@fastify/swagger` library.\n\n### Create Document Options\n\nIf you wish to use [CreateDocumentOptions](https://github.com/samchungy/zod-openapi#createdocumentoptions), pass it in via the plugin options:\n\n```ts\nawait app.register(fastifyZodOpenApiPlugin, {\n  documentOpts: {\n    unionOneOf: true,\n  },\n});\n```\n\n### Custom Response Serializer\n\nThe default response serializer `serializerCompiler` uses [fast-json-stringify](https://github.com/fastify/fast-json-stringify). Under the hood, the schema passed to the response is transformed using OpenAPI 3.1.0 and passed to `fast-json-stringify` as a JSON Schema.\n\nIf are running into any compatibility issues or wish to restore the previous `JSON.stringify` functionality, you can use the `createSerializerCompiler` function.\n\n```ts\nconst customSerializerCompiler = createSerializerCompiler({\n  stringify: JSON.stringify,\n});\n```\n\n### Error Handling\n\nBy default, `fastify-zod-openapi` emits request validation errors in a similar manner to `fastify` when used in conjunction with it's native JSON Schema error handling.\n\nAs an example:\n\n```json\n{\n  \"code\": \"FST_ERR_VALIDATION\",\n  \"error\": \"Bad Request\",\n  \"message\": \"params/jobId Expected number, received string\",\n  \"statusCode\": 400\n}\n```\n\nFor responses, it will emit a 500 error along with a vague error which will protect your implementation details\n\n```json\n{\n  \"code\": \"FST_ERR_RESPONSE_SERIALIZATION\",\n  \"error\": \"Internal Server Error\",\n  \"message\": \"Response does not match the schema\",\n  \"statusCode\": 500\n}\n```\n\nTo customise this behaviour, you may follow the [fastify error handling](https://fastify.dev/docs/latest/Reference/Validation-and-Serialization/#error-handling) guidance.\n\n#### Request Errors\n\nThis library throws a `RequestValidationError` when a request fails to validate against your Zod Schemas\n\n##### setErrorHandler\n\n```ts\nfastify.setErrorHandler(function (error, request, reply) {\n  if (error.validation) {\n    const zodValidationErrors = error.validation.filter(\n      (err) => err instanceof RequestValidationError,\n    );\n    const zodIssues = zodValidationErrors.map((err) => err.params.issue);\n    const originalError = zodValidationErrors?.[0]?.params.error;\n    return reply.status(422).send({\n      zodIssues\n      originalError\n    });\n  }\n});\n```\n\n##### setSchemaErrorFormatter\n\n```ts\nfastify.setSchemaErrorFormatter(function (errors, dataVar) {\n  let message = `${dataVar}:`;\n  for (const error of errors) {\n    if (error instanceof RequestValidationError) {\n      message += ` ${error.instancePath} ${error.keyword}`;\n    }\n  }\n\n  return new Error(message);\n});\n\n// {\n// code: 'FST_ERR_VALIDATION',\n// error: 'Bad Request',\n// message: 'querystring: /jobId invalid_type',\n// statusCode: 400,\n// }\n```\n\n##### attachValidation\n\n```ts\napp.withTypeProvider<FastifyZodOpenApiTypeProvider>().get(\n  '/',\n  {\n    schema: {\n      querystring: z.object({\n        jobId: z.string().openapi({\n          description: 'Job ID',\n          example: '60002023',\n        }),\n      }),\n    },\n    attachValidation: true,\n  },\n  (req, res) => {\n    if (req.validationError?.validation) {\n      const zodValidationErrors = req.validationError.validation.filter(\n        (err) => err instanceof RequestValidationError,\n      );\n      console.error(zodValidationErrors);\n    }\n\n    return res.send(req.query);\n  },\n);\n```\n\n#### Response Errors\n\n```ts\napp.setErrorHandler((error, _req, res) => {\n  if (error instanceof ResponseSerializationError) {\n    return res.status(500).send({\n      error: 'Bad response',\n    });\n  }\n});\n\n// {\n//   error: 'Bad response';\n// }\n```\n\n## Credits\n\n[fastify-type-provider-zod](https://github.com/turkerdev/fastify-type-provider-zod): Big kudos to this library for lighting the way with how to create type providers, validators and serializers. fastify-zod-openapi is just an extension to this library whilst adding support for the functionality of zod-openapi.\n\n## Development\n\n### Prerequisites\n\n- Node.js LTS\n- pnpm\n\n```shell\npnpm install\npnpm build\n```\n\n### Test\n\n```shell\npnpm test\n```\n\n### Lint\n\n```shell\n# Fix issues\npnpm format\n\n# Check for issues\npnpm lint\n```\n\n### Release\n\nTo release a new version\n\n1. Create a [new GitHub Release](https://github.com/samchungy/zod-openapi/releases/new)\n2. Select `🏷️ Choose a tag`, enter a version number. eg. `v1.2.0` and click `+ Create new tag: vX.X.X on publish`.\n3. Click the `Generate release notes` button and adjust the description.\n4. Tick the `Set as the latest release` box and click `Publish release`. This will trigger the `Release` workflow.\n5. Check the `Pull Requests` tab for a PR labelled `Release vX.X.X`.\n6. Click `Merge Pull Request` on that Pull Request to update main with the new package version.\n\nTo release a new beta version\n\n1. Create a [new GitHub Release](https://github.com/samchungy/fastify-zod-openapi/releases/new)\n2. Select `🏷️ Choose a tag`, enter a version number with a `-beta.X` suffix eg. `v1.2.0-beta.1` and click `+ Create new tag: vX.X.X-beta.X on publish`.\n3. Click the `Generate release notes` button and adjust the description.\n4. Tick the `Set as a pre-release` box and click `Publish release`. This will trigger the `Prerelease` workflow.\n","readmeFilename":"README.md"}