File tree Expand file tree Collapse file tree 5 files changed +43
-3
lines changed
main/java/com/sap/ai/sdk/core
test/java/com/sap/ai/sdk/core
orchestration/src/main/java/com/sap/ai/sdk/orchestration
sample-code/spring-app/src/test/java/com/sap/ai/sdk/app/controllers Expand file tree Collapse file tree 5 files changed +43
-3
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,11 @@ static ServiceBinding createServiceBinding(@Nonnull final String serviceKey)
8181 new AiCoreCredentialsInvalidException ("Missing clientid in service key" ));
8282 }
8383
84+ if (credentials .get ("clientsecret" ) != null && credentials .get ("credential-type" ) == null ) {
85+ // add missing "credential-type: binding-secret"
86+ credentials .put ("credential-type" , "binding-secret" );
87+ }
88+
8489 return new DefaultServiceBindingBuilder ()
8590 .withServiceIdentifier (ServiceIdentifier .AI_CORE )
8691 .withCredentials (credentials )
Original file line number Diff line number Diff line change @@ -55,4 +55,32 @@ void testMalformedDotenv() {
5555 assertThatThrownBy (accessor ::getServiceBindings )
5656 .isInstanceOf (ServiceBindingAccessException .class );
5757 }
58+
59+ @ Test
60+ void testServiceBindingCreation () {
61+ var serviceKeyWithoutCredentialType =
62+ """
63+ {
64+ "clientid": "",
65+ "clientsecret": ""
66+ }
67+ """ ;
68+ var binding1 = AiCoreServiceKeyAccessor .createServiceBinding (serviceKeyWithoutCredentialType );
69+ assertThat (binding1 .getCredentials ().containsKey ("credential-type" ))
70+ .describedAs ("The missing 'credential-type' should have automatically been added" )
71+ .isTrue ();
72+ var serviceKeyWithCredentialType =
73+ """
74+ {
75+ "clientid": "",
76+ "clientsecret": "",
77+ "credential-type": "foo"
78+ }
79+ }
80+ """ ;
81+ var binding2 = AiCoreServiceKeyAccessor .createServiceBinding (serviceKeyWithCredentialType );
82+ assertThat (binding2 .getCredentials ().get ("credential-type" ))
83+ .describedAs ("The 'credential-type' field should not get overwritten" )
84+ .isEqualTo ("foo" );
85+ }
5886}
Original file line number Diff line number Diff line change 1616
1717### 📈 Improvements
1818
19- -
19+ - [ Core] If the AI Core credentials used are missing an explicit ` credential-type ` but ` clientid ` and ` clientsecret ` are present then ` "credential-type": "binding-secret" ` is inferred automatically.
20+
2021
2122### 🐛 Fixed Issues
2223
Original file line number Diff line number Diff line change @@ -33,6 +33,11 @@ public class ResponseJsonSchema {
3333 @ Nonnull Map <String , Object > schemaMap ;
3434 @ Nonnull String name ;
3535 @ Nullable String description ;
36+
37+ /**
38+ * ⚠️ Fields of the schema class should be annotated with {@code @JsonProperty(required = true)}
39+ * to not fail requests if set to true.
40+ */
3641 @ Nullable Boolean strict ;
3742
3843 /**
@@ -51,6 +56,9 @@ public static ResponseJsonSchema fromMap(
5156 /**
5257 * Create a new instance of {@link ResponseJsonSchema} from a given class.
5358 *
59+ * <p>⚠️ Fields of the schema class should be annotated with {@code @JsonProperty(required =
60+ * true)}.
61+ *
5462 * @param classType The class to generate the schema from
5563 * @return The new instance of {@link ResponseJsonSchema}
5664 */
Original file line number Diff line number Diff line change 1616import java .time .format .TextStyle ;
1717import java .util .Locale ;
1818import java .util .UUID ;
19- import org .junit .jupiter .api .Disabled ;
2019import org .junit .jupiter .api .Test ;
2120
2221class GroundingTest {
@@ -52,7 +51,6 @@ void testRepositoriesGetAll() {
5251 }
5352
5453 @ Test
55- @ Disabled ("Temporary disabled because of an unresolved minor bug" ) // SAP/ai-sdk-java-backlog#232
5654 void testCreateDeleteCollection () {
5755 final var controller = new GroundingController ();
5856
You can’t perform that action at this time.
0 commit comments