From c22150bc3e2436d74b43843770a00fbe8cc8f992 Mon Sep 17 00:00:00 2001 From: themylogin Date: Mon, 13 Jan 2025 18:07:54 +0100 Subject: [PATCH] Documentation: list roles that are allowed to call a method --- src/middlewared/middlewared/api/base/server/doc.py | 2 ++ src/middlewared_docs/generate_docs.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/middlewared/middlewared/api/base/server/doc.py b/src/middlewared/middlewared/api/base/server/doc.py index d121ba1a31542..13e5cf06b3af2 100644 --- a/src/middlewared/middlewared/api/base/server/doc.py +++ b/src/middlewared/middlewared/api/base/server/doc.py @@ -15,6 +15,7 @@ class APIDump(BaseModel): class APIDumpMethod(BaseModel): name: str + roles: list[str] doc: str | None schemas: dict @@ -64,6 +65,7 @@ def _dump_method(self, method: Method): return APIDumpMethod( name=name, + roles=method.methodobj.roles, doc=doc, schemas=self._dump_method_schemas(method), ) diff --git a/src/middlewared_docs/generate_docs.py b/src/middlewared_docs/generate_docs.py index d7688e02b98d8..4e427f9deedde 100644 --- a/src/middlewared_docs/generate_docs.py +++ b/src/middlewared_docs/generate_docs.py @@ -151,7 +151,11 @@ def _generate_method_rst(self, method: APIDumpMethod, method_schemas_html: str): result += f"{method.doc}\n\n" result += f".. raw:: html\n\n" - result += textwrap.indent(f"
" + method_schemas_html + "
", " " * 4) + "\n\n" + result += textwrap.indent( + f"
" + method_schemas_html + "


", " " * 4 + ) + "\n\n" + + result += "*Required roles:* " + " | ".join(method.roles) + "\n\n" return result