Skip to content

Commit 140ebdb

Browse files
committed
Fix swagger ui in dev mode and package naming
Signed-off-by: ppadti <ppadti@redhat.com>
1 parent 182f5ee commit 140ebdb

File tree

9 files changed

+29
-27
lines changed

9 files changed

+29
-27
lines changed

clients/ui/bff/internal/api/app.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,10 @@ func (app *App) Routes() http.Handler {
281281
apiRouter.POST(CheckNamespaceRegistryAccessPath, app.CheckNamespaceRegistryAccessHandler)
282282
apiRouter.GET(ModelRegistryListPath, app.AttachNamespace(app.RequireListServiceAccessInNamespace(app.GetAllModelRegistriesHandler)))
283283

284-
// Swagger UI (interactive API docs)
285-
apiRouter.GET(SwaggerPath+"/*filepath", app.GetSwaggerHandler)
284+
// Swagger UI (interactive API docs) — only in dev mode
285+
if app.config.DevMode {
286+
apiRouter.GET(SwaggerPath+"/*filepath", app.GetSwaggerHandler)
287+
}
286288

287289
// Enable these routes in all cases except Kubeflow integration mode
288290
// (Kubeflow integration mode is when DeploymentMode is kubeflow)

clients/ui/bff/internal/api/healthcheck__handler_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
"github.com/kubeflow/model-registry/ui/bff/internal/config"
1111
"github.com/kubeflow/model-registry/ui/bff/internal/mocks"
12-
"github.com/kubeflow/model-registry/ui/bff/internal/models/health_check"
12+
"github.com/kubeflow/model-registry/ui/bff/internal/models/healthcheck"
1313
"github.com/kubeflow/model-registry/ui/bff/internal/repositories"
1414
"github.com/stretchr/testify/assert"
1515
)
@@ -35,15 +35,15 @@ func TestHealthCheckHandler(t *testing.T) {
3535
body, err := io.ReadAll(rs.Body)
3636
assert.NoError(t, err)
3737

38-
var healthCheckRes health_check.HealthCheckModel
38+
var healthCheckRes healthcheck.HealthCheckModel
3939
err = json.Unmarshal(body, &healthCheckRes)
4040
assert.NoError(t, err)
4141

4242
assert.Equal(t, http.StatusOK, rr.Code)
4343

44-
expected := health_check.HealthCheckModel{
44+
expected := healthcheck.HealthCheckModel{
4545
Status: "available",
46-
SystemInfo: health_check.SystemInfo{
46+
SystemInfo: healthcheck.SystemInfo{
4747
Version: Version,
4848
},
4949
}

clients/ui/bff/internal/api/healthcheck_handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/julienschmidt/httprouter"
77

88
// imported for swag documentation
9-
_ "github.com/kubeflow/model-registry/ui/bff/internal/models/health_check"
9+
_ "github.com/kubeflow/model-registry/ui/bff/internal/models/healthcheck"
1010
)
1111

1212
// HealthcheckHandler returns the health status of the application.
@@ -16,7 +16,7 @@ import (
1616
// @Tags healthcheck
1717
// @ID getHealthcheck
1818
// @Produce application/json
19-
// @Success 200 {object} health_check.HealthCheckModel "Successful healthcheck response"
19+
// @Success 200 {object} healthcheck.HealthCheckModel "Successful healthcheck response"
2020
// @Failure 401 {object} ErrorEnvelope "Unauthorized. Authentication is required."
2121
// @Failure 403 {object} ErrorEnvelope "Forbidden. User does not have permission to access the resource."
2222
// @Failure 404 {object} ErrorEnvelope "Not Found. Resource does not exist."

clients/ui/bff/internal/api/swagger_handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2024.
2+
Copyright 2026.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
// GetSwaggerHandler serves the Swagger UI for interactive API documentation.
27-
func (app *App) GetSwaggerHandler(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { //nolint:unused // receiver required for route signature
27+
func (app *App) GetSwaggerHandler(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
2828
httpSwagger.Handler(
2929
httpSwagger.URL(SwaggerDocPath),
3030
httpSwagger.DeepLinking(true),

clients/ui/bff/internal/models/health_check/health_check.go renamed to clients/ui/bff/internal/models/healthcheck/healthcheck.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package health_check
1+
package healthcheck
22

33
type SystemInfo struct {
44
Version string `json:"version"`

clients/ui/bff/internal/repositories/health_check.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package repositories
22

3-
import "github.com/kubeflow/model-registry/ui/bff/internal/models/health_check"
3+
import "github.com/kubeflow/model-registry/ui/bff/internal/models/healthcheck"
44

55
type HealthCheckRepository struct{}
66

77
func NewHealthCheckRepository() *HealthCheckRepository {
88
return &HealthCheckRepository{}
99
}
1010

11-
func (r *HealthCheckRepository) HealthCheck(version string) (health_check.HealthCheckModel, error) {
12-
return health_check.HealthCheckModel{
11+
func (r *HealthCheckRepository) HealthCheck(version string) (healthcheck.HealthCheckModel, error) {
12+
return healthcheck.HealthCheckModel{
1313
Status: "available",
14-
SystemInfo: health_check.SystemInfo{
14+
SystemInfo: healthcheck.SystemInfo{
1515
Version: version,
1616
},
1717
}, nil

clients/ui/bff/openapi/docs.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/ui/bff/openapi/swagger.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"200": {
3333
"description": "Successful healthcheck response",
3434
"schema": {
35-
"$ref": "#/definitions/health_check.HealthCheckModel"
35+
"$ref": "#/definitions/healthcheck.HealthCheckModel"
3636
}
3737
},
3838
"401": {
@@ -81,7 +81,7 @@
8181
}
8282
}
8383
},
84-
"health_check.HealthCheckModel": {
84+
"healthcheck.HealthCheckModel": {
8585
"type": "object",
8686
"required": [
8787
"status",
@@ -92,11 +92,11 @@
9292
"type": "string"
9393
},
9494
"system_info": {
95-
"$ref": "#/definitions/health_check.SystemInfo"
95+
"$ref": "#/definitions/healthcheck.SystemInfo"
9696
}
9797
}
9898
},
99-
"health_check.SystemInfo": {
99+
"healthcheck.SystemInfo": {
100100
"type": "object",
101101
"required": [
102102
"version"

clients/ui/bff/openapi/swagger.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ definitions:
77
required:
88
- error
99
type: object
10-
health_check.HealthCheckModel:
10+
healthcheck.HealthCheckModel:
1111
properties:
1212
status:
1313
type: string
1414
system_info:
15-
$ref: '#/definitions/health_check.SystemInfo'
15+
$ref: '#/definitions/healthcheck.SystemInfo'
1616
required:
1717
- status
1818
- system_info
1919
type: object
20-
health_check.SystemInfo:
20+
healthcheck.SystemInfo:
2121
properties:
2222
version:
2323
type: string
@@ -54,7 +54,7 @@ paths:
5454
"200":
5555
description: Successful healthcheck response
5656
schema:
57-
$ref: '#/definitions/health_check.HealthCheckModel'
57+
$ref: '#/definitions/healthcheck.HealthCheckModel'
5858
"401":
5959
description: Unauthorized. Authentication is required.
6060
schema:

0 commit comments

Comments
 (0)