modelina icon indicating copy to clipboard operation
modelina copied to clipboard

Generate channel type

Open mcoevert opened this issue 3 years ago • 6 comments

Reason/Context

To ensure only channels allowed in the schema are being used, generating a type of available channels would be very nice.

For example:

channels:
  channelOne:
    ...
  channelTwo:
    ...

Expected outcome:

type Topics = "channelOne" | "channelTwo";

mcoevert avatar Nov 01 '22 09:11 mcoevert

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

github-actions[bot] avatar Nov 01 '22 09:11 github-actions[bot]

Thanks for the issue @mcoevert!

Somewhat related to https://github.com/asyncapi/modelina/issues/181

This is possible to do with a bit of custom code, by combining pre-parsing the AsyncAPI document you are able to iterate over the channels and create your own Enum MetaModel, and provide it to a generator.

Maybe it would make sense to add this behavior to the AsyncAPI processor and enable it through an option such as includeChannelModels 🤔 What do you think?

jonaslagoni avatar Nov 01 '22 11:11 jonaslagoni

(I'm a colleague of @mcoevert ) - we have for now done this ourselves in the generate script, but I do think it would make sense to have this be included...

PanMan avatar Nov 09 '22 17:11 PanMan

Definitely a good request, just gonna leave this open 🙂

@PanMan you are more than welcome to provide a PR with this, I think we could include it here: https://github.com/asyncapi/modelina/blob/c4a5f678affbdf78aa046aed310689580923665b/src/processors/AsyncAPIInputProcessor.ts#L45

And create a new processor option to switch it on and off 🤔

What do you think?

jonaslagoni avatar Nov 10 '22 13:11 jonaslagoni

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 Mar 11 '23 00:03 github-actions[bot]

Because this IS enabled by using the core meta model as inputs, I am going ahead and close this issue. As it is unlikely we are going to enable this even further natively in Modelina. Unless someone wants to champion this.

See https://modelina.org/examples?selectedExample=meta-model

jonaslagoni avatar Jun 24 '23 21:06 jonaslagoni