openapi: warn on missing description
This commit is contained in:
@@ -140,16 +140,26 @@ def main() -> None:
|
|||||||
"components": {"schemas": {}},
|
"components": {"schemas": {}},
|
||||||
}
|
}
|
||||||
|
|
||||||
# === Convert each function ===
|
# === Check all functions ===
|
||||||
warnings = []
|
warnings: list[str] = []
|
||||||
for func_name, _ in functions.items():
|
errors: list[str] = []
|
||||||
|
for func_name, func_schema in functions.items():
|
||||||
normalized = normalize_op_name(func_name)
|
normalized = normalize_op_name(func_name)
|
||||||
check_res = check_operation_name(func_name, normalized)
|
check_res = check_operation_name(func_name, normalized)
|
||||||
if check_res:
|
if check_res:
|
||||||
warnings.append(check_res)
|
errors.extend(check_res)
|
||||||
|
|
||||||
|
if not func_schema.get("description"):
|
||||||
|
warnings.append(
|
||||||
|
f"{func_name} doesn't have a description. Python docstring is required for an API function."
|
||||||
|
)
|
||||||
|
|
||||||
if warnings:
|
if warnings:
|
||||||
for message in warnings:
|
for message in warnings:
|
||||||
print(f"⚠️ WARNING: {message}")
|
print(f"⚠️ Warn: {message}")
|
||||||
|
if errors:
|
||||||
|
for m in errors:
|
||||||
|
print(f"❌ Error: {m}")
|
||||||
os.abort()
|
os.abort()
|
||||||
|
|
||||||
# === Convert each function ===
|
# === Convert each function ===
|
||||||
@@ -168,6 +178,7 @@ def main() -> None:
|
|||||||
"post": {
|
"post": {
|
||||||
"summary": func_name,
|
"summary": func_name,
|
||||||
"operationId": func_name,
|
"operationId": func_name,
|
||||||
|
"description": func_schema.get("description"),
|
||||||
"tags": [tag],
|
"tags": [tag],
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"required": True,
|
"required": True,
|
||||||
|
|||||||
Reference in New Issue
Block a user