"""OpenAPI 3.1 + Redocly recommended, matching internal-portal (DEV-289).""" from pathlib import Path ROOT = Path(__file__).resolve().parents[1] def test_openapi_uses_redocly_recommended(): redocly = (ROOT / ".redocly.yaml").read_text() package = (ROOT / "package.json").read_text() spec = (ROOT / "openapi.yaml").read_text() ci = (ROOT / ".github" / "workflows" / "ci.yml").read_text() assert "extends:" in redocly assert "- recommended" in redocly assert "operation-2xx-response: off" in redocly assert "operation-4xx-response: error" in redocly assert "rule/operation-2xx-or-3xx-response" in redocly assert "severity: error" in redocly health = spec.split("/api/health:", 1)[1].split("\n /", 1)[0] assert '"403":' in health assert '"400":' not in health roster = spec.split("/api/roster:", 1)[1].split("\n /", 1)[0] assert '"403":' in roster assert '"400":' not in roster form_status = spec.split("/api/form-status/{week}:", 1)[1].split("\n /", 1)[0] assert '"400":' in form_status menu = spec.split("/api/menu/{week}:", 1)[1].split("\n /", 1)[0] orders = spec.split("/api/orders/{week}:", 1)[1].split("\n /", 1)[0] assert "MenuWeekPath" in menu assert "MenuWeekPath" in form_status assert "OrderWeekPath" in orders assert "WeekPath" not in spec.split("components:", 1)[1].split("MenuWeekPath", 1)[0] assert "`current` or `YYYY-WNN`" in spec assert "`YYYY-WNN` or `YYYY-MM-DD`" in spec meal = spec.split(" Meal:", 1)[1].split("\n MenuPayload:", 1)[0] assert 'type: [string, number, "null"]' in meal assert 'type: [string, "null"]' in meal assert 'menu_url:\n type: [string, "null"]' in spec assert "root: openapi.yaml" in redocly assert '"openapi:lint"' in package assert '"@redocly/cli": "2.52.1"' in package assert "npm run openapi:lint" in ci assert "openapi: 3.1.0" in spec assert "required: [stage, sha]" in spec assert "{ error: string }" in spec or "`{ error: string }`" in spec