-
-
Notifications
You must be signed in to change notification settings - Fork 109
Description
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