Skip to content

[FEATURE] Change the name of the generated model class withe name of message name. #1996

@AayushSaini101

Description

@AayushSaini101

Why do we need this improvement?

Asyncapi.yml:

asyncapi: '2.2.0'
info:
  title: Account Service
  version: 1.0.0
  description: This service is in charge of processing user signups
channels:
  user/signedup:
    subscribe:
      message:
        $ref: '#/components/messages/UserSignedUp'
components:
  messages:
    UserSignedUp:
      payload:
        type: object
        properties:
          displayName:
            type: string
            description: Name of the user
          email:
            type: string
            format: email
            description: Email of the user

Output:

asyncapi generate models java ./asyncapi.yml --packageName=src

Successfully generated the following models: 
## Model name: AnonymousSchema_1 // Name should be change to userSignedUp
package src;

import java.util.Map;
public class AnonymousSchema_1 {
  private String displayName;
  private String email;
  private Map<String, Object> additionalProperties;

  public String getDisplayName() { return this.displayName; }
  public void setDisplayName(String displayName) { this.displayName = displayName; }

  public String getEmail() { return this.email; }
  public void setEmail(String email) { this.email = email; }

  public Map<String, Object> getAdditionalProperties() { return this.additionalProperties; }
  public void setAdditionalProperties(Map<String, Object> additionalProperties) { this.additionalProperties = additionalProperties; }
}

How will this change help?

This change will help to adhere proper naming of the project, lets suppose if we want to call the model class we need to call the AnonymousSchema_1 which seems to be not valid.

Screenshots

No response

How could it be implemented/designed?

  • Use the name of the message as the class name

🚧 Breaking changes

No

👀 Have you checked for similar open issues?

  • I checked and didn't find a similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue?

Yes I am willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions