OpenAPI auto generated meta from defineEventHandler<{ body: {...} }> Request types
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 899
- Avg merge
- 2d 24m
- Merged PRs (30d)
- 40
Description
Describe the feature
I was looking for a way to auto generate openAPI meta based of my api routes.
defineEventHandler already allows to define the Request type like:
export default defineEventHandler<{
body: { foo: string, bar: boolean },
}>(() => {});
or something like:
import { z } from 'zod';
const bodySchema = z.object({
foo: z.string(),
bar: z.boolean(),
});
export default defineEventHandler<{
body: z.infer<typeof bodySchema>,
}>(() => {});
I came across this issue: #2974
But it would be nice, to be able to define it with defineEventHandler.
Thanks!
Additional information
- Would you be willing to help implement this feature?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the defineEventHandler request-type examples in this issue and the referenced issue #2974. Determine how OpenAPI metadata could be derived for both explicit TypeScript request types and zod-inferred types. Done means the supported route definitions produce usable OpenAPI request metadata, but the implementation scope and validation approach are not specified here.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, typescript
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100