From f7afd0c7afd7ec99505d6cb6e493b85ab184532c Mon Sep 17 00:00:00 2001 From: valenti Date: Thu, 16 Apr 2026 12:35:11 -0400 Subject: [PATCH] API client --- fastcheck_api/app/api/v1/routers/auth.py | 35 ---------------------- fastcheck_api/app/api/v1/routers/checks.py | 35 ---------------------- 2 files changed, 70 deletions(-) diff --git a/fastcheck_api/app/api/v1/routers/auth.py b/fastcheck_api/app/api/v1/routers/auth.py index 32a8bb9..028531a 100644 --- a/fastcheck_api/app/api/v1/routers/auth.py +++ b/fastcheck_api/app/api/v1/routers/auth.py @@ -7,7 +7,6 @@ from fastapi import APIRouter, Depends, HTTPException, status from motor.motor_asyncio import AsyncIOMotorDatabase from fastcheck_api.app.api.dependencies import CurrentUser, get_current_user -from fastcheck_api.app.core.config import settings from fastcheck_api.app.core.mongodb import get_db from fastcheck_api.app.core.security import create_access_token from fastcheck_api.app.schemas.auth import LoginRequest, LoginResponse, UserOut @@ -15,7 +14,6 @@ from fastcheck_api.app.services.auth_service import AuthService router = APIRouter(prefix="/auth", tags=["auth"]) -API_PREFIX = settings.normalized_api_prefix or "/api/v1" @router.post( @@ -23,25 +21,6 @@ API_PREFIX = settings.normalized_api_prefix or "/api/v1" response_model=LoginResponse, summary="Login", description="Authenticate with email and password and receive a bearer JWT token compatible with the existing Node.js backend.", - openapi_extra={ - "x-code-samples": [ - { - "lang": "curl", - "label": "cURL", - "source": f"curl -X POST 'http://127.0.0.1:8181{API_PREFIX}/auth/login' \\\n -H 'Content-Type: application/json' \\\n -d '{{\"email\":\"user@example.com\",\"password\":\"********\"}}'", - }, - { - "lang": "python", - "label": "httpx", - "source": f"import httpx\nresp = httpx.post('http://127.0.0.1:8181{API_PREFIX}/auth/login', json={{\n 'email': 'user@example.com',\n 'password': '********'\n}})\nprint(resp.json())", - }, - { - "lang": "js", - "label": "fetch", - "source": f"const resp = await fetch('http://127.0.0.1:8181{API_PREFIX}/auth/login', {{\n method: 'POST',\n headers: {{ 'Content-Type': 'application/json' }},\n body: JSON.stringify({{ email: 'user@example.com', password: '********' }})\n}});\nconsole.log(await resp.json());", - }, - ] - }, ) async def login(payload: LoginRequest, db: Annotated[AsyncIOMotorDatabase, Depends(get_db)]): try: @@ -81,20 +60,6 @@ async def me( "/refresh", summary="Refresh token", description="Issue a new JWT token using the current token's identity and tenant context.", - openapi_extra={ - "x-code-samples": [ - { - "lang": "curl", - "label": "cURL", - "source": f"curl -X POST 'http://127.0.0.1:8181{API_PREFIX}/auth/refresh' \\\n -H 'Authorization: Bearer '", - }, - { - "lang": "python", - "label": "httpx", - "source": f"import httpx\nresp = httpx.post('http://127.0.0.1:8181{API_PREFIX}/auth/refresh', headers={{\n 'Authorization': 'Bearer '\n}})\nprint(resp.json())", - }, - ] - }, ) async def refresh(user: Annotated[CurrentUser, Depends(get_current_user)]): token = create_access_token(user_id=user.id, email=user.email, role=user.role, tenant_id=user.tenant) diff --git a/fastcheck_api/app/api/v1/routers/checks.py b/fastcheck_api/app/api/v1/routers/checks.py index 15bf0d9..3950339 100644 --- a/fastcheck_api/app/api/v1/routers/checks.py +++ b/fastcheck_api/app/api/v1/routers/checks.py @@ -7,7 +7,6 @@ from fastapi import APIRouter, Depends, HTTPException, Query, Request, status from motor.motor_asyncio import AsyncIOMotorDatabase from fastcheck_api.app.api.dependencies import CurrentUser, require_permission -from fastcheck_api.app.core.config import settings from fastcheck_api.app.core.mongodb import get_db from fastcheck_api.app.schemas.checks import ( CreateCheckRequest, @@ -20,7 +19,6 @@ from fastcheck_api.app.services.check_service import CheckService, InsufficientC router = APIRouter(prefix="/checks", tags=["checks"]) -API_PREFIX = settings.normalized_api_prefix or "/api/v1" @router.get( @@ -44,25 +42,6 @@ async def list_checks( status_code=status.HTTP_201_CREATED, summary="Create a check", description="Create a single evaluation job and enqueue processing in RabbitMQ using the existing queue and message format.", - openapi_extra={ - "x-code-samples": [ - { - "lang": "curl", - "label": "cURL", - "source": f"curl -X POST 'http://127.0.0.1:8181{API_PREFIX}/checks' \\\n -H 'Authorization: Bearer ' \\\n -H 'Content-Type: application/json' \\\n -d '{{\"supplier\":{{\"rut\":\"12345678-9\",\"name\":\"ACME SpA\"}}}}'", - }, - { - "lang": "python", - "label": "httpx", - "source": f"import httpx\nresp = httpx.post('http://127.0.0.1:8181{API_PREFIX}/checks',\n headers={{'Authorization': 'Bearer '}},\n json={{'supplier': {{'rut': '12345678-9', 'name': 'ACME SpA'}}}})\nprint(resp.json())", - }, - { - "lang": "js", - "label": "fetch", - "source": f"const resp = await fetch('http://127.0.0.1:8181{API_PREFIX}/checks', {{\n method: 'POST',\n headers: {{\n 'Authorization': 'Bearer ',\n 'Content-Type': 'application/json'\n }},\n body: JSON.stringify({{ supplier: {{ rut: '12345678-9', name: 'ACME SpA' }} }})\n}});\nconsole.log(await resp.json());", - }, - ] - }, ) async def create_check( request: Request, @@ -139,20 +118,6 @@ async def get_check( response_model=ListResultsResponse, summary="List check results", description="List evaluation results for a given job id (tenant-scoped).", - openapi_extra={ - "x-code-samples": [ - { - "lang": "curl", - "label": "cURL", - "source": f"curl 'http://127.0.0.1:8181{API_PREFIX}/checks//results?page=1&limit=10' \\\n -H 'Authorization: Bearer '", - }, - { - "lang": "python", - "label": "httpx", - "source": f"import httpx\nresp = httpx.get('http://127.0.0.1:8181{API_PREFIX}/checks//results',\n params={{'page': 1, 'limit': 10}},\n headers={{'Authorization': 'Bearer '}})\nprint(resp.json())", - }, - ] - }, ) async def get_check_results( job_id: str,