discord-gophers / goapi-gen

This package contains a set of utilities for generating Go boilerplate code for services based on OpenAPI 3.0 API definitions
Apache License 2.0
137 stars 12 forks source link

Proposal: Allow non-pointer optional fields #76

Closed diamondburned closed 2 years ago

diamondburned commented 2 years ago

I propose a new x-go-valuetype: true attribute that, if true, will make the generator output a primitive type with an ,omitempty attribute and without a pointer.

This particular use case is useful in a lot of cases where an omitted field and an empty value are treated the same:

{
  "id": "",  // useless
  "bio": "", // consider as empty in either cases
}

Either of these fields being *string isn't any more useful.

Karitham commented 2 years ago

Fixed by #82