danielgtaylor / danielgtaylor/huma
Can't set the Operation's `Errors` in a group modifier
- Dominant language
- Go
- Stars
- 4.4k
- Forks
- 285
- Avg merge
- 40m
- Merged PRs (30d)
- 1
Description
I've got something like this:
```go
internalApi := huma.NewGroup(api, "/internal")
requireUserAuthHandler := auth.CreateRequireUserAuthHandler(internalApi)
internalApi.UseSimpleModifier(func(op *huma.Operation) {
op.Tags = append(op.Tags, "Internal")
if _, noAuth := op.Metadata["NoUserAuth"]; !noAuth {
op.Security = append(op.Security, map[string][]string{"SessionCookie": {}})
op.Middlewares = append(op.Middlewares, auth.UserAuthHandler, requireUserAuthHandler)
op.Errors = append(op.Errors, http.StatusUnauthorized)
}
})
sessionApi := huma.NewGroup(internalApi, "/session")
// a bunch of calls to huma.Register(sessionApi, ...)
```
When I specify `Errors` in the `Operation` passed to `huma.Register`, it's correctly defined in the OpenAPI document. But, it doesn't reflect the error codes updated by the simple modifier. The changes in the modifier to `Middlewares`, `Security`, and `Tags` are reflected correctly by the OpenAPI document, only changes to `Errors` are not reflected in the document.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.