asyncapi-codegen icon indicating copy to clipboard operation
asyncapi-codegen copied to clipboard

Regression in 0.45.2: codegen leads to compile error for `allOf` in a named schema

Open pofl opened this issue 9 months ago • 3 comments

This YAML generates code that can't be compiled. The problem does not occur on 0.45.1 or when reverting the commit for 0.45.2.

asyncapi: 2.6.0
info:
  title: Sample
  version: 0.0.2
defaultContentType: application/json
channels:
  channel:
    publish:
      operationId: event
      message:
        payload:
          $ref: '#/components/schemas/Payload'

components:
  schemas:

    Payload:
      allOf:
        - type: string
        - type: string

The problem seems to be that there is a place where the codegen should use the name of the generated struct for Payload, but instead it uses the name that would be used if Payload wasn't defined in component.schema but inline in the message instead.

pofl avatar Mar 10 '25 08:03 pofl

See demonstration at https://github.com/pofl/asyncapi-codegen/pull/1/files

pofl avatar Mar 10 '25 08:03 pofl

I don't know how to fix this issue. If somebody with some insights into the inner workings of the generator could look into this, that would greatly help me and my team. Maybe @fairyhunter13?

pofl avatar Mar 10 '25 08:03 pofl

Thanks @pofl for reporting and sorry about this, I'll take a look when I'll have a bit of time. I @fairyhunter13 you have some time to look into, please do not hesitate :)

lerenn avatar Mar 10 '25 10:03 lerenn