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

[AsyncApi] $ref resultion are always a class #293

Closed devNbis closed 1 year ago

devNbis commented 1 year ago

I've fired out that there is a problem on references !type:object . It creates always the object name like a class.

"EventDataDTO": {
    "name":" EventDataDTO",
     "$id":"EventDataDTO",
     "title": "Event",
     "type": "object",          
     "properties": {
          "name": {
            "type": "string"
          },
          "currency": {
                "$ref": "#/components/schemas/Currency"
           }
      }
 },
 "Currency": {
     "type": "string",
       "format": "currency",
 }

Will result as

@JsonProperty(value ="leadingCurrency") private Currency leadingCurrency;

But it should be

@JsonProperty(value ="leadingCurrency") private String leadingCurrency;
jemacineiras commented 1 year ago

I will take a look

jemacineiras commented 1 year ago

Hi @devNbis, do you mind to try the brach attached to this issue to test the solution?

Cheers

devNbis commented 1 year ago

Hi @jemacineiras I've test it the sample which is inside of https://studio.asyncapi.com/. It generates the model now as String correctly. But end with an error

[ERROR] Failed to execute goal com.sngular:scs-multiapi-maven-plugin:5.0.2:asyncapi-generation (default) on project consuming-retry: Execution default of goal com.sngular:scs-multiapi-maven-plugin:5.0.2:asyncapi-generation failed: AsyncApi -> File System error trying to manipulate files: The following has evaluated to null or missing:                              
[ERROR] ==> value  [in template "templateSchema.ftlh" at line 141, column 7]
[ERROR] 
[ERROR] ----
[ERROR] Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??                                                                                                                                                              
[ERROR] ----
jemacineiras commented 1 year ago

Hi @devNbis ,

I´ll take a look,

Cheers