The OpenAPI specification version to target ("3.0" or "3.1"). Defaults to "3.1" for enhanced JSON Schema Draft 2020-12 compatibility. This determines the schema format, validation capabilities, and available features like tuple support and null type handling.
The original TypeScript type that was analyzed to generate this JSON schema unit. This provides compile-time type safety and enables IDEs to provide better intellisense and validation.
interface User {
id: string;
name: string;
email?: string;
}
// Generate a single schema unit for OpenAPI v3.1 (default)
const userSchema = typia.json.schema<User>();
// Type: IJsonSchemaUnit<"3.1", User>
// Generate a single schema unit for OpenAPI v3.0 (Swagger compatibility)
const swaggerUserSchema = typia.json.schema<User, "3.0">();
// Type: IJsonSchemaUnit<"3.0", User>
IJsonSchemaCollection For handling multiple schemas at once
Single unit of JSON schema representation.
IJsonSchemaUnit
represents a self-contained JSON schema unit that encapsulates a single schema definition along with its associated reusable components. This is typically used when generating a JSON schema for a single TypeScript type, as opposed to a collection of multiple types.Unlike IJsonSchemaCollection which handles multiple schemas,
IJsonSchemaUnit
focuses on representing a single schema with its dependencies. This makes it ideal for scenarios where you need to work with individual type definitions or when integrating with systems that expect single schema documents.The unit contains:
Key differences from collection: