diff --git a/mux.go b/mux.go index e5dfa929..2cff9bf3 100644 --- a/mux.go +++ b/mux.go @@ -86,10 +86,6 @@ func Register[T, B any](s *Server, route Route[T, B], controller http.Handler, o route.Middlewares = append(s.middlewares, route.Middlewares...) s.Mux.Handle(fullPath, withMiddlewares(route.Handler, route.Middlewares...)) - if route.Hidden || route.Method == "" { - return &route - } - err := route.RegisterOpenAPIOperation(s.OpenAPI) if err != nil { slog.Warn("error documenting openapi operation", "error", err) diff --git a/openapi.go b/openapi.go index a30ce75a..8f3a0839 100644 --- a/openapi.go +++ b/openapi.go @@ -208,6 +208,10 @@ func validateSwaggerUrl(swaggerUrl string) bool { // RegisterOpenAPIOperation registers the route to the OpenAPI description. // Modifies the route's Operation. func (route *Route[ResponseBody, RequestBody]) RegisterOpenAPIOperation(openapi *OpenAPI) error { + if route.Hidden || route.Method == "" { + return nil + } + operation, err := RegisterOpenAPIOperation(openapi, *route) route.Operation = operation return err