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

Generation: add overwriteable type names

Open wizzardich opened this issue 9 months ago • 2 comments

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

  • Ok, I'm back with more XD
  • This is similar to #162. It's handy to be able to overwrite the generated field names, for the consistency of the user's codebase.

wizzardich avatar May 06 '24 15:05 wizzardich

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 :)

lerenn avatar May 07 '24 14:05 lerenn

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

wizzardich avatar May 13 '24 20:05 wizzardich