diff --git a/Vistas.md b/Vistas.md new file mode 100644 index 0000000..52fdd3b --- /dev/null +++ b/Vistas.md @@ -0,0 +1,244 @@ +### Documentación - API ogCore + +## Select Language / Seleccionar Idioma + +- [English](#english) +- [Español](#español) + +--- + +## English + +### Table of Contents + +1. [Introduction](#introduction) +2. [Configuration](#configuration) +3. [Resource Definition](#resource-definition) +4. [API Operations](#api-operations) +5. [Entity Properties](#entity-properties) +6. [View Input DTO](#view-input-dto) + +### Introduction + +This documentation describes the configuration of API Platform in a Symfony project. It details the resources, operations, and entity properties exposed through the API. + +### Configuration + +API configuration is done in Symfony configuration files, usually in the `config/packages/api_platform.yaml` file. + +```yaml +resources: + App\Entity\View: + processor: App\State\Processor\ViewProcessor + input: App\Dto\Input\ViewInput + output: App\Dto\Output\ViewOutput + normalizationContext: + groups: ['default', 'view:read'] + denormalizationContext: + groups: ['view:write'] + operations: + ApiPlatform\Metadata\GetCollection: + provider: App\State\Provider\ViewProvider + filters: + - 'api_platform.filter.view.order' + - 'api_platform.filter.view.search' + ApiPlatform\Metadata\Get: + provider: App\State\Provider\ViewProvider + ApiPlatform\Metadata\Put: + provider: App\State\Provider\ViewProvider + ApiPlatform\Metadata\Patch: + provider: App\State\Provider\ViewProvider + ApiPlatform\Metadata\Post: ~ + ApiPlatform\Metadata\Delete: ~ + +properties: + App\Entity\View: + id: + identifier: false + uuid: + identifier: true +``` + +### Resource Definition + +#### App\Entity\View + +- **Processor**: `App\State\Processor\ViewProcessor` +- **Input**: `App\Dto\Input\ViewInput` +- **Output**: `App\Dto\Output\ViewOutput` +- **Normalization Context**: `['default', 'view:read']` +- **Denormalization Context**: `['view:write']` + +### API Operations + +#### View Operations + +##### Get View Collection (GetCollection) +- **Provider**: `App\State\Provider\ViewProvider` +- **Filters**: + - Order views: `api_platform.filter.view.order` + - Search views: `api_platform.filter.view.search` + +##### Get View (Get) +- **Provider**: `App\State\Provider\ViewProvider` + +##### Update View (Put) +- **Provider**: `App\State\Provider\ViewProvider` + +##### Partially Update View (Patch) +- **Provider**: `App\State\Provider\ViewProvider` + +##### Create View (Post) +- **Default Operation**: ~ + +##### Delete View (Delete) +- **Default Operation**: ~ + +### Entity Properties + +#### App\Entity\View + +- **id**: + - **Identifier**: `false` + +- **uuid**: + - **Identifier**: `true` + +### View Input DTO + +#### Fields Required in View Endpoint Input + +1. **name** + - **Type**: string + - **Validation**: Not blank + - **Groups**: `view:write` + +2. **description** + - **Type**: string + - **Validation**: Optional + - **Groups**: `view:write` + +3. **isActive** + - **Type**: boolean + - **Validation**: Not null + - **Groups**: `view:write` + - **Default**: false + +--- + +## Español + +### Índice + +1. [Introducción](#introducción) +2. [Configuración](#configuración) +3. [Definición de Recursos](#definición-de-recursos) +4. [Operaciones de API](#operaciones-de-api) +5. [Propiedades de la Entidad](#propiedades-de-la-entidad) +6. [DTO de Entrada de Vista](#dto-de-entrada-de-vista) + +### Introducción + +Esta documentación describe la configuración de API Platform en un proyecto Symfony. Se detallan los recursos, operaciones y propiedades de las entidades expuestas a través de la API. + +### Configuración + +La configuración de la API se realiza en los archivos de configuración de Symfony, generalmente en `config/packages/api_platform.yaml`. + +```yaml +resources: + App\Entity\View: + processor: App\State\Processor\ViewProcessor + input: App\Dto\Input\ViewInput + output: App\Dto\Output\ViewOutput + normalizationContext: + groups: ['default', 'view:read'] + denormalizationContext: + groups: ['view:write'] + operations: + ApiPlatform\Metadata\GetCollection: + provider: App\State\Provider\ViewProvider + filters: + - 'api_platform.filter.view.order' + - 'api_platform.filter.view.search' + ApiPlatform\Metadata\Get: + provider: App\State\Provider\ViewProvider + ApiPlatform\Metadata\Put: + provider: App\State\Provider\ViewProvider + ApiPlatform\Metadata\Patch: + provider: App\State\Provider\ViewProvider + ApiPlatform\Metadata\Post: ~ + ApiPlatform\Metadata\Delete: ~ + +properties: + App\Entity\View: + id: + identifier: false + uuid: + identifier: true +``` + +### Definición de Recursos + +#### App\Entity\View + +- **Processor**: `App\State\Processor\ViewProcessor` +- **Input**: `App\Dto\Input\ViewInput` +- **Output**: `App\Dto\Output\ViewOutput` +- **Contexto de Normalización**: `['default', 'view:read']` +- **Contexto de Desnormalización**: `['view:write']` + +### Operaciones de API + +#### Operaciones de Vista + +##### Obtener Colección de Vistas (GetCollection) +- **Provider**: `App\State\Provider\ViewProvider` +- **Filtros**: + - Ordenar vistas: `api_platform.filter.view.order` + - Buscar vistas: `api_platform.filter.view.search` + +##### Obtener Vista (Get) +- **Provider**: `App\State\Provider\ViewProvider` + +##### Actualizar Vista (Put) +- **Provider**: `App\State\Provider\ViewProvider` + +##### Actualización Parcial de Vista (Patch) +- **Provider**: `App\State\Provider\ViewProvider` + +##### Crear Vista (Post) +- **Operación Predeterminada**: ~ + +##### Eliminar Vista (Delete) +- **Operación Predeterminada**: ~ + +### Propiedades de la Entidad + +#### App\Entity\View + +- **id**: + - **Identificador**: `false` + +- **uuid**: + - **Identificador**: `true` + +### DTO de Entrada de Vista + +#### Campos Requeridos en la Entrada del Endpoint de Vista + +1. **name** + - **Tipo**: string + - **Validación**: No nulo + - **Groups**: `view:write` + +2. **description** + - **Tipo**: string + - **Validación**: Opcional + - **Groups**: `view:write` + +3. **isActive** + - **Tipo**: booleano + - **Validación**: No nulo + - **Groups**: `view:write` + - **Predeterminado**: false \ No newline at end of file