How to define struct true using pydantic model in python.
Here is the code but I cant see strict true in schema
from pydantic import BaseModel, Field, conlist
from enum import Enum
class CategoryEnum(str, Enum):
ecommerce = 'ecommerce'
dropshipping = 'dropshipping'
content_arbitrage = 'content_arbitrage'
business_coaching = 'business_coaching'
class MyBaseModel(BaseModel):
class Config:
strict = True # This is for runtime enforcement
class CategoriesAnnotation(MyBaseModel):
multi_label_categories: list[conlist(CategoryEnum)] = Field(
...,
description="A list of annotated multilabel categories."
)
class Config:
json_schema_extra = {
"additionalProperties": False
}
# Generate the schema
schema = CategoriesAnnotation.schema()
print(schema)