Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛Source Braintree: resolve '$ref' in schema and spec #9042

Merged
merged 6 commits into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 1 addition & 0 deletions docs/integrations/sources/braintree.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ 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.0 | 2021-08-17 | [5362](https://github.com/airbytehq/airbyte/pull/5362) | Initial version |
annalvova05 marked this conversation as resolved.
Show resolved Hide resolved