-
-
Notifications
You must be signed in to change notification settings - Fork 120
Open
Description
Problem
Nitric generates OpenAPI specs during build (as shown in the architecture docs), but the generated specs only include route definitions — no request/response body schemas. This limits the usefulness of the generated spec for:
- API documentation — Consumers can't see what payloads are expected
- Client generation — Tools like
openapi-typescriptproduceunknowntypes for bodies - Contract testing — No machine-readable contract to validate against
Currently, developers must validate request bodies manually in handlers, but this knowledge doesn't flow back into the OpenAPI spec.
Suggested Solution
Allow defining schemas using plain TypeScript types:
import { api } from '@nitric/sdk';
interface CreateUserBody {
name: string;
email: string;
age?: number;
}
interface CreateUserResponse {
id: string;
name: string;
email: string;
}
api.post<CreateUserBody, CreateUserResponse>('/users', async (ctx) => {
const body = ctx.req.json(); // typed as CreateUserBody
// ...
return { id: '123', name: body.name, email: body.email };
});Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels