-
Notifications
You must be signed in to change notification settings - Fork 3
Property with name class generates invalid Java code #29
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
Comments
I fear there is no workaround at the moment for this issue except renaming the property. The processor should check this and replace the invalid identifier with something else (maybe configurable). The current check only handles space and dash. |
Unfortunately I cannot change the OpenAPI yaml, because it is from an external service. So changing the properties is not possible. Please note that this happens for all the Java keywords. |
right, it should avoid all keywords. What I didn't suggest, was excluding the endpoint (https://openapiprocessor.io/spring/2023.2/mapping/endpoint.html#_excluding_endpoints) this would be an option to implement it manually. Problem with this is, that it still generates the broken interface/classes. One would need to avoid compilation of them... |
fixed in 2023.2.1, https://github.com/openapi-processor/openapi-processor-base/releases/tag/v2023.2.1 just published it, it will take about an hour before it is available on maven central. |
Thanks for the fix! The code does not yet compile. It still generates the method as public FareClass getClass() { // 'getClass()' cannot override 'getClass()' in 'java.lang.Object'; overridden method is final
return aClass;
} Do you want me to open a new issue? |
grmpf, that was intentional ;-) I thought the method prefix would avoid that problem so the fix takes care of parameters & properties only. Guess it should avoid all methods from no need to create a new issue, I re-open this one |
there is only one |
next try :-) fixed in 2023.2.2, https://github.com/openapi-processor/openapi-processor-base/releases/tag/v2023.2.2 |
When having properties with a name similar to one of the Java keywords it will generate Java code that is invalid.
Example:
This wil generate:
Is there a way to fix this?
The text was updated successfully, but these errors were encountered: