0.1.1 • Published 9 months ago
@standard-community/standard-openapi v0.1.1
Standard OpenAPI
Standard Schema Validator's OpenAPI Schema Converter
Installation
Install the main package -
pnpm add @standard-community/standard-openapiFor some specific vendor, install the respective package also -
| Vendor | Package |
|---|---|
| Zod | zod-openapi |
| Valibot | @standard-community/standard-json @valibot/to-json-schema json-schema-walker |
| ArkType | @standard-community/standard-json json-schema-walker |
| Effect Schema | @standard-community/standard-json json-schema-walker |
Usage
import { toOpenAPISchema } from "@standard-community/standard-openapi";
// Define your schema
const schema = v.pipe(
v.object({
myString: v.string(),
myUnion: v.union([v.number(), v.boolean()]),
}),
v.description("My neat object schema"),
);
// Convert it to OpenAPI Schema
const openapiSchema = await toOpenAPISchema(schema);Compatibility
List of supported validators -
| Vendor | Supported |
|---|---|
| Zod | ✅ |
| Valibot | ✅ |
| ArkType | ✅ |
| Effect Schema | 🛠️ |
You can check the compatibility versions at standardschema.dev