@vayo-hq/openapi-compiler
v0.1.1-beta.3
Published
Compiles resolved endpoints into a valid OpenAPI 3.1 document with x-vayo-* extensions. Validates via @apidevtools/swagger-parser before ever returning a document.
Readme
@vayo-hq/openapi-compiler
Compiles Vayo's resolved endpoints into a valid OpenAPI 3.1 document — the
backbone of vayo export and the docs UI's /api/spec endpoint.
Vayo-specific data (which folder an endpoint lives in, whether its schema
is confirmed or inferred, its detected auth requirements, ...) is carried
entirely in x-vayo-* extension fields — the document itself always
validates as plain OpenAPI 3.1, so it works with any tool that already
speaks that format.
import { compile, validate } from "@vayo-hq/openapi-compiler";
const doc = await compile(resolvedEndpoints, "v1"); // throws if the result wouldn't validate
// Optional third argument fills in info.title/description and servers[] —
// mirrors swagger-jsdoc's options.definition.info/servers. Left out
// entirely, compile() falls back to "Vayo API", no description, no servers.
await compile(resolvedEndpoints, "v1", {
title: "Acme API",
description: "Internal order-management API.",
servers: [{ url: "https://api.acme.com", description: "Production" }],
});Other exports:
diffSpecs(specA, specB)— the structural diff behindvayo diff(added/removed operations, added/removed required fields, type changes, enum changes).planOpenApiImport(spec, existingEndpoints, existingEnvironments)— pure planning function behindvayo import: reads an existing OpenAPI 3.0.x/3.1 document and matches its operations/examples/servers against endpoints Vayo already knows about, returning a plan of description/example overrides and new environment candidates to write — no I/O itself. Throws if the input looks like a Postman Collection export instead (a distinct, not-yet-built import path).
Most people use this via vayo export/vayo import, not directly — see
@vayo-hq/cli. To use it standalone:
npm install @vayo-hq/openapi-compiler@betaLicense
MIT
