sngular / scs-multiapi-plugin

This is a Maven plugin designed to help developers automatizing the creation of code classes from YML files based on AsyncApi and OpenAPI.
http://sngular.com
Mozilla Public License 2.0
48 stars 10 forks source link

When specification contains word "new" generated files cannot be compiled #295

Closed hebrayah closed 1 year ago

hebrayah commented 1 year ago

When AsyncAPI specificaiton file contain property named "new", causes Java file generation with property using reserved word - and generated files are not possible to compile. In such case generated java field should be _new or something like that ...

github-actions[bot] commented 1 year ago

Thank you for collaborating with the project by giving us feedback! Cheers!

jemacineiras commented 1 year ago

HI @hebrayah, Can you please provide a use case about the situation you need such a feature? Because doesn't make anysense to modify the property building from the tool for only some special words. Keep in mind the code also generate Lombok annotated class you what you are suggesting is to generate something like

public class Something
....
private Boolean _new;

.....

so we should generate then get_New() and set_New() unless you want to we create special getter and setter for you unique case as getNew() and setNew().

Please clarify.

jemacineiras commented 1 year ago

HI @hebrayah,

I just was playing around a bit with this request... may you try the branch I created?

Cheers

hebrayah commented 1 year ago

Hello,

I have tried to replicate this issue on openapi-genearator. it handles this situation precisely the way i described, so:

image

Caused generation of:

  public static final String JSON_PROPERTY_NEW = "new";
  private GeographyRuleNew _new;

   /**
   * Get _new
   * @return _new
  **/
  @javax.annotation.Nullable
  @JsonProperty(JSON_PROPERTY_NEW)
  @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

  public GeographyRuleNew getNew() {
    return _new;
  }

  @JsonProperty(JSON_PROPERTY_NEW)
  @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
  public void setNew(GeographyRuleNew _new) {
    this._new = _new;
  }

Bear in mind that method _new can be already generated and has different meaning. public GeographyRule _new(GeographyRuleNew _new) { this._new = _new; return this; }

hebrayah commented 1 year ago

I do think that this behavior is just a problem between a reserved wors lists in two languages - so it should not impact the shape of the interface itself.

jemacineiras commented 1 year ago

Hi @hebrayah, had you a chance to try the branch associated to this issus?

Cheers

hebrayah commented 1 year ago

Hi

Sorry for that delay, U unfortunately i didnt have occasion to do that - however, as this is not PR but just new branch - I am not familiar with code itself to judge if changes are fine. I hope i described desired output as a business analyst ;)

Best regards marcin

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Nie zawiera wirusów.www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

czw., 5 paź 2023 o 10:18 Jose E. Garcia Maciñeiras @.***> napisał(a):

Hi @hebrayah https://github.com/hebrayah, had you a chance to try the branch associated to this issus?

Cheers

— Reply to this email directly, view it on GitHub https://github.com/sngular/scs-multiapi-plugin/issues/295#issuecomment-1748351723, or unsubscribe https://github.com/notifications/unsubscribe-auth/AECCXSCTKHHQUHX5FSS3YSLX5ZUNJAVCNFSM6AAAAAA5H6AJJKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBYGM2TCNZSGM . You are receiving this because you were mentioned.Message ID: @.***>

hebrayah commented 1 year ago

Awesome, thanks for the update!

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Nie zawiera wirusów.www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

śr., 25 paź 2023 o 11:35 Jose E. Garcia Maciñeiras @.***> napisał(a):

Closed #295 https://github.com/sngular/scs-multiapi-plugin/issues/295 as completed via #296 https://github.com/sngular/scs-multiapi-plugin/pull/296.

— Reply to this email directly, view it on GitHub https://github.com/sngular/scs-multiapi-plugin/issues/295#event-10764777982, or unsubscribe https://github.com/notifications/unsubscribe-auth/AECCXSDBR2K7ONMKLBNVWY3YBDMNXAVCNFSM6AAAAAA5H6AJJKVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJQG43DINZXG44TQMQ . You are receiving this because you were mentioned.Message ID: @.***>