diff --git a/internal/bootstrap/router_bootstrap.go b/internal/bootstrap/router_bootstrap.go index 0735320c..b0e97b16 100644 --- a/internal/bootstrap/router_bootstrap.go +++ b/internal/bootstrap/router_bootstrap.go @@ -89,10 +89,12 @@ func (app *BootstrapApp) setupRouter() error { return fmt.Errorf("failed to provide api router group: %w", err) } - err = app.setupScalar() + if app.config.Server.ScalarEnabled { + err = app.setupScalar() - if err != nil { - return fmt.Errorf("failed to setup scalar: %w", err) + if err != nil { + return fmt.Errorf("failed to setup scalar: %w", err) + } } controllerProvideFor := []any{ diff --git a/internal/controller/health_controller.go b/internal/controller/health_controller.go index 9f50a23c..ca0792ac 100644 --- a/internal/controller/health_controller.go +++ b/internal/controller/health_controller.go @@ -35,6 +35,6 @@ func NewHealthController(i HealthControllerInput) *HealthController { func (controller *HealthController) healthHandler(c *gin.Context) { c.JSON(200, SimpleResponse{ Status: 200, - Message: "OK", + Message: "Healthy", }) } diff --git a/internal/controller/health_controller_test.go b/internal/controller/health_controller_test.go index d670f018..6caf412a 100644 --- a/internal/controller/health_controller_test.go +++ b/internal/controller/health_controller_test.go @@ -23,9 +23,9 @@ func TestHealthController(t *testing.T) { path: "/api/healthz", method: "GET", expected: func() string { - expectedHealthResponse := map[string]any{ - "status": 200, - "message": "Healthy", + expectedHealthResponse := SimpleResponse{ + Status: 200, + Message: "Healthy", } bytes, err := json.Marshal(expectedHealthResponse) require.NoError(t, err) @@ -37,9 +37,9 @@ func TestHealthController(t *testing.T) { path: "/api/healthz", method: "HEAD", expected: func() string { - expectedHealthResponse := map[string]any{ - "status": 200, - "message": "Healthy", + expectedHealthResponse := SimpleResponse{ + Status: 200, + Message: "Healthy", } bytes, err := json.Marshal(expectedHealthResponse) require.NoError(t, err) diff --git a/internal/model/config.go b/internal/model/config.go index b72c9656..66c42b31 100644 --- a/internal/model/config.go +++ b/internal/model/config.go @@ -34,8 +34,9 @@ func NewDefaultConfiguration(runtimeEnv RuntimeEnv) *Config { Path: "./resources", }, Server: ServerConfig{ - Port: 3000, - Address: "0.0.0.0", + Port: 3000, + Address: "0.0.0.0", + ScalarEnabled: true, }, Auth: AuthConfig{ SubdomainsEnabled: true, @@ -134,9 +135,10 @@ type ResourcesConfig struct { } type ServerConfig struct { - Port int `description:"The port on which the server listens." yaml:"port,omitempty"` - Address string `description:"The address on which the server listens." yaml:"address,omitempty"` - SocketPath string `description:"The path to the Unix socket." yaml:"socketPath,omitempty"` + Port int `description:"The port on which the server listens." yaml:"port,omitempty"` + Address string `description:"The address on which the server listens." yaml:"address,omitempty"` + SocketPath string `description:"The path to the Unix socket." yaml:"socketPath,omitempty"` + ScalarEnabled bool `description:"Enable API docs with Scalar under /scalar." yaml:"scalarEnabled,omitempty"` } type AuthConfig struct {