parser-js: "messageId" must be unique across all the messages.
Describe the bug
One message cannot be reused in publish and subscribe in the same channel, if a messageId is defined on the message
To Reproduce
Steps to reproduce the behavior:
- Assume someMessage has messageId defined.
- Create a document with a channel like so:
channels:
someChannel:
publish:
message:
$ref: "#/components/messages/someMessage"
subscribe:
message:
$ref: "#/components/messages/someMessage"
bindings:
eventstore:
# This is not autogenerated to go code unfortunately
streamName: "someStream"
- Try to
asyncapi generate models golang
- See error
error asyncapi2-message-messageId-uniqueness "messageId" must be unique across all the messages.
Expected behavior
This should be possible. My usecase is that i want the same service to publish and subscribe to the same eventstore channel, that is used to persist data
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 16 (9 by maintainers)
@wiegell would you like to work on the fix considering the suggested solutions @magicmatatjahu posted? We can bring you assistance if you need it.
There should be a possibility to check the references (I mean the dereferenced messages) by the reference in JS memory, so comparison of two messages which are referenced from this same reference should be equal
true
- so you can create the storage mechanism to check equality.json-schema-ref-parser
works in that way, I don’t remember if Spectral resolver also.EDIT: if references won’t work, there is still possibility to use the
documentInventory
from Spectral context to check the “path” of references, so then we can make the comparison of$ref
value.I mean the asyncapi cli validate command. I know i don’t have to specify it, but why not have the option when it seems to be best practice? It just seems to me that the id’s are evaluated for duplicates in an unfit place, when my initial example is not possible?