Skip to content

Commit

Permalink
Moves route.Hidden check to RegisterOpenAPIOperation
Browse files Browse the repository at this point in the history
  • Loading branch information
EwenQuim committed Dec 22, 2024
1 parent ab8f736 commit d556b3b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 0 additions & 4 deletions mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d556b3b

Please sign in to comment.