-
Notifications
You must be signed in to change notification settings - Fork 517
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
feat: experimental defineRouteMeta
#2102
Conversation
Also, I wanted to add a test for the defineOpenAPISchema function, but it errors out with or My idea was to add an additional preset with something like:
|
β Live Preview ready!
|
This looks really promising and sorry being delayed. I might need time until 2.10 release to properly test it. (in the meantime you don't need to rebase I can happily handle rebase once ready to check on it ππΌ ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely looks like a nice improvement. I am still mostly looking forward to automatically inferring the type (see #938) but this is a good compromise for the time being.
What I do not like is that is seems to only support object literals (based on reading the code, please correct me if I am wrong). No real evaluation for the route metadata is possible. This can and will confuse a lot of people. My first though was that this could be used with zod to generate zome of the types automatically but this does not seem feasible.
defineRouteMeta
Thanks for your initiatives on this dear @eriksLapins. I have made some refactors in the way it works to experiment alternative approach for Nitro. The meta is scanned using a rollup plugin now to allow HMR and uses a native parser of rollup + AST to Object transform and is only enabled with an experimental open API flag. |
How can we share the validation (let's say I am using zod) between the route meta and the |
It is experimental and not for validation right now. |
@pi0 Any idea when this will be in production and not just on the "nightly" version? |
2.10 release no ETA. Also mind you, this API is likely to completely change into event handler object format nothing to rely on. |
π Linked issue
β Type of change
π Description
I added the option to change the default provided schema directly in the server route file with defineRouteMeta, which can take in any key: value pair, with one defined in this PR - openAPI operations object, which will amend the default schema with types inferred from OperationsObject in openapi-typescript
This solves the issue that we can get better looking openapi documentation with better support
Possibly resolves the problem shown in discussion #2056
π Checklist