lerenn / asyncapi-codegen

An AsyncAPI Golang Code generator that generates all Go code from the broker to the application/user. Just plug your application to your favorite message broker!
Apache License 2.0
82 stars 22 forks source link

Fix correlation id requirement check #103

Closed derfenix closed 9 months ago

derfenix commented 9 months ago

When the message have correation section and payload is reference to a model, the createTreeUntilCorrelationID ignores the referenced schema and create empty one. So, the required schema field becomes unrequired when checking the requirement of the correlation id field.

The case:

components:
  messages:
    identityNew:
      correlationId:
        location: $message.payload#/id
      payload:
        $ref: "#/components/schemas/identity"
  schemas:
    identity:
      type: object
      required:
        - id
        - role
      properties:
        id:
          type: string
          format: uuid
        role:
          type: string
lerenn commented 9 months ago

Hello @derfenix, thank a lot for your PR !

I'll take a look as soon as possible and add a test to avoid this regression in the future :)