From 63ff3d75b49ecb124e6462fabc14a187cb00abb9 Mon Sep 17 00:00:00 2001 From: Lake Mossman Date: Thu, 12 Jan 2023 14:23:04 -0800 Subject: [PATCH] Make documentation_url optional in a declarative connector spec (#21347) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Make documentation_url optional in a declarative connector spec * simplify if statement * bump patch version of cdk * Revert "bump patch version of cdk" This reverts commit 1854bf3be1ee71500b95053ebd9b595a71b3d693. * 🤖 Bump patch version of Airbyte CDK * Revert "🤖 Bump patch version of Airbyte CDK" This reverts commit 85d5a989e2a8dde04342ee31e8dbc03df5887154. * 🤖 Bump patch version of Airbyte CDK Co-authored-by: lmossman --- airbyte-cdk/python/.bumpversion.cfg | 2 +- airbyte-cdk/python/CHANGELOG.md | 3 +++ .../declarative/declarative_component_schema.yaml | 1 - .../models/declarative_component_schema.py | 2 +- .../airbyte_cdk/sources/declarative/spec/spec.py | 15 +++++++++------ airbyte-cdk/python/setup.py | 2 +- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/airbyte-cdk/python/.bumpversion.cfg b/airbyte-cdk/python/.bumpversion.cfg index 49a00e29f9c..c0c9e5ce3dd 100644 --- a/airbyte-cdk/python/.bumpversion.cfg +++ b/airbyte-cdk/python/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.19.0 +current_version = 0.19.1 commit = False [bumpversion:file:setup.py] diff --git a/airbyte-cdk/python/CHANGELOG.md b/airbyte-cdk/python/CHANGELOG.md index b8a48367d4f..cf57eeddf77 100644 --- a/airbyte-cdk/python/CHANGELOG.md +++ b/airbyte-cdk/python/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 0.19.1 +Low-code: Make documentation_url in the Spec be optional + ## 0.19.0 Low-Code: Handle forward references in manifest diff --git a/airbyte-cdk/python/airbyte_cdk/sources/declarative/declarative_component_schema.yaml b/airbyte-cdk/python/airbyte_cdk/sources/declarative/declarative_component_schema.yaml index 9d005d999b4..d74e86bb65f 100644 --- a/airbyte-cdk/python/airbyte_cdk/sources/declarative/declarative_component_schema.yaml +++ b/airbyte-cdk/python/airbyte_cdk/sources/declarative/declarative_component_schema.yaml @@ -1024,7 +1024,6 @@ definitions: required: - type - connection_specification - - documentation_url properties: type: type: string diff --git a/airbyte-cdk/python/airbyte_cdk/sources/declarative/models/declarative_component_schema.py b/airbyte-cdk/python/airbyte_cdk/sources/declarative/models/declarative_component_schema.py index c7b849242ee..6e9f4814453 100644 --- a/airbyte-cdk/python/airbyte_cdk/sources/declarative/models/declarative_component_schema.py +++ b/airbyte-cdk/python/airbyte_cdk/sources/declarative/models/declarative_component_schema.py @@ -299,7 +299,7 @@ class SingleSlice(BaseModel): class Spec(BaseModel): type: Literal["Spec"] connection_specification: Dict[str, Any] - documentation_url: str + documentation_url: Optional[str] = None class WaitTimeFromHeader(BaseModel): diff --git a/airbyte-cdk/python/airbyte_cdk/sources/declarative/spec/spec.py b/airbyte-cdk/python/airbyte_cdk/sources/declarative/spec/spec.py index d5ac6a1d586..fd3b67f1386 100644 --- a/airbyte-cdk/python/airbyte_cdk/sources/declarative/spec/spec.py +++ b/airbyte-cdk/python/airbyte_cdk/sources/declarative/spec/spec.py @@ -3,7 +3,7 @@ # from dataclasses import InitVar, dataclass -from typing import Any, Mapping +from typing import Any, Mapping, Optional from airbyte_cdk.models.airbyte_protocol import ConnectorSpecification from dataclasses_jsonschema import JsonSchemaMixin @@ -15,20 +15,23 @@ class Spec(JsonSchemaMixin): Returns a connection specification made up of information about the connector and how it can be configured Attributes: - documentation_url (str): The link the Airbyte documentation about this connector connection_specification (Mapping[str, Any]): information related to how a connector can be configured + documentation_url (Optional[str]): The link the Airbyte documentation about this connector """ - documentation_url: str connection_specification: Mapping[str, Any] options: InitVar[Mapping[str, Any]] + documentation_url: Optional[str] = None def generate_spec(self) -> ConnectorSpecification: """ Returns the connector specification according the spec block defined in the low code connector manifest. """ + obj = {"connectionSpecification": self.connection_specification} + + if self.documentation_url: + obj["documentationUrl"] = self.documentation_url + # We remap these keys to camel case because that's the existing format expected by the rest of the platform - return ConnectorSpecification.parse_obj( - {"documentationUrl": self.documentation_url, "connectionSpecification": self.connection_specification} - ) + return ConnectorSpecification.parse_obj(obj) diff --git a/airbyte-cdk/python/setup.py b/airbyte-cdk/python/setup.py index ff6346769ae..5cb79a06d94 100644 --- a/airbyte-cdk/python/setup.py +++ b/airbyte-cdk/python/setup.py @@ -15,7 +15,7 @@ README = (HERE / "README.md").read_text() setup( name="airbyte-cdk", - version="0.19.0", + version="0.19.1", description="A framework for writing Airbyte Connectors.", long_description=README, long_description_content_type="text/markdown",