nitro
nitro copied to clipboard
defineRouteMeta needs to take a type parameter for examples value
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?