v1.31.0
conocimientodocumentacion-tecnicatemplates/6287 B

API-REFERENCE.md.template

Fichero que /hv:documentacion-tecnica usa o materializa en el proyecto. Se muestra tal cual está en el plugin.

documentacion-tecnicaskill
templatescarpeta
6287 Btamaño
2026-10-06último cambio del pack
# Referencia de API

> Template para documentación de API REST
> Skill: documentacion-tecnica

## Información General

| Campo | Valor |
|-------|-------|
| **Base URL** | `https://api.example.org/v1` |
| **Autenticación** | Bearer Token (Azure AD) |
| **Formato** | JSON |
| **Encoding** | UTF-8 |

---

## Autenticación

Todas las peticiones requieren un token Bearer en el header `Authorization`:

` ` `http
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOi...
` ` `

### Obtener Token

` ` `http
POST https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded

client_id={client_id}
&scope=api://{api_client_id}/.default
&client_secret={client_secret}
&grant_type=client_credentials
` ` `

---

## Respuestas

### Códigos HTTP

| Código | Descripción |
|--------|-------------|
| `200` | OK - Petición exitosa |
| `201` | Created - Recurso creado |
| `204` | No Content - Operación exitosa sin contenido |
| `400` | Bad Request - Error de validación |
| `401` | Unauthorized - Token inválido o ausente |
| `403` | Forbidden - Sin permisos |
| `404` | Not Found - Recurso no encontrado |
| `409` | Conflict - Conflicto de status |
| `500` | Internal Server Error |

### Formato de Error

` ` `json
{
  "type": "https://example.org/errors/validation",
  "title": "Error de validación",
  "status": 400,
  "detail": "Name is required",
  "instance": "/api/scholarships",
  "errors": {
    "Name": ["Name is required"],
    "Amount": ["El amount debe ser mayor que 0"]
  }
}
` ` `

---

## Paginación

Los endpoints de listado soportan paginación:

` ` `http
GET /api/scholarships?page=1&size=10
` ` `

### Respuesta Paginada

` ` `json
{
  "items": [...],
  "totalCount": 100,
  "page": 1,
  "size": 10,
  "totalPages": 10,
  "hasNextPage": true,
  "hasPreviousPage": false
}
` ` `

---

## Endpoints

### Scholarships

#### Listar Scholarships

` ` `http
GET /api/scholarships
` ` `

**Query Parameters:**

| Parámetro | Tipo | Descripción | Default |
|-----------|------|-------------|---------|
| `page` | int | Número de página | 1 |
| `size` | int | Elementos por página | 10 |
| `status` | string | Filtrar por status | - |
| `orderBy` | string | Campo para ordenar | createdAt |
| `orderDesc` | bool | Orden descendente | true |

**Response:** `200 OK`

` ` `json
{
  "items": [
    {
      "id": 1,
      "code": "BECA-001",
      "name": "Scholarship de Excelencia",
      "amount": 5000.00,
      "status": "Published",
      "startDate": "2025-01-01",
      "endDate": "2025-12-31"
    }
  ],
  "totalCount": 50,
  "page": 1,
  "size": 10
}
` ` `

---

#### Obtener Scholarship

` ` `http
GET /api/scholarships/{id}
` ` `

**Path Parameters:**

| Parámetro | Tipo | Descripción |
|-----------|------|-------------|
| `id` | int | ID de la scholarship |

**Response:** `200 OK`

` ` `json
{
  "id": 1,
  "code": "BECA-001",
  "name": "Scholarship de Excelencia",
  "descripcion": "Scholarship para students con expediente académico destacado",
  "amount": 5000.00,
  "status": "Published",
  "startDate": "2025-01-01",
  "endDate": "2025-12-31",
  "createdAt": "2025-01-01T10:00:00Z",
  "createdBy": "admin@example.com"
}
` ` `

**Error Response:** `404 Not Found`

` ` `json
{
  "type": "https://example.org/errors/not-found",
  "title": "Recurso no encontrado",
  "status": 404,
  "detail": "No existe una scholarship con ID 999"
}
` ` `

---

#### Crear Scholarship

` ` `http
POST /api/scholarships
` ` `

**Request Body:**

` ` `json
{
  "code": "BECA-002",
  "name": "New Scholarship",
  "descripcion": "Descripción opcional",
  "amount": 3000.00,
  "startDate": "2025-06-01",
  "endDate": "2025-12-31"
}
` ` `

**Validaciones:**

| Campo | Reglas |
|-------|--------|
| `code` | Requerido, único, max 20 chars |
| `name` | Requerido, max 200 chars |
| `descripcion` | Opcional, max 2000 chars |
| `amount` | Requerido, > 0, <= 100000 |
| `startDate` | Requerido |
| `endDate` | Requerido, > startDate |

**Response:** `201 Created`

` ` `http
Location: /api/scholarships/2
` ` `

` ` `json
{
  "id": 2,
  "code": "BECA-002",
  "name": "New Scholarship",
  "status": "Draft"
}
` ` `

**Error Response:** `400 Bad Request`

` ` `json
{
  "type": "https://example.org/errors/validation",
  "title": "Error de validación",
  "status": 400,
  "errors": {
    "Name": ["Name is required"],
    "Amount": ["El amount debe ser mayor que 0"]
  }
}
` ` `

---

#### Actualizar Scholarship

` ` `http
PUT /api/scholarships/{id}
` ` `

**Request Body:**

` ` `json
{
  "name": "Name Actualizado",
  "descripcion": "Nueva descripción",
  "amount": 4000.00
}
` ` `

**Response:** `204 No Content`

---

#### Eliminar Scholarship

` ` `http
DELETE /api/scholarships/{id}
` ` `

**Response:** `204 No Content`

**Error Response:** `409 Conflict`

` ` `json
{
  "type": "https://example.org/errors/conflict",
  "title": "Conflicto",
  "status": 409,
  "detail": "No se puede eliminar una scholarship con applications activas"
}
` ` `

---

### Applications

#### Listar Applications de una Scholarship

` ` `http
GET /api/scholarships/{scholarshipId}/applications
` ` `

#### Crear ScholarshipApplication

` ` `http
POST /api/scholarships/{scholarshipId}/applications
` ` `

**Request Body:**

` ` `json
{
  "studentId": 123,
  "motivacion": "Texto de motivación..."
}
` ` `

---

## Ejemplos con cURL

### Listar Scholarships

` ` `bash
curl -X GET "https://api.example.org/v1/scholarships?page=1&size=10" \
  -H "Authorization: Bearer eyJ0eXAi..." \
  -H "Accept: application/json"
` ` `

### Crear Scholarship

` ` `bash
curl -X POST "https://api.example.org/v1/scholarships" \
  -H "Authorization: Bearer eyJ0eXAi..." \
  -H "Content-Type: application/json" \
  -d '{
    "code": "BECA-003",
    "name": "New Scholarship",
    "amount": 2500.00,
    "startDate": "2025-01-01",
    "endDate": "2025-06-30"
  }'
` ` `

---

## Rate Limiting

| Límite | Valor |
|--------|-------|
| Peticiones por minuto | 100 |
| Peticiones por hora | 1000 |

Headers de respuesta:

` ` `http
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640000000
` ` `

---

## Versionado

La API está versionada en la URL: `/v1/`, `/v2/`, etc.

Cambios menores se documentan en el changelog sin cambiar versión.
Cambios breaking requieren nueva versión.

---

*Generado con documentacion-tecnica skill v2.8.0*

← Volver a la ficha de documentacion-tecnica