Skip to content
1 change: 1 addition & 0 deletions .pipeline/spotbugs-exclusions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<Package name="com.sap.ai.sdk.orchestration.model"/>
<Package name="com.sap.ai.sdk.grounding.client"/>
<Package name="com.sap.ai.sdk.grounding.model"/>
<Package name="com.sap.ai.sdk.foundationmodels.openai.generated.model"/>
<Package name="com.sap.ai.sdk.prompt.registry.model"/>
<Package name="com.sap.ai.sdk.prompt.registry.client"/>
</Or>
Expand Down
61 changes: 61 additions & 0 deletions foundation-models/openai/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,65 @@
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
<profile>
<id>generate</id>
<activation>
<activeByDefault>false</activeByDefault>
<property>
<name>generate</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.sap.cloud.sdk.datamodel</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<configuration>
<outputDirectory>${project.basedir}/src/main/java</outputDirectory>
<apiMaturity>beta</apiMaturity>
<enableOneOfAnyOfGeneration>true</enableOneOfAnyOfGeneration>
<compileScope>COMPILE</compileScope>
<deleteOutputDirectory>true</deleteOutputDirectory>
</configuration>
<executions>
<execution>
<id>openai</id>
<goals>
<goal>generate</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/spec/openapi-2024-10-21.yaml</inputSpec>
<apiPackage>com.sap.ai.sdk.foundationmodels.openai.generated.api</apiPackage>
<modelPackage>com.sap.ai.sdk.foundationmodels.openai.generated.model</modelPackage>
<generateApis>false</generateApis>
<additionalProperties>
<enumUnknownDefaultCase>true</enumUnknownDefaultCase>
<useOneOfInterfaces>true</useOneOfInterfaces>
<useOneOfCreators>true</useOneOfCreators>
<useFloatArrays>true</useFloatArrays>

<!-- new exclude paths -->
<excludePaths>/deployments/{deployment-id}/completions
/deployments/{deployment-id}/audio/transcriptions
/deployments/{deployment-id}/audio/translations
/deployments/{deployment-id}/images/generations</excludePaths>

<!-- new exclude properties -->
<excludeProperties>chatCompletionResponseMessage.context
createChatCompletionRequest.data_sources</excludeProperties>

<!-- new: remove unassigned components -->
<removeUnusedComponents>true</removeUnusedComponents>
</additionalProperties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
/*
* Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved.
*/

/*
* Azure OpenAI Service API
* Azure OpenAI APIs for completions and search
*
* The version of the OpenAPI document: 2024-10-21
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand All @@ -20,6 +15,7 @@
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.annotations.Beta;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.NoSuchElementException;
Expand All @@ -32,8 +28,7 @@
* Deprecated and replaced by &#x60;tool_calls&#x60;. The name and arguments of a function that
* should be called, as generated by the model.
*/
// CHECKSTYLE:OFF
@com.google.common.annotations.Beta
@Beta // CHECKSTYLE:OFF
public class ChatCompletionFunctionCall
// CHECKSTYLE:ON
{
Expand Down Expand Up @@ -132,11 +127,13 @@ public Set<String> getCustomFieldNames() {
* Get the value of an unrecognizable property of this {@link ChatCompletionFunctionCall}
* instance.
*
* @deprecated Use {@link #toMap()} instead.
* @param name The name of the property
* @return The value of the property
* @throws NoSuchElementException If no property with the given name could be found.
*/
@Nullable
@Deprecated
public Object getCustomField(@Nonnull final String name) throws NoSuchElementException {
if (!cloudSdkCustomFields.containsKey(name)) {
throw new NoSuchElementException(
Expand All @@ -145,6 +142,21 @@ public Object getCustomField(@Nonnull final String name) throws NoSuchElementExc
return cloudSdkCustomFields.get(name);
}

/**
* Get the value of all properties of this {@link ChatCompletionFunctionCall} instance including
* unrecognized properties.
*
* @return The map of all properties
*/
@JsonIgnore
@Nonnull
public Map<String, Object> toMap() {
final Map<String, Object> declaredFields = new LinkedHashMap<>(cloudSdkCustomFields);
if (name != null) declaredFields.put("name", name);
if (arguments != null) declaredFields.put("arguments", arguments);
return declaredFields;
}

/**
* Set an unrecognizable property of this {@link ChatCompletionFunctionCall} instance. If the map
* previously contained a mapping for the key, the old value is replaced by the specified value.
Expand All @@ -158,7 +170,7 @@ public void setCustomField(@Nonnull String customFieldName, @Nullable Object cus
}

@Override
public boolean equals(@Nullable final Object o) {
public boolean equals(@Nullable final java.lang.Object o) {
Comment on lines -161 to +173
Copy link
Member

@Jonas-Isr Jonas-Isr Apr 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Question)
Why is this change necessary/happening?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Our generator has always (i.e. 2+ years) generated java.lang.Object.

What happened?

My assumption is: When I originally pushed the model classes, I generated them once in Cloud SDK repo. Then I moved them to AI SDK. Very likely, IntelliJ did some reduction / unintentional improvement, to remove the redundant FQN for Object.

Why would we want java.lang.Object in the first place?

Because some schema components may be called "Object" in the spec, leading to "Object" being generated. It's not a reserved keyword in java. Therefore, safest approach is to reference everything with fully-qualified-name.

if (this == o) {
return true;
}
Expand Down Expand Up @@ -194,7 +206,7 @@ public String toString() {
/**
* Convert the given object to string with each line indented by 4 spaces (except the first line).
*/
private String toIndentedString(final Object o) {
private String toIndentedString(final java.lang.Object o) {
if (o == null) {
return "null";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
/*
* Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved.
*/

/*
* Azure OpenAI Service API
* Azure OpenAI APIs for completions and search
*
* The version of the OpenAPI document: 2024-10-21
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand All @@ -20,6 +15,7 @@
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.annotations.Beta;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.NoSuchElementException;
Expand All @@ -32,8 +28,7 @@
* Specifying a particular function via &#x60;{\&quot;name\&quot;: \&quot;my_function\&quot;}&#x60;
* forces the model to call that function.
*/
// CHECKSTYLE:OFF
@com.google.common.annotations.Beta
@Beta // CHECKSTYLE:OFF
public class ChatCompletionFunctionCallOption
// CHECKSTYLE:ON
{
Expand Down Expand Up @@ -90,11 +85,13 @@ public Set<String> getCustomFieldNames() {
* Get the value of an unrecognizable property of this {@link ChatCompletionFunctionCallOption}
* instance.
*
* @deprecated Use {@link #toMap()} instead.
* @param name The name of the property
* @return The value of the property
* @throws NoSuchElementException If no property with the given name could be found.
*/
@Nullable
@Deprecated
public Object getCustomField(@Nonnull final String name) throws NoSuchElementException {
if (!cloudSdkCustomFields.containsKey(name)) {
throw new NoSuchElementException(
Expand All @@ -103,6 +100,20 @@ public Object getCustomField(@Nonnull final String name) throws NoSuchElementExc
return cloudSdkCustomFields.get(name);
}

/**
* Get the value of all properties of this {@link ChatCompletionFunctionCallOption} instance
* including unrecognized properties.
*
* @return The map of all properties
*/
@JsonIgnore
@Nonnull
public Map<String, Object> toMap() {
final Map<String, Object> declaredFields = new LinkedHashMap<>(cloudSdkCustomFields);
if (name != null) declaredFields.put("name", name);
return declaredFields;
}

/**
* Set an unrecognizable property of this {@link ChatCompletionFunctionCallOption} instance. If
* the map previously contained a mapping for the key, the old value is replaced by the specified
Expand All @@ -117,7 +128,7 @@ public void setCustomField(@Nonnull String customFieldName, @Nullable Object cus
}

@Override
public boolean equals(@Nullable final Object o) {
public boolean equals(@Nullable final java.lang.Object o) {
if (this == o) {
return true;
}
Expand Down Expand Up @@ -152,7 +163,7 @@ public String toString() {
/**
* Convert the given object to string with each line indented by 4 spaces (except the first line).
*/
private String toIndentedString(final Object o) {
private String toIndentedString(final java.lang.Object o) {
if (o == null) {
return "null";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
/*
* Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved.
*/

/*
* Azure OpenAI Service API
* Azure OpenAI APIs for completions and search
*
* The version of the OpenAPI document: 2024-10-21
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand All @@ -20,6 +15,7 @@
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.annotations.Beta;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
Expand All @@ -35,8 +31,7 @@
* @deprecated
*/
@Deprecated
// CHECKSTYLE:OFF
@com.google.common.annotations.Beta
@Beta // CHECKSTYLE:OFF
public class ChatCompletionFunctions
// CHECKSTYLE:ON
{
Expand Down Expand Up @@ -198,11 +193,13 @@ public Set<String> getCustomFieldNames() {
/**
* Get the value of an unrecognizable property of this {@link ChatCompletionFunctions} instance.
*
* @deprecated Use {@link #toMap()} instead.
* @param name The name of the property
* @return The value of the property
* @throws NoSuchElementException If no property with the given name could be found.
*/
@Nullable
@Deprecated
public Object getCustomField(@Nonnull final String name) throws NoSuchElementException {
if (!cloudSdkCustomFields.containsKey(name)) {
throw new NoSuchElementException(
Expand All @@ -211,6 +208,22 @@ public Object getCustomField(@Nonnull final String name) throws NoSuchElementExc
return cloudSdkCustomFields.get(name);
}

/**
* Get the value of all properties of this {@link ChatCompletionFunctions} instance including
* unrecognized properties.
*
* @return The map of all properties
*/
@JsonIgnore
@Nonnull
public Map<String, Object> toMap() {
final Map<String, Object> declaredFields = new LinkedHashMap<>(cloudSdkCustomFields);
if (description != null) declaredFields.put("description", description);
if (name != null) declaredFields.put("name", name);
if (parameters != null) declaredFields.put("parameters", parameters);
return declaredFields;
}

/**
* Set an unrecognizable property of this {@link ChatCompletionFunctions} instance. If the map
* previously contained a mapping for the key, the old value is replaced by the specified value.
Expand All @@ -224,7 +237,7 @@ public void setCustomField(@Nonnull String customFieldName, @Nullable Object cus
}

@Override
public boolean equals(@Nullable final Object o) {
public boolean equals(@Nullable final java.lang.Object o) {
if (this == o) {
return true;
}
Expand Down Expand Up @@ -261,7 +274,7 @@ public String toString() {
/**
* Convert the given object to string with each line indented by 4 spaces (except the first line).
*/
private String toIndentedString(final Object o) {
private String toIndentedString(final java.lang.Object o) {
if (o == null) {
return "null";
}
Expand Down
Loading