defineRouteMeta needs to take a type parameter for examples value
Open
Nobody has claimed this yet.
enhancement
v2
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 899
- Avg merge
- 2d 24m
- Merged PRs (30d)
- 40
Description
Describe the feature
defineRouteMeta({
openAPI: {
tags: ["test"],
description: "Test route description",
requestBody: {
required: true,
content: {
"application/json": {
description: "Payload",
summary: "Payload",
schema: SomeInputSchemaJson,
examples: {
my_correct_example {
summary: "an awesome example",
value: {
yayValidField: 'nice'
},
},
my_incorrect_example {
summary: "oops",
value: {
failTrain: 'lmao'
},
},
},
},
},
},
responses: {
"200": {
summary: "Success",
description: "Success",
content: {
"application/json": {
encoding: {},
schema: SomeOutputSchemaJson,
},
},
},
},
},
});
Given the above route meta, we should be able to ensure that we get type safety when inserting incorrect example data structure :
defineRouteMeta<SomeInput>({
openAPI: {
tags: ["test"],
description: "Test route description",
requestBody: {
required: true,
content: {
"application/json": {
description: "Payload",
summary: "Payload",
schema: SomeInputSchemaJson,
examples: {
my_correct_example {
summary: "an awesome example",
value: {
yayValidField: 'nice'
},
},
my_incorrect_example {
summary: "oops",
value: {
failTrain: 'lmao' 👈👈👈👈👈👈👈👈 should now show error
},
},
},
},
},
},
responses: {
"200": {
summary: "Success",
description: "Success",
content: {
"application/json": {
encoding: {},
schema: SomeOutputSchemaJson,
},
},
},
},
},
});
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
The issue names defineRouteMeta but no source files or tests. Start by locating its TypeScript definition and the OpenAPI requestBody content types, then inspect how examples values are typed. Done means a generic such as SomeInput causes incorrect example fields to be rejected while valid values remain accepted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, typescript
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100