Comments (8)
However, if we use the parser under next-major-spec branch so we parse v3 docs, it does not happen:
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?
from parser-js.
However, if we use the parser under next-major-spec branch so we parse v3 docs, it does not happen:
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.
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: '#/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
from parser-js.
Updated description according to previous comment
from parser-js.
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?
from parser-js.
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
messages:
- $ref: '#/components/messages/UserSignedUp'
is not the same as
messages:
subscribe.message:
$ref: '#/components/messages/UserSignedUp'
the id do not match
from parser-js.
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 .json()
object of those.
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);
}
}
Source: https://github.com/asyncapi/parser-js/blob/next-major-spec/src/models/v3/asyncapi.ts#L149-L154 (same for v2 model as well)
Note that we check if the schema.json()
is already present in the set, however we never store the output of .json()
on it but the Schema. Meaning if (!schemas.has(schema.json())) {
is always true.
from parser-js.
Here is the fix #897
from parser-js.
Fixed by #897
from parser-js.
Related Issues (20)
- Parser do not validate and throw error when `parameters` are provided but address is null HOT 4
- Parser do not validate if channel that is referenced in reply with location has `null` in address HOT 6
- Parser returns `undefined` when there's bindings in message HOT 1
- Parser fails to throw an error when i provide an invalid asyncapi file HOT 1
- Inconsistence Parser Methods HOT 2
- .id() doesn't work for `$ref`ed components HOT 1
- Parser fails to return Operation Channel HOT 1
- Parser fails to return Operation HOT 1
- Upgrade parser in `next-major-spec` to use latest `@asyncapi/[email protected]`
- Some Spectral Rules for spec v3 should run after resolving references HOT 1
- The automated release is failing 🚨
- Inconsistent `range` Values in Error Diagnostics for Different AsyncAPI File Formats HOT 3
- chained messages().get('xx').operations() call returns unrelated operations HOT 2
- Divide "Maintainer" role into two categories: Triager and Committer HOT 9
- Integrate smoya/multi-parser-js into asyncapi/parser-js HOT 32
- [BUG] payload of type date shows validation error HOT 9
- [BUG] message payload schema object cannot be called by parser api HOT 2
- [BUG] Parsing yields error due to correlation between a Channel and Operation HOT 1
- [BUG] schemaValidation does not allow string examples for other schema types HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from parser-js.