airbyte_cdk.sources.file_based.config.excel_format

 1#
 2# Copyright (c) 2024 Airbyte, Inc., all rights reserved.
 3#
 4
 5from pydantic.v1 import BaseModel, Field
 6
 7from airbyte_cdk.utils.oneof_option_config import OneOfOptionConfig
 8
 9
10class ExcelFormat(BaseModel):
11    class Config(OneOfOptionConfig):
12        title = "Excel Format"
13        discriminator = "filetype"
14
15    filetype: str = Field(
16        "excel",
17        const=True,
18    )
class ExcelFormat(pydantic.v1.main.BaseModel):
11class ExcelFormat(BaseModel):
12    class Config(OneOfOptionConfig):
13        title = "Excel Format"
14        discriminator = "filetype"
15
16    filetype: str = Field(
17        "excel",
18        const=True,
19    )
filetype: str
class ExcelFormat.Config(airbyte_cdk.utils.oneof_option_config.OneOfOptionConfig):
12    class Config(OneOfOptionConfig):
13        title = "Excel Format"
14        discriminator = "filetype"

Base class to configure a Pydantic model that's used as a oneOf option in a parent model in a way that's compatible with all Airbyte consumers.

Inherit from this class in the nested Config class in a model and set title and description (these show up in the UI) and discriminator (this is making sure it's marked as required in the schema).

Usage:
class OptionModel(BaseModel):
    mode: Literal["option_a"] = Field("option_a", const=True)
    option_a_field: str = Field(...)

    class Config(OneOfOptionConfig):
        title = "Option A"
        description = "Option A description"
        discriminator = "mode"
title = 'Excel Format'
discriminator = 'filetype'