Skip to content
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

Merged
merged 7 commits into from
Jan 15, 2019

Conversation

Eomm
Copy link
Member

@Eomm Eomm commented Jan 6, 2019

Checklist

  • run npm run test and npm run benchmark
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message and code follows Code of conduct

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 (via fastify.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 on function override but I don't found a better way.

I'll wait for your precious feedback 馃槂

Thank you

@mcollina mcollina requested a review from delvedor January 7, 2019 10:36
@mcollina mcollina added the semver-major Issue or PR that should land as semver major label Jan 7, 2019
Copy link
Member

@mcollina mcollina left a 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!

@@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Member

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?

Copy link
Member Author

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 馃

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@delvedor delvedor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
semver-major Issue or PR that should land as semver major
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants