fastify-type-provider-json-schema-to-ts
fastify-type-provider-json-schema-to-ts copied to clipboard
Accept FromSchemaOptions in plugin definitions for references
I would like to propose that the Plugin definition of this type provider support accepting FromSchemaOptions somewhere in the generics argument, so that I can pass in schema references on routes that have external references.
Is that something you are open to? Feedback welcome. I will add test shortly. I just wanted to open up for some feedback in terms of implementation.
Also, do you want me to target latest or next?
Checklist
- [ ] run
npm run testandnpm run benchmark - [ ] tests and/or benchmarks are included
- [x] documentation is changed or added
- [x] commit message and code follows the Developer's Certification of Origin and the Code of conduct
I'll update this for 4.0. Is this (or similar) something people would be willing to land?
I'm ok to land this in v4. Can you update this?
Sorry for the long wait, it ended up at the bottom of my long GH notification queue.
Yeah. Been playing with it inside of a fork. Will update
This would be a nice addition, currently working it around by using .withTypeProvider, but it would be nice sugar to have it in the plugin definition instead.
Sorry to be slow on this PR, if anyone wants to beat me to it, feel free.
The main hangup I'm having here is figuring out an API that is acceptable.
I think given the new changes in fastify type providers, the generic should accept two options objects, one for the serializer and one for the validator. In practice, I've found that I need to pass serialize options to one side and not the other.
Ok, I refactored a bunch of discoveries I made while using this. I think this is ready to go but open to feedback and objections regarding the breaking change.
cc @mcollina this is ready to go, @Fdawgs as the most active maintainer and also @kalvenschraut as the original contributor of these options.
I'm quite happy with how this turned out, especially when used with the async plugin provider. Very clean!
Published my fork at @bcomnes/fastify-type-provider-json-schema-to-ts if anyone wants to play with it in the meantime.
I'll try the fork in my project and drop feedback here if anything breaks.
Sorry @bcomnes, this'll need a rebase to resolve conflicts due to migrating this repo from standard to neostandard for linting. :)
Ok @Fdawgs should be good to go. I also simplified the README.md to reduce redundancy in some of the examples. I also added some migration examples to the PR to link from the changelog.
~~@bcomnes where was that fork published ?~~
Never mind. I installed it from bcomnes/fastify-type-provider-json-schema-to-ts#references-in-helpers.
Works great!!