mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 12:32:03 +00:00
ProducesObject should only update the returned API object resource documentation
This commit is contained in:
parent
775f5d232d
commit
e18eeb2d63
@ -545,9 +545,9 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
reqScope.MetaGroupVersion = *a.group.MetaGroupVersion
|
||||
}
|
||||
for _, action := range actions {
|
||||
versionedObject := storageMeta.ProducesObject(action.Verb)
|
||||
if versionedObject == nil {
|
||||
versionedObject = defaultVersionedObject
|
||||
producedObject := storageMeta.ProducesObject(action.Verb)
|
||||
if producedObject == nil {
|
||||
producedObject = defaultVersionedObject
|
||||
}
|
||||
reqScope.Namer = action.Namer
|
||||
namespaced := ""
|
||||
@ -618,8 +618,8 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
|
||||
Operation("read"+namespaced+kind+strings.Title(subresource)+operationSuffix).
|
||||
Produces(append(storageMeta.ProducesMIMETypes(action.Verb), mediaTypes...)...).
|
||||
Returns(http.StatusOK, "OK", versionedObject).
|
||||
Writes(versionedObject)
|
||||
Returns(http.StatusOK, "OK", producedObject).
|
||||
Writes(producedObject)
|
||||
if isGetterWithOptions {
|
||||
if err := addObjectParams(ws, route, versionedGetOptions); err != nil {
|
||||
return nil, err
|
||||
@ -678,9 +678,9 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
|
||||
Operation("replace"+namespaced+kind+strings.Title(subresource)+operationSuffix).
|
||||
Produces(append(storageMeta.ProducesMIMETypes(action.Verb), mediaTypes...)...).
|
||||
Returns(http.StatusOK, "OK", versionedObject).
|
||||
Reads(versionedObject).
|
||||
Writes(versionedObject)
|
||||
Returns(http.StatusOK, "OK", producedObject).
|
||||
Reads(defaultVersionedObject).
|
||||
Writes(producedObject)
|
||||
addParams(route, action.Params)
|
||||
routes = append(routes, route)
|
||||
case "PATCH": // Partially update a resource
|
||||
@ -695,9 +695,9 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
Consumes(string(types.JSONPatchType), string(types.MergePatchType), string(types.StrategicMergePatchType)).
|
||||
Operation("patch"+namespaced+kind+strings.Title(subresource)+operationSuffix).
|
||||
Produces(append(storageMeta.ProducesMIMETypes(action.Verb), mediaTypes...)...).
|
||||
Returns(http.StatusOK, "OK", versionedObject).
|
||||
Returns(http.StatusOK, "OK", producedObject).
|
||||
Reads(metav1.Patch{}).
|
||||
Writes(versionedObject)
|
||||
Writes(producedObject)
|
||||
addParams(route, action.Params)
|
||||
routes = append(routes, route)
|
||||
case "POST": // Create a resource.
|
||||
@ -718,9 +718,9 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
|
||||
Operation("create"+namespaced+kind+strings.Title(subresource)+operationSuffix).
|
||||
Produces(append(storageMeta.ProducesMIMETypes(action.Verb), mediaTypes...)...).
|
||||
Returns(http.StatusOK, "OK", versionedObject).
|
||||
Reads(versionedObject).
|
||||
Writes(versionedObject)
|
||||
Returns(http.StatusOK, "OK", producedObject).
|
||||
Reads(defaultVersionedObject).
|
||||
Writes(producedObject)
|
||||
addParams(route, action.Params)
|
||||
routes = append(routes, route)
|
||||
case "DELETE": // Delete a resource.
|
||||
@ -815,6 +815,10 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
routes = append(routes, buildProxyRoute(ws, "OPTIONS", a.prefix, action.Path, kind, resource, subresource, namespaced, namespaceScope, hasSubresource, action.Params, proxyHandler, operationSuffix))
|
||||
case "CONNECT":
|
||||
for _, method := range connecter.ConnectMethods() {
|
||||
connectProducedObject := storageMeta.ProducesObject(method)
|
||||
if connectProducedObject == nil {
|
||||
connectProducedObject = "string"
|
||||
}
|
||||
doc := "connect " + method + " requests to " + kind
|
||||
if hasSubresource {
|
||||
doc = "connect " + method + " requests to " + subresource + " of " + kind
|
||||
@ -826,7 +830,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
Operation("connect" + strings.Title(strings.ToLower(method)) + namespaced + kind + strings.Title(subresource) + operationSuffix).
|
||||
Produces("*/*").
|
||||
Consumes("*/*").
|
||||
Writes("string")
|
||||
Writes(connectProducedObject)
|
||||
if versionedConnectOptions != nil {
|
||||
if err := addObjectParams(ws, route, versionedConnectOptions); err != nil {
|
||||
return nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user