-
-
Notifications
You must be signed in to change notification settings - Fork 380
Description
The specification does not explicitly define how null values in traits or target objects should be interpreted.
While it references the JSON Merge Patch algorithm (which assigns special meaning to null values in merge patches), it also states that "a property on a trait MUST NOT override the same property on the target object." This creates ambiguity regarding how to reconcile the special meaning of null values in a patch with this overriding restriction.
I have tested several examples and examined the output from the @asyncapi/parser. The results differ depending on whether it is a top-level property (directly under the Operation/Operation Trait Object) or a nested property (e.g., within a binding under the Operation/Operation Trait Object), which is confusing.
Could you please clarify how null values should be interpreted in the trait merge mechanism—and whether they should be interpreted at all?
// operations.myOperation['x-test'] === null
// operations.myOperation.bindings.kafka['x-test'] === null
const spec = {
asyncapi: '3.0.0',
info: {
title: 'Object null properties, no traits merge',
version: '1.0',
},
channels: {
myChannel: {}
},
operations: {
myOperation: {
action: 'send',
channel: {
$ref: '#/channels/myChannel'
},
'x-test': null,
bindings: {
kafka: {
'x-test': null
}
}
}
}
}// operations.myOperation['x-test'] === null
// operations.myOperation.bindings.kafka['x-test'] === undefined
const spec = {
asyncapi: '3.0.0',
info: {
title: 'Object null properties, trigger traits merge',
version: '1.0',
},
channels: {
myChannel: {}
},
operations: {
myOperation: {
action: 'send',
channel: {
$ref: '#/channels/myChannel'
},
'x-test': null,
bindings: {
kafka: {
'x-test': null
}
},
traits: [
{}
]
}
}
}// operations.myOperation['x-test'] === null
// operations.myOperation.bindings.kafka['x-test'] === undefined
const spec = {
asyncapi: '3.0.0',
info: {
title: 'Trait null properties',
version: '1.0',
},
channels: {
myChannel: {}
},
operations: {
myOperation: {
action: 'send',
channel: {
$ref: '#/channels/myChannel'
},
traits: [
{
'x-test': null,
bindings: {
kafka: {
'x-test': null
}
},
}
]
}
}
}