@yasumu/schema package provides a parser for Yasumu Schema Language (YSL), a custom DSL for defining REST API request schemas.
Installation
Install the schema parser package:Package configuration
The package supports multiple runtimes:Supported runtimes
- Node.js - ESM modules with TypeScript definitions
- Deno - Direct TypeScript import
- Bun - Native TypeScript support
What is Yasumu Schema Language?
Yasumu Schema Language is a structured format for defining API requests with embedded JavaScript code blocks:Key features
- Type-safe parsing - Full TypeScript support with type inference
- Structured blocks - Define metadata, requests, and scripts
- Code blocks - Embed JavaScript for pre-request, post-request, and test scripts
- Serialization - Convert parsed objects back to schema format
- Validation - Automatic schema validation during parsing
Quick start
Schema types
Thet factory provides methods to define schema structure:
t.string()- String valuest.number()- Numeric valuest.boolean()- Boolean valuest.null()- Null valuest.code()- JavaScript code blockst.enum(...)- Enumerated valuest.object({...})- Object structurest.record(type)- Key-value mapst.list(type)- Arrayst.nullable(type)- Optional valuest.union(...)- Union typest.script({...})- Root schema definition
Exports
The package exports the following:Next steps
Parsing API
Learn how to parse schemas
RestModule
Use schemas with REST entities