Skip to content

Dereference behavior does not follow AsyncAPI reference object and JSON Schema draft 7 behavior #404

Closed as not planned

Description

@jonaslagoni

Describe the bug

We use the @apidevtools/json-schema-ref-parser dependency to resolve all references, however, this has a faulty implementation.

AsyncAPI 2.2.0 defines a reference as:

The Reference Object is defined by JSON Reference and follows the same structure, behavior and rules. ... . This object cannot be extended with additional properties and any properties added SHALL be ignored.

JSON Schema draft 7 defines the reference behavior as:

An object schema with a "$ref" property MUST be interpreted as a "$ref" reference. ... . All other properties in a "$ref" object MUST be ignored.

Meaning the two overlap in their behavior (lucky for us).

This means that given the following AsyncAPI document:

asyncapi: '2.2.0'
info:
  title: Test overriding dereferenced objects 
  version: '1.0.0'
channels:
  test:
    publish:
      message:
        $ref: '#/components/messages/myMessage'
        name: 'MyOtherMessageName' # Should not be valid
components:
  messages:
    myMessage:
      name: 'MyMessage'
      payload:
        type: object
        properties:
          sentAt:
            $ref: "#/components/schemas/sentAt"
            description: 'test' # Should not be valid
  schemas:
    sentAt:
      type: string
      format: date-time
      description: Date and time when the message was sent.

Check out the studio example (it uses this parser library for bundling the references)

As it can be seen both name in the AsyncAPI reference object for the message is applied, which results in the message being called MyOtherMessageName and not MyMessage.

Same with the JSON Schema the description of the payload message object it has the description test and not Date and time when the message was sent.

Activity

  1. added
    bug
    on Nov 10, 2021
  2. smoya commented on Nov 18, 2021

    @smoya
    Member

    For the record, there is a recent effort on building JSON Schema foundational tooling with kind of (TBD) official support, lead by @jviotti and @Relequestual here json-schema-org/community#113.

  3. jonaslagoni commented on Feb 2, 2022

    @jonaslagoni
    MemberAuthor
  4. github-actions commented on Jun 3, 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 ❤️

  5. github-actions commented on Oct 6, 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 ❤️

  6. github-actions commented on Feb 15, 2023

    @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 ❤️

  7. github-actions commented on Oct 16, 2023

    @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 ❤️

  8. github-actions commented on Feb 29, 2024

    @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 ❤️

  9. jviotti commented on Jun 30, 2024

    @jviotti

    For the record, the bundle command of the JSON Schema CLI tool I've been working on properly does these kind of stuff: https://github.com/Intelligence-AI/jsonschema/blob/main/docs/bundle.markdown

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

    bugstale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions