mirror of
https://github.com/langgenius/dify.git
synced 2026-04-28 14:38:06 +08:00
fix(plugin): update trigger field type to allow None and add field validator for parameters in EventEntity
This commit is contained in:
@ -3,7 +3,7 @@ from datetime import datetime
|
||||
from enum import StrEnum
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
from pydantic import BaseModel, ConfigDict, Field, ValidationInfo, field_validator
|
||||
|
||||
from core.entities.provider_entities import ProviderConfig
|
||||
from core.plugin.entities.parameters import (
|
||||
@ -89,12 +89,19 @@ class EventEntity(BaseModel):
|
||||
"""
|
||||
|
||||
identity: EventIdentity = Field(..., description="The identity of the event")
|
||||
parameters: list[EventParameter] = Field(default_factory=list, description="The parameters of the event")
|
||||
parameters: list[EventParameter] = Field(
|
||||
default_factory=list[EventParameter], description="The parameters of the event"
|
||||
)
|
||||
description: I18nObject = Field(..., description="The description of the event")
|
||||
output_schema: Optional[Mapping[str, Any]] = Field(
|
||||
default=None, description="The output schema that this event produces"
|
||||
)
|
||||
|
||||
@field_validator("parameters", mode="before")
|
||||
@classmethod
|
||||
def set_parameters(cls, v, validation_info: ValidationInfo) -> list[EventParameter]:
|
||||
return v or []
|
||||
|
||||
|
||||
class OAuthSchema(BaseModel):
|
||||
client_schema: list[ProviderConfig] = Field(default_factory=list, description="The schema of the OAuth client")
|
||||
|
||||
Reference in New Issue
Block a user