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] No compile when define a referenced object with siblings #253

Closed alfredo9f closed 1 year ago

alfredo9f commented 1 year ago

What happens?

If you have a referenced object and a definition type of this object, the plugin is not able to generate code. For example:

...
components:
  schemas:
     ...
    customerProductHolding:
      type: object
      properties:
      ...
        account:
          $ref: "#/components/schemas/account"
          type: object   <------------------------------------------------ This is the definition that crash
      ...
    account:
      type: object
      properties:
        accountId:
          type: string
        ...

The error showed is:

----
FTL stack trace ("~" means nesting-related):
        - Failed at: #if field.dataType?has_content && (fi...  [in template "templateSchema.ftlh" at line 121, column 3]
----
    at freemarker.core.InvalidReferenceException.getInstance (InvalidReferenceException.java:134)
    at freemarker.core.EvalUtil.compare (EvalUtil.java:198)
    at freemarker.core.EvalUtil.compare (EvalUtil.java:115)
    at freemarker.core.ComparisonExpression.evalToBoolean (ComparisonExpression.java:78)

What is expected?

The generator should ignored all sibling of #ref node in account and create an account object. The specification of OpenApi says: image

rukundob451 commented 1 year ago

Hey @alfredo9f, how is it going with this?

alfredo9f commented 1 year ago

Hi @rukundob451 , The code is generated well in new versions of the plugin, so we can close it :)