From c81dee69995afb2f433271a3b375658d0ce2aad2 Mon Sep 17 00:00:00 2001 From: Alex Bair Date: Wed, 13 Nov 2024 15:57:40 -0500 Subject: [PATCH] source-genesys: add discriminator to endpoint config's credentials Additionally, wrap the `ClientCredentialsOAuth2Credentials` class in a more user-friendly name since it shows up in the UI. There's likely a more elegant & correct solution to fix this, but I haven't found it yet. --- source-genesys/source_genesys/models.py | 8 ++++++-- .../snapshots__spec__capture.stdout.json | 16 +++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/source-genesys/source_genesys/models.py b/source-genesys/source_genesys/models.py index c9a6f996f..d53f96b14 100644 --- a/source-genesys/source_genesys/models.py +++ b/source-genesys/source_genesys/models.py @@ -22,7 +22,10 @@ } ) -OAuth2Credentials = ClientCredentialsOAuth2Credentials +# The class name appears in the UI's Authentication section, so we wrap the non-user friendly name in a slighly better name. +# TODO(alex): figure out why the class name is appearing in the UI & determine if there's some property to set that overrides it. +class OAuth(ClientCredentialsOAuth2Credentials): + pass def default_start_date(): @@ -55,8 +58,9 @@ class EndpointConfig(BaseModel): ] = Field( title="Genesys Cloud Domain" ) - credentials: OAuth2Credentials = Field( + credentials: OAuth = Field( title="Authentication", + discriminator="credentials_title" ) diff --git a/source-genesys/tests/snapshots/snapshots__spec__capture.stdout.json b/source-genesys/tests/snapshots/snapshots__spec__capture.stdout.json index 896a7b49c..b057ebd93 100644 --- a/source-genesys/tests/snapshots/snapshots__spec__capture.stdout.json +++ b/source-genesys/tests/snapshots/snapshots__spec__capture.stdout.json @@ -3,7 +3,7 @@ "protocol": 3032023, "configSchema": { "$defs": { - "ClientCredentialsOAuth2Credentials": { + "OAuth": { "properties": { "credentials_title": { "const": "OAuth Credentials", @@ -29,7 +29,7 @@ "client_id", "client_secret" ], - "title": "ClientCredentialsOAuth2Credentials", + "title": "OAuth", "type": "object" } }, @@ -62,7 +62,17 @@ "type": "string" }, "credentials": { - "$ref": "#/$defs/ClientCredentialsOAuth2Credentials", + "discriminator": { + "mapping": { + "OAuth Credentials": "#/$defs/OAuth" + }, + "propertyName": "credentials_title" + }, + "oneOf": [ + { + "$ref": "#/$defs/OAuth" + } + ], "title": "Authentication" } },