Registry
M

fastify/5/route-schema-enhancement

No description available

manishjha-04343 executions

  • Legacy
  • fastify
  • 5
  • migration
Connect a repo
npx codemod fastify/5/route-schema-enhancement

This codemod enhances the schema definition for query strings by converting it to the full object schema format, adding properties and required fields.

Before

ts
fastify.get(
  '/route', {
    schema: {
      querystring: {
        name: { type: 'string' },
      },
    },
  },
  (req, reply) => {
    reply.send({ hello: req.query.name });
  },
);

After

ts
fastify.get(
  '/route', {
    schema: {
      querystring: {
        type: 'object',
        properties: {
          name: { type: 'string' },
        },
        required: ['name'],
      },
    },
  },
  (req, reply) => {
    reply.send({ hello: req.query.name });
  },
);

This illustrates how the codemod updates query string schema definitions in Fastify v5 to the more detailed object schema format, ensuring proper validation.

Ready to evolve your codebase?

Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.