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

AsyncAPI Gernerator skips to generate java code for spec part containing "allOf"-element #327

Open
taotao100 opened this issue Aug 18, 2023 · 5 comments
Labels
bug Something isn't working stale

Comments

@taotao100
Copy link

Describe the bug

AsyncAPI Gernerator skips to generate java code for spec part containing "allOf"-element

How to Reproduce

using the following sample spec to generate java classes

asyncapi: 2.6.0
info:
  title: Hello world application
  version: "0.1.0"
channels:
  hello:
    publish:
      message:
        payload:
          $ref: "#/components/schemas/type1"

components:
  messages:
    myMessage:
      name: myTestMessage
      payload:
        $ref: "#/components/schemas/type1"
      headers:
        allOf:
          - $ref: "#/components/schemas/type1"
          - $ref: "#/components/schemas/type2"
  schemas:
    type1:
      type: string
    type2:
      type: string

code generation through cli
asyncapi generate fromTemplate ./test-sample.yaml @asyncapi/java-spring-template -p javaPackage=Exporter.models --output allofTest
The java class does not contain expected 'Headers'-element see java code below

package Exporter.models.model;

import javax.validation.Valid;

import java.util.Objects;
import java.util.List;


public class MyTestMessage {
    private @Valid Type1 payload;

    public Type1 getPayload() {
        return payload;
    }

    public void setPayload(Type1 payload) {
        this.payload = payload;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        MyTestMessage event = (MyTestMessage) o;
        return Objects.equals(this.payload, event.payload);
    }

    @Override
    public int hashCode() {
        return Objects.hash(payload);
    }

    @Override
    public String toString() {
        return "class MyTestMessage {\n" +
                "    payload: " + toIndentedString(payload) + "\n" +
                "}";
    }

    /**
     * Convert the given object to string with each line indented by 4 spaces (except the first line).
     */
    private String toIndentedString(Object o) {
        if (o == null) {
            return "null";
        }
        return o.toString().replace("\n", "\n    ");
    }
}

Expected behavior

Java Class contains the headers-part in spec above

@taotao100 taotao100 added the bug Something isn't working label Aug 18, 2023
@github-actions
Copy link

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.

@derberg
Copy link
Member

derberg commented Sep 4, 2023

moving to java template repo. Generator do not influence the generation result, it only provides a set of tools and API to enable java template to define what should be generated

@derberg derberg transferred this issue from asyncapi/generator Sep 4, 2023
@Tenischev
Copy link
Member

Hello @taotao100
You are right, the problem is with header section, current template doesn't support them. I'm sorry, that i didn't mentioned it in readme.
The problem that headers is a bit protocol-broker specific and so template still doesn't have a proper implementation for them.
If you could share your case, e.g. which protocol, broker and headers you are interested in, I would be glad to discuss details and update template.

@taotao100
Copy link
Author

Hi @Tenischev,

thanks for the response, we are working on use AsyncApi to specify the messages (payload & headers) in Kafka.

Copy link

github-actions bot commented Feb 3, 2024

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

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 ❤️

@github-actions github-actions bot added the stale label Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

3 participants