-
Notifications
You must be signed in to change notification settings - Fork 32
fix: [OpenAPI] String properties are not mistakenly generated as File anymore #1260
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...rces/DataModelGeneratorApacheIntegrationTest/multipart-binary-string/input/sodastore.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
135 changes: 135 additions & 0 deletions
135
.../multipart-binary-string/output/com/sap/cloud/sdk/datamodel/rest/test/api/DefaultApi.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } |
173 changes: 173 additions & 0 deletions
173
...rt-binary-string/output/com/sap/cloud/sdk/datamodel/rest/test/model/PredictionConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 "); | ||
| } | ||
|
|
||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.