mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 02:18:08 +08:00
fix(plugin): update trigger field type to allow None and add field validator for parameters in EventEntity
This commit is contained in:
@ -109,7 +109,7 @@ class PluginDeclaration(BaseModel):
|
|||||||
endpoint: EndpointProviderDeclaration | None = None
|
endpoint: EndpointProviderDeclaration | None = None
|
||||||
agent_strategy: AgentStrategyProviderEntity | None = None
|
agent_strategy: AgentStrategyProviderEntity | None = None
|
||||||
datasource: DatasourceProviderEntity | None = None
|
datasource: DatasourceProviderEntity | None = None
|
||||||
trigger: Optional[TriggerProviderEntity] = None
|
trigger: TriggerProviderEntity | None = None
|
||||||
meta: Meta
|
meta: Meta
|
||||||
|
|
||||||
@field_validator("version")
|
@field_validator("version")
|
||||||
|
|||||||
@ -3,7 +3,7 @@ from datetime import datetime
|
|||||||
from enum import StrEnum
|
from enum import StrEnum
|
||||||
from typing import Any, Optional, Union
|
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.entities.provider_entities import ProviderConfig
|
||||||
from core.plugin.entities.parameters import (
|
from core.plugin.entities.parameters import (
|
||||||
@ -89,12 +89,19 @@ class EventEntity(BaseModel):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
identity: EventIdentity = Field(..., description="The identity of the event")
|
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")
|
description: I18nObject = Field(..., description="The description of the event")
|
||||||
output_schema: Optional[Mapping[str, Any]] = Field(
|
output_schema: Optional[Mapping[str, Any]] = Field(
|
||||||
default=None, description="The output schema that this event produces"
|
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):
|
class OAuthSchema(BaseModel):
|
||||||
client_schema: list[ProviderConfig] = Field(default_factory=list, description="The schema of the OAuth client")
|
client_schema: list[ProviderConfig] = Field(default_factory=list, description="The schema of the OAuth client")
|
||||||
|
|||||||
Reference in New Issue
Block a user