Closed Bram-dc closed 2 weeks ago
Refs will be added once they find a matching object in the "components" objects. It uses JSON.stringify to check for this. It also checks for some common alterations like nullable.
const app = Fastify();
app.setValidatorCompiler(validatorCompiler);
app.setSerializerCompiler(serializerCompiler);
const TOKEN_SCHEMA = z.string().length(12);
app.register(fastifySwagger, {
openapi: {
info: {
title: 'SampleApi',
description: 'Sample backend service',
version: '1.0.0',
},
components: {
schemas: jsonSchemaTransformSchemas({
Token: TOKEN_SCHEMA,
}),
},
servers: [],
},
transform: jsonSchemaTransform,
transformObject: jsonSchemaTransformObject,
});
This change got accepted in: https://github.com/fastify/fastify/pull/5427
I just merged the latest changes into my branch and resolved some linting errors! This should be ready to go for v5. I you wish to have the ref feature separated please tell me.
I just merged the latest changes into my branch and resolved some linting errors! This should be ready to go for v5. I you wish to have the ref feature separated please tell me.
https://github.com/turkerdev/fastify-type-provider-zod/pull/97
I created 2 other PRs to separate these changes:
https://github.com/turkerdev/fastify-type-provider-zod/pull/97 https://github.com/turkerdev/fastify-type-provider-zod/pull/98
I added a way to add refs to your schema and modified the type provider correctly for when this PR is accepted: https://github.com/fastify/fastify/discussions/5311