1 Hardware
Manuel Aranda Rosales edited this page 2024-08-02 09:11:00 +02:00

Documentación - API ogCore

Select Language / Seleccionar Idioma


English

Table of Contents

  1. Introduction
  2. Configuration
  3. Resource Definition
  4. API Operations
  5. Entity Properties
  6. Hardware 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.

resources:
    App\Entity\Hardware:
        processor: App\State\Processor\HardwareProcessor
        input: App\Dto\Input\HardwareInput
        output: App\Dto\Output\HardwareOutput
        normalizationContext:
            groups: ['default', 'hardware:read']
        denormalizationContext:
            groups: ['hardware:write']
        operations:
            ApiPlatform\Metadata\GetCollection:
                provider: App\State\Provider\HardwareProvider
                filters:
                    - 'api_platform.filter.hardware.order'
                    - 'api_platform.filter.hardware.search'
            ApiPlatform\Metadata\Get:
                provider: App\State\Provider\HardwareProvider
            ApiPlatform\Metadata\Put:
                provider: App\State\Provider\HardwareProvider
            ApiPlatform\Metadata\Patch:
                provider: App\State\Provider\HardwareProvider
            ApiPlatform\Metadata\Post: ~
            ApiPlatform\Metadata\Delete: ~

properties:
    App\Entity\Hardware:
        id:
            identifier: false
        uuid:
            identifier: true

Resource Definition

App\Entity\Hardware

  • Processor: App\State\Processor\HardwareProcessor
  • Input: App\Dto\Input\HardwareInput
  • Output: App\Dto\Output\HardwareOutput
  • Normalization Context: ['default', 'hardware:read']
  • Denormalization Context: ['hardware:write']

API Operations

Hardware Operations

Get Hardware Collection (GetCollection)
  • Provider: App\State\Provider\HardwareProvider
  • Filters:
    • Order hardware: api_platform.filter.hardware.order
    • Search hardware: api_platform.filter.hardware.search
Get Hardware (Get)
  • Provider: App\State\Provider\HardwareProvider
Update Hardware (Put)
  • Provider: App\State\Provider\HardwareProvider
Partially Update Hardware (Patch)
  • Provider: App\State\Provider\HardwareProvider
Create Hardware (Post)
  • Default Operation: ~
Delete Hardware (Delete)
  • Default Operation: ~

Entity Properties

App\Entity\Hardware

  • id:

    • Identifier: false
  • uuid:

    • Identifier: true

Hardware Input DTO

Fields Required in Hardware Endpoint Input

  1. name

    • Type: string
    • Validation: Not blank
    • Groups: hardware:write
  2. description

    • Type: string
    • Validation: Optional
    • Groups: hardware:write
  3. type

    • Type: string
    • Validation: Not blank
    • Groups: hardware:write
  4. price

    • Type: float
    • Validation: Positive value
    • Groups: hardware:write

Español

Índice

  1. Introducción
  2. Configuración
  3. Definición de Recursos
  4. Operaciones de API
  5. Propiedades de la Entidad
  6. DTO de Entrada de Hardware

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.

resources:
    App\Entity\Hardware:
        processor: App\State\Processor\HardwareProcessor
        input: App\Dto\Input\HardwareInput
        output: App\Dto\Output\HardwareOutput
        normalizationContext:
            groups: ['default', 'hardware:read']
        denormalizationContext:
            groups: ['hardware:write']
        operations:
            ApiPlatform\Metadata\GetCollection:
                provider: App\State\Provider\HardwareProvider
                filters:
                    - 'api_platform.filter.hardware.order'
                    - 'api_platform.filter.hardware.search'
            ApiPlatform\Metadata\Get:
                provider: App\State\Provider\HardwareProvider
            ApiPlatform\Metadata\Put:
                provider: App\State\Provider\HardwareProvider
            ApiPlatform\Metadata\Patch:
                provider: App\State\Provider\HardwareProvider
            ApiPlatform\Metadata\Post: ~
            ApiPlatform\Metadata\Delete: ~

properties:
    App\Entity\Hardware:
        id:
            identifier: false
        uuid:
            identifier: true

Definición de Recursos

App\Entity\Hardware

  • Processor: App\State\Processor\HardwareProcessor
  • Input: App\Dto\Input\HardwareInput
  • Output: App\Dto\Output\HardwareOutput
  • Contexto de Normalización: ['default', 'hardware:read']
  • Contexto de Desnormalización: ['hardware:write']

Operaciones de API

Operaciones de Hardware

Obtener Colección de Hardware (GetCollection)
  • Provider: App\State\Provider\HardwareProvider
  • Filtros:
    • Ordenar hardware: api_platform.filter.hardware.order
    • Buscar hardware: api_platform.filter.hardware.search
Obtener Hardware (Get)
  • Provider: App\State\Provider\HardwareProvider
Actualizar Hardware (Put)
  • Provider: App\State\Provider\HardwareProvider
Actualización Parcial de Hardware (Patch)
  • Provider: App\State\Provider\HardwareProvider
Crear Hardware (Post)
  • Operación Predeterminada: ~
Eliminar Hardware (Delete)
  • Operación Predeterminada: ~

Propiedades de la Entidad

App\Entity\Hardware

  • id:

    • Identificador: false
  • uuid:

    • Identificador: true

DTO de Entrada de Hardware

Campos Requeridos en la Entrada del Endpoint de Hardware

  1. name

    • Tipo: string
    • Validación: No nulo
    • Groups: hardware:write
  2. description

    • Tipo: string
    • Validación: Opcional
    • Groups: hardware:write
  3. type

    • Tipo: string
    • Validación: No nulo
    • Groups: hardware:write
  4. price

    • Tipo: float
    • Validación: Valor positivo
    • Groups: hardware:write