Skip to content
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

JSON Schema references do not follow $id dereference behavior #403

Closed
jonaslagoni opened this issue Nov 10, 2021 · 6 comments
Closed

JSON Schema references do not follow $id dereference behavior #403

jonaslagoni opened this issue Nov 10, 2021 · 6 comments
Labels
bug Something isn't working keep-open

Comments

@jonaslagoni
Copy link
Member

jonaslagoni commented Nov 10, 2021

Describe the bug

We use the @apidevtools/json-schema-ref-parser dependency to resolve all references, however, this tool does not follow JSON Schema specification in terms of dereferencing: APIDevTools/json-schema-ref-parser#22 (comment)

Based on JSON Schema draft 7, it states that:

The "$id" keyword defines a URI for the schema, and the base URI that other URI references within the schema are resolved against. A subschema's "$id" is resolved against the base URI of its parent schema. If no parent sets an explicit base with "$id", the base URI is that of the entire document, as determined per RFC 3986 section 5 [RFC3986].

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'
components:
  messages:
    myMessage:
      schemaFormat: application/schema+json;version=draft-07
      name: MyMessage
      payload:
          $id: 'http://localhost.com/'
          type: object
          properties:
            sentAt:
              $ref: "/components/schemas/sentAt"

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

The library tries to resolve the reference athttps:///components/schemas/sentAt when it should have tried to resolve it from http://localhost.com/components/schemas/sentAt

@jonaslagoni jonaslagoni added the bug Something isn't working label Nov 10, 2021
@jonaslagoni
Copy link
Member Author

Related issue: APIDevTools/json-schema-ref-parser#136

@smoya
Copy link
Member

smoya commented Nov 18, 2021

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.

@github-actions
Copy link

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

@github-actions
Copy link

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

@github-actions github-actions bot added stale and removed stale labels Sep 17, 2022
@github-actions
Copy link

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

@github-actions github-actions bot added the stale label Jan 17, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 17, 2023
@jonaslagoni
Copy link
Member Author

Still a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working keep-open
Projects
None yet
Development

No branches or pull requests

3 participants