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

Invalid Java class generated for free-form Map data type by use of 'additionalProperties' property #322

Closed
taotao100 opened this issue Aug 16, 2023 · 6 comments · Fixed by #273
Labels
bug Something isn't working released

Comments

@taotao100
Copy link

taotao100 commented Aug 16, 2023

Describe the bug

Async Generator generates a invalid java class for free-form Map data type through 'additionalProperties' property in schema/model declarations.

How to Reproduce

a sample AsyncAPI looks like this

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

components:
  schemas:
    keyValueType:
      type: object
      additionalProperties: true

by use of AsyncApi/cli Generator like
asyncapi generate fromTemplate ./sample.yaml @asyncapi/java-spring-template -p javaPackage=Exporter.models --output myoutputTest

an invalid java class is generated see its equals-method at last return, this class is not compilable

package Exporter.models.model;

import javax.validation.constraints.*;
import javax.validation.Valid;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;

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

public class KeyValueType {  

    
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        KeyValueType keyValueType = (KeyValueType) o;
        return 
    }

...
}

Expected behavior

a valid java class is generated for 'additionalProperties' property to compile

@taotao100 taotao100 added the bug Something isn't working label Aug 16, 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.

@taotao100 taotao100 changed the title Invalid Java class generated for Map data type by use of 'additionalProperties' property Invalid Java class generated for free-form Map data type by use of 'additionalProperties' property Aug 16, 2023
@taotao100
Copy link
Author

Property 'additionalProperties' is available since AsyncAPI 2.0.0 see https://www.asyncapi.com/docs/reference/specification/v2.0.0

@taotao100
Copy link
Author

relevant to issue #272

@derberg
Copy link
Member

derberg commented Aug 31, 2023

I'm moving it to template repo, as CLI just rungs generation, has no control over the process

@derberg derberg transferred this issue from asyncapi/cli Aug 31, 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.

@asyncapi-bot
Copy link
Contributor

🎉 This issue has been resolved in version 1.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants