Fastify ​
WARNING
Fastify plugin is currently in beta. The interface might change before it becomes stable. We encourage you to leave feedback on GitHub.
About ​
Fastify is a fast and low overhead web framework for Node.js.
Collaborators ​
Features ​
- seamless integration with 
@hey-api/openapi-tsecosystem - type-safe route handlers
 - minimal learning curve thanks to extending the underlying technology
 
Installation ​
In your configuration, add fastify to your plugins and you'll be ready to generate Fastify artifacts. 🎉
js
import { defaultPlugins } from '@hey-api/openapi-ts';
export default {
  input: 'https://get.heyapi.dev/hey-api/backend',
  output: 'src/client',
  plugins: [
    ...defaultPlugins,
    'fastify', 
  ],
};Output ​
The Fastify plugin will generate the following artifacts, depending on the input specification.
Route Handlers ​
Route handlers are generated from all endpoints. The generated interface follows the naming convention of SDK functions.
ts
const fastify = Fastify();
const serviceHandlers: RouteHandlers = {
  createPets(request, reply) {
    reply.code(201).send();
  },
  listPets(request, reply) {
    reply.code(200).send([]);
  },
  showPetById(request, reply) {
    reply.code(200).send({
      id: Number(request.params.petId),
      name: 'Kitty',
    });
  },
};
fastify.register(glue, { serviceHandlers });Examples ​
You can view live examples on StackBlitz.
Sponsors ​
Love Hey API? Become our sponsor.




