Skip to content

Clearly define how traits should be applied #36

Closed as not planned
Closed as not planned

Description

@jonaslagoni

Reason/Context

Because traits can be somewhat hard to get right, we need to ensure that all parsers apply them correctly and provide all the necessary documentation to achieve it.

Related issues:
Spec issue: asyncapi/spec#505
Spec PR: asyncapi/spec#532

Activity

  1. added
    enhancement
    on Dec 17, 2021
  2. Fannon commented on Dec 17, 2021

    @Fannon

    Thanks for bringing this up!

    In this JSFiddle I've provided two example implementations in JavaScript, in the case that we want to go with the approach proposed in #532:

    The first implementation (function apply(origin, patch)) is based on JSON Merge patch and deletes target properties if null is passed.

    The second implementation (function merge(...objects)) is very similar, but skips on the special null behavior (my personal preference)

    In general, I'm unsure whether we should base trait inheritance on the JSON Merge patch RFC, as its semantics are different from what we want to have from traits. Merge Path is basically about the patch overwriting the target. Inheritance / Traits are about applying information from the source to the target, but never overwriting the target.
    I'm also unsure on the Merge Patch behavior of using null to remove a property. This is essential for patches, but I can see how this is misleading (and I think even unnecessary) for trait inheritance.

    Please be aware that there are no unit-tests for this implementation. Before putting it into the spec, we should write unit-tests with various example data.

  3. github-actions commented on Apr 17, 2022

    @github-actions

    This issue has been automatically marked as stale because it has not had recent activity 😴

    It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

    There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

    Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

    Thank you for your patience ❤️

  4. github-actions commented on Nov 27, 2022

    @github-actions

    This issue has been automatically marked as stale because it has not had recent activity 😴

    It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

    There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

    Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

    Thank you for your patience ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementstale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions