-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/encapsulation json schema #1370
Feature/encapsulation json schema #1370
Conversation
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.
Good work! I think this is a semver-major change, but I think we should land this in v2.
I've just left some nits in the docs!
docs/Validation-and-Serialization.md
Outdated
@@ -50,7 +50,7 @@ fastify.post('/the/url', { schema }, handler) | |||
|
|||
<a name="shared-schema"></a> | |||
#### Adding a shared schema | |||
Thanks to the `addSchema` API, you can add multiple schemas to the Fastify instance and then reuse them in multiple parts of your application. *(Note that this API is not encapsulated)* | |||
Thanks to the `addSchema` API, you can add multiple schemas to the Fastify instance and then reuse them in multiple parts of your application. As usual this API is encapsulated. |
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.
Thanks to the `addSchema` API, you can add multiple schemas to the Fastify instance and then reuse them in multiple parts of your application. As usual this API is encapsulated. | |
Thanks to the `addSchema` API, you can add multiple schemas to the Fastify instance and then reuse them in multiple parts of your application. As usual, this API is encapsulated. |
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.
Can you also add an example of using this functionality in an encapsulated way?
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.
Done 馃憤 Let me know if it is clear 馃
Co-Authored-By: Eomm <behemoth89@gmail.com>
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.
LGTM
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.
LGTM
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Checklist
npm run test
andnpm run benchmark
Hi, I'm opening this PR for the issue #1351.
I have tried to follow the logic of middleware (for the children update) and hooks (for the
buildHooks
) to implement this feature.Now each fastify instance will have a private
Schemas
object that is replicated when another instance is created (viafastify.build.override()
)I have added some tests that seem logical to me, let me know if there are other cases to cover that I didn't spot.
I have one doubt regarding how I have implemented the
.getSchemas
, replicating the function declaration onfunction override
but I don't found a better way.I'll wait for your precious feedback 馃槂
Thank you