Skip to content

Commit

Permalink
馃悰Source Braintree: resolve '$ref' in schema and spec (#9042)
Browse files Browse the repository at this point in the history
* resolve refs

* upd spec

* bump version

* upd changelog

* bump version
  • Loading branch information
annalvova05 committed Dec 22, 2021
1 parent fb58aae commit c142dc1
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
- name: Braintree
sourceDefinitionId: 63cea06f-1c75-458d-88fe-ad48c7cb27fd
dockerRepository: airbyte/source-braintree
dockerImageTag: 0.1.0
dockerImageTag: 0.1.2
documentationUrl: https://docs.airbyte.io/integrations/sources/braintree
icon: braintree.svg
sourceType: api
Expand Down
17 changes: 6 additions & 11 deletions airbyte-config/init/src/main/resources/seed/source_specs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@
supportsNormalization: false
supportsDBT: false
supported_destination_sync_modes: []
- dockerImage: "airbyte/source-braintree:0.1.0"
- dockerImage: "airbyte/source-braintree:0.1.2"
spec:
documentationUrl: "https://docs.airbyte.io/integrations/sources/braintree"
connectionSpecification:
Expand Down Expand Up @@ -870,23 +870,18 @@
- "production"
- "qa"
- "development"
allOf:
- $ref: "#/definitions/Environment"
required:
- "merchant_id"
- "public_key"
- "private_key"
- "environment"
definitions:
Environment:
title: "Environment"
description: "An enumeration."
enum:
- "Development"
- "Sandbox"
- "Qa"
- "Production"
type: "string"
required:
- "merchant_id"
- "public_key"
- "private_key"
- "environment"
supportsNormalization: false
supportsDBT: false
supported_destination_sync_modes: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ RUN pip install .
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.1
LABEL io.airbyte.version=0.1.2
LABEL io.airbyte.name=airbyte/source-braintree
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,11 @@
"description": "Environment specifies where the data will come from.",
"name": "Environment",
"examples": ["sandbox", "production", "qa", "development"],
"allOf": [
{
"$ref": "#/definitions/Environment"
}
]
}
},
"required": ["merchant_id", "public_key", "private_key", "environment"],
"definitions": {
"Environment": {
"title": "Environment",
"description": "An enumeration.",
"enum": ["Development", "Sandbox", "Qa", "Production"],
"type": "string"
}
}
},
"required": ["merchant_id", "public_key", "private_key", "environment"]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Any, Dict, Optional, Type

import pydantic
from airbyte_cdk.sources.utils.schema_helpers import expand_refs
from pydantic import BaseModel
from pydantic.typing import resolve_annotations

Expand Down Expand Up @@ -61,6 +62,12 @@ def schema_extra(cls, schema: Dict[str, Any], model: Type["BaseModel"]) -> None:
ref = prop.pop("$ref")
prop["oneOf"] = [{"type": "null"}, {"$ref": ref}]

@classmethod
def schema(cls, **kwargs) -> Dict[str, Any]:
schema = super().schema(**kwargs)
expand_refs(schema)
return schema


class AddOn(CatalogModel):
amount: Decimal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,13 @@ def to_lower_case(cls, v):
@validator("environment", pre=True)
def to_camel_case(cls, v):
return camelize(v)

@classmethod
def schema(cls, **kwargs):
schema = super().schema(**kwargs)
if "definitions" in schema:
schema["definitions"]["Environment"].pop("description")
schema["properties"]["environment"].update(schema["definitions"]["Environment"])
schema["properties"]["environment"].pop("allOf", None)
del schema["definitions"]
return schema
2 changes: 2 additions & 0 deletions docs/integrations/sources/braintree.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,7 @@ We recommend creating a restricted, read-only key specifically for Airbyte acces

| Version | Date | Pull Request | Subject |
| :--- | :--- | :--- | :--- |
| 0.1.2 | 2021-12-22 | [9042](https://github.com/airbytehq/airbyte/pull/9042) | Fix `$ref` in schema and spec |
| 0.1.1 | 2021-10-27 | [7432](https://github.com/airbytehq/airbyte/pull/7432) | Dispute model should accept multiple Evidences |
| 0.1.0 | 2021-08-17 | [5362](https://github.com/airbytehq/airbyte/pull/5362) | Initial version |

0 comments on commit c142dc1

Please sign in to comment.