Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -137,7 +137,8 @@ public Schema normalizeSchema( final @Nonnull Schema schema, final @Nonnull Set<
} else if( schema.getContentEncoding() != null ) {
Comment thread
vladimir-a-sap marked this conversation as resolved.
// Any other content encoding (e.g., "binary") → treat as binary
schema.setFormat("binary");
} else if( schema.getContentMediaType() != null ) {
} else if( schema.getContentMediaType() != null
&& !"application/json".equalsIgnoreCase(schema.getContentMediaType()) ) {
// contentMediaType without contentEncoding → binary stream
schema.setFormat("binary");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ enum TestCase
6,
Map.of(),
Map.of()),
MULTIPART_BINARY_STRING(
"multipart-binary-string",
"sodastore.yaml",
"com.sap.cloud.sdk.datamodel.rest.test.api",
"com.sap.cloud.sdk.datamodel.rest.test.model",
ApiMaturity.RELEASED,
false,
true,
2,
Map.of(),
Map.of()),
INLINEOBJECT_SCHEMA_NAME(
"inlineobject-schemas-enabled",
"sodastore.yaml",
Expand Down Expand Up @@ -257,7 +268,10 @@ enum TestCase
}

@ParameterizedTest
@EnumSource( value = TestCase.class, mode = EnumSource.Mode.EXCLUDE, names = { "FILE_HANDLING" } )
@EnumSource(
value = TestCase.class,
mode = EnumSource.Mode.EXCLUDE,
names = { "FILE_HANDLING", "MULTIPART_BINARY_STRING" } )
void integrationTests( final TestCase testCase, @TempDir final Path path )
throws Throwable
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
openapi: 3.1.0
info:
title: String and File multipart body
version: 1.0.0

paths:
/predict_parquet:
post:
summary: Make predictions from Parquet file
operationId: predict_parquet
requestBody:
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/Body_predict_parquet'
encoding:
file:
contentType: application/vnd.apache.parquet
required: true

components:
schemas:
Body_predict_parquet:
type: object
properties:
file:
type: string
contentMediaType: application/vnd.apache.parquet
title: File
prediction_config:
type: string
title: Prediction Config
description: JSON string containing the prediction configuration (see PredictionConfig schema).
example: { \"target_columns\": [ { \"name\": \"PRICE\",\"prediction_placeholder\": null,\"task_type\": \"regression\" } ] }
contentMediaType: application/json
contentSchema:
$ref: '#/components/schemas/PredictionConfig'
PredictionConfig:
type: object
properties:
test:
type: string
title: Test
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/*
* Copyright (c) 2026 SAP SE or an SAP affiliate company. All rights reserved.
*/

package com.sap.cloud.sdk.datamodel.rest.test.api;

import com.fasterxml.jackson.core.type.TypeReference;

import com.sap.cloud.sdk.services.openapi.apache.core.OpenApiRequestException;
import com.sap.cloud.sdk.services.openapi.apache.core.OpenApiResponse;
import com.sap.cloud.sdk.services.openapi.apache.apiclient.ApiClient;
import com.sap.cloud.sdk.services.openapi.apache.apiclient.BaseApi;
import com.sap.cloud.sdk.services.openapi.apache.apiclient.Pair;


import java.io.File;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.StringJoiner;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import com.sap.cloud.sdk.cloudplatform.connectivity.Destination;


/**
* String and File multipart body in version 1.0.0.
* <p>
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*/
public class DefaultApi extends BaseApi {

/**
* Instantiates this API class to invoke operations on the String and File multipart body.
*
* @param httpDestination The destination that API should be used with
*/
public DefaultApi( @Nonnull final Destination httpDestination )
{
super(httpDestination);
}

/**
* Instantiates this API class to invoke operations on the String and File multipart body based on a given {@link ApiClient}.
*
* @param apiClient
* ApiClient to invoke the API on
*/
public DefaultApi(@Nonnull final ApiClient apiClient) {
super(apiClient);
}

/**
* Creates a new API instance with additional default headers.
*
* @param defaultHeaders Additional headers to include in all requests
* @return A new API instance with the combined headers
*/
public DefaultApi withDefaultHeaders(@Nonnull final Map<String, String> defaultHeaders) {
final var api = new DefaultApi(apiClient);
api.defaultHeaders.putAll(this.defaultHeaders);
api.defaultHeaders.putAll(defaultHeaders);
return api;
}

/**
* <p>Make predictions from Parquet file
* <p>
* @param _file (optional)
* The value for the parameter _file
* @param predictionConfig (optional)
* JSON string containing the prediction configuration (see PredictionConfig schema).
* @return An OpenApiResponse containing the status code of the HttpResponse.
* @throws OpenApiRequestException if an error occurs while attempting to invoke the API
*/
@Nonnull
public OpenApiResponse predictParquet(@Nullable final File _file , @Nullable final String predictionConfig ) throws OpenApiRequestException {

// create path and map variables
final String localVarPath = "/predict_parquet";

final StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
final List<Pair> localVarQueryParams = new ArrayList<Pair>();
final List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
final Map<String, String> localVarHeaderParams = new HashMap<String, String>(defaultHeaders);
final Map<String, Object> localVarFormParams = new HashMap<String, Object>();

if (_file != null)
localVarFormParams.put("file", _file);
if (predictionConfig != null)
localVarFormParams.put("prediction_config", predictionConfig);

final String[] localVarAccepts = {

};
final String localVarAccept = ApiClient.selectHeaderAccept(localVarAccepts);
final String[] localVarContentTypes = {
"multipart/form-data"
};
final String localVarContentType = ApiClient.selectHeaderContentType(localVarContentTypes);

final TypeReference<OpenApiResponse> localVarReturnType = new TypeReference<OpenApiResponse>() {};

return apiClient.invokeAPI(
localVarPath,
"POST",
localVarQueryParams,
localVarCollectionQueryParams,
localVarQueryStringJoiner.toString(),
null,
localVarHeaderParams,
localVarFormParams,
localVarAccept,
localVarContentType,
localVarReturnType
);
}

/**
* <p>Make predictions from Parquet file
* <p>
* @return An OpenApiResponse containing the status code of the HttpResponse.
* @throws OpenApiRequestException if an error occurs while attempting to invoke the API
*/
@Nonnull
public OpenApiResponse predictParquet() throws OpenApiRequestException {
return predictParquet(null, null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
/*
* Copyright (c) 2026 SAP SE or an SAP affiliate company. All rights reserved.
*/

/*
* String and File multipart body
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

package com.sap.cloud.sdk.datamodel.rest.test.model;

import java.util.Objects;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
* PredictionConfig
*/
// CHECKSTYLE:OFF
public class PredictionConfig
// CHECKSTYLE:ON
{
@JsonProperty("test")
private String test;

@JsonAnySetter
@JsonAnyGetter
private final Map<String, Object> cloudSdkCustomFields = new LinkedHashMap<>();

/**
* Set the test of this {@link PredictionConfig} instance and return the same instance.
*
* @param test The test of this {@link PredictionConfig}
* @return The same instance of this {@link PredictionConfig} class
*/
@Nonnull public PredictionConfig test( @Nullable final String test) {
this.test = test;
return this;
}

/**
* Get test
* @return test The test of this {@link PredictionConfig} instance.
*/
@Nonnull
public String getTest() {
return test;
}

/**
* Set the test of this {@link PredictionConfig} instance.
*
* @param test The test of this {@link PredictionConfig}
*/
public void setTest( @Nullable final String test) {
this.test = test;
}

/**
* Get the names of the unrecognizable properties of the {@link PredictionConfig}.
* @return The set of properties names
*/
@JsonIgnore
@Nonnull
public Set<String> getCustomFieldNames() {
return cloudSdkCustomFields.keySet();
}

/**
* Get the value of an unrecognizable property of this {@link PredictionConfig} 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("PredictionConfig has no field with name '" + name + "'.");
}
return cloudSdkCustomFields.get(name);
}

/**
* Get the value of all properties of this {@link PredictionConfig} 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( test != null ) declaredFields.put("test", test);
return declaredFields;
}

/**
* Set an unrecognizable property of this {@link PredictionConfig} instance. If the map previously contained a mapping
* for the key, the old value is replaced by the specified value.
* @param customFieldName The name of the property
* @param customFieldValue The value of the property
*/
@JsonIgnore
public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue )
{
cloudSdkCustomFields.put(customFieldName, customFieldValue);
}


@Override
public boolean equals(@Nullable final java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final PredictionConfig predictionConfig = (PredictionConfig) o;
return Objects.equals(this.cloudSdkCustomFields, predictionConfig.cloudSdkCustomFields) &&
Objects.equals(this.test, predictionConfig.test);
}

@Override
public int hashCode() {
return Objects.hash(test, cloudSdkCustomFields);
}

@Override
@Nonnull public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append("class PredictionConfig {\n");
sb.append(" test: ").append(toIndentedString(test)).append("\n");
cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n"));
sb.append("}");
return sb.toString();
}

/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(final java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}

}

2 changes: 1 addition & 1 deletion release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@

### 🐛 Fixed Issues

-
- [OpenAPI Generator] `String` properties with `contentMediaType: application/json` are not mistakenly generated as `File` anymore