-
Notifications
You must be signed in to change notification settings - Fork 69
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
feat: Support union schemas #1525
Conversation
2ebaa94
to
842e9f3
Compare
Codecov Report
@@ Coverage Diff @@
## main #1525 +/- ##
==========================================
- Coverage 86.12% 85.98% -0.14%
==========================================
Files 59 59
Lines 4944 4959 +15
Branches 809 811 +2
==========================================
+ Hits 4258 4264 +6
- Misses 485 492 +7
- Partials 201 203 +2
... and 2 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@ReubenFrankel I'd love to get your thoughts on this? Is it helpful, intuitive? |
@edgarrmondragon I think this looks great - really like the syntax! I've spent a while thinking about what this might not cover with more complex cases, but I think its better to tackle those as and when they come up, since the only scenarios I can think of at the moment are pretty unrealistic. My only question is what does a validation error for this look like? Is it helpful to the user? This would be great to get into |
@ReubenFrankel The default jsonschema.exceptions.ValidationError: {'flow': 'oauth', 'client_id': '123', 'username': '456', 'password': '789'} is not valid under any of the given schemas
Failed validating 'oneOf' in schema:
{'oneOf': [{'additionalProperties': False,
'properties': {'client_id': {'secret': True,
'type': ['string'],
'writeOnly': True},
'client_secret': {'secret': True,
'type': ['string'],
'writeOnly': True},
'flow': {'const': 'oauth',
'description': 'Discriminator for '
'object of type '
"'oauth'."}},
'required': ['flow', 'client_id', 'client_secret'],
'type': 'object'},
{'additionalProperties': False,
'properties': {'flow': {'const': 'password',
'description': 'Discriminator for '
'object of type '
"'password'."},
'password': {'secret': True,
'type': ['string'],
'writeOnly': True},
'username': {'type': ['string']}},
'required': ['flow', 'username', 'password'],
'type': 'object'}]}
On instance:
{'client_id': '123',
'flow': 'oauth',
'password': '789',
'username': '456'} But we could of course grab the context and print something that better explains the error and expectation. I have a PR where it might make sense to add that: #768. |
@kgpayne can you give this PR a look when get a chance? |
Related:
host
,user
,port
, etc. into individual config values MeltanoLabs/tap-postgres#121Docs: https://meltano-sdk--1525.org.readthedocs.build/en/1525/classes/typing/singer_sdk.typing.DiscriminatedUnion.html
📚 Documentation preview 📚: https://meltano-sdk--1525.org.readthedocs.build/en/1525/