asyncapi / asyncapi/modelina

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

Open
#2,407 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug stale
Dominant language
TypeScript
Stars
448
Forks
242
Avg merge
15m
Merged PRs (30d)
7

Description

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!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running modelina generate csharp with the minimal YAML from the reproduction and inspect how the nested allOf and anyOf schemas are represented during model generation. Compare the generated C# fields with the HTML generator output and determine whether the result should represent the anyOf branches or report an explicit unsupported-nesting error.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.