Examples
Examples
Live Demo
Check out our live example application to see SvelteKit Auto OpenAPI in action.
The demo showcases:
- Automatic inference - Routes with no
_configthat use AST analysis - Runtime validation - Routes with full validation schemas
- Interactive documentation - Browse the generated Scalar API docs
- All three levels - Examples of automatic, strict, and raw JSON Schema approaches
Source Code
Explore the complete source code on GitHub:
The repository includes:
src/routes/api/usersBasic/+server.ts- Level 1: Automatic inference without_configsrc/routes/api/usersOverride/+server.ts- Level 2/3: Full validation with schemassrc/routes/api-docs/[slug]/+server.ts- ScalarModule documentation setup- Full SvelteKit application configuration
What You'll Learn
By exploring the live demo and source code, you'll see:
- How AST inference works - No configuration needed for basic endpoints
- How to add validation - Schemas with StandardSchema or JSON Schema
- Type-safe helpers - Using
validated,json(), anderror() - Documentation generation - OpenAPI schemas created automatically
- Scalar integration - Beautiful interactive docs out of the box
Next Steps
After exploring the examples:
- Read the Quick Start to add SvelteKit Auto OpenAPI to your project
- Learn about Route Configuration to add validation to your routes
- Check out the Validation Guide to use Zod, TypeBox, or other libraries
- Dive into Best Practices for production-ready APIs