-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
fix: assign schemas to host ajv instance #126
base: master
Are you sure you want to change the base?
Conversation
@diogosilva95 The CI is failing, can you add a unit test as well please? |
@Fdawgs added the test and fixed lint :) |
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.
Not sure if it is a good idea, when encapsulation is exist, you can have same $id
with different content.
would you provide an example please? when you add a schema to the ajv instance with an existing id it throws an error |
That is the exact problem I mention, import fastify from "fastify";
const app = fastify();
app.register(async (instance) => {
instance.addSchema({
$id: 'foo',
type: 'object',
properties: {
foo: { type: 'string' }
}
})
})
app.register(async (instance) => {
instance.addSchema({
$id: 'foo',
type: 'object',
properties: {
foo: { type: 'string' },
bar: { type: 'string' }
}
})
})
await app.ready() |
Isn't |
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
The ajv
instance is encapsulated too.
I would just add another test to cover the cliba feedback 👍🏼
The problem is similar to |
Fixes the issue #113 by adding the schemas to the internal avj instance used by the plugin
Checklist
npm run test
andnpm run benchmark
and the Code of conduct