Skip to content

Feature Request: OpenAPI Framework Support for Fastify #915

@SiddhantBohra

Description

@SiddhantBohra

We currently have excellent support for OpenAPI integration with Express using libraries like express-openapi, which streamline the development of APIs by providing features such as validation, routing, and documentation based on OpenAPI specifications. However, there is a lack of a similar robust framework for the Fastify ecosystem, which is a fast, lightweight, and developer-friendly alternative to Express.

This feature request is for developing or integrating a library that offers similar OpenAPI capabilities for Fastify.

Key Features

  1. Schema-Driven Development
    • Generate routes, request validation, and response validation based on OpenAPI specifications.
    • Ensure that API implementations strictly follow the OpenAPI spec.
  2. Middleware & Hook Support
    • Ability to easily integrate with Fastify’s hooks, schema validation, and plugins for additional flexibility.
  3. Documentation Integration
    • Automatically generate API documentation (e.g., Swagger UI) based on the OpenAPI spec.
    • Support exporting the OpenAPI spec dynamically.
  4. Error Handling
    • Standardized error responses based on OpenAPI definitions.
  5. Extensibility
    • Provide hooks or extension points to customize the behavior, such as modifying schema or adding custom middleware.
  6. Compatibility with Fastify Ecosystem
    • Support Fastify’s plugin system and align with its performance and lightweight nature.

Benefits
• Improved developer productivity and consistency when building APIs with Fastify.
• Easier migration paths for teams moving from Express to Fastify while maintaining OpenAPI-based workflows.
• Streamlined process for adhering to API design-first principles.

Possible Implementation Considerations
• Base the architecture on existing Fastify plugins and schema validation features.
• Leverage existing OpenAPI parsers like swagger-parser or openapi-schema-validator.
• Include robust TypeScript support for type inference and validation.

References
express-openapi: The existing library for Express.
Fastify Documentation: Explore plugin and validation capabilities of Fastify.

Looking for Feedback
• Are there existing solutions or plugins that partially address this need?
• Suggestions for additional features or use cases to consider?
• Volunteers to help design or implement the library?

By creating this feature, we can empower the Fastify community to build OpenAPI-compliant APIs more efficiently while retaining the performance benefits of Fastify.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions