(base: str)
| 151 | |
| 152 | |
| 153 | def cmd_check(base: str) -> None: |
| 154 | head: Final = head_violations() |
| 155 | base_point: Final = resolve_base_point(base) |
| 156 | breaches: Final = evaluate(count_by_rule(head), base_counts_cached(checker_identity(), base_point, base_counts)) |
| 157 | if not breaches: |
| 158 | print(f"OK: no OA rule grew past its merge-base count (base {base})") |
| 159 | return |
| 160 | diff: Final = _run(["git", "diff", base_point, "--unified=0", "--no-color", "--", TARGET]) |
| 161 | new: Final = introduced(head, added_text(diff)) |
| 162 | print(f"FAIL: OA-rule totals grew past their merge-base count (base {base}):") |
| 163 | for breach in breaches: |
| 164 | print(f" {breach.rule}: total {breach.total} over ceiling {breach.ceiling} (this change added {breach.added})") |
| 165 | for violation in sorted(v for v in new if v.code == breach.rule): |
| 166 | print(f" {violation.method} {violation.path}") |
| 167 | print( |
| 168 | "Give every new POST route a request body schema (a typed body parameter, or " |
| 169 | "`openapi_extra={'requestBody': inline_request_body(Model, example)}` when the handler reads " |
| 170 | "`request.body()`), a docstring, and a 200 schema (`response_model=` or `responses={200: {'model': ...}}`), " |
| 171 | "or document an equal number of existing routes; the ceiling is the merge-base count. Run " |
| 172 | "`python scripts/check_openapi_docs.py` to see every finding." |
| 173 | ) |
| 174 | raise SystemExit(1) |
| 175 | |
| 176 | |
| 177 | def main() -> None: |
no test coverage detected