mirror of
https://github.com/langgenius/dify.git
synced 2026-05-03 17:08:03 +08:00
fix: allow None AuthorizationConfig
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
from typing import Literal, Optional, Union
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, validator
|
||||
|
||||
from core.workflow.entities.base_node_data_entities import BaseNodeData
|
||||
from core.workflow.entities.variable_entities import VariableSelector
|
||||
@ -17,7 +17,20 @@ class HttpRequestNodeData(BaseNodeData):
|
||||
header: Union[None, str]
|
||||
|
||||
type: Literal['no-auth', 'api-key']
|
||||
config: Config
|
||||
config: Optional[Config]
|
||||
|
||||
@validator('config', always=True, pre=True)
|
||||
def check_config(cls, v, values):
|
||||
"""
|
||||
Check config, if type is no-auth, config should be None, otherwise it should be a dict.
|
||||
"""
|
||||
if values['type'] == 'no-auth':
|
||||
return None
|
||||
else:
|
||||
if not v or not isinstance(v, dict):
|
||||
raise ValueError('config should be a dict')
|
||||
|
||||
return v
|
||||
|
||||
class Body(BaseModel):
|
||||
type: Literal[None, 'form-data', 'x-www-form-urlencoded', 'raw', 'json']
|
||||
|
||||
Reference in New Issue
Block a user