KosmoJS can automatically generate OpenAPI 3.1 specifications from your API routes.
The generator analyzes your route structure, type definitions, and validation schemas to produce a complete, standards-compliant OpenAPI spec.
Installation β
sh
pnpm install -D @kosmojs/openapi-generatorsh
npm install -D @kosmojs/openapi-generatorsh
yarn add -D @kosmojs/openapi-generatorAdd the OpenAPI generator to your source folder's vite.config.ts:
typescript
import devPlugin from "@kosmojs/dev";
import openapiGenerator from "@kosmojs/openapi-generator";
export default {
plugins: [
devPlugin(apiurl, {
generators: [
openapiGenerator({
outfile: "openapi.json",
openapi: "3.1.0",
info: {
title: "My API",
version: "1.0.0",
description: "API documentation for My App",
},
servers: [
{
url: "http://localhost:4000",
description: "Development server"
}
],
}),
// other generators
],
}),
],
}