From: Aashish Sharma Date: Tue, 1 Jun 2021 05:09:24 +0000 (+0530) Subject: mgr/dashboard: API Version changes do not apply to pre-defined methods (list, create... X-Git-Tag: v16.2.5~84^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4145337d73098c512365c794505f51579c413adb;p=ceph.git mgr/dashboard: API Version changes do not apply to pre-defined methods (list, create etc.) Methods like list(), create(), get() etc doesn't get applied the version.Also for the endpoints that get the version changed, the docs and the request header has still the version v1.0+ in them. So with the version reduced it gives 415 error when trying to make the request. This PR fixes this issue. Fixes: https://tracker.ceph.com/issues/50855 Signed-off-by: Aashish Sharma (cherry picked from commit dc4becfde8ddf8745b5d63c941236f95d9e64ba3) Conflicts: src/pybind/mgr/dashboard/controllers/__init__.py(resolved conflicts due to https://github.com/ceph/ceph/pull/40063) --- diff --git a/src/pybind/mgr/dashboard/controllers/docs.py b/src/pybind/mgr/dashboard/controllers/docs.py index 87c46e327bd6..331f2479a69b 100644 --- a/src/pybind/mgr/dashboard/controllers/docs.py +++ b/src/pybind/mgr/dashboard/controllers/docs.py @@ -291,14 +291,14 @@ class Docs(BaseController): resp = {} p_info = [] - if hasattr(func, 'method_map_method'): - version = func.method_map_method['version'] + if hasattr(func, '__method_map_method__'): + version = func.__method_map_method__['version'] - elif hasattr(func, 'resource_method'): - version = func.resource_method['version'] + elif hasattr(func, '__resource_method__'): + version = func.__resource_method__['version'] - elif hasattr(func, 'collection_method'): - version = func.collection_method['version'] + elif hasattr(func, '__collection_method__'): + version = func.__collection_method__['version'] if hasattr(func, 'doc_info'): if func.doc_info['summary']: diff --git a/src/pybind/mgr/dashboard/tests/test_docs.py b/src/pybind/mgr/dashboard/tests/test_docs.py index 623d5baf6efa..072985e8bf89 100644 --- a/src/pybind/mgr/dashboard/tests/test_docs.py +++ b/src/pybind/mgr/dashboard/tests/test_docs.py @@ -1,7 +1,6 @@ # # -*- coding: utf-8 -*- from __future__ import absolute_import -from .. import DEFAULT_VERSION from ..api.doc import SchemaType from ..controllers import ApiController, ControllerDoc, Endpoint, EndpointDoc, RESTController from ..controllers.docs import Docs