From 23509cbcc944d44f1da41a92e9013a931c296451 Mon Sep 17 00:00:00 2001 From: AlexeerCT Date: Tue, 24 Mar 2026 12:06:55 -0500 Subject: [PATCH] Refactor DTO classes to use `model_config` with `ConfigDict` for attribute handling - Updated multiple DTO classes across various modules to replace the `Config` class with `model_config = ConfigDict(from_attributes=True)`. - This change enhances consistency in attribute handling and aligns with the latest Pydantic practices. - Adjusted error handling in core modules to change status codes from `HTTP_422_UNPROCESSABLE_ENTITY` to `HTTP_422_UNPROCESSABLE_CONTENT` for improved clarity in validation responses. --- .../v1/modules/a24/fa/fa_item_lines/dto.py | 9 +++---- .../modules/a76/clients_and_providers/dto.py | 26 +++++++------------ .../a76/general_catalogs/company/dto.py | 8 +++--- .../fractions/tariff_fractions/dto.py | 15 ++++------- backend/api/v1/modules/core/tenants/dto.py | 21 ++++++++------- .../api/v1/modules/sitar/aladi2/schemas.py | 5 ++-- .../api/v1/modules/sitar/cuotas2/schemas.py | 5 ++-- backend/api/v1/modules/sitar/cupos/schemas.py | 5 ++-- .../v1/modules/sitar/fracciones/schemas.py | 5 ++-- .../sitar/fracciones_anteriores/schemas.py | 5 ++-- .../modules/sitar/fracciones_usa/schemas.py | 5 ++-- .../modules/sitar/fundamentos_tlc/schemas.py | 5 ++-- backend/api/v1/modules/sitar/ieps/schemas.py | 5 ++-- .../sitar/informacion_general/schemas.py | 5 ++-- backend/api/v1/modules/sitar/noms/schemas.py | 5 ++-- .../sitar/precios_estimados/schemas.py | 5 ++-- .../api/v1/modules/sitar/prosec/schemas.py | 5 ++-- backend/api/v1/modules/sitar/rcg2/schemas.py | 5 ++-- .../v1/modules/sitar/regulaciones/schemas.py | 5 ++-- backend/api/v1/modules/sitar/reit/schemas.py | 5 ++-- .../modules/sitar/requisito_previo/schemas.py | 5 ++-- backend/api/v1/modules/sitar/tlcs/schemas.py | 5 ++-- .../modules/sitar/vehiculos_marcas/schemas.py | 5 ++-- .../sitar/vehiculos_modelos/schemas.py | 5 ++-- backend/core/error_handlers.py | 8 +++--- backend/core/exceptions.py | 2 +- 26 files changed, 75 insertions(+), 109 deletions(-) diff --git a/backend/api/v1/modules/a24/fa/fa_item_lines/dto.py b/backend/api/v1/modules/a24/fa/fa_item_lines/dto.py index 9c464513..34b8f35b 100644 --- a/backend/api/v1/modules/a24/fa/fa_item_lines/dto.py +++ b/backend/api/v1/modules/a24/fa/fa_item_lines/dto.py @@ -60,8 +60,7 @@ class FaLineItemCreateDTO(BaseModel): own_equipment: Optional[bool] = Field(None, description="Equipo propio") omit_annex31: Optional[bool] = Field(None, description="Omitir en Anexo 31") - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) class FaLineItemUpdateDTO(BaseModel): @@ -112,8 +111,7 @@ class FaLineItemUpdateDTO(BaseModel): own_equipment: Optional[bool] = Field(None, description="Equipo propio") omit_annex31: Optional[bool] = Field(None, description="Omitir en Anexo 31") - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) class FaLineItemResponseDTO(BaseModel): @@ -164,5 +162,4 @@ class FaLineItemResponseDTO(BaseModel): created_at: datetime = Field(..., description="Fecha de creación") updated_at: datetime = Field(..., description="Fecha de actualización") - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) diff --git a/backend/api/v1/modules/a76/clients_and_providers/dto.py b/backend/api/v1/modules/a76/clients_and_providers/dto.py index e461addd..fbe8d766 100644 --- a/backend/api/v1/modules/a76/clients_and_providers/dto.py +++ b/backend/api/v1/modules/a76/clients_and_providers/dto.py @@ -6,7 +6,7 @@ Reemplaza schemas.py siguiendo enfoque DDD y estilo NestJS from decimal import Decimal from typing import List, Literal, Optional -from pydantic import BaseModel, Field, model_validator +from pydantic import BaseModel, ConfigDict, Field, model_validator from .validators import is_valid_rfc, is_valid_tax_id @@ -36,8 +36,7 @@ class ClientProviderAddressDTO(BaseModel): contact: Optional[str] = Field(None, max_length=50, description="Contact person") reference: Optional[str] = Field(None, max_length=250, description="Reference") - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) # DTOs para programas @@ -86,8 +85,7 @@ class ClientProviderProgramsDTO(BaseModel): None, max_length=300, description="AUTSE number" ) - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) # DTOs principales @@ -145,8 +143,7 @@ class ClientProviderCreateDTO(BaseModel): ) return self - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) class ClientProviderUpdateDTO(BaseModel): @@ -203,8 +200,7 @@ class ClientProviderUpdateDTO(BaseModel): ) return self - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) class ClientProviderResponseDTO(BaseModel): @@ -232,8 +228,7 @@ class ClientProviderResponseDTO(BaseModel): address: Optional[ClientProviderAddressDTO] = None programs: Optional[ClientProviderProgramsDTO] = None - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) # DTOs para respuestas específicas @@ -247,8 +242,7 @@ class ClientProviderBasicDTO(BaseModel): client_or_provider: Optional[str] = None is_active: Optional[bool] = None - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) class ClientProviderListDTO(BaseModel): @@ -259,8 +253,7 @@ class ClientProviderListDTO(BaseModel): page: int size: int - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) class ClientProviderPaginatedResponseDTO(BaseModel): @@ -271,5 +264,4 @@ class ClientProviderPaginatedResponseDTO(BaseModel): page: int page_size: int - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) diff --git a/backend/api/v1/modules/a76/general_catalogs/company/dto.py b/backend/api/v1/modules/a76/general_catalogs/company/dto.py index dff8a610..a83faf81 100644 --- a/backend/api/v1/modules/a76/general_catalogs/company/dto.py +++ b/backend/api/v1/modules/a76/general_catalogs/company/dto.py @@ -6,7 +6,7 @@ Reemplaza schemas.py siguiendo enfoque DDD y estilo NestJS from datetime import datetime from typing import Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field class CompanyCreateDTO(BaseModel): @@ -221,8 +221,7 @@ class CompanyCreateDTO(BaseModel): cancel_key_exp: Optional[int] = None - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) class CompanyUpdateDTO(CompanyCreateDTO): @@ -417,5 +416,4 @@ class CompanyResponseDTO(BaseModel): - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) diff --git a/backend/api/v1/modules/a76/general_catalogs/fractions/tariff_fractions/dto.py b/backend/api/v1/modules/a76/general_catalogs/fractions/tariff_fractions/dto.py index 498d859a..16463397 100644 --- a/backend/api/v1/modules/a76/general_catalogs/fractions/tariff_fractions/dto.py +++ b/backend/api/v1/modules/a76/general_catalogs/fractions/tariff_fractions/dto.py @@ -19,8 +19,7 @@ class TariffFractionCreateDTO(BaseModel): adv_impo: Optional[str] = Field(None, max_length=20, description="Ad valorem importación") adv_expo: Optional[str] = Field(None, max_length=20, description="Ad valorem exportación") - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) class TariffFractionUpdateDTO(BaseModel): @@ -33,8 +32,7 @@ class TariffFractionUpdateDTO(BaseModel): adv_impo: Optional[str] = Field(None, max_length=20, description="Ad valorem importación") adv_expo: Optional[str] = Field(None, max_length=20, description="Ad valorem exportación") - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) class TariffFractionResponseDTO(BaseModel): @@ -66,8 +64,7 @@ class TariffFractionBasicDTO(BaseModel): adv_impo: Optional[str] = None adv_expo: Optional[str] = None - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) class TariffFractionListDTO(BaseModel): @@ -79,8 +76,7 @@ class TariffFractionListDTO(BaseModel): page_size: int pages: int - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) class TariffFractionSearchDTO(BaseModel): @@ -92,5 +88,4 @@ class TariffFractionSearchDTO(BaseModel): nico: Optional[str] = Field(None, description="Filtrar por NICO") umt: Optional[str] = Field(None, description="Filtrar por UMT") - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) diff --git a/backend/api/v1/modules/core/tenants/dto.py b/backend/api/v1/modules/core/tenants/dto.py index 46094676..d851a514 100644 --- a/backend/api/v1/modules/core/tenants/dto.py +++ b/backend/api/v1/modules/core/tenants/dto.py @@ -7,7 +7,7 @@ from datetime import datetime from enum import Enum from typing import Optional -from pydantic import BaseModel, EmailStr, Field +from pydantic import BaseModel, ConfigDict, EmailStr, Field class TenantTypeDTO(str, Enum): @@ -41,8 +41,8 @@ class TenantCreateDTO(BaseModel): None, max_length=50, description="Teléfono de contacto" ) - class Config: - json_schema_extra = { + model_config = ConfigDict( + json_schema_extra={ "example": { "name": "Empresa ABC S.A. de C.V.", "slug": "empresa-abc", @@ -53,6 +53,7 @@ class TenantCreateDTO(BaseModel): "contact_phone": "+52 55 1234 5678", } } + ) class TenantUpdateDTO(BaseModel): @@ -64,13 +65,14 @@ class TenantUpdateDTO(BaseModel): contact_phone: Optional[str] = Field(None, max_length=50) is_active: Optional[bool] = None - class Config: - json_schema_extra = { + model_config = ConfigDict( + json_schema_extra={ "example": { "name": "Empresa ABC S.A. de C.V. - Actualizado", "contact_email": "nuevo@empresa-abc.com", } } + ) class TenantResponseDTO(BaseModel): @@ -88,9 +90,9 @@ class TenantResponseDTO(BaseModel): created_at: datetime updated_at: datetime - class Config: - from_attributes = True - json_schema_extra = { + model_config = ConfigDict( + from_attributes=True, + json_schema_extra={ "example": { "id": 1, "name": "Empresa ABC S.A. de C.V.", @@ -104,7 +106,8 @@ class TenantResponseDTO(BaseModel): "created_at": "2025-01-15T10:30:00Z", "updated_at": "2025-01-15T10:30:00Z", } - } + }, + ) class TenantListResponseDTO(BaseModel): diff --git a/backend/api/v1/modules/sitar/aladi2/schemas.py b/backend/api/v1/modules/sitar/aladi2/schemas.py index 511ba5a8..ac136931 100644 --- a/backend/api/v1/modules/sitar/aladi2/schemas.py +++ b/backend/api/v1/modules/sitar/aladi2/schemas.py @@ -1,7 +1,7 @@ """ALADI2 Schemas""" from typing import Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field class Aladi2Response(BaseModel): @@ -20,5 +20,4 @@ class Aladi2Response(BaseModel): NICO: Optional[str] = Field(None, max_length=2) SYSID: int - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) diff --git a/backend/api/v1/modules/sitar/cuotas2/schemas.py b/backend/api/v1/modules/sitar/cuotas2/schemas.py index d9c29164..74ca8ca2 100644 --- a/backend/api/v1/modules/sitar/cuotas2/schemas.py +++ b/backend/api/v1/modules/sitar/cuotas2/schemas.py @@ -1,7 +1,7 @@ """Cuotas2 Schemas""" from typing import Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field class Cuotas2Response(BaseModel): @@ -26,5 +26,4 @@ class Cuotas2Response(BaseModel): NICO: Optional[str] = Field("", max_length=2) SYSID: int - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) diff --git a/backend/api/v1/modules/sitar/cupos/schemas.py b/backend/api/v1/modules/sitar/cupos/schemas.py index 4a6f652f..d607d6d5 100644 --- a/backend/api/v1/modules/sitar/cupos/schemas.py +++ b/backend/api/v1/modules/sitar/cupos/schemas.py @@ -1,7 +1,7 @@ """Cupos Schemas""" from typing import Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field class CuposResponse(BaseModel): @@ -21,5 +21,4 @@ class CuposResponse(BaseModel): NICO: Optional[str] = Field("", max_length=2) SYSID: int - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) diff --git a/backend/api/v1/modules/sitar/fracciones/schemas.py b/backend/api/v1/modules/sitar/fracciones/schemas.py index a657c68b..1e01b4af 100644 --- a/backend/api/v1/modules/sitar/fracciones/schemas.py +++ b/backend/api/v1/modules/sitar/fracciones/schemas.py @@ -2,7 +2,7 @@ from decimal import Decimal from typing import Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field class FraccionesResponse(BaseModel): @@ -35,5 +35,4 @@ class FraccionesResponse(BaseModel): NICO: Optional[str] = Field(None, max_length=14) SYSID: Optional[int] = None - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) diff --git a/backend/api/v1/modules/sitar/fracciones_anteriores/schemas.py b/backend/api/v1/modules/sitar/fracciones_anteriores/schemas.py index 9ddd8247..20b4757d 100644 --- a/backend/api/v1/modules/sitar/fracciones_anteriores/schemas.py +++ b/backend/api/v1/modules/sitar/fracciones_anteriores/schemas.py @@ -1,7 +1,7 @@ """Fracciones Anteriores Schemas""" from typing import Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field class FraccionesAnterioresResponse(BaseModel): @@ -11,5 +11,4 @@ class FraccionesAnterioresResponse(BaseModel): FRACCIONANTERIOR: Optional[str] = Field(None, max_length=10) SYSID: int - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) diff --git a/backend/api/v1/modules/sitar/fracciones_usa/schemas.py b/backend/api/v1/modules/sitar/fracciones_usa/schemas.py index 1c5a8ba7..36e02fa3 100644 --- a/backend/api/v1/modules/sitar/fracciones_usa/schemas.py +++ b/backend/api/v1/modules/sitar/fracciones_usa/schemas.py @@ -1,7 +1,7 @@ """Fracciones USA Schemas""" from typing import Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field class FraccionesUSAResponse(BaseModel): @@ -20,5 +20,4 @@ class FraccionesUSAResponse(BaseModel): NOTAS: Optional[str] = None CONSECUTIVO: int - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) diff --git a/backend/api/v1/modules/sitar/fundamentos_tlc/schemas.py b/backend/api/v1/modules/sitar/fundamentos_tlc/schemas.py index 2a2350b7..d05c328c 100644 --- a/backend/api/v1/modules/sitar/fundamentos_tlc/schemas.py +++ b/backend/api/v1/modules/sitar/fundamentos_tlc/schemas.py @@ -1,7 +1,7 @@ """Fundamentos TLC Schemas""" from typing import Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field class FundamentosTLCResponse(BaseModel): @@ -23,5 +23,4 @@ class FundamentosTLCResponse(BaseModel): NICO: Optional[str] = Field("", max_length=2) SYSID: int - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) diff --git a/backend/api/v1/modules/sitar/ieps/schemas.py b/backend/api/v1/modules/sitar/ieps/schemas.py index f65e0def..2966f4ab 100644 --- a/backend/api/v1/modules/sitar/ieps/schemas.py +++ b/backend/api/v1/modules/sitar/ieps/schemas.py @@ -1,7 +1,7 @@ """IEPS Schemas""" from typing import Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field class IepsResponse(BaseModel): @@ -16,5 +16,4 @@ class IepsResponse(BaseModel): NICO: Optional[str] = Field("", max_length=2) CONSECUTIVO: int - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) diff --git a/backend/api/v1/modules/sitar/informacion_general/schemas.py b/backend/api/v1/modules/sitar/informacion_general/schemas.py index 1b044670..b0c68238 100644 --- a/backend/api/v1/modules/sitar/informacion_general/schemas.py +++ b/backend/api/v1/modules/sitar/informacion_general/schemas.py @@ -1,7 +1,7 @@ """Información General Schemas""" from typing import Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field class InformacionGeneralResponse(BaseModel): @@ -17,5 +17,4 @@ class InformacionGeneralResponse(BaseModel): NICO: Optional[str] = Field("", max_length=2) SYSID: int - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) diff --git a/backend/api/v1/modules/sitar/noms/schemas.py b/backend/api/v1/modules/sitar/noms/schemas.py index e02de133..e1ad6777 100644 --- a/backend/api/v1/modules/sitar/noms/schemas.py +++ b/backend/api/v1/modules/sitar/noms/schemas.py @@ -1,7 +1,7 @@ """NOMs Schemas""" from typing import Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field class NomsResponse(BaseModel): @@ -23,5 +23,4 @@ class NomsResponse(BaseModel): PAIS: Optional[str] = Field("", max_length=3) SYSID: int - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) diff --git a/backend/api/v1/modules/sitar/precios_estimados/schemas.py b/backend/api/v1/modules/sitar/precios_estimados/schemas.py index 62753b6b..b3f18ed3 100644 --- a/backend/api/v1/modules/sitar/precios_estimados/schemas.py +++ b/backend/api/v1/modules/sitar/precios_estimados/schemas.py @@ -1,7 +1,7 @@ """Precios Estimados Schemas""" from typing import Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field class PreciosEstimados2Response(BaseModel): @@ -14,5 +14,4 @@ class PreciosEstimados2Response(BaseModel): NICO: Optional[str] = Field("", max_length=2) SYSID: int - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) diff --git a/backend/api/v1/modules/sitar/prosec/schemas.py b/backend/api/v1/modules/sitar/prosec/schemas.py index 13d7b96c..0e798b99 100644 --- a/backend/api/v1/modules/sitar/prosec/schemas.py +++ b/backend/api/v1/modules/sitar/prosec/schemas.py @@ -1,7 +1,7 @@ """PROSEC Schemas""" from typing import Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field class ProsecResponse(BaseModel): @@ -17,5 +17,4 @@ class ProsecResponse(BaseModel): NICO: Optional[str] = Field("", max_length=2) SYSID: int - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) diff --git a/backend/api/v1/modules/sitar/rcg2/schemas.py b/backend/api/v1/modules/sitar/rcg2/schemas.py index 977cb8af..3f90814b 100644 --- a/backend/api/v1/modules/sitar/rcg2/schemas.py +++ b/backend/api/v1/modules/sitar/rcg2/schemas.py @@ -1,7 +1,7 @@ """RCG2 Schemas""" from typing import Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field class Rcg2Response(BaseModel): @@ -22,5 +22,4 @@ class Rcg2Response(BaseModel): NICO: Optional[str] = Field("", max_length=2) SYSID: int - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) diff --git a/backend/api/v1/modules/sitar/regulaciones/schemas.py b/backend/api/v1/modules/sitar/regulaciones/schemas.py index ddb6f4b3..c33387cf 100644 --- a/backend/api/v1/modules/sitar/regulaciones/schemas.py +++ b/backend/api/v1/modules/sitar/regulaciones/schemas.py @@ -1,7 +1,7 @@ """Regulaciones Schemas""" from typing import Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field class RegulacionesResponse(BaseModel): @@ -15,5 +15,4 @@ class RegulacionesResponse(BaseModel): NICO: Optional[str] = Field("", max_length=2) SYSID: int - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) diff --git a/backend/api/v1/modules/sitar/reit/schemas.py b/backend/api/v1/modules/sitar/reit/schemas.py index 9d079198..bea940d6 100644 --- a/backend/api/v1/modules/sitar/reit/schemas.py +++ b/backend/api/v1/modules/sitar/reit/schemas.py @@ -1,7 +1,7 @@ """REIT Schemas""" from typing import Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field class ReitResponse(BaseModel): @@ -21,5 +21,4 @@ class ReitResponse(BaseModel): NICO: Optional[str] = Field("", max_length=2) SYSID: int - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) diff --git a/backend/api/v1/modules/sitar/requisito_previo/schemas.py b/backend/api/v1/modules/sitar/requisito_previo/schemas.py index bc711e76..75082e71 100644 --- a/backend/api/v1/modules/sitar/requisito_previo/schemas.py +++ b/backend/api/v1/modules/sitar/requisito_previo/schemas.py @@ -1,7 +1,7 @@ """Requisito Previo Schemas""" from typing import Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field class RequisitoPrevioResponse(BaseModel): @@ -24,5 +24,4 @@ class RequisitoPrevioResponse(BaseModel): NICO: Optional[str] = Field("", max_length=2) SYSID: int - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) diff --git a/backend/api/v1/modules/sitar/tlcs/schemas.py b/backend/api/v1/modules/sitar/tlcs/schemas.py index 944731ea..86a462ed 100644 --- a/backend/api/v1/modules/sitar/tlcs/schemas.py +++ b/backend/api/v1/modules/sitar/tlcs/schemas.py @@ -1,7 +1,7 @@ """TLCS Schemas""" from typing import Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field class TLCSResponse(BaseModel): @@ -19,5 +19,4 @@ class TLCSResponse(BaseModel): NICO: Optional[str] = Field("", max_length=2) SYSID: int - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) diff --git a/backend/api/v1/modules/sitar/vehiculos_marcas/schemas.py b/backend/api/v1/modules/sitar/vehiculos_marcas/schemas.py index 979a8fba..0c3ea9b8 100644 --- a/backend/api/v1/modules/sitar/vehiculos_marcas/schemas.py +++ b/backend/api/v1/modules/sitar/vehiculos_marcas/schemas.py @@ -1,7 +1,7 @@ """Vehiculos Marcas Schemas""" from typing import Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field class VehiculosMarcasResponse(BaseModel): @@ -11,5 +11,4 @@ class VehiculosMarcasResponse(BaseModel): MARCA: Optional[str] = Field(None, max_length=60) SYSID: int - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) diff --git a/backend/api/v1/modules/sitar/vehiculos_modelos/schemas.py b/backend/api/v1/modules/sitar/vehiculos_modelos/schemas.py index 0153c215..1fdb8d7a 100644 --- a/backend/api/v1/modules/sitar/vehiculos_modelos/schemas.py +++ b/backend/api/v1/modules/sitar/vehiculos_modelos/schemas.py @@ -1,7 +1,7 @@ """Vehiculos Modelos Schemas""" from typing import Optional -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field class VehiculosModelosResponse(BaseModel): @@ -34,5 +34,4 @@ class VehiculosModelosResponse(BaseModel): A1: Optional[str] = Field(None, max_length=19) SYSID: int - class Config: - from_attributes = True + model_config = ConfigDict(from_attributes=True) diff --git a/backend/core/error_handlers.py b/backend/core/error_handlers.py index 7a68ccb7..8423403d 100644 --- a/backend/core/error_handlers.py +++ b/backend/core/error_handlers.py @@ -159,11 +159,11 @@ async def validation_exception_handler( ) response = JSONResponse( - status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, + status_code=status.HTTP_422_UNPROCESSABLE_CONTENT, content={ "error": "VALIDATION_ERROR", "message": summary, - "status_code": status.HTTP_422_UNPROCESSABLE_ENTITY, + "status_code": status.HTTP_422_UNPROCESSABLE_CONTENT, "errors": errors, }, ) @@ -209,11 +209,11 @@ async def inner_validation_exception_handler( ) response = JSONResponse( - status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, + status_code=status.HTTP_422_UNPROCESSABLE_CONTENT, content={ "error": "VALIDATION_ERROR", "message": summary, - "status_code": status.HTTP_422_UNPROCESSABLE_ENTITY, + "status_code": status.HTTP_422_UNPROCESSABLE_CONTENT, "errors": errors, }, ) diff --git a/backend/core/exceptions.py b/backend/core/exceptions.py index e53d20fe..1d457804 100644 --- a/backend/core/exceptions.py +++ b/backend/core/exceptions.py @@ -44,7 +44,7 @@ class ValidationException(BaseAPIException): ): super().__init__( message=message, - status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, + status_code=status.HTTP_422_UNPROCESSABLE_CONTENT, errors=errors, error_code="VALIDATION_ERROR", )