mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
Added SwaggerDoc() in api-server
This commit is contained in:
parent
9f21ae21e8
commit
ff2fcd43f7
@ -52,6 +52,11 @@ type action struct {
|
|||||||
Namer ScopeNamer
|
Namer ScopeNamer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// An interface to see if an object supports swagger documentation as a method
|
||||||
|
type documentable interface {
|
||||||
|
SwaggerDoc() map[string]string
|
||||||
|
}
|
||||||
|
|
||||||
// errEmptyName is returned when API requests do not fill the name section of the path.
|
// errEmptyName is returned when API requests do not fill the name section of the path.
|
||||||
var errEmptyName = errors.NewBadRequest("name must be provided")
|
var errEmptyName = errors.NewBadRequest("name must be provided")
|
||||||
|
|
||||||
@ -796,7 +801,11 @@ func addObjectParams(ws *restful.WebService, route *restful.RouteBuilder, obj in
|
|||||||
if len(jsonName) == 0 {
|
if len(jsonName) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
desc := sf.Tag.Get("description")
|
|
||||||
|
var desc string
|
||||||
|
if docable, ok := obj.(documentable); ok {
|
||||||
|
desc = docable.SwaggerDoc()[jsonName]
|
||||||
|
}
|
||||||
route.Param(ws.QueryParameter(jsonName, desc).DataType(typeToJSON(sf.Type.Name())))
|
route.Param(ws.QueryParameter(jsonName, desc).DataType(typeToJSON(sf.Type.Name())))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,11 +247,18 @@ func (*SimpleRoot) IsAnAPIObject() {}
|
|||||||
|
|
||||||
type SimpleGetOptions struct {
|
type SimpleGetOptions struct {
|
||||||
api.TypeMeta `json:",inline"`
|
api.TypeMeta `json:",inline"`
|
||||||
Param1 string `json:"param1" description:"description for param1"`
|
Param1 string `json:"param1"`
|
||||||
Param2 string `json:"param2" description:"description for param2"`
|
Param2 string `json:"param2"`
|
||||||
Path string `json:"atAPath"`
|
Path string `json:"atAPath"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (SimpleGetOptions) SwaggerDoc() map[string]string {
|
||||||
|
return map[string]string{
|
||||||
|
"param1": "description for param1",
|
||||||
|
"param2": "description for param2",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (*SimpleGetOptions) IsAnAPIObject() {}
|
func (*SimpleGetOptions) IsAnAPIObject() {}
|
||||||
|
|
||||||
type SimpleList struct {
|
type SimpleList struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user