airbyte_cdk.sources.config

 1#
 2# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
 3#
 4
 5from typing import Any, Dict
 6
 7from pydantic.v1 import BaseModel
 8
 9from airbyte_cdk.sources.utils.schema_helpers import expand_refs, rename_key
10
11
12class BaseConfig(BaseModel):
13    """Base class for connector spec, adds the following behaviour:
14
15    - resolve $ref and replace it with definition
16    - replace all occurrences of anyOf with oneOf
17    - drop description
18    """
19
20    @classmethod
21    def schema(cls, *args: Any, **kwargs: Any) -> Dict[str, Any]:
22        """We're overriding the schema classmethod to enable some post-processing"""
23        schema = super().schema(*args, **kwargs)
24        rename_key(schema, old_key="anyOf", new_key="oneOf")  # UI supports only oneOf
25        expand_refs(schema)
26        schema.pop("description", None)  # description added from the docstring
27        return schema
class BaseConfig(pydantic.v1.main.BaseModel):
13class BaseConfig(BaseModel):
14    """Base class for connector spec, adds the following behaviour:
15
16    - resolve $ref and replace it with definition
17    - replace all occurrences of anyOf with oneOf
18    - drop description
19    """
20
21    @classmethod
22    def schema(cls, *args: Any, **kwargs: Any) -> Dict[str, Any]:
23        """We're overriding the schema classmethod to enable some post-processing"""
24        schema = super().schema(*args, **kwargs)
25        rename_key(schema, old_key="anyOf", new_key="oneOf")  # UI supports only oneOf
26        expand_refs(schema)
27        schema.pop("description", None)  # description added from the docstring
28        return schema

Base class for connector spec, adds the following behaviour:

  • resolve $ref and replace it with definition
  • replace all occurrences of anyOf with oneOf
  • drop description
@classmethod
def schema(cls, *args: Any, **kwargs: Any) -> Dict[str, Any]:
21    @classmethod
22    def schema(cls, *args: Any, **kwargs: Any) -> Dict[str, Any]:
23        """We're overriding the schema classmethod to enable some post-processing"""
24        schema = super().schema(*args, **kwargs)
25        rename_key(schema, old_key="anyOf", new_key="oneOf")  # UI supports only oneOf
26        expand_refs(schema)
27        schema.pop("description", None)  # description added from the docstring
28        return schema

We're overriding the schema classmethod to enable some post-processing