-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
feat: toc and operation reply #523
Merged
Merged
Changes from 5 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
eb8b9d5
feat: common helpers with tests
korifey91 c3dd464
chore: update `@asyncapi/cli` and `@asyncapi/parser` versions
korifey91 7b2f685
fix: show operation reply messages
korifey91 400b4d0
fix(table of contents): correctly show all operations
korifey91 deaa2eb
feat(table of contents): use new `CommonHelpers` class for `Operation…
korifey91 a7e0ffc
fix: adjust `v2` operation types constants
korifey91 4182d41
feat(test): handle v3 `request` operation type
korifey91 eea544d
feat: move `isV3` helper into `CommonHelpers`
korifey91 0cb2e29
feat: show short operation type for v2
korifey91 2ab0ff8
chore: add comment to v2 operation types
korifey91 5b9c7f3
feat(test): add `CommonHelpers.isV3` unit tests
korifey91 9dcdd1e
feat: common helpers with tests
korifey91 130daed
chore: update `@asyncapi/cli` and `@asyncapi/parser` versions
korifey91 916ac2a
fix: show operation reply messages
korifey91 73bf5ed
fix(table of contents): correctly show all operations
korifey91 3de2a03
feat(table of contents): use new `CommonHelpers` class for `Operation…
korifey91 3b87982
fix: adjust `v2` operation types constants
korifey91 9199903
feat(test): handle v3 `request` operation type
korifey91 0e75817
feat: move `isV3` helper into `CommonHelpers`
korifey91 414da8a
feat: show short operation type for v2
korifey91 09da43e
chore: add comment to v2 operation types
korifey91 2839be0
feat(test): add `CommonHelpers.isV3` unit tests
korifey91 e5acf7a
Merge remote-tracking branch 'origin/master'
korifey91 24182cd
fix(test): create asyncapi doc with version using `createAsyncAPIDocu…
korifey91 0839c64
fix(test): use valid `bindingVersion` in `Operations` test in case `s…
korifey91 47b462b
fix(test): update snapshots
korifey91 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const OPERATION_TYPES = { | ||
V3: { | ||
REQUEST: 'request', | ||
SEND: 'send', | ||
REPLY: 'reply', | ||
RECEIVE: 'receive', | ||
}, | ||
V2: { | ||
REQUEST: 'request', | ||
SEND: 'publish', | ||
REPLY: 'reply', | ||
RECEIVE: 'subscribe', | ||
} | ||
}; | ||
|
||
const getOperationTypesByVersion = (version) => { | ||
const [majorVersion] = version.split('.'); | ||
|
||
return OPERATION_TYPES[`V${majorVersion}`]; | ||
}; | ||
|
||
export class CommonHelpers { | ||
static getOperationType(operation, asyncApiDoc) { | ||
const operationsTypes = getOperationTypesByVersion(asyncApiDoc.version()); | ||
|
||
if (operation.isSend()) { | ||
if (operation.reply() !== undefined) { | ||
return operationsTypes.REQUEST; | ||
} | ||
return operationsTypes.SEND; | ||
} | ||
if (operation.isReceive() && operation.reply() !== undefined) { | ||
return operationsTypes.REPLY; | ||
} | ||
return operationsTypes.RECEIVE; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v2 did not support request/reply pattern, so we really need to stick to publish/subscribe always, no
request/reply
what I mean is that in case of v2 it is either
publish
orsubscribe
and I believeoperation.reply()
is anyway always undefined in v2not sure if you are familiar in v2
so in v2 spec, we had publish/subscribe from perspective of the user of the API. So if AsyncAPI document for service A had
publish
operation - then it meant that end user can send a message, and service A in fact subscribes to a message. Same around, if service A hadsubscribe
operation, it meant that user cansubscribe
so the service A was in factpublishing
. Yeah, confusing, thus we changed itin v3 we say what API does, so
send
means API sends andreceive
means API receives - as simple as that.REQUEST: 'request'
should bepublish
REPLY: 'request'
should besubscribe
any anyway, they will never be use as in v2, reply is always undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for detailed comment! I appreciate it.
I'll fix types.