Sveltekit Api Generator screenshot

Sveltekit Api Generator

Author Avatar Theme by Langscot
Updated: 21 Aug 2023
22 Stars

Generates a Swagger UI and API client based on your SvelteKit API endpoints in +server.ts files

Categories

Overview

This innovative project focuses on enhancing type safety for SvelteKit’s API endpoints, providing developers with a convenient way to generate OpenAPI schemas from their existing API code. By utilizing a Vite plugin, this tool not only generates schemas but also offers a powerful Swagger UI for easy exploration of your APIs. Although still in the early development stages and not suitable for production use, it promises to streamline your SvelteKit projects by ensuring a robust and error-free environment for API communication.

The inspiration behind this initiative arises from the growing need for type safety when dealing with JSON data fetched from SvelteKit’s API endpoints. By simplifying the API exploration process and offering automatic type safety, this project aims to enhance overall development efficiency as codebases expand in complexity.

Features

  • OpenAPI Schema Generation: Automatically generates an OpenAPI schema from your +server.ts files to keep your APIs well-documented and easily accessible.
  • Type-Safe Client Library: Creates a type-safe client library for your API at src/lib/api.ts, minimizing the risk of type-related errors.
  • Swagger UI Integration: Serves an intuitive Swagger UI to explore your API endpoints without the need for manual schema definition.
  • Easy Vite Plugin Setup: Simple installation and configuration through the vite.config.ts file, allowing developers to integrate with their existing SvelteKit projects seamlessly.
  • Type Safety with json() Helper: Ensures that only endpoints using the SvelteKit’s json() helper function provide type safety for response bodies.
  • Support for Query Parameters: Automatically includes query parameters in the OpenAPI schema when using SvelteKit’s searchParams methods.
  • Active Development and Contributions: The project welcomes contributions from the community, encouraging improvements and new feature suggestions via GitHub.