API contract
Solivio generates OpenAPI from TypeScript route contracts instead of maintaining a handwritten schema file.
Source of truth
Section titled “Source of truth”API contracts live in apps/solivio/src/server/api/contracts.ts. Each contract
declares:
- HTTP method and path.
- Operation ID, summary, and tags.
- Zod request body schema, when the endpoint accepts a body.
- Zod response schemas by status code.
The Next.js route handlers import those same schemas for request validation and response parsing. That keeps implementation behavior and documentation tied to the same boundary definitions.
Generate the schema
Section titled “Generate the schema”yarn openapi:generateThis runs scripts/generate-openapi.ts, registers the route contracts with
@asteasolutions/zod-to-openapi, and writes:
apps/docs/public/openapi/solivio.jsonThe Starlight OpenAPI plugin consumes that generated file and builds the API
reference pages under /api/.
Documented endpoints
Section titled “Documented endpoints”The generated API reference covers every Next.js route handler under
apps/solivio/src/app/api:
GET /api/auth/{authPath}POST /api/auth/{authPath}POST /api/chatGET /api/embedding-modelsGET /api/healthGET /api/offersPOST /api/offersGET /api/offers/{offerId}PATCH /api/offers/{offerId}DELETE /api/offers/{offerId}GET /api/offers/{offerId}/chat/threadsPOST /api/offers/{offerId}/chat/threadsGET /api/offers/{offerId}/chat/threads/{threadId}/messagesGET /api/offers/{offerId}/pdfPOST /api/offers/{offerId}/productsPATCH /api/offers/{offerId}/products/{offerProductId}DELETE /api/offers/{offerId}/products/{offerProductId}GET /api/offers/{offerId}/revisionsPOST /api/offers/{offerId}/revisionsGET /api/offers/{offerId}/revisions/{revisionId}POST /api/offers/{offerId}/revisions/{revisionId}/restoreGET /api/offers/pdfPOST /api/offers/pdfPOST /api/offers/quickGET /api/productsPOST /api/products/importPOST /api/products/searchPOST /api/products/text-searchGET /api/requestsPOST /api/requests
The Better Auth route is documented as a catch-all because the concrete subroutes are owned by the Better Auth handler rather than by Solivio route code.
Validation policy
Section titled “Validation policy”Route handlers validate request bodies with the Zod schemas exported from the
contract module and return standard 400 error payloads for contract
violations. Add new error responses to the contract at the same time as stricter
runtime handling lands.