-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
JavaFileGenerator in the generate models command ONLY generates the java model classes correctly if the openapi specs follow the java naming conventions #1038
Comments
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. |
If it helps I could do the coding myself and provide a pr. |
@oliverkuntze |
Great news. Thank you, @Athul0491 ! Can't wait for the release. :-) In the PR: Cheers |
🎉 This issue has been resolved in version 1.3.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@Athul0491 , could it be that I was right with the remark that |
@oliverkuntze now that i look at the PR again, i realize that you are right. I'll push the changes asap! Pretty sure the same problem exists for TS as well. |
Perfect! Thanks @Athul0491 ! We are really eager to use the feature. :-) |
🎉 This issue has been resolved in version 1.4.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Describe the bug
At the moment the
JavaFileGenerator
in the generate models command ONLY generates the java model classes correctly if the openapi specs follow the java naming conventions.For example if a schema in the openapi spec contains a property
myID
thegenerate models java
command will generate a propertymyId
in the corresponding class.We cannot assume that authors of asyncapi specs strictly follow the rules of java naming conventions.
We should assure that all openapi specs can be correctly generated into java model classes independent of following java naming conventions when writing the specs or not.
Description
In https://github.com/asyncapi/cli/blob/master/src/commands/generate/models.ts the
JavaFileGenerator
currently is instantiated this way:fileGenerator = new JavaFileGenerator();
The
JavaFileGenerator
should be instantiated this way:fileGenerator = new JavaGenerator({ presets: [JAVA_JACKSON_PRESET] });
This way the schema properties not following the java naming conventions would annotated with the corresponding
JsonProperty
annotations.This won't be a breaking change other than one has to add the
jackson-annotations
dependency to one's project.How to Reproduce
Take any asyncapi spec with schema properties that are not written in camel case and run the cli with
generate models java
.Have a look at the model classes to find all non camel case schema properties converted to camel case java properties, thus breaking the contract.
Expected behavior
Since asyncapi does not enforce the usage of java compliant naming conventions for the schema properties in their specs it should correctly generate model classes for specs that don't follow the java naming conventions.
The text was updated successfully, but these errors were encountered: