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
91 stars 23 forks source link

Generation: add overwriteable type names #214

Open wizzardich opened 4 months ago

wizzardich commented 4 months ago

Current Behaviour

Given the following spec:

components:
  messages:
    EventSuccess:
      payload:
        type: object
        properties:
          event_id:
            type: integer
            description: The id of the event
            x-go-name: EventID 

The produced output will have the generated type:

> asyncapi-codegen -i asyncapi.yml -g types -o gen.gen.go
// EventSuccessMessagePayload is a schema from the AsyncAPI specification required in messages
type EventSuccessMessagePayload struct {
    // Description: The id of the event
    EventId *int64 `json:"event_id"`
}

Desired Behaviour

The x-go-name directive is respected, the same way oapi-codegen does here

type EventSuccessMessagePayload struct {
    // Description: The id of the event
    EventID *int64 `json:"event_id"`
}

Notes

lerenn commented 4 months ago

Hello @wizzardich ! Thanks for taking the time to open the issues !

I'm on vacation until next week, so I may have not a lot of time, but I'll review everything ASAP :)

wizzardich commented 4 months ago

It's a bit busy for me as well right now, but I'll try to get to it in coming weeks!