Skip to content

Commit 5f5d6ba

Browse files
committed
fix: regenerate OpenAPI code and remove stale converter files
Signed-off-by: Sidney Glinton <[email protected]>
1 parent 3f04d40 commit 5f5d6ba

File tree

8 files changed

+25
-3876
lines changed

8 files changed

+25
-3876
lines changed

catalog/internal/server/openapi/api.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,28 @@ import (
1717
model "github.com/kubeflow/model-registry/catalog/pkg/openapi"
1818
)
1919

20+
21+
2022
// ModelCatalogServiceAPIRouter defines the required methods for binding the api requests to a responses for the ModelCatalogServiceAPI
2123
// The ModelCatalogServiceAPIRouter implementation should parse necessary information from the http request,
2224
// pass the data to a ModelCatalogServiceAPIServicer to perform the required actions, then write the service results to the http response.
23-
type ModelCatalogServiceAPIRouter interface {
25+
type ModelCatalogServiceAPIRouter interface {
2426
FindModels(http.ResponseWriter, *http.Request)
2527
FindModelsFilterOptions(http.ResponseWriter, *http.Request)
2628
FindSources(http.ResponseWriter, *http.Request)
2729
GetAllModelArtifacts(http.ResponseWriter, *http.Request)
2830
GetModel(http.ResponseWriter, *http.Request)
2931
}
3032

33+
3134
// ModelCatalogServiceAPIServicer defines the api actions for the ModelCatalogServiceAPI service
3235
// This interface intended to stay up to date with the openapi yaml used to generate it,
3336
// while the service implementation can be ignored with the .openapi-generator-ignore file
3437
// and updated with the logic required for the API.
35-
type ModelCatalogServiceAPIServicer interface {
36-
FindModels(context.Context, []string, string, string, string, string, model.OrderByField, model.SortOrder, string) (ImplResponse, error)
37-
FindModelsFilterOptions(context.Context) (ImplResponse, error)
38-
FindSources(context.Context, string, string, model.OrderByField, model.SortOrder, string) (ImplResponse, error)
39-
GetAllModelArtifacts(context.Context, string, string, string, model.OrderByField, model.SortOrder, string, string) (ImplResponse, error)
40-
GetModel(context.Context, string, string) (ImplResponse, error)
38+
type ModelCatalogServiceAPIServicer interface {
39+
FindModels(context.Context, []string, string, string, string, string, model.OrderByField, model.SortOrder, string) (ImplResponse, error)
40+
FindModelsFilterOptions(context.Context) (ImplResponse, error)
41+
FindSources(context.Context, string, string, model.OrderByField, model.SortOrder, string) (ImplResponse, error)
42+
GetAllModelArtifacts(context.Context, string, string, string, model.OrderByField, model.SortOrder, string, string) (ImplResponse, error)
43+
GetModel(context.Context, string, string) (ImplResponse, error)
4144
}

catalog/internal/server/openapi/api_model_catalog_service.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
package openapi
1212

1313
import (
14+
1415
"net/http"
1516
"strings"
1617

@@ -154,22 +155,7 @@ func (c *ModelCatalogServiceAPIController) GetAllModelArtifacts(w http.ResponseW
154155
// GetModel - Get a `CatalogModel`.
155156
func (c *ModelCatalogServiceAPIController) GetModel(w http.ResponseWriter, r *http.Request) {
156157
sourceIdParam := chi.URLParam(r, "source_id")
157-
modelNameParam := chi.URLParam(r, "*")
158-
159-
// Special handling for getModel to delegate /artifacts requests to getAllModelArtifacts
160-
// The wildcard /* pattern catches /artifacts requests, but we want those to go to GetAllModelArtifacts
161-
if strings.HasSuffix(r.URL.Path, "/artifacts") {
162-
// Extract the model name by removing the /artifacts suffix
163-
modelName := strings.TrimSuffix(modelNameParam, "/artifacts")
164-
165-
// Add the model_name parameter to the route context so GetAllModelArtifacts can access it
166-
chi.RouteContext(r.Context()).URLParams.Add("model_name", modelName)
167-
168-
// Call the GetAllModelArtifacts handler directly
169-
c.GetAllModelArtifacts(w, r)
170-
return
171-
}
172-
158+
modelNameParam := chi.URLParam(r, "model_name+")
173159
result, err := c.service.GetModel(r.Context(), sourceIdParam, modelNameParam)
174160
// If an error occurred, encode the error with the status code
175161
if err != nil {

catalog/internal/server/openapi/helpers.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@
1111
package openapi
1212

1313
import (
14-
"net/http"
1514
"reflect"
15+
"net/http"
1616

1717
model "github.com/kubeflow/model-registry/pkg/openapi"
1818
)
1919

2020
// Response return a ImplResponse struct filled
2121
func Response(code int, body interface{}) ImplResponse {
22-
return ImplResponse{
22+
return ImplResponse {
2323
Code: code,
2424
Body: body,
2525
}
2626
}
2727

2828
func ErrorResponse(code int, err error) ImplResponse {
29-
return ImplResponse{
30-
Code: code,
31-
Body: model.Error{
32-
Code: http.StatusText(code),
33-
Message: err.Error(),
34-
},
35-
}
29+
return ImplResponse{
30+
Code: code,
31+
Body: model.Error{
32+
Code: http.StatusText(code),
33+
Message: err.Error(),
34+
},
35+
}
3636
}
3737

3838
// IsZeroValue checks if the val is the zero-ed value.

catalog/internal/server/openapi/routers.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import (
3030

3131
// A Route defines the parameters for an api endpoint
3232
type Route struct {
33-
Method string
34-
Pattern string
33+
Method string
34+
Pattern string
3535
HandlerFunc http.HandlerFunc
3636
}
3737

@@ -80,8 +80,8 @@ func EncodeJSONResponse(i interface{}, status *int, w http.ResponseWriter) {
8080

8181
if i != nil {
8282
if err := json.NewEncoder(w).Encode(i); err != nil {
83-
// FIXME: is it too late to inform the client of an error at this point??
84-
glog.Errorf("error encoding JSON response: %v", err)
83+
// FIXME: is it too late to inform the client of an error at this point??
84+
glog.Errorf("error encoding JSON response: %v", err)
8585
}
8686
}
8787
}

0 commit comments

Comments
 (0)