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

Convert generated Golang object to specific case

Open TheSadlig opened this issue 1 year ago • 0 comments

Hello,

I am working to implement a new tag --convert-naming -C (not sure about that option name, open to suggestions) that would override the name from the contract in the generated model. Similarly to --convert-keys, you would be able to specify camel or none (snake and kebab case don't really make sense) and it would apply to generated structs and struct fields.

Is that something that you would be open to include upstream ?

A few examples:

  schemas:
    TEST:
      type: object
      properties:
        PROP:
          type: string
        PROP_2:
          type: string
  • With --convert-naming none (default, current behaviour)
type TESTSchema struct {
	PROPTEST *string `json:"PROP"`
	PROP2 *string `json:"PROP_2"`
}
  • With --convert-naming camel
type TestSchema struct {
	PropTest *string `json:"PROP"`
	Prop2*string `json:"PROP_2"`
}

Thanks, TheSadlig

TheSadlig avatar May 14 '24 20:05 TheSadlig