-
Notifications
You must be signed in to change notification settings - Fork 551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamically computed meta with defineRouteMeta()
#2641
Comments
Additional info: As an alternative, I'd be interested if it would be possible to define route meta using the event handler object format: export default defineEventHandler({
meta: {
// Specify meta
},
handler: async (event) => 'Hello World'
}) |
when i use zod-openapi to generate schema, defineRouteMeta can't recognize import { z } from 'zod'
import { createSchema, extendZodWithOpenApi } from 'zod-openapi'
extendZodWithOpenApi(z)
const TestLoginDto = z.object({
username: z.string().openapi({ description: 'Username' }),
password: z.string().openapi({ description: 'Password' }),
})
const { schema: TestLoginSchema } = createSchema(TestLoginDto)
defineRouteMeta({
openAPI: {
summary: 'Login',
requestBody: {
content: {
'application/json': {
schema: TestLoginSchema,
},
},
},
},
}) |
Currently, |
defineRouteMeta()
I think it's a good idea, and without this meta-definition, the entire OpenAPI documentation generation wouldn't make sense. Alternatively, everything could be generated automatically through TypeScript. |
I have same problem with you. I think it is very necessary to support dynamic variables for defineRouteMeta |
Moving to #2974 |
Environment
Nitro
npm:nitropack-nightly@latest
Bun
1.1.21
Reproduction
Describe the bug
Seems like I cannot import any variables inside the openAPI object, it would be very useful to be able to do so since I for example this api returns a value from DB
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: