I've got something like this:
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.
I've got something like this:
When I specify
Errorsin theOperationpassed tohuma.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 toMiddlewares,Security, andTagsare reflected correctly by the OpenAPI document, only changes toErrorsare not reflected in the document.