mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-05-06 14:03:15 +08:00
ColumnDef
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from typing import Any, Callable
|
||||
from typing import Any, Callable, Literal, Optional
|
||||
|
||||
from pydantic import GetCoreSchemaHandler, GetJsonSchemaHandler
|
||||
from pydantic import BaseModel, Field, GetCoreSchemaHandler, GetJsonSchemaHandler
|
||||
from pydantic.json_schema import JsonSchemaValue
|
||||
from pydantic_core import CoreSchema, core_schema
|
||||
|
||||
@@ -11,9 +11,7 @@ class OptionsEndpoint:
|
||||
|
||||
class DynamicOptions:
|
||||
@classmethod
|
||||
def __get_pydantic_core_schema__(
|
||||
cls, _source_type: Any, _handler: GetCoreSchemaHandler
|
||||
) -> CoreSchema:
|
||||
def __get_pydantic_core_schema__(cls, _source_type: Any, _handler: GetCoreSchemaHandler) -> CoreSchema:
|
||||
return core_schema.literal_schema(values)
|
||||
|
||||
@classmethod
|
||||
@@ -28,3 +26,32 @@ class OptionsEndpoint:
|
||||
}
|
||||
|
||||
return DynamicOptions
|
||||
|
||||
|
||||
class RenderFnParams(BaseModel):
|
||||
actionType: str = Field(..., description="Specifies the action type for the render function")
|
||||
|
||||
|
||||
class ColumnDef(BaseModel):
|
||||
field: str = Field(..., description="The name of the field from the JSON data")
|
||||
headerName: str = Field(..., description="The display name of the column header")
|
||||
chartDataType: Optional[Literal["category", "series", "time", "excluded"]] = Field(
|
||||
None, description="Specifies how data is treated in a chart"
|
||||
)
|
||||
cellDataType: Optional[Literal["text", "number", "boolean", "date", "dateString", "object"]] = Field(
|
||||
None, description="Specifies the data type of the cell"
|
||||
)
|
||||
formatterFn: Optional[str] = Field(None, description="Specifies how to format the data")
|
||||
renderFn: Optional[Literal["greenRed", "cellOnClick", "titleCase"]] = Field(
|
||||
None, description="Specifies a rendering function for cell data"
|
||||
)
|
||||
renderFnParams: Optional[RenderFnParams] = Field(
|
||||
None, description="Required if renderFn cellOnClick is used. Specifies the parameters for the render function"
|
||||
)
|
||||
width: Optional[int] = Field(None, gt=0, description="Specifies the width of the column in pixels")
|
||||
maxWidth: Optional[int] = Field(None, gt=0, description="Specifies the maximum width of the column in pixels")
|
||||
minWidth: Optional[int] = Field(None, gt=0, description="Specifies the minimum width of the column in pixels")
|
||||
hide: Optional[bool] = Field(False, description="Hides the column from the table")
|
||||
pinned: Optional[Literal["left", "right"]] = Field(
|
||||
None, description="Pins the column to the left or right of the table"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user