Skip to content

[BUG] modelGenrator Nested allOf anyOf doesn't create fields #2407

@lynxSven

Description

@lynxSven

Describe the bug.

When I have a nested

  allOf:
        - anyOf: 
           - ....
           - .....
   - someobject...

Someobject will be created as field. Everything in anyof will not be present.
There is no error thrown. The classes will be created (without the fields in anyOf).
(Full minmal yml in repdroduce)

the html-generator creates a correct index.html which is has all the fields.
Maybe the nesting is not possible in a model representation but i then an error or a hint would be helpful

namespace minimalnamespace
{
  public partial class DoSomethingEvent
  {
    private System.DateTimeOffset? timestamp;
    private string detailType;
    private DoSomethingEventDetail detail;

    public System.DateTimeOffset? Timestamp 
    {
      get { return timestamp; }
      set { this.timestamp = value; }
    }

    public string DetailType 
    {
      get { return detailType; }
      set { this.detailType = value; }
    }

    public DoSomethingEventDetail Detail 
    {
      get { return detail; }
      set { this.detail = value; }
    }
  }
}

Detail

namespace minimalnamespace
{
  public partial class DoSomethingEventDetail
  {
    private string? value3;

    public string? Value3 
    {
      get { return value3; }
      set { this.value3 = value; }
    }
  }
}

Expected behavior

Throw an error or create an representation of the anyof in model files.
Dont fail quietly.

Screenshots

Terminaloutput

Processing allOf, inheritance is not enabled. AllOf model is merged together with already interpreted model
 »   Warning: Found duplicate additionalItems for model. additionalItems from anonymous_schema_3 merged into       
 »   unknown
Processing allOf, inheritance is not enabled. AllOf model is merged together with already interpreted model        
Successfully generated the following models: DoSomethingEvent, DoSomethingEventDetail

How to Reproduce

  1. install modalina-cli next or latest
  2. use this yml
asyncapi: 3.0.0
info:
  title: minimal
  version: 1.0.0
channels:
  doSomething:
    address: doSomething
    messages:
      doSomethingEvent:
        $ref: '#/components/messages/doSomethingEvent'
operations:
  publishoSomethingEvents:
    action: send
    channel:
      $ref: '#/channels/doSomething'
    summary: Publish doSomething lifecycle events
    messages:
      - $ref: '#/channels/doSomething/messages/doSomethingEvent'
components:
  messages:
    doSomethingEvent:
      name: doSomethingEvent
      title: doSomething Event
      payload:
        $ref: '#/components/schemas/doSomethingEvent'
  schemas:
    doSomethingEvent:
      additionalProperties: false
      type: object
      properties:
        timestamp:
          type: string
          format: date-time
          pattern: ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
        detailType:
          type: string
        detail:
          $ref: '#/components/schemas/doSomethingEventDetail'
      required:
        - detailType
        - detail
    doSomethingEventDetail:
      additionalProperties: false
      allOf:
        - anyOf:
          - type: object
            properties:
                value2:
                  type: string
          - type: object
            properties:
                value1:
                  type: string
        - type: object
          properties:
              value3:
                type: string
          additionalProperties: false 
  1. modelina generate csharp minimal.yml --namespace=minimalnamespace -o nextout

🖥️ Device Information [optional]

  • Operating System (OS): windows
  • Browser:
  • Browser Version:

👀 Have you checked for similar open issues?

  • I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

Yes I am willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions