Repository navigation
feat: new traits merge mechanism - #907
asyncapi-bot merged 9 commits into
Conversation
|
Kudos, SonarCloud Quality Gate passed! |
fmvilas
left a comment
There was a problem hiding this comment.
Like it but got some suggestions.
|
@magicmatatjahu am I to understand you champion this for version 3? |
|
Yeah, I can champion this, but please give me a time to apply changes :) |
Would you be able to provide an ETA? Please don't take it as me chasing but just want to know if it's gonna be a week, a month, a quarter, etc, so we can decide if it makes sense to move forward, or look for an alternative, etc. Thanks! |
|
Concerning my previous comment, @magicmatatjahu do you think you will have time to work on it this week or the next one? Thanks! |
|
@smoya It should be easy to add in parser :) Hopefully I will do it in this weekend :) |
2ff014b to
fdc93d3
Compare
|
You have successfully added a new SonarCloud configuration ``. As part of the setup process, we have scanned this repository and found no existing alerts. In the future, you will see all code scanning alerts on the repository Security tab. |
Co-authored-by: Fran Méndez <[email protected]>
|
Kudos, SonarCloud Quality Gate passed! |
|
@smoya PR in ParserJS asyncapi/parser-js#744 I also added review suggestions. It can be merged. |
|
|
||
| ### <a name="traitsMergeMechanism"></a>Traits Merge Mechanism | ||
|
|
||
| Traits MUST be merged with the main object using the [JSON Merge Patch](https://tools.ietf.org/html/rfc7386) algorithm in the same order they are defined. A property on a trait MUST NOT override the same property on the main object. |
There was a problem hiding this comment.
I would be more explicit on the exception over JSON Merge Patch mechanism on not overriding properties on the target. Like mentioning it is literally an exception
There was a problem hiding this comment.
Additionally, I will suggest using wording from JSON Merge Patch RFC, for example calling "target" to what you called "main object"
There was a problem hiding this comment.
Target is good, but you need to keep in mind that the whole problem that JSON Merge patch addresses and describes is an inverse situation than merging traits ;)
There was a problem hiding this comment.
So how to call it?
There was a problem hiding this comment.
Yeah, target sounds better to me too.
|
@magicmatatjahu do you need anything specific to push this forward? |
|
|
||
| ### <a name="traitsMergeMechanism"></a>Traits Merge Mechanism | ||
|
|
||
| Traits MUST be merged with the main object using the [JSON Merge Patch](https://tools.ietf.org/html/rfc7386) algorithm in the same order they are defined. A property on a trait MUST NOT override the same property on the main object. |
There was a problem hiding this comment.
Yeah, target sounds better to me too.
|
@jonaslagoni as discussed in DM, go forward with this PR :) |
Co-authored-by: Fran Méndez <[email protected]>
|
Thanks for bringing this in, @magicmatatjahu ! |
|
|
||
| ### <a name="traitsMergeMechanism"></a>Traits Merge Mechanism | ||
|
|
||
| Traits MUST be merged with the target object using the [JSON Merge Patch](https://tools.ietf.org/html/rfc7386) algorithm in the same order they are defined. A property on a trait MUST NOT override the same property on the target object. |
There was a problem hiding this comment.
When implementing this, I think we need to be a bit careful here. The JSON Merge Patch is meant to overwrite the target by design. It's not just making sure that properties are not overridden, also the "null" semantics of JSON Merge Patch is then not applicable, I think.
But I like that this solution is very concise and you avoided defining your own merge algorithm.
Imho, it would be very nice to point to a reference implementation or code snippet how this is to be implemented correctly. As a Dev, I would feel more confident looking at a code example to check my understanding. I like the example, but a simple example cannot cover all the interesting corner cases :)
There was a problem hiding this comment.
I created a followup issue for your suggestion @Fannon asyncapi/website#1879
|
Kudos, SonarCloud Quality Gate passed! |
|
/rtm |
|
🎉 This PR is included in version 3.0.0-next-major-spec.13 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |








title: "new traits merge mechanism"
Related issue(s):
#505
That PR introduces the new traits merge mechanism. In simple words, in the current approach (in
2.x.x) traits overwrite values defined on the main object. New approach treat main object with higher priority, so Message Object like:after trait merging should be defined as:
That PR doesn't fix problems described in the PR #532, it only change the "main" trait merge mechanism, not JSON Merge Patch mechanism.