-
-
Notifications
You must be signed in to change notification settings - Fork 208
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
allOf Schema and additionalProperties result in unexpected result #684
Comments
Your example is using |
@climba03003 yep my bad, i've updated title and details |
cc @ivan-tymoshenko it might be a bug in your latest changes |
I cannot reproduce your problem. import { mergeSchemas } from '@fastify/merge-json-schemas'
import { build } from 'fast-json-stringify'
const schema = {
allOf: [
{
type: 'object',
properties: {
id: {
type: 'integer'
},
parent_id: {
type: ['null', 'integer'],
default: null
},
name: {
type: 'string'
}
},
required: ['id', 'name']
},
{
type: 'object',
properties: {
integrations: {
type: 'array',
items: {
type: 'object',
properties: {
id: {
type: 'integer'
},
domain: {
type: 'string'
},
is_enabled: {
type: 'boolean'
}
},
required: ['id', 'domain', 'is_enabled']
}
}
},
required: ['integrations']
},
{
type: 'object',
properties: {
parent: {
oneOf: [
{
type: 'object',
properties: {
id: {
type: 'integer'
},
name: {
type: 'string'
}
},
required: ['id', 'name']
},
{
type: 'null'
}
],
default: null
}
}
}
]
}
const merged = mergeSchemas(schema.allOf)
console.log(JSON.stringify(merged, null, 2))
const input = {
id: 1,
name: 'Name',
integrations: [
{
id: 1,
domain: 'example.com',
is_enabled: 1
}
],
parent_id: 1,
parent: {
id: 1,
name: 'Name'
}
}
const stringify = build(merged)
const result = stringify(input)
console.log(result)
const stringify2 = build(schema)
const result2 = stringify2(input)
console.log(result2) |
I see where the problem comes from. |
@climba03003 hmm, yep i've double checked it now and found that
|
@climba03003 yep, seems i should update my codebase then. Thank you for fast response, you're very helpful! Have a good day, guys |
It should be a bug that need to fix though. |
If I understand @climba03003 correctly than this is a bug. @climba03003 Close please If i misunderstood |
In the test, it seems like expected result. https://github.com/fastify/merge-json-schemas/blob/main/test/properties.test.js#L138-L167 It is easy to have additional I would say we should either
|
Prerequisites
Last working version
5.11.1
Stopped working in version
5.12.0
Node.js version
21.x
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
14.2
💥 Regression Report
allOf schema stringify doesn't work as expected. See details below.
Steps to Reproduce
Here is example:
Expected Behavior
Version 5.11.1
Expected result:
Next, if i comment down
integrations.domain
inside input object i should receive error:Version 5.12.0
Next in version 5.12.0 result will be following:
We can see that
integrations.is_enabled
has wrong type.Next, if i comment down
integrations.domain
inside input object i should receive error, but got this:No error fired and domain property is missed. Remove additional props is not working as well.
Thank you for attention.
Cheers.
The text was updated successfully, but these errors were encountered: