@questpie/openapi
v3.0.0
Published
Auto-generate an OpenAPI 3.1 spec from a QUESTPIE app instance and serve interactive API docs via Scalar UI.
Downloads
145
Readme
@questpie/openapi
Auto-generate an OpenAPI 3.1 spec from a QUESTPIE app instance and serve interactive API docs via Scalar UI.
Installation
bun add @questpie/openapiUsage
Register openApiModule() in your modules.ts file to add /openapi.json and /docs routes:
// src/questpie/server/modules.ts
import { adminModule } from "@questpie/admin/server";
import { openApiModule } from "@questpie/openapi";
export default [
adminModule,
openApiModule({
info: { title: "My API", version: "1.0.0" },
scalar: { theme: "purple" },
}),
] as const;Your route handler stays clean — no wrapper needed:
// routes/api/$.ts
import { createFetchHandler } from "questpie";
import { app } from "#questpie";
const handler = createFetchHandler(app, { basePath: "/api" });Once registered, the following endpoints are available:
GET /api/openapi.json → OpenAPI spec
GET /api/docs → Scalar UIWhat Gets Documented
| Category | Endpoints | | --------------- | --------------------------------------------------------------------------------------------------------- | | Collections | List, create, findOne, update, delete, count, deleteMany, restore, versions, revert, upload, schema, meta | | Globals | Get, update, versions, revert, schema | | Routes | All standalone routes, with input/output from Zod schemas | | Auth | Better Auth endpoints (sign-in, sign-up, session, sign-out) | | Search | Full-text search and reindex |
Routes with an explicit outputSchema get full request/response documentation. Routes without it fall back to { type: "object" }.
Standalone Spec Generation
Generate the spec without mounting routes:
import { generateOpenApiSpec } from "@questpie/openapi";
const spec = generateOpenApiSpec(app, {
basePath: "/api",
info: { title: "My API", version: "1.0.0" },
});Documentation
Full documentation: https://questpie.com/docs/client/openapi
License
MIT
