Skip to content
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

[Extension Proposal] AsyncAPI generator #41207

Open
rquinio1A opened this issue Jun 14, 2024 · 10 comments
Open

[Extension Proposal] AsyncAPI generator #41207

rquinio1A opened this issue Jun 14, 2024 · 10 comments
Labels
area/quarkiverse This issue/PR is part of the Quarkiverse organization kind/extension-proposal Discuss and Propose new extensions

Comments

@rquinio1A
Copy link
Contributor

rquinio1A commented Jun 14, 2024

Description

Interested in this extension, please +1 via the emoji/reaction feature of GitHub (top right).

The go-to library to generare Java model classes from an AsyncAPI document is modelina
However, as it's a typscript library, using it in a Maven project requires a lot of boilerplate (frontend-maven-plugin + npm package.json + generator.ts).

There are probably 2 questions to answer for such an extension:

  1. Where to host the extension ?
  1. Which Java generator to use ?

I have a PoC that generates an intermediate OpenAPI document and calls quarkus-openapi-generator on it, but it brings "quarkus-rest-client" dependencies, which don't make sense for event-driven microservices.

Ideally I'd want the same capibilities and user experience for schema-first developement with Quarkus, whether it is for REST server, REST client or event processors.

/cc @hbelmiro @ChMThiel @fjtirado

Repository name

quarkus-asyncapi-generator

Short description

Generate Java POJO from AsyncAPI components

Repository Homepage URL

https://quarkiverse.github.io/quarkiverse-docs/quarkus-asyncapi-generator/dev/

Repository Topics

No response

Team Members

No response

Additional context

No response

@rquinio1A rquinio1A added area/quarkiverse This issue/PR is part of the Quarkiverse organization kind/extension-proposal Discuss and Propose new extensions labels Jun 14, 2024
Copy link

quarkus-bot bot commented Jun 14, 2024

/cc @aloubyansky (extension-proposal), @gastaldi (extension-proposal), @gsmet (extension-proposal), @maxandersen (extension-proposal)

@ChMThiel
Copy link

I think that's a question mainly for @fjtirado since it's for the contract-first part of the extension...

@maxandersen
Copy link
Member

on first hunch this feels like a thing the asyncapi extension could/should do - but I honestly know too little about asyncapi to say which generator to use.

@maxandersen
Copy link
Member

completely out-of-box thinking...would a modelina extension make sense?

one that allows generation using modelina?

similar to how done for kiota?

@maxandersen
Copy link
Member

btw. modelina does not seem to implement/generate a client just generate the model do I read that right?

@rquinio1A
Copy link
Contributor Author

btw. modelina does not seem to implement/generate a client just generate the model do I read that right?

Indeed it generates only the payload model class, in v3 it's components.schemas.* referenced from components.messages.[eventName].payload.$ref.
I've seen requests to also generate wrappers for components.messages.[eventName] containing event metadata (cloud events, headers, ...), but smallrye-reactive-message has its own APIs to manipulate such metadata so I think it doesn't matter.

completely out-of-box thinking...would a modelina extension make sense?
one that allows generation using modelina?
similar to how done for kiota?

Here's an example of calling it from a Maven project: https://github.com/asyncapi/modelina/tree/master/examples/integrate-with-maven
Do you mean Quarkus could hide this boilerplate by packaging nodejs + npm pre-requisites into an extension ?

@maxandersen
Copy link
Member

Do you mean Quarkus could hide this boilerplate by packaging nodejs + npm pre-requisites into an extension ?

kinda - we have quinoa that does that for webapp usage and webbundler that bundles esbuild to enable interesting usecases.

not sure if it suffices for modelina - personally I'm not a fan of dragging nodejs ecosystem in just to generate some classes - but if that's what is available ...

@andreaTP
Copy link
Contributor

Hi @rquinio1A !
It's pretty straightforward to hide some setup in a Quarkus Extension, and you have various alternatives, in quarkus-kiota we are wrapping a CLI.

In no particular order, things that can work:

  • create a Node CLI (there are a few independent projects and this more official) and wrap it
  • try to execute modelina on a Java JS runtime like Nashorn
  • embed the full node distribution

@andreaTP
Copy link
Contributor

I quickly hacked around a POC: https://github.com/andreaTP/quarkus-modelina-poc

You can check the basic usage in the integration-tests.

It uses eirslett/frontend-maven-plugin behind the scenes to setup Node, NPM and install Modelina etc.

Not sure if there is any better recommendation on how to implement this kind of automation cc. @ia3andy

@radcortez
Copy link
Member

We did some prototype work for AsyncAPI in SmallRye: https://github.com/smallrye/smallrye-async-api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/quarkiverse This issue/PR is part of the Quarkiverse organization kind/extension-proposal Discuss and Propose new extensions
Projects
None yet
Development

No branches or pull requests

5 participants