Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-133078 / 25.04 / Documentation: list roles that are allowed to call a method #15380

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/middlewared/middlewared/api/base/server/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class APIDump(BaseModel):

class APIDumpMethod(BaseModel):
name: str
roles: list[str]
doc: str | None
schemas: dict

Expand Down Expand Up @@ -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),
)
Expand Down
6 changes: 5 additions & 1 deletion src/middlewared_docs/generate_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"<div id=\"json-schema\">" + method_schemas_html + "</div>", " " * 4) + "\n\n"
result += textwrap.indent(
f"<div id=\"json-schema\">" + method_schemas_html + "</div><br><br>", " " * 4
) + "\n\n"

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

return result

Expand Down
Loading