0.1.1 • Published 9 months ago

@standard-community/standard-openapi v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

Standard OpenAPI

npm version npm downloads license

Standard Schema Validator's OpenAPI Schema Converter

Installation

Install the main package -

pnpm add @standard-community/standard-openapi

For some specific vendor, install the respective package also -

VendorPackage
Zodzod-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 -

VendorSupported
Zod
Valibot
ArkType
Effect Schema🛠️

You can check the compatibility versions at standardschema.dev