spec icon indicating copy to clipboard operation
spec copied to clipboard

operationId usability in code generation

Open derberg opened this issue 4 years ago • 5 comments

tl;dr we need a way to provide operationId for code generation of different applications, both server and clients, or in other words consumers and producers. So there is a need for different operationId names depending on the "perspective" or let's simply call it the "purpose of generated code"

Currently, AsyncAPI document should be written from the perspective of the "client", the user that interacts with described API.

This perspective causes for example a confusion around the understanding of pub/sub semantics

Another challenge with having only one "perspective" is around the operationId.

Let's take the following part of AsyncAPI document:

/travel/status:
    subscribe:
        summary: You can listen to travel info status.
        operationId: onTravelInfo #client code perspective, generated client reacts "onTravelInfo" incomming message 
        message:
           $ref: '#/components/messages/travelInfo'

The client, the user subscribes to /travel/status. The generated code gets a function onTravelInfo, that reacts on incoming travel info. Sounds good, right?

Challenge is that I want to not only generate a code for the client, but also the server, the server that exposed the API described with AsyncAPI document. What shall I do with operationId. I either rename to to something like subTravelInfo which is neutral, but not super clear about the purpose and will make my generated code cryptic. I could also just rename it to sendTravelInfo but then have a situation that I do not follow the AsyncAPI approach to describe API from client perspective, make things even more confusing.

derberg avatar May 17 '21 12:05 derberg

Same problem exists with the summary and description fields. A description that is best suited for "clients" doesn't fit well when documenting your "application". It's a mess. And it's all caused by the mess with publish/subscribe. I think once it's fixed there it will be automatically fixed here too. Especially, if we split verbs into the two categories/point of view.

fmvilas avatar May 18 '21 18:05 fmvilas

This issue has been automatically marked as stale because it has not had recent activity :sleeping: It will be closed in 60 days if no further activity occurs. To unstale this issue, add a comment with detailed explanation. Thank you for your contributions :heart:

github-actions[bot] avatar Jul 18 '21 00:07 github-actions[bot]

This issue has been automatically marked as stale because it has not had recent activity :sleeping: It will be closed in 60 days if no further activity occurs. To unstale this issue, add a comment with detailed explanation. Thank you for your contributions :heart:

github-actions[bot] avatar Sep 18 '21 00:09 github-actions[bot]

This issue has been automatically marked as stale because it has not had recent activity :sleeping:

It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience :heart:

github-actions[bot] avatar Jan 19 '22 00:01 github-actions[bot]

This issue has been automatically marked as stale because it has not had recent activity :sleeping:

It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience :heart:

github-actions[bot] avatar May 26 '22 00:05 github-actions[bot]

This issue has been automatically marked as stale because it has not had recent activity :sleeping:

It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience :heart:

github-actions[bot] avatar Nov 03 '22 00:11 github-actions[bot]

I think in v3 we should require one document for the client and another one for the server. In other words, we don't allow deriving one from the other. So you can't figure out the client by just switching send and receive from the "server" document to get the client one.

It needs a PR though. @derberg I'll be happy to take it if you're not in the mood.

fmvilas avatar Nov 11 '22 14:11 fmvilas

@fmvilas be my guest ☺️

derberg avatar Nov 14 '22 20:11 derberg

Done https://github.com/asyncapi/spec/pull/875

fmvilas avatar Nov 20 '22 18:11 fmvilas

:tada: This issue has been resolved in version 3.0.0-next-major-spec.8 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

asyncapi-bot avatar Feb 07 '23 16:02 asyncapi-bot

This issue has been automatically marked as stale because it has not had recent activity :sleeping:

It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience :heart:

github-actions[bot] avatar Jun 28 '23 00:06 github-actions[bot]

Calm down, almighty bot, calm down.

fmvilas avatar Jul 07 '23 06:07 fmvilas

This issue has been automatically marked as stale because it has not had recent activity :sleeping:

It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience :heart:

github-actions[bot] avatar Nov 07 '23 00:11 github-actions[bot]