Skip to content

Commit cf4d4d3

Browse files
committed
swagger API changes
1 parent d3282b3 commit cf4d4d3

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

pkg/cmd/server/origin/swagger.go

+14-8
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,35 @@ var apiInfo = map[string]swagger.Info{
1818

1919
// customizeSwaggerDefinition applies selective patches to the swagger API docs
2020
// TODO: move most of these upstream or to go-restful
21-
func customizeSwaggerDefinition(api map[string]swagger.ApiDeclaration) {
21+
func customizeSwaggerDefinition(api *swagger.ApiDeclarationList) {
2222
for path, info := range apiInfo {
23-
if dec, ok := api[path]; ok {
23+
if dec, ok := api.At(path); ok {
2424
if len(info.Title) > 0 {
2525
dec.Info.Title = info.Title
2626
}
2727
if len(info.Description) > 0 {
2828
dec.Info.Description = info.Description
2929
}
30-
api[path] = dec
30+
api.Put(path, dec)
3131
} else {
3232
glog.Warningf("No API exists for predefined swagger description %s", path)
3333
}
3434
}
3535
for _, version := range []string{OpenShiftAPIPrefixV1} {
36-
model := api[version].Models["runtime.RawExtension"]
36+
apiDeclaration, _ := api.At(version)
37+
models := &apiDeclaration.Models
38+
39+
model, _ := models.At("runtime.RawExtension")
3740
model.Required = []string{}
38-
model.Properties = map[string]swagger.ModelProperty{}
41+
model.Properties = swagger.ModelPropertyList{}
3942
model.Description = "this may be any JSON object with a 'kind' and 'apiVersion' field; and is preserved unmodified by processing"
40-
api[version].Models["runtime.RawExtension"] = model
43+
models.Put("runtime.RawExtension", model)
4144

42-
model = api[version].Models["patch.Object"]
45+
model, _ = models.At("patch.Object")
4346
model.Description = "represents an object patch, which may be any of: JSON patch (RFC 6902), JSON merge patch (RFC 7396), or the Kubernetes strategic merge patch"
44-
api[version].Models["patch.Object"] = model
47+
models.Put("patch.Object", model)
48+
49+
apiDeclaration.Models = *models
50+
api.Put(version, apiDeclaration)
4551
}
4652
}

0 commit comments

Comments
 (0)