diff --git a/generic_mux.go b/generic_mux.go index 354ac752..fe067808 100644 --- a/generic_mux.go +++ b/generic_mux.go @@ -11,6 +11,9 @@ type Registerer[T, B any] interface { func Registers[B, T any](engine *Engine, a Registerer[B, T]) *Route[B, T] { route := a.Register() + if engine.OpenAPIConfig.Disabled { + return &route + } err := route.RegisterOpenAPIOperation(engine.OpenAPI) if err != nil { slog.Warn("error documenting openapi operation", "error", err) diff --git a/openapi_test.go b/openapi_test.go index a30bffd1..554749eb 100644 --- a/openapi_test.go +++ b/openapi_test.go @@ -286,7 +286,7 @@ func TestServer_OutputOpenApiSpec(t *testing.T) { require.Error(t, err) require.Nil(t, file) }) - t.Run("swagger disabled", func(t *testing.T) { + t.Run("OpenAPI disabled", func(t *testing.T) { s := NewServer( WithEngineOptions( WithOpenAPIConfig( @@ -303,7 +303,7 @@ func TestServer_OutputOpenApiSpec(t *testing.T) { }) document := s.OutputOpenAPISpec() - require.Len(t, document.Paths.Map(), 1) + require.Empty(t, document.Paths.Map()) require.NotNil(t, document) file, err := os.Open(docPath) @@ -434,7 +434,7 @@ func TestAutoGroupTags(t *testing.T) { WithEngineOptions( WithOpenAPIConfig(OpenAPIConfig{ DisableLocalSave: true, - Disabled: true, + Disabled: false, }), ), )