[FEATURE] Change the name of the generated model class withe name of message name.
- Dominant language
- TypeScript
- Stars
- 447
- Forks
- 241
- Avg merge
- 15m
- Merged PRs (30d)
- 7
Description
### 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 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 getAdditionalProperties() { return this.additionalProperties; }
public void setAdditionalProperties(Map 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?
- [X] I checked and didn't find a similar issue
### 🏢 Have you read the Contributing Guidelines?
- [X] I have read the [Contributing Guidelines](https://github.com/asyncapi/.github/blob/master/CONTRIBUTING.md)
### Are you willing to work on this issue?
Yes I am willing to submit a PR!
Contributor guide
Research direction
Start from the model-generation path invoked by `asyncapi generate models java ./asyncapi.yml --packageName=src`, using the message reference in `asyncapi.yml` as the reproduction case. Trace where `AnonymousSchema_1` is chosen, then verify that the generated Java model uses the message name `UserSignedUp` and that the command completes successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100