Giter VIP home page Giter VIP logo

Comments (10)

github-actions avatar github-actions commented on September 25, 2024

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.

from jasyncapi.

derberg avatar derberg commented on September 25, 2024

@jarpz do you mean https://github.com/asyncapi/generator/?

from jasyncapi.

jarpz avatar jarpz commented on September 25, 2024

@jarpz do you mean https://github.com/asyncapi/generator/?

Yes, where did we find your templates, or how we implement our custom templates? I mean for instance in: https://github.com/OpenAPITools/openapi-generator

You can create your custom templates or extends existing ones.

Regards

from jasyncapi.

derberg avatar derberg commented on September 25, 2024

so AsyncAPI Generator is what you're looking for. It is a tool that allows you to write templates. We have some official templates like this and you can also write custom ones on your own. There is a sample that teaches all generator options. We also write a library that can in addition generate models for different languages, so when you write a template you focus on writing template for main app logic and do not have to care about templating models.

Makes sense?

from jasyncapi.

jarpz avatar jarpz commented on September 25, 2024

so AsyncAPI Generator is what you're looking for. It is a tool that allows you to write templates. We have some official templates like this and you can also write custom ones on your own. There is a sample that teaches all generator options. We also write a library that can in addition generate models for different languages, so when you write a template you focus on writing template for main app logic and do not have to care about templating models.

Makes sense?

No, I missunderstand this plugin allow me to use it just with maven. In the case of https://github.com/asyncapi/generator, you need to install npm and nodejs. We are looking for a plugin full java that allows code generation.

Any info about that?

Or if we can use your plugin.. any example? I can find any documentation about how to use it as maven plugin, config options.

Our approach is to generate code from the contract and put it in the target folder, use it at runtime.. we don't git models.

Regards

from jasyncapi.

derberg avatar derberg commented on September 25, 2024

@jarpz I know people are able to run npm with maven but I'm personally not java user so never tried it:

have a look at those articles, once you get it running it would be super cool if you could contribute an instruction. Better to integrate npm with maven then write completely separate code generator

from jasyncapi.

derberg avatar derberg commented on September 25, 2024

@jarpz did you give it a try?

from jasyncapi.

jarpz avatar jarpz commented on September 25, 2024

@jarpz did you give it a try?

Yeah, that was my solution, but it is not elegant. As you know this method generated a complete scaffolding for an "empty" application, So When we used to put files in the target. the code is not recognized because generated java sources change the order of the folders (src,main). So, we had to use another plugin to add additional classpath classes.

The solution is like that:

<plugin>
                    <groupId>com.github.eirslett</groupId>
                    <artifactId>frontend-maven-plugin</artifactId>
                    <version>1.12.0</version>
                    <executions>
                      <execution>
                        <id>install node and npm</id>
                        <goals>
                          <goal>install-node-and-npm</goal>
                        </goals>
                      </execution>
                      <execution>
                        <id>npm install</id>
                        <goals>
                          <goal>npm</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                          <arguments>install</arguments>
                        </configuration>
                      </execution>
                      <execution>
                        <id>run generator</id>
                        <goals>
                          <goal>npm</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                          <arguments>run generate -- -p javaPackage=${package}</arguments>
                        </configuration>
                      </execution>
                    </executions>
                    <configuration>
                      <nodeVersion>v14.17.0</nodeVersion>
                    </configuration>
                  </plugin>

                  <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>3.0.0</version>
                    <executions>
                      <execution>
                        <phase>generate-sources</phase>
                        <goals>
                          <goal>add-source</goal>
                        </goals>
                        <configuration>
                          <sources>
                            <source>target/generated-sources/asyncapi/src</source>
                          </sources>
                        </configuration>
                      </execution>
                    </executions>
                  </plugin>

That's why I'm looking for a java-native asyncapi plugin.

Regards

from jasyncapi.

derberg avatar derberg commented on September 25, 2024

@jarpz I think it is better to have just few lines of XML than writing an alternative generator in Java. Much less work, even if it doesn't look super elegant. Unless you mean That's why I'm looking for a java-native asyncapi plugin. that it would be cool to have maven plugin just like frontend-maven-plugin - this would be cool I think. Then please propose a solution here https://github.com/asyncapi/community/issues

As for your current configuration:

                      <execution>
                        <id>run generator</id>
                        <goals>
                          <goal>npm</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                          <arguments>run generate -- -p javaPackage=${package}</arguments>
                        </configuration>
                      </execution>

Do I get it right that you have a package JSON where you have a generator and the template set as dependencies. Probably to lock versions, right? Then it makes sense

from jasyncapi.

github-actions avatar github-actions commented on September 25, 2024

This issue has been automatically marked as stale because it has not had recent activity 😴
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 ❤️

from jasyncapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.