Sveltekit Api Generator

screenshot of Sveltekit Api Generator
express
svelte
vite

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

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.
express
Express

Express.js is a simple Node.js framework for single, multi-page, and hybrid web applications.

svelte
Svelte

Svelte is a modern front-end framework that compiles your code at build time, resulting in smaller and faster applications. It uses a reactive approach to update the DOM, allowing for high performance and a smoother user experience.

vite
Vite

Vite is a build tool that aims to provide a faster and leaner development experience for modern web projects

typescript
Typescript

TypeScript is a superset of JavaScript, providing optional static typing, classes, interfaces, and other features that help developers write more maintainable and scalable code. TypeScript's static typing system can catch errors at compile-time, making it easier to build and maintain large applications.