-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
document.allSchemas() returns "duplicated" schemas #896
Comments
That example is technically an invalid v3 document as the channel does not contain the messages being references in the operation. If you add the messages to the v3 doc, does that re-create the problem as in v2? |
Yes, I was about to write it right now. Same issue happens with v3 as well. And it's about the pointer.
|
Updated description according to previous comment |
but your v3 example is not valid either, right? valid is: asyncapi: '3.0.0'
info:
title: Account Service
version: 1.0.0
description: This service is in charge of processing user signups
channels:
UserSignedUp:
messages:
UserSignedUp:
$ref: '#/components/messages/UserSignedUp'
operations:
user/signedup:
action: send
channel:
$ref: '#/channels/UserSignedUp'
messages:
- $ref: '#/channels/UserSignedUp/messages/UserSignedUp'
components:
messages:
UserSignedUp:
payload:
type: object
properties:
displayName:
type: string
description: Name of the user
email:
type: string
format: email
description: Email of the user so you should reference message from a channel, not components. How else will you validate if message referenced from the operation it the same as in the channel? especially that you need to validate the messageId as well, right? |
let's take asyncapi: '2.6.0'
info:
title: Account Service
version: 1.0.0
description: This service is in charge of processing user signups
channels:
user/signedup:
subscribe:
message:
$ref: '#/components/messages/UserSignedUp'
components:
messages:
UserSignedUp:
payload:
type: object
properties:
displayName:
type: string
description: Name of the user
email:
type: string
format: email
description: Email of the user and converter creates asyncapi: 3.0.0
info:
title: Account Service
version: 1.0.0
description: This service is in charge of processing user signups
channels:
user/signedup:
address: user/signedup
messages:
subscribe.message:
$ref: '#/components/messages/UserSignedUp'
operations:
user/signedup.subscribe:
action: send
channel:
$ref: '#/channels/user~1signedup'
messages:
- $ref: '#/components/messages/UserSignedUp'
components:
messages:
UserSignedUp:
payload:
type: object
properties:
displayName:
type: string
description: Name of the user
email:
type: string
format: email
description: Email of the user it is invalid document
is not the same as
the id do not match |
Whatever you use, it doesn't really matter. The issue keeps happening because the ID of those objects are not used for comparing but the BTW, I just found the bug. This is the callback we use for comparing: const schemas: Set<SchemaInterface> = new Set();
function callback(schema: SchemaInterface) {
if (!schemas.has(schema.json())) {
schemas.add(schema);
}
}
Note that we check if the |
Here is the fix #897 |
Fixed by #897 |
Describe the bug
document.allSchemas()
method returns duplicated schemas when a schema is referenced from a component.In order to compare if two schemas are equal, we compare against their JSON representation (
object.json()
).I compared the JSON string between duplicated and the only thing that changes is the pointer: one refers to the component section, the other to the place where the reference is.
How to Reproduce
Given the following doc:
Parse the document and print all schemas:
This prints the following 6 schemas:
Open
The issue seems to be the
pointer
field, which differs from/components/messages/UserSignedUp/...
and /channels/user~1signedup/subscribe/message/...`Shall we skip pointer field when comparing perhaps?
Expected behavior
Schemas should not be duplicated, as in v3. As per the example, only 3 schemas should be returned.
The text was updated successfully, but these errors were encountered: