minor: service schema nomenclature

This commit is contained in:
Chris Milne 2026-05-28 14:27:14 +01:00
parent 33e78d4a9b
commit 00dcf7ce35
2 changed files with 8 additions and 8 deletions

View file

@ -17,7 +17,7 @@ from src.service.models import Service
from src.service.utils import generate_api_key
from src.service.dependencies import service_model_body_dependency
from src.service.schemas import ServiceGetServiceResponse, ServicePostServiceRequest, ServicePostServiceResponse, \
ServiceWithKeyResponse, ServicePatchKeyResponse, ServicePatchKeyRequest, ServiceDeleteServiceRequest
ServiceWithKeySchema, ServicePatchKeyResponse, ServicePatchKeyRequest, ServiceDeleteServiceRequest
router = APIRouter(
tags=["Service"],
@ -42,7 +42,7 @@ async def register_service(db: db_dependency, su: super_admin_dependency, servic
if isinstance(e.orig, UniqueViolation):
raise Conflict(message="Service with this name already exists")
db.commit()
response = ServiceWithKeyResponse(**service_model.__dict__)
response = ServiceWithKeySchema(**service_model.__dict__)
db.commit()
return {"service": response}
@ -52,7 +52,7 @@ async def regenerate_api_key(db: db_dependency, su: super_admin_dependency, serv
service_model.api_key = key
db.flush()
response = ServiceWithKeyResponse(**service_model.__dict__)
response = ServiceWithKeySchema(**service_model.__dict__)
db.commit()
return {"service": response}

View file

@ -12,29 +12,29 @@ from src.schemas import CustomBaseModel
class ServiceIDMixin(CustomBaseModel):
service_id: int
class ServiceResponse(CustomBaseModel):
class ServiceSchema(CustomBaseModel):
model_config = ConfigDict(from_attributes=True, extra="ignore")
id: int
name: str
class ServiceWithKeyResponse(ServiceResponse):
class ServiceWithKeySchema(ServiceSchema):
api_key: str
class ServiceGetServiceResponse(CustomBaseModel):
services: list[ServiceResponse]
services: list[ServiceSchema]
class ServicePostServiceRequest(CustomBaseModel):
name: str
class ServicePostServiceResponse(CustomBaseModel):
service: ServiceWithKeyResponse
service: ServiceWithKeySchema
class ServicePatchKeyRequest(ServiceIDMixin):
pass
class ServicePatchKeyResponse(CustomBaseModel):
service: ServiceWithKeyResponse
service: ServiceWithKeySchema
class ServiceDeleteServiceRequest(ServiceIDMixin):
pass