swagger.restapi:
def restapi(url, **kwargs): """REST API endpoint decorator.""" def _real_decorator(cls): cls.rest_api = True cls.tagged_api_comps = [] members = inspect.getmembers(cls, is_rest_api_method) for name, member in members: doc = inspect.getdoc(member) if not doc: continue path_spec = docparser.parse_from_docstring(str(doc)) if path_spec: setattr(member, 'path_spec', path_spec) cls.tagged_api_comps.append(name) settings.add_api_handler(cls) settings.add_route(url, cls, **kwargs) return cls return _real_decorator
posted on 2019-03-16 16:59 阅读( ...) 评论( ...)