dify/api/fields/end_user_fields.py
Stephen Zhou 92016aa139
fix(api): align Service API OpenAPI contract (#41248)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-08-25 10:54:14 +00:00

38 lines
1023 B
Python

from __future__ import annotations
from datetime import datetime
from typing import Annotated
from pydantic import Field, WithJsonSchema
from fields.base import ResponseModel
UUIDString = Annotated[str, WithJsonSchema({"format": "uuid", "type": "string"})]
class SimpleEndUser(ResponseModel):
id: str
type: str
is_anonymous: bool
session_id: str | None = None
class EndUserDetail(ResponseModel):
"""Full EndUser record for API responses.
Note: The SQLAlchemy model defines an `is_anonymous` property for Flask-Login semantics
(always False). The database column is exposed as `_is_anonymous`, so this DTO maps
`is_anonymous` from `_is_anonymous` to return the stored value.
"""
id: UUIDString
tenant_id: UUIDString
app_id: UUIDString | None = None
type: str
external_user_id: str | None = None
name: str | None = None
is_anonymous: bool = Field(validation_alias="_is_anonymous")
session_id: str
created_at: datetime
updated_at: datetime