oapi-codegen
oapi-codegen copied to clipboard
feat: add config to emit `required:"true"` field tag
It is handy for cases when openapi spec is generated from sources and source's types reuses types generated from other openapi spec.
type StructuresProject struct {
CreatedAt int `json:"createdAt" required:"true"`
CreatorID string `json:"creatorID" required:"true"`
Deleted bool `json:"deleted" required:"true"`
}
We use https://github.com/swaggest/openapi-go to generate schemas from the code
So, basically, we use spec generation from internal types, and generates public client and types from generated spec.
Then, other service tries to reuse type generated from spec, but it generated spec it turns optional field since has no required:"true"
tag
As for now we're using patched fork but really want to jump back to main package to avoid mess with merging your updates.
In the end I've managed to make a hook for spec-generator and it utilizes x-oapi-codegen-extra-tags
to achieve same functionality.