diff --git a/datamodel/openapi/openapi-api-apache-sample/pom.xml b/datamodel/openapi/openapi-api-apache-sample/pom.xml new file mode 100644 index 000000000..0872d59c6 --- /dev/null +++ b/datamodel/openapi/openapi-api-apache-sample/pom.xml @@ -0,0 +1,107 @@ + + + 4.0.0 + + com.sap.cloud.sdk.datamodel + openapi-parent + 5.26.0-SNAPSHOT + + + openapi-api-apache-sample + + + 22 + 22 + UTF-8 + + + + + com.sap.cloud.sdk.datamodel + openapi-core + + + com.google.guava + guava + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.core + jackson-annotations + + + + + + com.sap.cloud.sdk.datamodel + openapi-generator-maven-plugin + + ${project.basedir}/src/main/java + true + true + + + + sample-generation + + generate + + generate-sources + + ${project.basedir}/src/main/resources/sodastore.yaml + com.sap.cloud.sdk.datamodel.openapi.apache.sample.api + com.sap.cloud.sdk.datamodel.openapi.apache.sample.model + + true + com.sap.cloud.sdk.services.openapi.apache + apache-httpclient + false + true + true + true + \. + 3 + + protected + true + + + + + + + net.revelc.code.formatter + formatter-maven-plugin + + + + format + + + + + false + + + + net.revelc.code + impsort-maven-plugin + + + + sort + + + + + false + + + + + diff --git a/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/api/OrdersApi.java b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/api/OrdersApi.java new file mode 100644 index 000000000..a68fbf053 --- /dev/null +++ b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/api/OrdersApi.java @@ -0,0 +1,162 @@ +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * + * + * 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.openapi.apache.sample.api; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.StringJoiner; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.sap.cloud.sdk.datamodel.openapi.apache.sample.model.Order; +import com.sap.cloud.sdk.services.openapi.apache.ApiClient; +import com.sap.cloud.sdk.services.openapi.apache.ApiException; +import com.sap.cloud.sdk.services.openapi.apache.BaseApi; +import com.sap.cloud.sdk.services.openapi.apache.Configuration; +import com.sap.cloud.sdk.services.openapi.apache.Pair; + +public class OrdersApi extends BaseApi +{ + + public OrdersApi() + { + super(Configuration.getDefaultApiClient()); + } + + public OrdersApi( ApiClient apiClient ) + { + super(apiClient); + } + + /** + * Create a new order + * + * @param order + * The order details (required) + * @return Order + * @throws ApiException + * if fails to make API call + */ + public Order ordersPost( @javax.annotation.Nonnull Order order ) + throws ApiException + { + return this.ordersPost(order, Collections.emptyMap()); + } + + /** + * Create a new order + * + * @param order + * The order details (required) + * @param additionalHeaders + * additionalHeaders for this call + * @return Order + * @throws ApiException + * if fails to make API call + */ + public Order ordersPost( @javax.annotation.Nonnull Order order, Map additionalHeaders ) + throws ApiException + { + Object localVarPostBody = order; + + // verify the required parameter 'order' is set + if( order == null ) { + throw new ApiException(400, "Missing the required parameter 'order' when calling ordersPost"); + } + + // create path and map variables + String localVarPath = "/orders"; + + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + localVarHeaderParams.putAll(additionalHeaders); + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { "application/json" }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "apiKeyAuth" }; + + TypeReference localVarReturnType = new TypeReference() + { + }; + return apiClient + .invokeAPI( + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarQueryStringJoiner.toString(), + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAccept, + localVarContentType, + localVarAuthNames, + localVarReturnType); + } + + @Override + public T invokeAPI( + String url, + String method, + Object request, + TypeReference returnType, + Map additionalHeaders ) + throws ApiException + { + String localVarPath = url.replace(apiClient.getBaseURL(), ""); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + localVarHeaderParams.putAll(additionalHeaders); + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { "application/json" }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "apiKeyAuth" }; + + return apiClient + .invokeAPI( + localVarPath, + method, + localVarQueryParams, + localVarCollectionQueryParams, + localVarQueryStringJoiner.toString(), + request, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAccept, + localVarContentType, + localVarAuthNames, + returnType); + } +} diff --git a/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/api/SodasApi.java b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/api/SodasApi.java new file mode 100644 index 000000000..9a5265ac2 --- /dev/null +++ b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/api/SodasApi.java @@ -0,0 +1,395 @@ +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * + * + * 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.openapi.apache.sample.api; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.StringJoiner; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.sap.cloud.sdk.datamodel.openapi.apache.sample.model.Soda; +import com.sap.cloud.sdk.datamodel.openapi.apache.sample.model.SodaWithId; +import com.sap.cloud.sdk.services.openapi.apache.ApiClient; +import com.sap.cloud.sdk.services.openapi.apache.ApiException; +import com.sap.cloud.sdk.services.openapi.apache.BaseApi; +import com.sap.cloud.sdk.services.openapi.apache.Configuration; +import com.sap.cloud.sdk.services.openapi.apache.Pair; + +public class SodasApi extends BaseApi +{ + + public SodasApi() + { + super(Configuration.getDefaultApiClient()); + } + + public SodasApi( ApiClient apiClient ) + { + super(apiClient); + } + + /** + * Download soda product data as binary + * + * @param id + * ID of the soda product to download (required) + * @return File + * @throws ApiException + * if fails to make API call + */ + public File sodasDownloadIdGet( @javax.annotation.Nonnull Long id ) + throws ApiException + { + return this.sodasDownloadIdGet(id, Collections.emptyMap()); + } + + /** + * Download soda product data as binary + * + * @param id + * ID of the soda product to download (required) + * @param additionalHeaders + * additionalHeaders for this call + * @return File + * @throws ApiException + * if fails to make API call + */ + public File sodasDownloadIdGet( @javax.annotation.Nonnull Long id, Map additionalHeaders ) + throws ApiException + { + Object localVarPostBody = null; + + // verify the required parameter 'id' is set + if( id == null ) { + throw new ApiException(400, "Missing the required parameter 'id' when calling sodasDownloadIdGet"); + } + + // create path and map variables + String localVarPath = + "/sodas/download/{id}" + .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(apiClient.parameterToString(id))); + + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + localVarHeaderParams.putAll(additionalHeaders); + + final String[] localVarAccepts = { "application/octet-stream" }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "apiKeyAuth", "bearerAuth" }; + + TypeReference localVarReturnType = new TypeReference() + { + }; + return apiClient + .invokeAPI( + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarQueryStringJoiner.toString(), + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAccept, + localVarContentType, + localVarAuthNames, + localVarReturnType); + } + + /** + * Get all soda products + * + * @return List<SodaWithId> + * @throws ApiException + * if fails to make API call + */ + public List sodasGet() + throws ApiException + { + return this.sodasGet(Collections.emptyMap()); + } + + /** + * Get all soda products + * + * @param additionalHeaders + * additionalHeaders for this call + * @return List<SodaWithId> + * @throws ApiException + * if fails to make API call + */ + public List sodasGet( Map additionalHeaders ) + throws ApiException + { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/sodas"; + + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + localVarHeaderParams.putAll(additionalHeaders); + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "apiKeyAuth" }; + + TypeReference> localVarReturnType = new TypeReference>() + { + }; + return apiClient + .invokeAPI( + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarQueryStringJoiner.toString(), + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAccept, + localVarContentType, + localVarAuthNames, + localVarReturnType); + } + + /** + * Get a specific soda product by ID + * + * @param id + * ID of the soda product to retrieve (required) + * @return SodaWithId + * @throws ApiException + * if fails to make API call + */ + public SodaWithId sodasIdGet( @javax.annotation.Nonnull Long id ) + throws ApiException + { + return this.sodasIdGet(id, Collections.emptyMap()); + } + + /** + * Get a specific soda product by ID + * + * @param id + * ID of the soda product to retrieve (required) + * @param additionalHeaders + * additionalHeaders for this call + * @return SodaWithId + * @throws ApiException + * if fails to make API call + */ + public SodaWithId sodasIdGet( @javax.annotation.Nonnull Long id, Map additionalHeaders ) + throws ApiException + { + Object localVarPostBody = null; + + // verify the required parameter 'id' is set + if( id == null ) { + throw new ApiException(400, "Missing the required parameter 'id' when calling sodasIdGet"); + } + + // create path and map variables + String localVarPath = + "/sodas/{id}".replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(apiClient.parameterToString(id))); + + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + localVarHeaderParams.putAll(additionalHeaders); + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "apiKeyAuth" }; + + TypeReference localVarReturnType = new TypeReference() + { + }; + return apiClient + .invokeAPI( + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarQueryStringJoiner.toString(), + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAccept, + localVarContentType, + localVarAuthNames, + localVarReturnType); + } + + /** + * Update a specific soda product by ID + * + * @param sodaWithId + * The updated soda product (required) + * @return Soda + * @throws ApiException + * if fails to make API call + */ + public Soda sodasPut( @javax.annotation.Nonnull SodaWithId sodaWithId ) + throws ApiException + { + return this.sodasPut(sodaWithId, Collections.emptyMap()); + } + + /** + * Update a specific soda product by ID + * + * @param sodaWithId + * The updated soda product (required) + * @param additionalHeaders + * additionalHeaders for this call + * @return Soda + * @throws ApiException + * if fails to make API call + */ + public Soda sodasPut( @javax.annotation.Nonnull SodaWithId sodaWithId, Map additionalHeaders ) + throws ApiException + { + Object localVarPostBody = sodaWithId; + + // verify the required parameter 'sodaWithId' is set + if( sodaWithId == null ) { + throw new ApiException(400, "Missing the required parameter 'sodaWithId' when calling sodasPut"); + } + + // create path and map variables + String localVarPath = "/sodas"; + + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + localVarHeaderParams.putAll(additionalHeaders); + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { "application/json" }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "apiKeyAuth" }; + + TypeReference localVarReturnType = new TypeReference() + { + }; + return apiClient + .invokeAPI( + localVarPath, + "PUT", + localVarQueryParams, + localVarCollectionQueryParams, + localVarQueryStringJoiner.toString(), + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAccept, + localVarContentType, + localVarAuthNames, + localVarReturnType); + } + + @Override + public T invokeAPI( + String url, + String method, + Object request, + TypeReference returnType, + Map additionalHeaders ) + throws ApiException + { + String localVarPath = url.replace(apiClient.getBaseURL(), ""); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + localVarHeaderParams.putAll(additionalHeaders); + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { "application/json" }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "apiKeyAuth" }; + + return apiClient + .invokeAPI( + localVarPath, + method, + localVarQueryParams, + localVarCollectionQueryParams, + localVarQueryStringJoiner.toString(), + request, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAccept, + localVarContentType, + localVarAuthNames, + returnType); + } +} diff --git a/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/AllOf.java b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/AllOf.java new file mode 100644 index 000000000..d6462cc87 --- /dev/null +++ b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/AllOf.java @@ -0,0 +1,413 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * + * + * 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.openapi.apache.sample.model; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.annotations.Beta; + +/** + * AllOf + */ + +@Beta // CHECKSTYLE:OFF +public class AllOf +// CHECKSTYLE:ON +{ + @JsonProperty( "sodaType" ) + private String sodaType; + + @JsonProperty( "caffeine" ) + private Boolean caffeine; + + @JsonProperty( "logo" ) + private ColaLogo logo; + + @JsonProperty( "barCode" ) + private ColaBarCode barCode; + + @JsonProperty( "color" ) + private String color; + + @JsonProperty( "flavor" ) + private FantaFlavor flavor; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Default constructor for AllOf. + */ + protected AllOf() + { + } + + /** + * Set the sodaType of this {@link AllOf} instance and return the same instance. + * + * @param sodaType + * The sodaType of this {@link AllOf} + * @return The same instance of this {@link AllOf} class + */ + @Nonnull + public AllOf sodaType( @Nullable final String sodaType ) + { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * + * @return sodaType The sodaType of this {@link AllOf} instance. + */ + @Nonnull + public String getSodaType() + { + return sodaType; + } + + /** + * Set the sodaType of this {@link AllOf} instance. + * + * @param sodaType + * The sodaType of this {@link AllOf} + */ + public void setSodaType( @Nullable final String sodaType ) + { + this.sodaType = sodaType; + } + + /** + * Set the caffeine of this {@link AllOf} instance and return the same instance. + * + * @param caffeine + * The caffeine of this {@link AllOf} + * @return The same instance of this {@link AllOf} class + */ + @Nonnull + public AllOf caffeine( @Nullable final Boolean caffeine ) + { + this.caffeine = caffeine; + return this; + } + + /** + * Get caffeine + * + * @return caffeine The caffeine of this {@link AllOf} instance. + */ + @Nonnull + public Boolean isCaffeine() + { + return caffeine; + } + + /** + * Set the caffeine of this {@link AllOf} instance. + * + * @param caffeine + * The caffeine of this {@link AllOf} + */ + public void setCaffeine( @Nullable final Boolean caffeine ) + { + this.caffeine = caffeine; + } + + /** + * Set the logo of this {@link AllOf} instance and return the same instance. + * + * @param logo + * The logo of this {@link AllOf} + * @return The same instance of this {@link AllOf} class + */ + @Nonnull + public AllOf logo( @Nullable final ColaLogo logo ) + { + this.logo = logo; + return this; + } + + /** + * Get logo + * + * @return logo The logo of this {@link AllOf} instance. + */ + @Nonnull + public ColaLogo getLogo() + { + return logo; + } + + /** + * Set the logo of this {@link AllOf} instance. + * + * @param logo + * The logo of this {@link AllOf} + */ + public void setLogo( @Nullable final ColaLogo logo ) + { + this.logo = logo; + } + + /** + * Set the barCode of this {@link AllOf} instance and return the same instance. + * + * @param barCode + * The barCode of this {@link AllOf} + * @return The same instance of this {@link AllOf} class + */ + @Nonnull + public AllOf barCode( @Nullable final ColaBarCode barCode ) + { + this.barCode = barCode; + return this; + } + + /** + * Get barCode + * + * @return barCode The barCode of this {@link AllOf} instance. + */ + @Nonnull + public ColaBarCode getBarCode() + { + return barCode; + } + + /** + * Set the barCode of this {@link AllOf} instance. + * + * @param barCode + * The barCode of this {@link AllOf} + */ + public void setBarCode( @Nullable final ColaBarCode barCode ) + { + this.barCode = barCode; + } + + /** + * Set the color of this {@link AllOf} instance and return the same instance. + * + * @param color + * The color of this {@link AllOf} + * @return The same instance of this {@link AllOf} class + */ + @Nonnull + public AllOf color( @Nullable final String color ) + { + this.color = color; + return this; + } + + /** + * Get color + * + * @return color The color of this {@link AllOf} instance. + */ + @Nonnull + public String getColor() + { + return color; + } + + /** + * Set the color of this {@link AllOf} instance. + * + * @param color + * The color of this {@link AllOf} + */ + public void setColor( @Nullable final String color ) + { + this.color = color; + } + + /** + * Set the flavor of this {@link AllOf} instance and return the same instance. + * + * @param flavor + * The flavor of this {@link AllOf} + * @return The same instance of this {@link AllOf} class + */ + @Nonnull + public AllOf flavor( @Nullable final FantaFlavor flavor ) + { + this.flavor = flavor; + return this; + } + + /** + * Get flavor + * + * @return flavor The flavor of this {@link AllOf} instance. + */ + @Nonnull + public FantaFlavor getFlavor() + { + return flavor; + } + + /** + * Set the flavor of this {@link AllOf} instance. + * + * @param flavor + * The flavor of this {@link AllOf} + */ + public void setFlavor( @Nullable final FantaFlavor flavor ) + { + this.flavor = flavor; + } + + /** + * Get the names of the unrecognizable properties of the {@link AllOf}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() + { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link AllOf} 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("AllOf has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link AllOf} instance including unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() + { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if( sodaType != null ) + declaredFields.put("sodaType", sodaType); + if( caffeine != null ) + declaredFields.put("caffeine", caffeine); + if( logo != null ) + declaredFields.put("logo", logo); + if( barCode != null ) + declaredFields.put("barCode", barCode); + if( color != null ) + declaredFields.put("color", color); + if( flavor != null ) + declaredFields.put("flavor", flavor); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link AllOf} 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 AllOf allOf = (AllOf) o; + return Objects.equals(this.cloudSdkCustomFields, allOf.cloudSdkCustomFields) + && Objects.equals(this.sodaType, allOf.sodaType) + && Objects.equals(this.caffeine, allOf.caffeine) + && Objects.equals(this.logo, allOf.logo) + && Objects.equals(this.barCode, allOf.barCode) + && Objects.equals(this.color, allOf.color) + && Objects.equals(this.flavor, allOf.flavor); + } + + @Override + public int hashCode() + { + return Objects.hash(sodaType, caffeine, logo, barCode, color, flavor, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append("class AllOf {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + sb.append(" caffeine: ").append(toIndentedString(caffeine)).append("\n"); + sb.append(" logo: ").append(toIndentedString(logo)).append("\n"); + sb.append(" barCode: ").append(toIndentedString(barCode)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).append("\n"); + sb.append(" flavor: ").append(toIndentedString(flavor)).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 "); + } + +} diff --git a/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/AnyOf.java b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/AnyOf.java new file mode 100644 index 000000000..97f8d677f --- /dev/null +++ b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/AnyOf.java @@ -0,0 +1,413 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * + * + * 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.openapi.apache.sample.model; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.annotations.Beta; + +/** + * AnyOf + */ + +@Beta // CHECKSTYLE:OFF +public class AnyOf +// CHECKSTYLE:ON +{ + @JsonProperty( "sodaType" ) + private String sodaType; + + @JsonProperty( "caffeine" ) + private Boolean caffeine; + + @JsonProperty( "logo" ) + private ColaLogo logo; + + @JsonProperty( "barCode" ) + private ColaBarCode barCode; + + @JsonProperty( "color" ) + private String color; + + @JsonProperty( "flavor" ) + private FantaFlavor flavor; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Default constructor for AnyOf. + */ + protected AnyOf() + { + } + + /** + * Set the sodaType of this {@link AnyOf} instance and return the same instance. + * + * @param sodaType + * The sodaType of this {@link AnyOf} + * @return The same instance of this {@link AnyOf} class + */ + @Nonnull + public AnyOf sodaType( @Nullable final String sodaType ) + { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * + * @return sodaType The sodaType of this {@link AnyOf} instance. + */ + @Nonnull + public String getSodaType() + { + return sodaType; + } + + /** + * Set the sodaType of this {@link AnyOf} instance. + * + * @param sodaType + * The sodaType of this {@link AnyOf} + */ + public void setSodaType( @Nullable final String sodaType ) + { + this.sodaType = sodaType; + } + + /** + * Set the caffeine of this {@link AnyOf} instance and return the same instance. + * + * @param caffeine + * The caffeine of this {@link AnyOf} + * @return The same instance of this {@link AnyOf} class + */ + @Nonnull + public AnyOf caffeine( @Nullable final Boolean caffeine ) + { + this.caffeine = caffeine; + return this; + } + + /** + * Get caffeine + * + * @return caffeine The caffeine of this {@link AnyOf} instance. + */ + @Nonnull + public Boolean isCaffeine() + { + return caffeine; + } + + /** + * Set the caffeine of this {@link AnyOf} instance. + * + * @param caffeine + * The caffeine of this {@link AnyOf} + */ + public void setCaffeine( @Nullable final Boolean caffeine ) + { + this.caffeine = caffeine; + } + + /** + * Set the logo of this {@link AnyOf} instance and return the same instance. + * + * @param logo + * The logo of this {@link AnyOf} + * @return The same instance of this {@link AnyOf} class + */ + @Nonnull + public AnyOf logo( @Nullable final ColaLogo logo ) + { + this.logo = logo; + return this; + } + + /** + * Get logo + * + * @return logo The logo of this {@link AnyOf} instance. + */ + @Nonnull + public ColaLogo getLogo() + { + return logo; + } + + /** + * Set the logo of this {@link AnyOf} instance. + * + * @param logo + * The logo of this {@link AnyOf} + */ + public void setLogo( @Nullable final ColaLogo logo ) + { + this.logo = logo; + } + + /** + * Set the barCode of this {@link AnyOf} instance and return the same instance. + * + * @param barCode + * The barCode of this {@link AnyOf} + * @return The same instance of this {@link AnyOf} class + */ + @Nonnull + public AnyOf barCode( @Nullable final ColaBarCode barCode ) + { + this.barCode = barCode; + return this; + } + + /** + * Get barCode + * + * @return barCode The barCode of this {@link AnyOf} instance. + */ + @Nonnull + public ColaBarCode getBarCode() + { + return barCode; + } + + /** + * Set the barCode of this {@link AnyOf} instance. + * + * @param barCode + * The barCode of this {@link AnyOf} + */ + public void setBarCode( @Nullable final ColaBarCode barCode ) + { + this.barCode = barCode; + } + + /** + * Set the color of this {@link AnyOf} instance and return the same instance. + * + * @param color + * The color of this {@link AnyOf} + * @return The same instance of this {@link AnyOf} class + */ + @Nonnull + public AnyOf color( @Nullable final String color ) + { + this.color = color; + return this; + } + + /** + * Get color + * + * @return color The color of this {@link AnyOf} instance. + */ + @Nonnull + public String getColor() + { + return color; + } + + /** + * Set the color of this {@link AnyOf} instance. + * + * @param color + * The color of this {@link AnyOf} + */ + public void setColor( @Nullable final String color ) + { + this.color = color; + } + + /** + * Set the flavor of this {@link AnyOf} instance and return the same instance. + * + * @param flavor + * The flavor of this {@link AnyOf} + * @return The same instance of this {@link AnyOf} class + */ + @Nonnull + public AnyOf flavor( @Nullable final FantaFlavor flavor ) + { + this.flavor = flavor; + return this; + } + + /** + * Get flavor + * + * @return flavor The flavor of this {@link AnyOf} instance. + */ + @Nonnull + public FantaFlavor getFlavor() + { + return flavor; + } + + /** + * Set the flavor of this {@link AnyOf} instance. + * + * @param flavor + * The flavor of this {@link AnyOf} + */ + public void setFlavor( @Nullable final FantaFlavor flavor ) + { + this.flavor = flavor; + } + + /** + * Get the names of the unrecognizable properties of the {@link AnyOf}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() + { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link AnyOf} 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("AnyOf has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link AnyOf} instance including unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() + { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if( sodaType != null ) + declaredFields.put("sodaType", sodaType); + if( caffeine != null ) + declaredFields.put("caffeine", caffeine); + if( logo != null ) + declaredFields.put("logo", logo); + if( barCode != null ) + declaredFields.put("barCode", barCode); + if( color != null ) + declaredFields.put("color", color); + if( flavor != null ) + declaredFields.put("flavor", flavor); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link AnyOf} 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 AnyOf anyOf = (AnyOf) o; + return Objects.equals(this.cloudSdkCustomFields, anyOf.cloudSdkCustomFields) + && Objects.equals(this.sodaType, anyOf.sodaType) + && Objects.equals(this.caffeine, anyOf.caffeine) + && Objects.equals(this.logo, anyOf.logo) + && Objects.equals(this.barCode, anyOf.barCode) + && Objects.equals(this.color, anyOf.color) + && Objects.equals(this.flavor, anyOf.flavor); + } + + @Override + public int hashCode() + { + return Objects.hash(sodaType, caffeine, logo, barCode, color, flavor, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append("class AnyOf {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + sb.append(" caffeine: ").append(toIndentedString(caffeine)).append("\n"); + sb.append(" logo: ").append(toIndentedString(logo)).append("\n"); + sb.append(" barCode: ").append(toIndentedString(barCode)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).append("\n"); + sb.append(" flavor: ").append(toIndentedString(flavor)).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 "); + } + +} diff --git a/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/Bar.java b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/Bar.java new file mode 100644 index 000000000..55111820b --- /dev/null +++ b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/Bar.java @@ -0,0 +1,309 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * + * + * 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.openapi.apache.sample.model; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import com.google.common.annotations.Beta; + +/** + * Bar + */ + +@Beta // CHECKSTYLE:OFF +public class Bar implements OneOfWithEnumDiscriminator +// CHECKSTYLE:ON +{ + @JsonProperty( "bar" ) + private String bar; + + /** + * Gets or Sets disc + */ + public enum DiscEnum + { + /** + * The DISC_BAR option of this Bar + */ + DISC_BAR("disc_bar"), + + /** + * The UNKNOWN_DEFAULT_OPEN_API option of this Bar + */ + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + DiscEnum( String value ) + { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() + { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() + { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value + * The String value + * @return The enum value of type Bar + */ + @JsonCreator + @Nonnull + public static DiscEnum fromValue( @Nonnull final String value ) + { + for( DiscEnum b : DiscEnum.values() ) { + if( b.value.equals(value) ) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + @JsonProperty( "disc" ) + private DiscEnum disc; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Default constructor for Bar. + */ + protected Bar() + { + } + + /** + * Set the bar of this {@link Bar} instance and return the same instance. + * + * @param bar + * The bar of this {@link Bar} + * @return The same instance of this {@link Bar} class + */ + @Nonnull + public Bar bar( @Nullable final String bar ) + { + this.bar = bar; + return this; + } + + /** + * Get bar + * + * @return bar The bar of this {@link Bar} instance. + */ + @Nonnull + public String getBar() + { + return bar; + } + + /** + * Set the bar of this {@link Bar} instance. + * + * @param bar + * The bar of this {@link Bar} + */ + public void setBar( @Nullable final String bar ) + { + this.bar = bar; + } + + /** + * Set the disc of this {@link Bar} instance and return the same instance. + * + * @param disc + * The disc of this {@link Bar} + * @return The same instance of this {@link Bar} class + */ + @Nonnull + public Bar disc( @Nullable final DiscEnum disc ) + { + this.disc = disc; + return this; + } + + /** + * Get disc + * + * @return disc The disc of this {@link Bar} instance. + */ + @Nonnull + public DiscEnum getDisc() + { + return disc; + } + + /** + * Set the disc of this {@link Bar} instance. + * + * @param disc + * The disc of this {@link Bar} + */ + public void setDisc( @Nullable final DiscEnum disc ) + { + this.disc = disc; + } + + /** + * Get the names of the unrecognizable properties of the {@link Bar}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() + { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link Bar} 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("Bar has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link Bar} instance including unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() + { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if( bar != null ) + declaredFields.put("bar", bar); + if( disc != null ) + declaredFields.put("disc", disc); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link Bar} 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 Bar bar = (Bar) o; + return Objects.equals(this.cloudSdkCustomFields, bar.cloudSdkCustomFields) + && Objects.equals(this.bar, bar.bar) + && Objects.equals(this.disc, bar.disc); + } + + @Override + public int hashCode() + { + return Objects.hash(bar, disc, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append("class Bar {\n"); + sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); + sb.append(" disc: ").append(toIndentedString(disc)).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 "); + } + +} diff --git a/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/Cola.java b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/Cola.java new file mode 100644 index 000000000..7d5bb90be --- /dev/null +++ b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/Cola.java @@ -0,0 +1,327 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * + * + * 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.openapi.apache.sample.model; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.annotations.Beta; + +/** + * Cola + */ + +@Beta // CHECKSTYLE:OFF +public class Cola implements OneOf, OneOfWithDiscriminator, OneOfWithDiscriminatorAndMapping +// CHECKSTYLE:ON +{ + @JsonProperty( "sodaType" ) + private String sodaType; + + @JsonProperty( "caffeine" ) + private Boolean caffeine; + + @JsonProperty( "logo" ) + private ColaLogo logo; + + @JsonProperty( "barCode" ) + private ColaBarCode barCode; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Default constructor for Cola. + */ + protected Cola() + { + } + + /** + * Set the sodaType of this {@link Cola} instance and return the same instance. + * + * @param sodaType + * The sodaType of this {@link Cola} + * @return The same instance of this {@link Cola} class + */ + @Nonnull + public Cola sodaType( @Nullable final String sodaType ) + { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * + * @return sodaType The sodaType of this {@link Cola} instance. + */ + @Nonnull + public String getSodaType() + { + return sodaType; + } + + /** + * Set the sodaType of this {@link Cola} instance. + * + * @param sodaType + * The sodaType of this {@link Cola} + */ + public void setSodaType( @Nullable final String sodaType ) + { + this.sodaType = sodaType; + } + + /** + * Set the caffeine of this {@link Cola} instance and return the same instance. + * + * @param caffeine + * The caffeine of this {@link Cola} + * @return The same instance of this {@link Cola} class + */ + @Nonnull + public Cola caffeine( @Nullable final Boolean caffeine ) + { + this.caffeine = caffeine; + return this; + } + + /** + * Get caffeine + * + * @return caffeine The caffeine of this {@link Cola} instance. + */ + @Nonnull + public Boolean isCaffeine() + { + return caffeine; + } + + /** + * Set the caffeine of this {@link Cola} instance. + * + * @param caffeine + * The caffeine of this {@link Cola} + */ + public void setCaffeine( @Nullable final Boolean caffeine ) + { + this.caffeine = caffeine; + } + + /** + * Set the logo of this {@link Cola} instance and return the same instance. + * + * @param logo + * The logo of this {@link Cola} + * @return The same instance of this {@link Cola} class + */ + @Nonnull + public Cola logo( @Nullable final ColaLogo logo ) + { + this.logo = logo; + return this; + } + + /** + * Get logo + * + * @return logo The logo of this {@link Cola} instance. + */ + @Nonnull + public ColaLogo getLogo() + { + return logo; + } + + /** + * Set the logo of this {@link Cola} instance. + * + * @param logo + * The logo of this {@link Cola} + */ + public void setLogo( @Nullable final ColaLogo logo ) + { + this.logo = logo; + } + + /** + * Set the barCode of this {@link Cola} instance and return the same instance. + * + * @param barCode + * The barCode of this {@link Cola} + * @return The same instance of this {@link Cola} class + */ + @Nonnull + public Cola barCode( @Nullable final ColaBarCode barCode ) + { + this.barCode = barCode; + return this; + } + + /** + * Get barCode + * + * @return barCode The barCode of this {@link Cola} instance. + */ + @Nonnull + public ColaBarCode getBarCode() + { + return barCode; + } + + /** + * Set the barCode of this {@link Cola} instance. + * + * @param barCode + * The barCode of this {@link Cola} + */ + public void setBarCode( @Nullable final ColaBarCode barCode ) + { + this.barCode = barCode; + } + + /** + * Get the names of the unrecognizable properties of the {@link Cola}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() + { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link Cola} 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("Cola has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link Cola} instance including unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() + { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if( sodaType != null ) + declaredFields.put("sodaType", sodaType); + if( caffeine != null ) + declaredFields.put("caffeine", caffeine); + if( logo != null ) + declaredFields.put("logo", logo); + if( barCode != null ) + declaredFields.put("barCode", barCode); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link Cola} 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 Cola cola = (Cola) o; + return Objects.equals(this.cloudSdkCustomFields, cola.cloudSdkCustomFields) + && Objects.equals(this.sodaType, cola.sodaType) + && Objects.equals(this.caffeine, cola.caffeine) + && Objects.equals(this.logo, cola.logo) + && Objects.equals(this.barCode, cola.barCode); + } + + @Override + public int hashCode() + { + return Objects.hash(sodaType, caffeine, logo, barCode, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append("class Cola {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + sb.append(" caffeine: ").append(toIndentedString(caffeine)).append("\n"); + sb.append(" logo: ").append(toIndentedString(logo)).append("\n"); + sb.append(" barCode: ").append(toIndentedString(barCode)).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 "); + } + +} diff --git a/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/ColaBarCode.java b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/ColaBarCode.java new file mode 100644 index 000000000..6ca5fa9dc --- /dev/null +++ b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/ColaBarCode.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * + * + * 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.openapi.apache.sample.model; + +import java.math.BigDecimal; +import java.util.List; + +import javax.annotation.Nonnull; + +import com.google.common.annotations.Beta; + +/** + * ColaBarCode + */ +@Beta +public interface ColaBarCode +{ + /** + * Helper class to create {@code List } that implements {@link ColaBarCode}. + */ + record ListOfBigDecimals(@com.fasterxml.jackson.annotation.JsonValue @Nonnull List values) implements ColaBarCode {} + + /** + * Creator to enable deserialization of {@code List }. + * + * @param val + * the value to use + * @return a new instance of {@link ListOfBigDecimals}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + @Nonnull + static ListOfBigDecimals createListOfBigDecimals( @Nonnull final List val ) + { + return new ListOfBigDecimals(val); + } + + /** + * Helper class to create {@code String } that implements {@link ColaBarCode}. + */ + record InnerString(@com.fasterxml.jackson.annotation.JsonValue @Nonnull String value) implements ColaBarCode {} + + /** + * Creator to enable deserialization of {@code String }. + * + * @param val + * the value to use + * @return a new instance of {@link InnerString}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + @Nonnull + static InnerString create( @Nonnull final String val ) + { + return new InnerString(val); + } + +} diff --git a/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/ColaLogo.java b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/ColaLogo.java new file mode 100644 index 000000000..84624d0e3 --- /dev/null +++ b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/ColaLogo.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * + * + * 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.openapi.apache.sample.model; + +import java.util.List; + +import javax.annotation.Nonnull; + +import com.google.common.annotations.Beta; + +/** + * ColaLogo + */ +@Beta +public interface ColaLogo +{ + /** + * Helper class to create {@code List> } that implements {@link ColaLogo}. + */ + record ListOfListOfIntegers(@com.fasterxml.jackson.annotation.JsonValue @Nonnull List> values) implements ColaLogo {} + + /** + * Creator to enable deserialization of {@code List> }. + * + * @param val + * the value to use + * @return a new instance of {@link ListOfListOfIntegers}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + @Nonnull + static ListOfListOfIntegers createListOfListOfIntegers( @Nonnull final List> val ) + { + return new ListOfListOfIntegers(val); + } + + /** + * Helper class to create {@code String } that implements {@link ColaLogo}. + */ + record InnerString(@com.fasterxml.jackson.annotation.JsonValue @Nonnull String value) implements ColaLogo {} + + /** + * Creator to enable deserialization of {@code String }. + * + * @param val + * the value to use + * @return a new instance of {@link InnerString}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + @Nonnull + static InnerString create( @Nonnull final String val ) + { + return new InnerString(val); + } + +} diff --git a/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/Fanta.java b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/Fanta.java new file mode 100644 index 000000000..0215af3cb --- /dev/null +++ b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/Fanta.java @@ -0,0 +1,284 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * + * + * 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.openapi.apache.sample.model; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.annotations.Beta; + +/** + * Fanta + */ + +@Beta // CHECKSTYLE:OFF +public class Fanta implements OneOf, OneOfWithDiscriminator, OneOfWithDiscriminatorAndMapping +// CHECKSTYLE:ON +{ + @JsonProperty( "sodaType" ) + private String sodaType; + + @JsonProperty( "color" ) + private String color; + + @JsonProperty( "flavor" ) + private FantaFlavor flavor; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Default constructor for Fanta. + */ + protected Fanta() + { + } + + /** + * Set the sodaType of this {@link Fanta} instance and return the same instance. + * + * @param sodaType + * The sodaType of this {@link Fanta} + * @return The same instance of this {@link Fanta} class + */ + @Nonnull + public Fanta sodaType( @Nullable final String sodaType ) + { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * + * @return sodaType The sodaType of this {@link Fanta} instance. + */ + @Nonnull + public String getSodaType() + { + return sodaType; + } + + /** + * Set the sodaType of this {@link Fanta} instance. + * + * @param sodaType + * The sodaType of this {@link Fanta} + */ + public void setSodaType( @Nullable final String sodaType ) + { + this.sodaType = sodaType; + } + + /** + * Set the color of this {@link Fanta} instance and return the same instance. + * + * @param color + * The color of this {@link Fanta} + * @return The same instance of this {@link Fanta} class + */ + @Nonnull + public Fanta color( @Nullable final String color ) + { + this.color = color; + return this; + } + + /** + * Get color + * + * @return color The color of this {@link Fanta} instance. + */ + @Nonnull + public String getColor() + { + return color; + } + + /** + * Set the color of this {@link Fanta} instance. + * + * @param color + * The color of this {@link Fanta} + */ + public void setColor( @Nullable final String color ) + { + this.color = color; + } + + /** + * Set the flavor of this {@link Fanta} instance and return the same instance. + * + * @param flavor + * The flavor of this {@link Fanta} + * @return The same instance of this {@link Fanta} class + */ + @Nonnull + public Fanta flavor( @Nullable final FantaFlavor flavor ) + { + this.flavor = flavor; + return this; + } + + /** + * Get flavor + * + * @return flavor The flavor of this {@link Fanta} instance. + */ + @Nonnull + public FantaFlavor getFlavor() + { + return flavor; + } + + /** + * Set the flavor of this {@link Fanta} instance. + * + * @param flavor + * The flavor of this {@link Fanta} + */ + public void setFlavor( @Nullable final FantaFlavor flavor ) + { + this.flavor = flavor; + } + + /** + * Get the names of the unrecognizable properties of the {@link Fanta}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() + { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link Fanta} 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("Fanta has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link Fanta} instance including unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() + { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if( sodaType != null ) + declaredFields.put("sodaType", sodaType); + if( color != null ) + declaredFields.put("color", color); + if( flavor != null ) + declaredFields.put("flavor", flavor); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link Fanta} 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 Fanta fanta = (Fanta) o; + return Objects.equals(this.cloudSdkCustomFields, fanta.cloudSdkCustomFields) + && Objects.equals(this.sodaType, fanta.sodaType) + && Objects.equals(this.color, fanta.color) + && Objects.equals(this.flavor, fanta.flavor); + } + + @Override + public int hashCode() + { + return Objects.hash(sodaType, color, flavor, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append("class Fanta {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).append("\n"); + sb.append(" flavor: ").append(toIndentedString(flavor)).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 "); + } + +} diff --git a/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/FantaFlavor.java b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/FantaFlavor.java new file mode 100644 index 000000000..143119694 --- /dev/null +++ b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/FantaFlavor.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * + * + * 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.openapi.apache.sample.model; + +import java.util.List; + +import javax.annotation.Nonnull; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.google.common.annotations.Beta; + +/** + * FantaFlavor + */ +@Beta +public interface FantaFlavor +{ + /** + * Helper class to create {@code String } that implements {@link FantaFlavor}. + */ + record InnerString(@com.fasterxml.jackson.annotation.JsonValue @Nonnull String value) implements FantaFlavor {} + + /** + * Creator to enable deserialization of {@code String }. + * + * @param val + * the value to use + * @return a new instance of {@link InnerString}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + @Nonnull + static InnerString create( @Nonnull final String val ) + { + return new InnerString(val); + } + + /** + * Helper class to create {@code Integer } that implements {@link FantaFlavor}. + */ + record InnerInteger(@com.fasterxml.jackson.annotation.JsonValue @Nonnull Integer value) implements FantaFlavor {} + + /** + * Creator to enable deserialization of {@code Integer }. + * + * @param val + * the value to use + * @return a new instance of {@link InnerInteger}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + @Nonnull + static InnerInteger create( @Nonnull final Integer val ) + { + return new InnerInteger(val); + } + + /** + * Helper class to create {@code FlavorType } that implements {@link FantaFlavor}. + */ + record InnerFlavorType(@com.fasterxml.jackson.annotation.JsonValue @Nonnull FlavorType value) implements FantaFlavor {} + + /** + * Creator to enable deserialization of {@code FlavorType }. + * + * @param val + * the value to use + * @return a new instance of {@link InnerFlavorType}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + @Nonnull + static InnerFlavorType createInnerFlavorType( @Nonnull final FlavorType val ) + { + return new InnerFlavorType(val); + } + + /** + * Helper class to create {@code List } that implements {@link FantaFlavor}. + */ + record ListOfFlavorTypes(@com.fasterxml.jackson.annotation.JsonValue @Nonnull List values) implements FantaFlavor {} + + /** + * Creator to enable deserialization of {@code List }. + * + * @param val + * the value to use + * @return a new instance of {@link ListOfFlavorTypes}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + @Nonnull + static ListOfFlavorTypes createListOfFlavorTypes( @Nonnull final List val ) + { + return new ListOfFlavorTypes(val); + } + +} diff --git a/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/FlavorType.java b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/FlavorType.java new file mode 100644 index 000000000..e95740c27 --- /dev/null +++ b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/FlavorType.java @@ -0,0 +1,241 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * + * + * 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.openapi.apache.sample.model; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.annotations.Beta; + +/** + * FlavorType + */ + +@Beta // CHECKSTYLE:OFF +public class FlavorType +// CHECKSTYLE:ON +{ + @JsonProperty( "intensity" ) + private Integer intensity; + + @JsonProperty( "nuance" ) + private String nuance; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Default constructor for FlavorType. + */ + protected FlavorType() + { + } + + /** + * Set the intensity of this {@link FlavorType} instance and return the same instance. + * + * @param intensity + * The intensity of the flavor + * @return The same instance of this {@link FlavorType} class + */ + @Nonnull + public FlavorType intensity( @Nullable final Integer intensity ) + { + this.intensity = intensity; + return this; + } + + /** + * The intensity of the flavor + * + * @return intensity The intensity of this {@link FlavorType} instance. + */ + @Nonnull + public Integer getIntensity() + { + return intensity; + } + + /** + * Set the intensity of this {@link FlavorType} instance. + * + * @param intensity + * The intensity of the flavor + */ + public void setIntensity( @Nullable final Integer intensity ) + { + this.intensity = intensity; + } + + /** + * Set the nuance of this {@link FlavorType} instance and return the same instance. + * + * @param nuance + * The nuance of the flavor + * @return The same instance of this {@link FlavorType} class + */ + @Nonnull + public FlavorType nuance( @Nullable final String nuance ) + { + this.nuance = nuance; + return this; + } + + /** + * The nuance of the flavor + * + * @return nuance The nuance of this {@link FlavorType} instance. + */ + @Nonnull + public String getNuance() + { + return nuance; + } + + /** + * Set the nuance of this {@link FlavorType} instance. + * + * @param nuance + * The nuance of the flavor + */ + public void setNuance( @Nullable final String nuance ) + { + this.nuance = nuance; + } + + /** + * Get the names of the unrecognizable properties of the {@link FlavorType}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() + { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link FlavorType} 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("FlavorType has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link FlavorType} instance including unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() + { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if( intensity != null ) + declaredFields.put("intensity", intensity); + if( nuance != null ) + declaredFields.put("nuance", nuance); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link FlavorType} 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 FlavorType flavorType = (FlavorType) o; + return Objects.equals(this.cloudSdkCustomFields, flavorType.cloudSdkCustomFields) + && Objects.equals(this.intensity, flavorType.intensity) + && Objects.equals(this.nuance, flavorType.nuance); + } + + @Override + public int hashCode() + { + return Objects.hash(intensity, nuance, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append("class FlavorType {\n"); + sb.append(" intensity: ").append(toIndentedString(intensity)).append("\n"); + sb.append(" nuance: ").append(toIndentedString(nuance)).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 "); + } + +} diff --git a/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/Foo.java b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/Foo.java new file mode 100644 index 000000000..963d22d89 --- /dev/null +++ b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/Foo.java @@ -0,0 +1,309 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * + * + * 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.openapi.apache.sample.model; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import com.google.common.annotations.Beta; + +/** + * Foo + */ + +@Beta // CHECKSTYLE:OFF +public class Foo implements OneOfWithEnumDiscriminator +// CHECKSTYLE:ON +{ + @JsonProperty( "foo" ) + private String foo; + + /** + * Gets or Sets disc + */ + public enum DiscEnum + { + /** + * The DISC_FOO option of this Foo + */ + DISC_FOO("disc_foo"), + + /** + * The UNKNOWN_DEFAULT_OPEN_API option of this Foo + */ + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + DiscEnum( String value ) + { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() + { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() + { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value + * The String value + * @return The enum value of type Foo + */ + @JsonCreator + @Nonnull + public static DiscEnum fromValue( @Nonnull final String value ) + { + for( DiscEnum b : DiscEnum.values() ) { + if( b.value.equals(value) ) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + @JsonProperty( "disc" ) + private DiscEnum disc; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Default constructor for Foo. + */ + protected Foo() + { + } + + /** + * Set the foo of this {@link Foo} instance and return the same instance. + * + * @param foo + * The foo of this {@link Foo} + * @return The same instance of this {@link Foo} class + */ + @Nonnull + public Foo foo( @Nullable final String foo ) + { + this.foo = foo; + return this; + } + + /** + * Get foo + * + * @return foo The foo of this {@link Foo} instance. + */ + @Nonnull + public String getFoo() + { + return foo; + } + + /** + * Set the foo of this {@link Foo} instance. + * + * @param foo + * The foo of this {@link Foo} + */ + public void setFoo( @Nullable final String foo ) + { + this.foo = foo; + } + + /** + * Set the disc of this {@link Foo} instance and return the same instance. + * + * @param disc + * The disc of this {@link Foo} + * @return The same instance of this {@link Foo} class + */ + @Nonnull + public Foo disc( @Nullable final DiscEnum disc ) + { + this.disc = disc; + return this; + } + + /** + * Get disc + * + * @return disc The disc of this {@link Foo} instance. + */ + @Nonnull + public DiscEnum getDisc() + { + return disc; + } + + /** + * Set the disc of this {@link Foo} instance. + * + * @param disc + * The disc of this {@link Foo} + */ + public void setDisc( @Nullable final DiscEnum disc ) + { + this.disc = disc; + } + + /** + * Get the names of the unrecognizable properties of the {@link Foo}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() + { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link Foo} 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("Foo has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link Foo} instance including unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() + { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if( foo != null ) + declaredFields.put("foo", foo); + if( disc != null ) + declaredFields.put("disc", disc); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link Foo} 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 Foo foo = (Foo) o; + return Objects.equals(this.cloudSdkCustomFields, foo.cloudSdkCustomFields) + && Objects.equals(this.foo, foo.foo) + && Objects.equals(this.disc, foo.disc); + } + + @Override + public int hashCode() + { + return Objects.hash(foo, disc, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append("class Foo {\n"); + sb.append(" foo: ").append(toIndentedString(foo)).append("\n"); + sb.append(" disc: ").append(toIndentedString(disc)).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 "); + } + +} diff --git a/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/OneOf.java b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/OneOf.java new file mode 100644 index 000000000..491aeb64a --- /dev/null +++ b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/OneOf.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * + * + * 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.openapi.apache.sample.model; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.google.common.annotations.Beta; + +/** + * OneOf + */ +@Beta +@JsonTypeInfo( use = JsonTypeInfo.Id.DEDUCTION ) +@JsonSubTypes( { @JsonSubTypes.Type( value = Cola.class ), @JsonSubTypes.Type( value = Fanta.class ), } ) + +public interface OneOf +{ +} diff --git a/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/OneOfWithDiscriminator.java b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/OneOfWithDiscriminator.java new file mode 100644 index 000000000..f71818d41 --- /dev/null +++ b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/OneOfWithDiscriminator.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * + * + * 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.openapi.apache.sample.model; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.google.common.annotations.Beta; + +/** + * OneOfWithDiscriminator + */ +@Beta +@JsonTypeInfo( use = JsonTypeInfo.Id.NAME, property = "sodaType", visible = true ) +@JsonSubTypes( { + @JsonSubTypes.Type( value = Cola.class, name = "Cola" ), + @JsonSubTypes.Type( value = Fanta.class, name = "Fanta" ), } ) + +public interface OneOfWithDiscriminator +{ + Object getSodaType(); +} diff --git a/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/OneOfWithDiscriminatorAndMapping.java b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/OneOfWithDiscriminatorAndMapping.java new file mode 100644 index 000000000..f9742cbd8 --- /dev/null +++ b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/OneOfWithDiscriminatorAndMapping.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * + * + * 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.openapi.apache.sample.model; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.google.common.annotations.Beta; + +/** + * OneOfWithDiscriminatorAndMapping + */ +@Beta +@JsonTypeInfo( use = JsonTypeInfo.Id.NAME, property = "sodaType", visible = true ) +@JsonSubTypes( { + @JsonSubTypes.Type( value = Cola.class, name = "cool_cola" ), + @JsonSubTypes.Type( value = Fanta.class, name = "fancy_fanta" ), } ) + +public interface OneOfWithDiscriminatorAndMapping +{ + Object getSodaType(); +} diff --git a/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/OneOfWithEnumDiscriminator.java b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/OneOfWithEnumDiscriminator.java new file mode 100644 index 000000000..c8657f4cb --- /dev/null +++ b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/OneOfWithEnumDiscriminator.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * + * + * 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.openapi.apache.sample.model; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.google.common.annotations.Beta; + +/** + * OneOfWithEnumDiscriminator + */ +@Beta +@JsonTypeInfo( use = JsonTypeInfo.Id.NAME, property = "disc", visible = true ) +@JsonSubTypes( { + @JsonSubTypes.Type( value = Bar.class, name = "disc_bar" ), + @JsonSubTypes.Type( value = Foo.class, name = "disc_foo" ), } ) + +public interface OneOfWithEnumDiscriminator +{ + Object getDisc(); +} diff --git a/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/Order.java b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/Order.java new file mode 100644 index 000000000..dfae11431 --- /dev/null +++ b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/Order.java @@ -0,0 +1,370 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * + * + * 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.openapi.apache.sample.model; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.annotations.Beta; + +/** + * Order + */ + +@Beta // CHECKSTYLE:OFF +public class Order +// CHECKSTYLE:ON +{ + @JsonProperty( "productId" ) + private Long productId; + + @JsonProperty( "quantity" ) + private Integer quantity; + + @JsonProperty( "totalPrice" ) + private Float totalPrice; + + @JsonProperty( "typelessProperty" ) + private Object typelessProperty = null; + + @JsonProperty( "nullableProperty" ) + private String nullableProperty; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Default constructor for Order. + */ + protected Order() + { + } + + /** + * Set the productId of this {@link Order} instance and return the same instance. + * + * @param productId + * The productId of this {@link Order} + * @return The same instance of this {@link Order} class + */ + @Nonnull + public Order productId( @Nonnull final Long productId ) + { + this.productId = productId; + return this; + } + + /** + * Get productId + * + * @return productId The productId of this {@link Order} instance. + */ + @Nonnull + public Long getProductId() + { + return productId; + } + + /** + * Set the productId of this {@link Order} instance. + * + * @param productId + * The productId of this {@link Order} + */ + public void setProductId( @Nonnull final Long productId ) + { + this.productId = productId; + } + + /** + * Set the quantity of this {@link Order} instance and return the same instance. + * + * @param quantity + * The quantity of this {@link Order} + * @return The same instance of this {@link Order} class + */ + @Nonnull + public Order quantity( @Nonnull final Integer quantity ) + { + this.quantity = quantity; + return this; + } + + /** + * Get quantity + * + * @return quantity The quantity of this {@link Order} instance. + */ + @Nonnull + public Integer getQuantity() + { + return quantity; + } + + /** + * Set the quantity of this {@link Order} instance. + * + * @param quantity + * The quantity of this {@link Order} + */ + public void setQuantity( @Nonnull final Integer quantity ) + { + this.quantity = quantity; + } + + /** + * Set the totalPrice of this {@link Order} instance and return the same instance. + * + * @param totalPrice + * The totalPrice of this {@link Order} + * @return The same instance of this {@link Order} class + */ + @Nonnull + public Order totalPrice( @Nullable final Float totalPrice ) + { + this.totalPrice = totalPrice; + return this; + } + + /** + * Get totalPrice + * + * @return totalPrice The totalPrice of this {@link Order} instance. + */ + @Nonnull + public Float getTotalPrice() + { + return totalPrice; + } + + /** + * Set the totalPrice of this {@link Order} instance. + * + * @param totalPrice + * The totalPrice of this {@link Order} + */ + public void setTotalPrice( @Nullable final Float totalPrice ) + { + this.totalPrice = totalPrice; + } + + /** + * Set the typelessProperty of this {@link Order} instance and return the same instance. + * + * @param typelessProperty + * Some typeless property, interpreted by the generator as nullable by default (because typeless) + * @return The same instance of this {@link Order} class + */ + @Nonnull + public Order typelessProperty( @Nullable final Object typelessProperty ) + { + this.typelessProperty = typelessProperty; + return this; + } + + /** + * Some typeless property, interpreted by the generator as nullable by default (because typeless) + * + * @return typelessProperty The typelessProperty of this {@link Order} instance. + */ + @Nullable + public Object getTypelessProperty() + { + return typelessProperty; + } + + /** + * Set the typelessProperty of this {@link Order} instance. + * + * @param typelessProperty + * Some typeless property, interpreted by the generator as nullable by default (because typeless) + */ + public void setTypelessProperty( @Nullable final Object typelessProperty ) + { + this.typelessProperty = typelessProperty; + } + + /** + * Set the nullableProperty of this {@link Order} instance and return the same instance. + * + * @param nullableProperty + * Some typed property that is deliberately made nullable + * @return The same instance of this {@link Order} class + */ + @Nonnull + public Order nullableProperty( @Nullable final String nullableProperty ) + { + this.nullableProperty = nullableProperty; + return this; + } + + /** + * Some typed property that is deliberately made nullable + * + * @return nullableProperty The nullableProperty of this {@link Order} instance. + */ + @Nullable + public String getNullableProperty() + { + return nullableProperty; + } + + /** + * Set the nullableProperty of this {@link Order} instance. + * + * @param nullableProperty + * Some typed property that is deliberately made nullable + */ + public void setNullableProperty( @Nullable final String nullableProperty ) + { + this.nullableProperty = nullableProperty; + } + + /** + * Get the names of the unrecognizable properties of the {@link Order}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() + { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link Order} 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("Order has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link Order} instance including unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() + { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if( productId != null ) + declaredFields.put("productId", productId); + if( quantity != null ) + declaredFields.put("quantity", quantity); + if( totalPrice != null ) + declaredFields.put("totalPrice", totalPrice); + if( typelessProperty != null ) + declaredFields.put("typelessProperty", typelessProperty); + if( nullableProperty != null ) + declaredFields.put("nullableProperty", nullableProperty); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link Order} 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 Order order = (Order) o; + return Objects.equals(this.cloudSdkCustomFields, order.cloudSdkCustomFields) + && Objects.equals(this.productId, order.productId) + && Objects.equals(this.quantity, order.quantity) + && Objects.equals(this.totalPrice, order.totalPrice) + && Objects.equals(this.typelessProperty, order.typelessProperty) + && Objects.equals(this.nullableProperty, order.nullableProperty); + } + + @Override + public int hashCode() + { + return Objects.hash(productId, quantity, totalPrice, typelessProperty, nullableProperty, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append("class Order {\n"); + sb.append(" productId: ").append(toIndentedString(productId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" totalPrice: ").append(toIndentedString(totalPrice)).append("\n"); + sb.append(" typelessProperty: ").append(toIndentedString(typelessProperty)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).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 "); + } + +} diff --git a/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/OrderWithTimestamp.java b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/OrderWithTimestamp.java new file mode 100644 index 000000000..709b90bb9 --- /dev/null +++ b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/OrderWithTimestamp.java @@ -0,0 +1,415 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * + * + * 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.openapi.apache.sample.model; + +import java.time.OffsetDateTime; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.annotations.Beta; + +/** + * OrderWithTimestamp + */ + +@Beta // CHECKSTYLE:OFF +public class OrderWithTimestamp +// CHECKSTYLE:ON +{ + @JsonProperty( "productId" ) + private Long productId; + + @JsonProperty( "quantity" ) + private Integer quantity; + + @JsonProperty( "totalPrice" ) + private Float totalPrice; + + @JsonProperty( "typelessProperty" ) + private Object typelessProperty; + + @JsonProperty( "nullableProperty" ) + private String nullableProperty; + + @JsonProperty( "timestamp" ) + private OffsetDateTime timestamp; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Default constructor for OrderWithTimestamp. + */ + protected OrderWithTimestamp() + { + } + + /** + * Set the productId of this {@link OrderWithTimestamp} instance and return the same instance. + * + * @param productId + * The productId of this {@link OrderWithTimestamp} + * @return The same instance of this {@link OrderWithTimestamp} class + */ + @Nonnull + public OrderWithTimestamp productId( @Nonnull final Long productId ) + { + this.productId = productId; + return this; + } + + /** + * Get productId + * + * @return productId The productId of this {@link OrderWithTimestamp} instance. + */ + @Nonnull + public Long getProductId() + { + return productId; + } + + /** + * Set the productId of this {@link OrderWithTimestamp} instance. + * + * @param productId + * The productId of this {@link OrderWithTimestamp} + */ + public void setProductId( @Nonnull final Long productId ) + { + this.productId = productId; + } + + /** + * Set the quantity of this {@link OrderWithTimestamp} instance and return the same instance. + * + * @param quantity + * The quantity of this {@link OrderWithTimestamp} + * @return The same instance of this {@link OrderWithTimestamp} class + */ + @Nonnull + public OrderWithTimestamp quantity( @Nonnull final Integer quantity ) + { + this.quantity = quantity; + return this; + } + + /** + * Get quantity + * + * @return quantity The quantity of this {@link OrderWithTimestamp} instance. + */ + @Nonnull + public Integer getQuantity() + { + return quantity; + } + + /** + * Set the quantity of this {@link OrderWithTimestamp} instance. + * + * @param quantity + * The quantity of this {@link OrderWithTimestamp} + */ + public void setQuantity( @Nonnull final Integer quantity ) + { + this.quantity = quantity; + } + + /** + * Set the totalPrice of this {@link OrderWithTimestamp} instance and return the same instance. + * + * @param totalPrice + * The totalPrice of this {@link OrderWithTimestamp} + * @return The same instance of this {@link OrderWithTimestamp} class + */ + @Nonnull + public OrderWithTimestamp totalPrice( @Nullable final Float totalPrice ) + { + this.totalPrice = totalPrice; + return this; + } + + /** + * Get totalPrice + * + * @return totalPrice The totalPrice of this {@link OrderWithTimestamp} instance. + */ + @Nonnull + public Float getTotalPrice() + { + return totalPrice; + } + + /** + * Set the totalPrice of this {@link OrderWithTimestamp} instance. + * + * @param totalPrice + * The totalPrice of this {@link OrderWithTimestamp} + */ + public void setTotalPrice( @Nullable final Float totalPrice ) + { + this.totalPrice = totalPrice; + } + + /** + * Set the typelessProperty of this {@link OrderWithTimestamp} instance and return the same instance. + * + * @param typelessProperty + * Some typeless property, interpreted by the generator as nullable by default (because typeless) + * @return The same instance of this {@link OrderWithTimestamp} class + */ + @Nonnull + public OrderWithTimestamp typelessProperty( @Nullable final Object typelessProperty ) + { + this.typelessProperty = typelessProperty; + return this; + } + + /** + * Some typeless property, interpreted by the generator as nullable by default (because typeless) + * + * @return typelessProperty The typelessProperty of this {@link OrderWithTimestamp} instance. + */ + @Nullable + public Object getTypelessProperty() + { + return typelessProperty; + } + + /** + * Set the typelessProperty of this {@link OrderWithTimestamp} instance. + * + * @param typelessProperty + * Some typeless property, interpreted by the generator as nullable by default (because typeless) + */ + public void setTypelessProperty( @Nullable final Object typelessProperty ) + { + this.typelessProperty = typelessProperty; + } + + /** + * Set the nullableProperty of this {@link OrderWithTimestamp} instance and return the same instance. + * + * @param nullableProperty + * Some typed property that is deliberately made nullable + * @return The same instance of this {@link OrderWithTimestamp} class + */ + @Nonnull + public OrderWithTimestamp nullableProperty( @Nullable final String nullableProperty ) + { + this.nullableProperty = nullableProperty; + return this; + } + + /** + * Some typed property that is deliberately made nullable + * + * @return nullableProperty The nullableProperty of this {@link OrderWithTimestamp} instance. + */ + @Nullable + public String getNullableProperty() + { + return nullableProperty; + } + + /** + * Set the nullableProperty of this {@link OrderWithTimestamp} instance. + * + * @param nullableProperty + * Some typed property that is deliberately made nullable + */ + public void setNullableProperty( @Nullable final String nullableProperty ) + { + this.nullableProperty = nullableProperty; + } + + /** + * Set the timestamp of this {@link OrderWithTimestamp} instance and return the same instance. + * + * @param timestamp + * The timestamp of this {@link OrderWithTimestamp} + * @return The same instance of this {@link OrderWithTimestamp} class + */ + @Nonnull + public OrderWithTimestamp timestamp( @Nullable final OffsetDateTime timestamp ) + { + this.timestamp = timestamp; + return this; + } + + /** + * Get timestamp + * + * @return timestamp The timestamp of this {@link OrderWithTimestamp} instance. + */ + @Nonnull + public OffsetDateTime getTimestamp() + { + return timestamp; + } + + /** + * Set the timestamp of this {@link OrderWithTimestamp} instance. + * + * @param timestamp + * The timestamp of this {@link OrderWithTimestamp} + */ + public void setTimestamp( @Nullable final OffsetDateTime timestamp ) + { + this.timestamp = timestamp; + } + + /** + * Get the names of the unrecognizable properties of the {@link OrderWithTimestamp}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() + { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link OrderWithTimestamp} 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("OrderWithTimestamp has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link OrderWithTimestamp} instance including unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() + { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if( productId != null ) + declaredFields.put("productId", productId); + if( quantity != null ) + declaredFields.put("quantity", quantity); + if( totalPrice != null ) + declaredFields.put("totalPrice", totalPrice); + if( typelessProperty != null ) + declaredFields.put("typelessProperty", typelessProperty); + if( nullableProperty != null ) + declaredFields.put("nullableProperty", nullableProperty); + if( timestamp != null ) + declaredFields.put("timestamp", timestamp); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link OrderWithTimestamp} 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 OrderWithTimestamp orderWithTimestamp = (OrderWithTimestamp) o; + return Objects.equals(this.cloudSdkCustomFields, orderWithTimestamp.cloudSdkCustomFields) + && Objects.equals(this.productId, orderWithTimestamp.productId) + && Objects.equals(this.quantity, orderWithTimestamp.quantity) + && Objects.equals(this.totalPrice, orderWithTimestamp.totalPrice) + && Objects.equals(this.typelessProperty, orderWithTimestamp.typelessProperty) + && Objects.equals(this.nullableProperty, orderWithTimestamp.nullableProperty) + && Objects.equals(this.timestamp, orderWithTimestamp.timestamp); + } + + @Override + public int hashCode() + { + return Objects + .hash(productId, quantity, totalPrice, typelessProperty, nullableProperty, timestamp, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append("class OrderWithTimestamp {\n"); + sb.append(" productId: ").append(toIndentedString(productId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" totalPrice: ").append(toIndentedString(totalPrice)).append("\n"); + sb.append(" typelessProperty: ").append(toIndentedString(typelessProperty)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append(" timestamp: ").append(toIndentedString(timestamp)).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 "); + } + +} diff --git a/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/Soda.java b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/Soda.java new file mode 100644 index 000000000..3f334cdf3 --- /dev/null +++ b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/Soda.java @@ -0,0 +1,448 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * + * + * 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.openapi.apache.sample.model; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import com.google.common.annotations.Beta; + +/** + * Soda + */ + +@Beta // CHECKSTYLE:OFF +public class Soda +// CHECKSTYLE:ON +{ + @JsonProperty( "name" ) + private String name; + + @JsonProperty( "brand" ) + private String brand; + + @JsonProperty( "quantity" ) + private Integer quantity; + + /** + * Gets or Sets packaging + */ + public enum PackagingEnum + { + /** + * The GLASS option of this Soda + */ + GLASS("glass"), + + /** + * The CARTON option of this Soda + */ + CARTON("carton"), + + /** + * The CAN option of this Soda + */ + CAN("can"), + + /** + * The UNKNOWN_DEFAULT_OPEN_API option of this Soda + */ + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + PackagingEnum( String value ) + { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() + { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() + { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value + * The String value + * @return The enum value of type Soda + */ + @JsonCreator + @Nonnull + public static PackagingEnum fromValue( @Nonnull final String value ) + { + for( PackagingEnum b : PackagingEnum.values() ) { + if( b.value.equals(value) ) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + @JsonProperty( "packaging" ) + private PackagingEnum packaging; + + @JsonProperty( "price" ) + private Float price; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Default constructor for Soda. + */ + protected Soda() + { + } + + /** + * Set the name of this {@link Soda} instance and return the same instance. + * + * @param name + * The name of this {@link Soda} + * @return The same instance of this {@link Soda} class + */ + @Nonnull + public Soda name( @Nonnull final String name ) + { + this.name = name; + return this; + } + + /** + * Get name + * + * @return name The name of this {@link Soda} instance. + */ + @Nonnull + public String getName() + { + return name; + } + + /** + * Set the name of this {@link Soda} instance. + * + * @param name + * The name of this {@link Soda} + */ + public void setName( @Nonnull final String name ) + { + this.name = name; + } + + /** + * Set the brand of this {@link Soda} instance and return the same instance. + * + * @param brand + * The brand of this {@link Soda} + * @return The same instance of this {@link Soda} class + */ + @Nonnull + public Soda brand( @Nonnull final String brand ) + { + this.brand = brand; + return this; + } + + /** + * Get brand + * + * @return brand The brand of this {@link Soda} instance. + */ + @Nonnull + public String getBrand() + { + return brand; + } + + /** + * Set the brand of this {@link Soda} instance. + * + * @param brand + * The brand of this {@link Soda} + */ + public void setBrand( @Nonnull final String brand ) + { + this.brand = brand; + } + + /** + * Set the quantity of this {@link Soda} instance and return the same instance. + * + * @param quantity + * The quantity of this {@link Soda} + * @return The same instance of this {@link Soda} class + */ + @Nonnull + public Soda quantity( @Nonnull final Integer quantity ) + { + this.quantity = quantity; + return this; + } + + /** + * Get quantity + * + * @return quantity The quantity of this {@link Soda} instance. + */ + @Nonnull + public Integer getQuantity() + { + return quantity; + } + + /** + * Set the quantity of this {@link Soda} instance. + * + * @param quantity + * The quantity of this {@link Soda} + */ + public void setQuantity( @Nonnull final Integer quantity ) + { + this.quantity = quantity; + } + + /** + * Set the packaging of this {@link Soda} instance and return the same instance. + * + * @param packaging + * The packaging of this {@link Soda} + * @return The same instance of this {@link Soda} class + */ + @Nonnull + public Soda packaging( @Nullable final PackagingEnum packaging ) + { + this.packaging = packaging; + return this; + } + + /** + * Get packaging + * + * @return packaging The packaging of this {@link Soda} instance. + */ + @Nonnull + public PackagingEnum getPackaging() + { + return packaging; + } + + /** + * Set the packaging of this {@link Soda} instance. + * + * @param packaging + * The packaging of this {@link Soda} + */ + public void setPackaging( @Nullable final PackagingEnum packaging ) + { + this.packaging = packaging; + } + + /** + * Set the price of this {@link Soda} instance and return the same instance. + * + * @param price + * The price of this {@link Soda} + * @return The same instance of this {@link Soda} class + */ + @Nonnull + public Soda price( @Nonnull final Float price ) + { + this.price = price; + return this; + } + + /** + * Get price + * + * @return price The price of this {@link Soda} instance. + */ + @Nonnull + public Float getPrice() + { + return price; + } + + /** + * Set the price of this {@link Soda} instance. + * + * @param price + * The price of this {@link Soda} + */ + public void setPrice( @Nonnull final Float price ) + { + this.price = price; + } + + /** + * Get the names of the unrecognizable properties of the {@link Soda}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() + { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link Soda} 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("Soda has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link Soda} instance including unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() + { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if( name != null ) + declaredFields.put("name", name); + if( brand != null ) + declaredFields.put("brand", brand); + if( quantity != null ) + declaredFields.put("quantity", quantity); + if( packaging != null ) + declaredFields.put("packaging", packaging); + if( price != null ) + declaredFields.put("price", price); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link Soda} 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 Soda soda = (Soda) o; + return Objects.equals(this.cloudSdkCustomFields, soda.cloudSdkCustomFields) + && Objects.equals(this.name, soda.name) + && Objects.equals(this.brand, soda.brand) + && Objects.equals(this.quantity, soda.quantity) + && Objects.equals(this.packaging, soda.packaging) + && Objects.equals(this.price, soda.price); + } + + @Override + public int hashCode() + { + return Objects.hash(name, brand, quantity, packaging, price, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append("class Soda {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" brand: ").append(toIndentedString(brand)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" packaging: ").append(toIndentedString(packaging)).append("\n"); + sb.append(" price: ").append(toIndentedString(price)).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 "); + } + +} diff --git a/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/SodaWithId.java b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/SodaWithId.java new file mode 100644 index 000000000..efe0b425e --- /dev/null +++ b/datamodel/openapi/openapi-api-apache-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/apache/sample/model/SodaWithId.java @@ -0,0 +1,491 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * + * + * 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.openapi.apache.sample.model; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import com.google.common.annotations.Beta; + +/** + * SodaWithId + */ + +@Beta // CHECKSTYLE:OFF +public class SodaWithId +// CHECKSTYLE:ON +{ + @JsonProperty( "name" ) + private String name; + + @JsonProperty( "brand" ) + private String brand; + + @JsonProperty( "quantity" ) + private Integer quantity; + + /** + * Gets or Sets packaging + */ + public enum PackagingEnum + { + /** + * The GLASS option of this SodaWithId + */ + GLASS("glass"), + + /** + * The CARTON option of this SodaWithId + */ + CARTON("carton"), + + /** + * The CAN option of this SodaWithId + */ + CAN("can"), + + /** + * The UNKNOWN_DEFAULT_OPEN_API option of this SodaWithId + */ + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + PackagingEnum( String value ) + { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() + { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() + { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value + * The String value + * @return The enum value of type SodaWithId + */ + @JsonCreator + @Nonnull + public static PackagingEnum fromValue( @Nonnull final String value ) + { + for( PackagingEnum b : PackagingEnum.values() ) { + if( b.value.equals(value) ) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + @JsonProperty( "packaging" ) + private PackagingEnum packaging; + + @JsonProperty( "price" ) + private Float price; + + @JsonProperty( "id" ) + private Long id; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Default constructor for SodaWithId. + */ + protected SodaWithId() + { + } + + /** + * Set the name of this {@link SodaWithId} instance and return the same instance. + * + * @param name + * The name of this {@link SodaWithId} + * @return The same instance of this {@link SodaWithId} class + */ + @Nonnull + public SodaWithId name( @Nonnull final String name ) + { + this.name = name; + return this; + } + + /** + * Get name + * + * @return name The name of this {@link SodaWithId} instance. + */ + @Nonnull + public String getName() + { + return name; + } + + /** + * Set the name of this {@link SodaWithId} instance. + * + * @param name + * The name of this {@link SodaWithId} + */ + public void setName( @Nonnull final String name ) + { + this.name = name; + } + + /** + * Set the brand of this {@link SodaWithId} instance and return the same instance. + * + * @param brand + * The brand of this {@link SodaWithId} + * @return The same instance of this {@link SodaWithId} class + */ + @Nonnull + public SodaWithId brand( @Nonnull final String brand ) + { + this.brand = brand; + return this; + } + + /** + * Get brand + * + * @return brand The brand of this {@link SodaWithId} instance. + */ + @Nonnull + public String getBrand() + { + return brand; + } + + /** + * Set the brand of this {@link SodaWithId} instance. + * + * @param brand + * The brand of this {@link SodaWithId} + */ + public void setBrand( @Nonnull final String brand ) + { + this.brand = brand; + } + + /** + * Set the quantity of this {@link SodaWithId} instance and return the same instance. + * + * @param quantity + * The quantity of this {@link SodaWithId} + * @return The same instance of this {@link SodaWithId} class + */ + @Nonnull + public SodaWithId quantity( @Nonnull final Integer quantity ) + { + this.quantity = quantity; + return this; + } + + /** + * Get quantity + * + * @return quantity The quantity of this {@link SodaWithId} instance. + */ + @Nonnull + public Integer getQuantity() + { + return quantity; + } + + /** + * Set the quantity of this {@link SodaWithId} instance. + * + * @param quantity + * The quantity of this {@link SodaWithId} + */ + public void setQuantity( @Nonnull final Integer quantity ) + { + this.quantity = quantity; + } + + /** + * Set the packaging of this {@link SodaWithId} instance and return the same instance. + * + * @param packaging + * The packaging of this {@link SodaWithId} + * @return The same instance of this {@link SodaWithId} class + */ + @Nonnull + public SodaWithId packaging( @Nullable final PackagingEnum packaging ) + { + this.packaging = packaging; + return this; + } + + /** + * Get packaging + * + * @return packaging The packaging of this {@link SodaWithId} instance. + */ + @Nonnull + public PackagingEnum getPackaging() + { + return packaging; + } + + /** + * Set the packaging of this {@link SodaWithId} instance. + * + * @param packaging + * The packaging of this {@link SodaWithId} + */ + public void setPackaging( @Nullable final PackagingEnum packaging ) + { + this.packaging = packaging; + } + + /** + * Set the price of this {@link SodaWithId} instance and return the same instance. + * + * @param price + * The price of this {@link SodaWithId} + * @return The same instance of this {@link SodaWithId} class + */ + @Nonnull + public SodaWithId price( @Nonnull final Float price ) + { + this.price = price; + return this; + } + + /** + * Get price + * + * @return price The price of this {@link SodaWithId} instance. + */ + @Nonnull + public Float getPrice() + { + return price; + } + + /** + * Set the price of this {@link SodaWithId} instance. + * + * @param price + * The price of this {@link SodaWithId} + */ + public void setPrice( @Nonnull final Float price ) + { + this.price = price; + } + + /** + * Set the id of this {@link SodaWithId} instance and return the same instance. + * + * @param id + * The id of this {@link SodaWithId} + * @return The same instance of this {@link SodaWithId} class + */ + @Nonnull + public SodaWithId id( @Nullable final Long id ) + { + this.id = id; + return this; + } + + /** + * Get id + * + * @return id The id of this {@link SodaWithId} instance. + */ + @Nonnull + public Long getId() + { + return id; + } + + /** + * Set the id of this {@link SodaWithId} instance. + * + * @param id + * The id of this {@link SodaWithId} + */ + public void setId( @Nullable final Long id ) + { + this.id = id; + } + + /** + * Get the names of the unrecognizable properties of the {@link SodaWithId}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() + { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link SodaWithId} 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("SodaWithId has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link SodaWithId} instance including unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() + { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if( name != null ) + declaredFields.put("name", name); + if( brand != null ) + declaredFields.put("brand", brand); + if( quantity != null ) + declaredFields.put("quantity", quantity); + if( packaging != null ) + declaredFields.put("packaging", packaging); + if( price != null ) + declaredFields.put("price", price); + if( id != null ) + declaredFields.put("id", id); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link SodaWithId} 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 SodaWithId sodaWithId = (SodaWithId) o; + return Objects.equals(this.cloudSdkCustomFields, sodaWithId.cloudSdkCustomFields) + && Objects.equals(this.name, sodaWithId.name) + && Objects.equals(this.brand, sodaWithId.brand) + && Objects.equals(this.quantity, sodaWithId.quantity) + && Objects.equals(this.packaging, sodaWithId.packaging) + && Objects.equals(this.price, sodaWithId.price) + && Objects.equals(this.id, sodaWithId.id); + } + + @Override + public int hashCode() + { + return Objects.hash(name, brand, quantity, packaging, price, id, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append("class SodaWithId {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" brand: ").append(toIndentedString(brand)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" packaging: ").append(toIndentedString(packaging)).append("\n"); + sb.append(" price: ").append(toIndentedString(price)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).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 "); + } + +} diff --git a/datamodel/openapi/openapi-api-apache-sample/src/main/resources/sodastore.yaml b/datamodel/openapi/openapi-api-apache-sample/src/main/resources/sodastore.yaml new file mode 100644 index 000000000..bf2b80a7f --- /dev/null +++ b/datamodel/openapi/openapi-api-apache-sample/src/main/resources/sodastore.yaml @@ -0,0 +1,307 @@ +openapi: 3.0.3 +info: + title: SodaStore API + version: 1.0.0 + description: API for managing soda products and orders in SodaStore. +tags: + - name: Sodas + description: Everything about our Sodas + - name: user + description: Operations about user + - name: Orders + description: Access to Sodastore orders +components: + securitySchemes: + apiKeyAuth: + type: apiKey + in: header + name: X-API-Key + bearerAuth: + type: http + scheme: bearer + schemas: + Soda: + type: object + required: + - name + - brand + - quantity + - price + properties: + name: + type: string + example: Cola + brand: + type: string + example: Coca-Cola + quantity: + type: integer + format: int32 + example: 100 + packaging: + type: string + enum: + - glass + - carton + - can + nullable: false + price: + type: number + format: float + example: 1.5 + SodaWithId: + allOf: + - $ref: '#/components/schemas/Soda' + - type: object + properties: + id: + type: integer + format: int64 + example: 123 + Order: + type: object + additionalProperties: true + required: + - productId + - quantity + properties: + productId: + type: integer + format: int64 + example: 1 + quantity: + type: integer + format: int32 + example: 2 + totalPrice: + type: number + format: float + example: 3 + typelessProperty: + description: >- + Some typeless property, interpreted by the generator as nullable by + default (because typeless) + nullableProperty: + type: string + description: Some typed property that is deliberately made nullable + nullable: true + OrderWithTimestamp: + allOf: + - $ref: '#/components/schemas/Order' + - type: object + properties: + timestamp: + type: string + format: date-time + OneOfWithDiscriminatorAndMapping: + oneOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + discriminator: + propertyName: sodaType + mapping: + cool_cola: '#/components/schemas/Cola' + fancy_fanta: '#/components/schemas/Fanta' + OneOfWithDiscriminator: + oneOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + discriminator: + propertyName: sodaType + OneOfWithEnumDiscriminator: + oneOf: + - $ref: '#/components/schemas/Foo' + - $ref: '#/components/schemas/Bar' + discriminator: + propertyName: disc + mapping: + disc_foo: '#/components/schemas/Foo' + disc_bar: '#/components/schemas/Bar' + Foo: + type: object + properties: + foo: + type: string + disc: + type: string + enum: + - disc_foo + Bar: + type: object + properties: + bar: + type: string + disc: + type: string + enum: + - disc_bar + OneOf: + oneOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + AnyOf: + anyOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + AllOf: + allOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + Cola: + type: object + properties: + sodaType: + type: string + caffeine: + type: boolean + logo: + oneOf: + - type: string + - type: array + items: + type: array + items: + type: integer + format: int32 + barCode: + oneOf: + - type: array + items: + type: number + - type: string + Fanta: + type: object + properties: + sodaType: + type: string + color: + type: string + flavor: + oneOf: + - type: string + - type: integer + - type: array + items: + $ref: '#/components/schemas/FlavorType' + - $ref: '#/components/schemas/FlavorType' + FlavorType: + type: object + properties: + intensity: + type: integer + description: The intensity of the flavor + nuance: + type: string + description: The nuance of the flavor +paths: + /sodas: + get: + summary: Get all soda products + tags: + - Sodas + security: + - apiKeyAuth: [ ] + responses: + '200': + description: A list of soda products + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/SodaWithId' + put: + summary: Update a specific soda product by ID + tags: + - Sodas + security: + - apiKeyAuth: [ ] + requestBody: + description: The updated soda product + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/SodaWithId' + responses: + '200': + description: The updated soda product + content: + application/json: + schema: + $ref: '#/components/schemas/Soda' + '204': + description: Nothing has changed + '404': + description: Soda product not found + /sodas/{id}: + get: + summary: Get a specific soda product by ID + tags: + - Sodas + security: + - apiKeyAuth: [ ] + parameters: + - name: id + in: path + description: ID of the soda product to retrieve + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: The soda product + content: + application/json: + schema: + $ref: '#/components/schemas/SodaWithId' + '404': + description: Soda product not found + /sodas/download/{id}: + get: + summary: Download soda product data as binary + tags: + - Sodas + parameters: + - name: id + in: path + description: ID of the soda product to download + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: Successful response + content: + application/octet-stream: + schema: + type: string + format: binary + '404': + description: Soda product not found + /orders: + post: + summary: Create a new order + tags: + - Orders + security: + - apiKeyAuth: [ ] + requestBody: + description: The order details + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Order' + responses: + '201': + description: The created order + content: + application/json: + schema: + $ref: '#/components/schemas/Order' +security: + - apiKeyAuth: [ ] + - bearerAuth: [ ] diff --git a/datamodel/openapi/openapi-core/pom.xml b/datamodel/openapi/openapi-core/pom.xml index 603a7db05..46cacdeab 100644 --- a/datamodel/openapi/openapi-core/pom.xml +++ b/datamodel/openapi/openapi-core/pom.xml @@ -59,10 +59,12 @@ org.springframework spring-core + true org.springframework spring-web + true com.fasterxml.jackson.core @@ -98,7 +100,6 @@ org.apache.httpcomponents.core5 httpcore5 - test diff --git a/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/ApiClient.java b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/ApiClient.java new file mode 100644 index 000000000..e8669d7bb --- /dev/null +++ b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/ApiClient.java @@ -0,0 +1,1150 @@ +/* + * Prompt Registry API + * Prompt Storage service for Design time & Runtime prompt templates. + * + * The version of the OpenAPI document: 0.0.1 + * + * + * 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.services.openapi.apache; + +import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Type; +import java.net.URI; +import java.net.URLEncoder; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.charset.UnsupportedCharsetException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.text.DateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.hc.client5.http.cookie.BasicCookieStore; +import org.apache.hc.client5.http.cookie.Cookie; +import org.apache.hc.client5.http.entity.UrlEncodedFormEntity; +import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.client5.http.impl.cookie.BasicClientCookie; +import org.apache.hc.client5.http.protocol.HttpClientContext; +import org.apache.hc.core5.http.ClassicHttpResponse; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.Header; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.core5.http.HttpResponse; +import org.apache.hc.core5.http.HttpStatus; +import org.apache.hc.core5.http.NameValuePair; +import org.apache.hc.core5.http.ParseException; +import org.apache.hc.core5.http.io.HttpClientResponseHandler; +import org.apache.hc.core5.http.io.entity.ByteArrayEntity; +import org.apache.hc.core5.http.io.entity.EntityUtils; +import org.apache.hc.core5.http.io.entity.FileEntity; +import org.apache.hc.core5.http.io.entity.StringEntity; +import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; +import org.apache.hc.core5.http.message.BasicNameValuePair; + +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import com.sap.cloud.sdk.services.openapi.apache.auth.Authentication; + +public class ApiClient +{ + protected Map defaultHeaderMap = new HashMap(); + protected Map defaultCookieMap = new HashMap(); + protected String basePath = "http://localhost"; + protected List servers = + new ArrayList( + Arrays + .asList(new ServerConfiguration("", "No description provided", new HashMap()))); + protected Integer serverIndex = 0; + protected Map serverVariables = null; + protected boolean debugging = false; + protected int connectionTimeout = 0; + + protected CloseableHttpClient httpClient; + protected ObjectMapper objectMapper; + protected String tempFolderPath = null; + + protected Map authentications; + + protected ThreadLocal lastStatusCode = new ThreadLocal<>(); + protected ThreadLocal>> lastResponseHeaders = new ThreadLocal<>(); + + protected DateFormat dateFormat; + + // Methods that can have a request body + protected static List bodyMethods = Arrays.asList("POST", "PUT", "DELETE", "PATCH"); + + public ApiClient( CloseableHttpClient httpClient ) + { + objectMapper = new ObjectMapper(); + objectMapper.setDefaultPropertyInclusion(JsonInclude.Include.NON_NULL); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + objectMapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false); + objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); + objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); + objectMapper.registerModule(new JavaTimeModule()); + objectMapper.registerModule(new RFC3339JavaTimeModule()); + objectMapper.setDateFormat(ApiClient.buildDefaultDateFormat()); + + dateFormat = ApiClient.buildDefaultDateFormat(); + + // Set default User-Agent. + setUserAgent("OpenAPI-Generator/0.0.1/java"); + + // Setup authentications (key: authentication name, value: authentication). + authentications = new HashMap(); + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + + this.httpClient = httpClient; + } + + public ApiClient() + { + this(HttpClients.createDefault()); + } + + public static DateFormat buildDefaultDateFormat() + { + return new RFC3339DateFormat(); + } + + /** + * Returns the current object mapper used for JSON serialization/deserialization. + *

+ * Note: If you make changes to the object mapper, remember to set it back via setObjectMapper in order + * to trigger HTTP client rebuilding. + *

+ * + * @return Object mapper + */ + public ObjectMapper getObjectMapper() + { + return objectMapper; + } + + /** + * Sets the object mapper. + * + * @param objectMapper + * object mapper + * @return API client + */ + public ApiClient setObjectMapper( ObjectMapper objectMapper ) + { + this.objectMapper = objectMapper; + return this; + } + + public CloseableHttpClient getHttpClient() + { + return httpClient; + } + + /** + * Sets the HTTP client. + * + * @param httpClient + * HTTP client + * @return API client + */ + public ApiClient setHttpClient( CloseableHttpClient httpClient ) + { + this.httpClient = httpClient; + return this; + } + + public String getBasePath() + { + return basePath; + } + + /** + * Sets the base path. + * + * @param basePath + * base path + * @return API client + */ + public ApiClient setBasePath( String basePath ) + { + this.basePath = basePath; + this.serverIndex = null; + return this; + } + + public List getServers() + { + return servers; + } + + /** + * Sets the server. + * + * @param servers + * a list of server configuration + * @return API client + */ + public ApiClient setServers( List servers ) + { + this.servers = servers; + return this; + } + + public Integer getServerIndex() + { + return serverIndex; + } + + /** + * Sets the server index. + * + * @param serverIndex + * server index + * @return API client + */ + public ApiClient setServerIndex( Integer serverIndex ) + { + this.serverIndex = serverIndex; + return this; + } + + public Map getServerVariables() + { + return serverVariables; + } + + /** + * Sets the server variables. + * + * @param serverVariables + * server variables + * @return API client + */ + public ApiClient setServerVariables( Map serverVariables ) + { + this.serverVariables = serverVariables; + return this; + } + + /** + * Gets the status code of the previous request + * + * @return Status code + */ + @Deprecated + public int getStatusCode() + { + return lastStatusCode.get(); + } + + /** + * Gets the response headers of the previous request + * + * @return Response headers + */ + @Deprecated + public Map> getResponseHeaders() + { + return lastResponseHeaders.get(); + } + + /** + * Get authentications (key: authentication name, value: authentication). + * + * @return Map of authentication + */ + public Map getAuthentications() + { + return authentications; + } + + /** + * Get authentication for the given name. + * + * @param authName + * The authentication name + * @return The authentication, null if not found + */ + public Authentication getAuthentication( String authName ) + { + return authentications.get(authName); + } + + /** + * The path of temporary folder used to store downloaded files from endpoints with file response. The default value + * is null, i.e. using the system's default temporary folder. + * + * @return Temp folder path + */ + public String getTempFolderPath() + { + return tempFolderPath; + } + + /** + * Set the User-Agent header's value (by adding to the default header map). + * + * @param userAgent + * User agent + * @return API client + */ + public final ApiClient setUserAgent( String userAgent ) + { + addDefaultHeader("User-Agent", userAgent); + return this; + } + + /** + * Set temp folder path + * + * @param tempFolderPath + * Temp folder path + * @return API client + */ + public ApiClient setTempFolderPath( String tempFolderPath ) + { + this.tempFolderPath = tempFolderPath; + return this; + } + + /** + * Add a default header. + * + * @param key + * The header's key + * @param value + * The header's value + * @return API client + */ + public final ApiClient addDefaultHeader( String key, String value ) + { + defaultHeaderMap.put(key, value); + return this; + } + + /** + * Add a default cookie. + * + * @param key + * The cookie's key + * @param value + * The cookie's value + * @return API client + */ + public ApiClient addDefaultCookie( String key, String value ) + { + defaultCookieMap.put(key, value); + return this; + } + + /** + * Check that whether debugging is enabled for this API client. + * + * @return True if debugging is on + */ + public boolean isDebugging() + { + return debugging; + } + + /** + * Enable/disable debugging for this API client. + * + * @param debugging + * To enable (true) or disable (false) debugging + * @return API client + */ + public ApiClient setDebugging( boolean debugging ) + { + // TODO: implement debugging mode + this.debugging = debugging; + return this; + } + + /** + * Connect timeout (in milliseconds). + * + * @return Connection timeout + */ + public int getConnectTimeout() + { + return connectionTimeout; + } + + /** + * Set the connect timeout (in milliseconds). A value of 0 means no timeout, otherwise values must be between 1 and + * {@link Integer#MAX_VALUE}. + * + * @param connectionTimeout + * Connection timeout in milliseconds + * @return API client + */ + public ApiClient setConnectTimeout( int connectionTimeout ) + { + this.connectionTimeout = connectionTimeout; + return this; + } + + /** + * Get the date format used to parse/format date parameters. + * + * @return Date format + */ + public DateFormat getDateFormat() + { + return dateFormat; + } + + /** + * Set the date format used to parse/format date parameters. + * + * @param dateFormat + * Date format + * @return API client + */ + public ApiClient setDateFormat( DateFormat dateFormat ) + { + this.dateFormat = dateFormat; + // Also set the date format for model (de)serialization with Date properties. + this.objectMapper.setDateFormat((DateFormat) dateFormat.clone()); + return this; + } + + /** + * Parse the given string into Date object. + * + * @param str + * String + * @return Date + */ + public Date parseDate( String str ) + { + try { + return dateFormat.parse(str); + } + catch( java.text.ParseException e ) { + throw new RuntimeException(e); + } + } + + /** + * Format the given Date object into string. + * + * @param date + * Date + * @return Date in string format + */ + public String formatDate( Date date ) + { + return dateFormat.format(date); + } + + /** + * Format the given parameter object into string. + * + * @param param + * Object + * @return Object in string format + */ + public String parameterToString( Object param ) + { + if( param == null ) { + return ""; + } else if( param instanceof Date ) { + return formatDate((Date) param); + } else if( param instanceof Collection ) { + StringBuilder b = new StringBuilder(); + for( Object o : (Collection) param ) { + if( b.length() > 0 ) { + b.append(','); + } + b.append(String.valueOf(o)); + } + return b.toString(); + } else { + return String.valueOf(param); + } + } + + /** + * Formats the specified query parameter to a list containing a single {@code Pair} object. + * + * Note that {@code value} must not be a collection. + * + * @param name + * The name of the parameter. + * @param value + * The value of the parameter. + * @return A list containing a single {@code Pair} object. + */ + public List parameterToPair( String name, Object value ) + { + List params = new ArrayList(); + + // preconditions + if( name == null || name.isEmpty() || value == null || value instanceof Collection ) { + return params; + } + + params.add(new Pair(name, escapeString(parameterToString(value)))); + return params; + } + + /** + * Formats the specified collection query parameters to a list of {@code Pair} objects. + * + * Note that the values of each of the returned Pair objects are percent-encoded. + * + * @param collectionFormat + * The collection format of the parameter. + * @param name + * The name of the parameter. + * @param value + * The value of the parameter. + * @return A list of {@code Pair} objects. + */ + public List parameterToPairs( String collectionFormat, String name, Collection value ) + { + List params = new ArrayList(); + + // preconditions + if( name == null || name.isEmpty() || value == null || value.isEmpty() ) { + return params; + } + + // create the params based on the collection format + if( "multi".equals(collectionFormat) ) { + for( Object item : value ) { + params.add(new Pair(name, escapeString(parameterToString(item)))); + } + return params; + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + // escape all delimiters except commas, which are URI reserved + // characters + if( "ssv".equals(collectionFormat) ) { + delimiter = escapeString(" "); + } else if( "tsv".equals(collectionFormat) ) { + delimiter = escapeString("\t"); + } else if( "pipes".equals(collectionFormat) ) { + delimiter = escapeString("|"); + } + + StringBuilder sb = new StringBuilder(); + for( Object item : value ) { + sb.append(delimiter); + sb.append(escapeString(parameterToString(item))); + } + + params.add(new Pair(name, sb.substring(delimiter.length()))); + + return params; + } + + /** + * Check if the given MIME is a JSON MIME. JSON MIME examples: application/json application/json; charset=UTF8 + * APPLICATION/JSON application/vnd.company+json + * + * @param mime + * MIME + * @return True if MIME type is boolean + */ + public boolean isJsonMime( String mime ) + { + String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"; + return mime != null && (mime.matches(jsonMime) || mime.equals("*/*")); + } + + /** + * Select the Accept header's value from the given accepts array: if JSON exists in the given array, use it; + * otherwise use all of them (joining into a string) + * + * @param accepts + * The accepts array to select from + * @return The Accept header to use. If the given array is empty, null will be returned (not to set the Accept + * header explicitly). + */ + public String selectHeaderAccept( String[] accepts ) + { + if( accepts.length == 0 ) { + return null; + } + for( String accept : accepts ) { + if( isJsonMime(accept) ) { + return accept; + } + } + return StringUtil.join(accepts, ","); + } + + /** + * Select the Content-Type header's value from the given array: if JSON exists in the given array, use it; otherwise + * use the first one of the array. + * + * @param contentTypes + * The Content-Type array to select from + * @return The Content-Type header to use. If the given array is empty, or matches "any", JSON will be used. + */ + public String selectHeaderContentType( String[] contentTypes ) + { + if( contentTypes.length == 0 || contentTypes[0].equals("*/*") ) { + return "application/json"; + } + for( String contentType : contentTypes ) { + if( isJsonMime(contentType) ) { + return contentType; + } + } + return contentTypes[0]; + } + + /** + * Escape the given string to be used as URL query value. + * + * @param str + * String + * @return Escaped string + */ + public String escapeString( String str ) + { + try { + return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20"); + } + catch( UnsupportedEncodingException e ) { + return str; + } + } + + /** + * Transforms response headers into map. + * + * @param headers + * HTTP headers + * @return a map of string array + */ + protected Map> transformResponseHeaders( Header[] headers ) + { + Map> headersMap = new HashMap<>(); + for( Header header : headers ) { + List valuesList = headersMap.get(header.getName()); + if( valuesList != null ) { + valuesList.add(header.getValue()); + } else { + valuesList = new ArrayList<>(); + valuesList.add(header.getValue()); + headersMap.put(header.getName(), valuesList); + } + } + return headersMap; + } + + /** + * Parse content type object from header value + */ + protected ContentType getContentType( String headerValue ) + throws ApiException + { + try { + return ContentType.parse(headerValue); + } + catch( UnsupportedCharsetException e ) { + throw new ApiException("Could not parse content type " + headerValue); + } + } + + /** + * Get content type of a response or null if one was not provided + */ + protected String getResponseMimeType( HttpResponse response ) + throws ApiException + { + Header contentTypeHeader = response.getFirstHeader("Content-Type"); + if( contentTypeHeader != null ) { + return getContentType(contentTypeHeader.getValue()).getMimeType(); + } + return null; + } + + /** + * Serialize the given Java object into string according the given Content-Type (only JSON is supported for now). + * + * @param obj + * Object + * @param contentType + * Content type + * @param formParams + * Form parameters + * @return Object + * @throws ApiException + * API exception + */ + public HttpEntity serialize( Object obj, Map formParams, ContentType contentType ) + throws ApiException + { + String mimeType = contentType.getMimeType(); + if( isJsonMime(mimeType) ) { + try { + return new StringEntity( + objectMapper.writeValueAsString(obj), + contentType.withCharset(StandardCharsets.UTF_8)); + } + catch( JsonProcessingException e ) { + throw new ApiException(e); + } + } else if( mimeType.equals(ContentType.MULTIPART_FORM_DATA.getMimeType()) ) { + MultipartEntityBuilder multiPartBuilder = MultipartEntityBuilder.create(); + for( Entry paramEntry : formParams.entrySet() ) { + Object value = paramEntry.getValue(); + if( value instanceof File ) { + multiPartBuilder.addBinaryBody(paramEntry.getKey(), (File) value); + } else if( value instanceof byte[] ) { + multiPartBuilder.addBinaryBody(paramEntry.getKey(), (byte[]) value); + } else { + Charset charset = contentType.getCharset(); + if( charset != null ) { + ContentType customContentType = + ContentType.create(ContentType.TEXT_PLAIN.getMimeType(), charset); + multiPartBuilder + .addTextBody( + paramEntry.getKey(), + parameterToString(paramEntry.getValue()), + customContentType); + } else { + multiPartBuilder.addTextBody(paramEntry.getKey(), parameterToString(paramEntry.getValue())); + } + } + } + return multiPartBuilder.build(); + } else if( mimeType.equals(ContentType.APPLICATION_FORM_URLENCODED.getMimeType()) ) { + List formValues = new ArrayList<>(); + for( Entry paramEntry : formParams.entrySet() ) { + formValues.add(new BasicNameValuePair(paramEntry.getKey(), parameterToString(paramEntry.getValue()))); + } + return new UrlEncodedFormEntity(formValues, contentType.getCharset()); + } else { + // Handle files with unknown content type + if( obj instanceof File ) { + return new FileEntity((File) obj, contentType); + } else if( obj instanceof byte[] ) { + return new ByteArrayEntity((byte[]) obj, contentType); + } + throw new ApiException("Serialization for content type '" + contentType + "' not supported"); + } + } + + /** + * Deserialize response body to Java object according to the Content-Type. + * + * @param + * Type + * @param response + * Response + * @param valueType + * Return type + * @return Deserialized object + * @throws ApiException + * API exception + * @throws IOException + * IO exception + */ + @SuppressWarnings( "unchecked" ) + public T deserialize( ClassicHttpResponse response, TypeReference valueType ) + throws ApiException, + IOException, + ParseException + { + if( valueType == null ) { + return null; + } + HttpEntity entity = response.getEntity(); + Type valueRawType = valueType.getType(); + if( valueRawType.equals(byte[].class) ) { + return (T) EntityUtils.toByteArray(entity); + } else if( valueRawType.equals(File.class) ) { + return (T) downloadFileFromResponse(response); + } + String mimeType = getResponseMimeType(response); + if( mimeType == null || isJsonMime(mimeType) ) { + // Assume json if no mime type + // convert input stream to string + String content = EntityUtils.toString(entity); + + if( "".equals(content) ) { // returns null for empty body + return null; + } + + return objectMapper.readValue(content, valueType); + } else if( mimeType.toLowerCase().startsWith("text/") ) { + // convert input stream to string + return (T) EntityUtils.toString(entity); + } else { + Map> responseHeaders = transformResponseHeaders(response.getHeaders()); + throw new ApiException( + "Deserialization for content type '" + mimeType + "' not supported for type '" + valueType + "'", + response.getCode(), + responseHeaders, + EntityUtils.toString(entity)); + } + } + + protected File downloadFileFromResponse( ClassicHttpResponse response ) + throws IOException + { + Header contentDispositionHeader = response.getFirstHeader("Content-Disposition"); + String contentDisposition = contentDispositionHeader == null ? null : contentDispositionHeader.getValue(); + File file = prepareDownloadFile(contentDisposition); + Files.copy(response.getEntity().getContent(), file.toPath(), StandardCopyOption.REPLACE_EXISTING); + return file; + } + + protected File prepareDownloadFile( String contentDisposition ) + throws IOException + { + String filename = null; + if( contentDisposition != null && !"".equals(contentDisposition) ) { + // Get filename from the Content-Disposition header. + Pattern pattern = Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?"); + Matcher matcher = pattern.matcher(contentDisposition); + if( matcher.find() ) + filename = matcher.group(1); + } + + String prefix; + String suffix = null; + if( filename == null ) { + prefix = "download-"; + suffix = ""; + } else { + int pos = filename.lastIndexOf('.'); + if( pos == -1 ) { + prefix = filename + "-"; + } else { + prefix = filename.substring(0, pos) + "-"; + suffix = filename.substring(pos); + } + // Files.createTempFile requires the prefix to be at least three characters long + if( prefix.length() < 3 ) + prefix = "download-"; + } + + if( tempFolderPath == null ) + return Files.createTempFile(prefix, suffix).toFile(); + else + return Files.createTempFile(Paths.get(tempFolderPath), prefix, suffix).toFile(); + } + + /** + * Returns the URL of the client as defined by the server (if exists) or the base path. + * + * @return The URL for the client. + */ + public String getBaseURL() + { + String baseURL; + if( serverIndex != null ) { + if( serverIndex < 0 || serverIndex >= servers.size() ) { + throw new ArrayIndexOutOfBoundsException( + String + .format( + Locale.ROOT, + "Invalid index %d when selecting the host settings. Must be less than %d", + serverIndex, + servers.size())); + } + baseURL = servers.get(serverIndex).URL(serverVariables); + } else { + baseURL = basePath; + } + return baseURL; + } + + /** + * Build full URL by concatenating base URL, the given sub path and query parameters. + * + * @param path + * The sub path + * @param queryParams + * The query parameters + * @param collectionQueryParams + * The collection query parameters + * @param urlQueryDeepObject + * URL query string of the deep object parameters + * @return The full URL + */ + protected + String + buildUrl( String path, List queryParams, List collectionQueryParams, String urlQueryDeepObject ) + { + String baseURL = getBaseURL(); + + final StringBuilder url = new StringBuilder(); + url.append(baseURL).append(path); + + if( queryParams != null && !queryParams.isEmpty() ) { + // support (constant) query string in `path`, e.g. "/posts?draft=1" + String prefix = path.contains("?") ? "&" : "?"; + for( Pair param : queryParams ) { + if( param.getValue() != null ) { + if( prefix != null ) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + // query parameter value already escaped as part of parameterToPair + url.append(escapeString(param.getName())).append("=").append(value); + } + } + } + + if( collectionQueryParams != null && !collectionQueryParams.isEmpty() ) { + String prefix = url.toString().contains("?") ? "&" : "?"; + for( Pair param : collectionQueryParams ) { + if( param.getValue() != null ) { + if( prefix != null ) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + // collection query parameter value already escaped as part of parameterToPairs + url.append(escapeString(param.getName())).append("=").append(value); + } + } + } + + if( urlQueryDeepObject != null && urlQueryDeepObject.length() > 0 ) { + url.append(url.toString().contains("?") ? "&" : "?"); + url.append(urlQueryDeepObject); + } + + return url.toString(); + } + + protected boolean isSuccessfulStatus( int statusCode ) + { + return statusCode >= 200 && statusCode < 300; + } + + protected boolean isBodyAllowed( String method ) + { + return bodyMethods.contains(method); + } + + protected Cookie buildCookie( String key, String value, URI uri ) + { + BasicClientCookie cookie = new BasicClientCookie(key, value); + cookie.setDomain(uri.getHost()); + cookie.setPath("/"); + return cookie; + } + + /** + * Creates an HttpClientResponseHandler for processing HTTP responses. Wraps checked exceptions (ParseException, + * ApiException) as IOException since the handler interface only allows IOException to be thrown. + * + * @param + * Type + * @param returnType + * Return type + * @return HttpClientResponseHandler instance + */ + protected HttpClientResponseHandler createResponseHandler( TypeReference returnType ) + { + return response -> { + try { + return processResponse(response, returnType); + } + catch( ParseException | ApiException e ) { + // Wrap exceptions as IOException since handler can only throw IOException + throw new IOException("Failed to process response: " + e.getMessage(), e); + } + }; + } + + protected T processResponse( ClassicHttpResponse response, TypeReference returnType ) + throws ApiException, + IOException, + ParseException + { + int statusCode = response.getCode(); + lastStatusCode.set(statusCode); + if( statusCode == HttpStatus.SC_NO_CONTENT ) { + return null; + } + + Map> responseHeaders = transformResponseHeaders(response.getHeaders()); + lastResponseHeaders.set(responseHeaders); + + if( isSuccessfulStatus(statusCode) ) { + return this.deserialize(response, returnType); + } else { + String message = EntityUtils.toString(response.getEntity()); + throw new ApiException(message, statusCode, responseHeaders, message); + } + } + + /** + * Invoke API by sending HTTP request with the given options. + * + * @param + * Type + * @param path + * The sub-path of the HTTP URL + * @param method + * The request method, one of "GET", "POST", "PUT", and "DELETE" + * @param queryParams + * The query parameters + * @param collectionQueryParams + * The collection query parameters + * @param urlQueryDeepObject + * A URL query string for deep object parameters + * @param body + * The request body object - if it is not binary, otherwise null + * @param headerParams + * The header parameters + * @param cookieParams + * The cookie parameters + * @param formParams + * The form parameters + * @param accept + * The request's Accept header + * @param contentType + * The request's Content-Type header + * @param authNames + * The authentications to apply + * @param returnType + * Return type + * @return The response body in type of string + * @throws ApiException + * API exception + */ + public T invokeAPI( + String path, + String method, + List queryParams, + List collectionQueryParams, + String urlQueryDeepObject, + Object body, + Map headerParams, + Map cookieParams, + Map formParams, + String accept, + String contentType, + String[] authNames, + TypeReference returnType ) + throws ApiException + { + if( body != null && !formParams.isEmpty() ) { + throw new ApiException("Cannot have body and form params"); + } + + updateParamsForAuth(authNames, queryParams, headerParams, cookieParams); + final String url = buildUrl(path, queryParams, collectionQueryParams, urlQueryDeepObject); + + ClassicRequestBuilder builder = ClassicRequestBuilder.create(method); + builder.setUri(url); + + if( accept != null ) { + builder.addHeader("Accept", accept); + } + for( Entry keyValue : headerParams.entrySet() ) { + builder.addHeader(keyValue.getKey(), keyValue.getValue()); + } + for( Map.Entry keyValue : defaultHeaderMap.entrySet() ) { + if( !headerParams.containsKey(keyValue.getKey()) ) { + builder.addHeader(keyValue.getKey(), keyValue.getValue()); + } + } + + BasicCookieStore store = new BasicCookieStore(); + for( Entry keyValue : cookieParams.entrySet() ) { + store.addCookie(buildCookie(keyValue.getKey(), keyValue.getValue(), builder.getUri())); + } + for( Entry keyValue : defaultCookieMap.entrySet() ) { + if( !cookieParams.containsKey(keyValue.getKey()) ) { + store.addCookie(buildCookie(keyValue.getKey(), keyValue.getValue(), builder.getUri())); + } + } + + HttpClientContext context = HttpClientContext.create(); + context.setCookieStore(store); + + ContentType contentTypeObj = getContentType(contentType); + if( body != null || !formParams.isEmpty() ) { + if( isBodyAllowed(method) ) { + // Add entity if we have content and a valid method + builder.setEntity(serialize(body, formParams, contentTypeObj)); + } else { + throw new ApiException("method " + method + " does not support a request body"); + } + } else { + // for empty body + builder.setEntity(new StringEntity("", contentTypeObj)); + } + + try { + HttpClientResponseHandler responseHandler = createResponseHandler(returnType); + return httpClient.execute(builder.build(), context, responseHandler); + } + catch( IOException e ) { + throw new ApiException(e); + } + } + + /** + * Update query and header parameters based on authentication settings. + * + * @param authNames + * The authentications to apply + * @param queryParams + * Query parameters + * @param headerParams + * Header parameters + * @param cookieParams + * Cookie parameters + */ + protected void updateParamsForAuth( + String[] authNames, + List queryParams, + Map headerParams, + Map cookieParams ) + { + for( String authName : authNames ) { + Authentication auth = authentications.get(authName); + if( auth == null ) + throw new RuntimeException("Authentication undefined: " + authName); + auth.applyToParams(queryParams, headerParams, cookieParams); + } + } +} diff --git a/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/ApiException.java b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/ApiException.java new file mode 100644 index 000000000..b8ab4534c --- /dev/null +++ b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/ApiException.java @@ -0,0 +1,129 @@ +/* + * Prompt Registry API + * Prompt Storage service for Design time & Runtime prompt templates. + * + * The version of the OpenAPI document: 0.0.1 + * + * + * 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.services.openapi.apache; + +import java.util.List; +import java.util.Map; + +public class ApiException extends Exception +{ + private static final long serialVersionUID = 1L; + + private int code = 0; + private transient Map> responseHeaders = null; + private String responseBody = null; + + public ApiException() + { + } + + public ApiException( Throwable throwable ) + { + super(throwable); + } + + public ApiException( String message ) + { + super(message); + } + + public ApiException( + String message, + Throwable throwable, + int code, + Map> responseHeaders, + String responseBody ) + { + super(message, throwable); + this.code = code; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + public ApiException( String message, int code, Map> responseHeaders, String responseBody ) + { + this(message, (Throwable) null, code, responseHeaders, responseBody); + } + + public ApiException( String message, Throwable throwable, int code, Map> responseHeaders ) + { + this(message, throwable, code, responseHeaders, null); + } + + public ApiException( int code, Map> responseHeaders, String responseBody ) + { + this( + "Response Code: " + code + " Response Body: " + responseBody, + (Throwable) null, + code, + responseHeaders, + responseBody); + } + + public ApiException( int code, String message ) + { + super(message); + this.code = code; + } + + public ApiException( int code, String message, Map> responseHeaders, String responseBody ) + { + this(code, message); + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + * Get the HTTP status code. + * + * @return HTTP status code + */ + public int getCode() + { + return code; + } + + /** + * Get the HTTP response headers. + * + * @return A map of list of string + */ + public Map> getResponseHeaders() + { + return responseHeaders; + } + + /** + * Get the HTTP response body. + * + * @return Response body in the form of string + */ + public String getResponseBody() + { + return responseBody; + } + + @Override + public String toString() + { + return "ApiException{" + + "code=" + + code + + ", responseHeaders=" + + responseHeaders + + ", responseBody='" + + responseBody + + '\'' + + '}'; + } +} diff --git a/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/BaseApi.java b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/BaseApi.java new file mode 100644 index 000000000..7203f9e7f --- /dev/null +++ b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/BaseApi.java @@ -0,0 +1,181 @@ +/* + * Prompt Registry API + * Prompt Storage service for Design time & Runtime prompt templates. + * + * The version of the OpenAPI document: 0.0.1 + * + * + * 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.services.openapi.apache; + +import java.util.Collections; +import java.util.Map; + +import com.fasterxml.jackson.core.type.TypeReference; + +public abstract class BaseApi +{ + + protected ApiClient apiClient; + + public BaseApi() + { + this(Configuration.getDefaultApiClient()); + } + + public BaseApi( ApiClient apiClient ) + { + this.apiClient = apiClient; + } + + public ApiClient getApiClient() + { + return apiClient; + } + + public void setApiClient( ApiClient apiClient ) + { + this.apiClient = apiClient; + } + + /** + * Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests. + * + * @param url + * The URL for the request, either full URL or only the path. + * @param method + * The HTTP method for the request. + * @throws ApiException + * if fails to make API call. + */ + public void invokeAPI( String url, String method ) + throws ApiException + { + invokeAPI(url, method, null, null, Collections.emptyMap()); + } + + /** + * Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests. + * + * @param url + * The URL for the request, either full URL or only the path. + * @param method + * The HTTP method for the request. + * @param additionalHeaders + * Additional headers for the request. + * @throws ApiException + * if fails to make API call. + */ + public void invokeAPI( String url, String method, Map additionalHeaders ) + throws ApiException + { + invokeAPI(url, method, null, null, additionalHeaders); + } + + /** + * Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests. + * + * @param url + * The URL for the request, either full URL or only the path. + * @param method + * The HTTP method for the request. + * @param request + * The request object. + * @throws ApiException + * if fails to make API call. + */ + public void invokeAPI( String url, String method, Object request ) + throws ApiException + { + invokeAPI(url, method, request, null, Collections.emptyMap()); + } + + /** + * Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests. + * + * @param url + * The URL for the request, either full URL or only the path. + * @param method + * The HTTP method for the request. + * @param request + * The request object. + * @param additionalHeaders + * Additional headers for the request. + * @throws ApiException + * if fails to make API call. + */ + public void invokeAPI( String url, String method, Object request, Map additionalHeaders ) + throws ApiException + { + invokeAPI(url, method, request, null, additionalHeaders); + } + + /** + * Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests. + * + * @param url + * The URL for the request, either full URL or only the path. + * @param method + * The HTTP method for the request. + * @param returnType + * The return type. + * @return The API response in the specified type. + * @throws ApiException + * if fails to make API call. + */ + public T invokeAPI( String url, String method, TypeReference returnType ) + throws ApiException + { + return invokeAPI(url, method, null, returnType, Collections.emptyMap()); + } + + /** + * Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests. + * + * @param url + * The URL for the request, either full URL or only the path. + * @param method + * The HTTP method for the request. + * @param request + * The request object. + * @param returnType + * The return type. + * @return The API response in the specified type. + * @throws ApiException + * if fails to make API call. + */ + public T invokeAPI( String url, String method, Object request, TypeReference returnType ) + throws ApiException + { + return invokeAPI(url, method, request, returnType, Collections.emptyMap()); + } + + /** + * Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests. + * + * @param url + * The URL for the request, either full URL or only the path. + * @param method + * The HTTP method for the request. + * @param request + * The request object. + * @param returnType + * The return type. + * @param additionalHeaders + * Additional headers for the request. + * @return The API response in the specified type. + * @throws ApiException + * if fails to make API call. + */ + public abstract T invokeAPI( + String url, + String method, + Object request, + TypeReference returnType, + Map additionalHeaders ) + throws ApiException; +} diff --git a/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/Configuration.java b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/Configuration.java new file mode 100644 index 000000000..8978044d7 --- /dev/null +++ b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/Configuration.java @@ -0,0 +1,67 @@ +/* + * Prompt Registry API + * Prompt Storage service for Design time & Runtime prompt templates. + * + * The version of the OpenAPI document: 0.0.1 + * + * + * 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.services.openapi.apache; + +import java.util.Objects; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Supplier; + +public class Configuration +{ + public static final String VERSION = "0.0.1"; + + private static final AtomicReference defaultApiClient = new AtomicReference<>(); + private static volatile Supplier apiClientFactory = ApiClient::new; + + /** + * Get the default API client, which would be used when creating API instances without providing an API client. + * + * @return Default API client + */ + public static ApiClient getDefaultApiClient() + { + ApiClient client = defaultApiClient.get(); + if( client == null ) { + client = defaultApiClient.updateAndGet(val -> { + if( val != null ) { // changed by another thread + return val; + } + return apiClientFactory.get(); + }); + } + return client; + } + + /** + * Set the default API client, which would be used when creating API instances without providing an API client. + * + * @param apiClient + * API client + */ + public static void setDefaultApiClient( ApiClient apiClient ) + { + defaultApiClient.set(apiClient); + } + + /** + * set the callback used to create new ApiClient objects + */ + public static void setApiClientFactory( Supplier factory ) + { + apiClientFactory = Objects.requireNonNull(factory); + } + + private Configuration() + { + } +} diff --git a/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/Pair.java b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/Pair.java new file mode 100644 index 000000000..c7e9a9711 --- /dev/null +++ b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/Pair.java @@ -0,0 +1,40 @@ +/* + * Prompt Registry API + * Prompt Storage service for Design time & Runtime prompt templates. + * + * The version of the OpenAPI document: 0.0.1 + * + * + * 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.services.openapi.apache; + +public class Pair +{ + private final String name; + private final String value; + + public Pair( String name, String value ) + { + this.name = isValidString(name) ? name : ""; + this.value = isValidString(value) ? value : ""; + } + + public String getName() + { + return this.name; + } + + public String getValue() + { + return this.value; + } + + private static boolean isValidString( String arg ) + { + return arg != null; + } +} diff --git a/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/RFC3339DateFormat.java b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/RFC3339DateFormat.java new file mode 100644 index 000000000..8d841d0bd --- /dev/null +++ b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/RFC3339DateFormat.java @@ -0,0 +1,61 @@ +/* + * Prompt Registry API + * Prompt Storage service for Design time & Runtime prompt templates. + * + * The version of the OpenAPI document: 0.0.1 + * + * + * 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.services.openapi.apache; + +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.text.FieldPosition; +import java.text.ParsePosition; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.TimeZone; + +import com.fasterxml.jackson.databind.util.StdDateFormat; + +public class RFC3339DateFormat extends DateFormat +{ + private static final long serialVersionUID = 1L; + private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC"); + + private final StdDateFormat fmt = new StdDateFormat().withTimeZone(TIMEZONE_Z).withColonInTimeZone(true); + + public RFC3339DateFormat() + { + this.calendar = new GregorianCalendar(); + this.numberFormat = new DecimalFormat(); + } + + @Override + public Date parse( String source ) + { + return parse(source, new ParsePosition(0)); + } + + @Override + public Date parse( String source, ParsePosition pos ) + { + return fmt.parse(source, pos); + } + + @Override + public StringBuffer format( Date date, StringBuffer toAppendTo, FieldPosition fieldPosition ) + { + return fmt.format(date, toAppendTo, fieldPosition); + } + + @Override + public Object clone() + { + return super.clone(); + } +} diff --git a/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/RFC3339InstantDeserializer.java b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/RFC3339InstantDeserializer.java new file mode 100644 index 000000000..ae5560a88 --- /dev/null +++ b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/RFC3339InstantDeserializer.java @@ -0,0 +1,108 @@ +/* + * Prompt Registry API + * Prompt Storage service for Design time & Runtime prompt templates. + * + * The version of the OpenAPI document: 0.0.1 + * + * + * 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.services.openapi.apache; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +public class RFC3339InstantDeserializer extends InstantDeserializer +{ + private static final long serialVersionUID = 1L; + private final static boolean DEFAULT_NORMALIZE_ZONE_ID = + JavaTimeFeature.NORMALIZE_DESERIALIZED_ZONE_ID.enabledByDefault(); + private final static boolean DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS = + JavaTimeFeature.ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS.enabledByDefault(); + + public static final RFC3339InstantDeserializer INSTANT = + new RFC3339InstantDeserializer<>( + Instant.class, + DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli(a.value), + a -> Instant.ofEpochSecond(a.integer, a.fraction), + null, + true, // yes, replace zero offset with Z + DEFAULT_NORMALIZE_ZONE_ID, + DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = + new RFC3339InstantDeserializer<>( + OffsetDateTime.class, + DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId), + a -> OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId), + ( + d, + z ) -> (d.isEqual(OffsetDateTime.MIN) || d.isEqual(OffsetDateTime.MAX) + ? d + : d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime()))), + true, // yes, replace zero offset with Z + DEFAULT_NORMALIZE_ZONE_ID, + DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = + new RFC3339InstantDeserializer<>( + ZonedDateTime.class, + DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId), + a -> ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId), + ZonedDateTime::withZoneSameInstant, + false, // keep zero offset and Z separate since zones explicitly supported + DEFAULT_NORMALIZE_ZONE_ID, + DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ, + boolean normalizeZoneId, + boolean readNumericStringsAsTimestamp ) + { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ, + normalizeZoneId, + readNumericStringsAsTimestamp); + } + + @Override + protected T _fromString( JsonParser p, DeserializationContext ctxt, String string0 ) + throws IOException + { + return super._fromString(p, ctxt, string0.replace(' ', 'T')); + } +} diff --git a/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/RFC3339JavaTimeModule.java b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/RFC3339JavaTimeModule.java new file mode 100644 index 000000000..ce882de8c --- /dev/null +++ b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/RFC3339JavaTimeModule.java @@ -0,0 +1,40 @@ +/* + * Prompt Registry API + * Prompt Storage service for Design time & Runtime prompt templates. + * + * The version of the OpenAPI document: 0.0.1 + * + * + * 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.services.openapi.apache; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +public class RFC3339JavaTimeModule extends SimpleModule +{ + private static final long serialVersionUID = 1L; + + public RFC3339JavaTimeModule() + { + super("RFC3339JavaTimeModule"); + } + + @Override + public void setupModule( SetupContext context ) + { + super.setupModule(context); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } + +} diff --git a/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/ServerConfiguration.java b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/ServerConfiguration.java new file mode 100644 index 000000000..3c91ed3b8 --- /dev/null +++ b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/ServerConfiguration.java @@ -0,0 +1,80 @@ +/* + * Prompt Registry API + * Prompt Storage service for Design time & Runtime prompt templates. + * + * The version of the OpenAPI document: 0.0.1 + * + * + * 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.services.openapi.apache; + +import java.util.Map; + +/** + * Representing a Server configuration. + */ +public class ServerConfiguration +{ + public String URL; + public String description; + public Map variables; + + /** + * @param URL + * A URL to the target host. + * @param description + * A description of the host designated by the URL. + * @param variables + * A map between a variable name and its value. The value is used for substitution in the server's URL + * template. + */ + public ServerConfiguration( String URL, String description, Map variables ) + { + this.URL = URL; + this.description = description; + this.variables = variables; + } + + /** + * Format URL template using given variables. + * + * @param variables + * A map between a variable name and its value. + * @return Formatted URL. + */ + public String URL( Map variables ) + { + String url = this.URL; + + // go through variables and replace placeholders + for( Map.Entry variable : this.variables.entrySet() ) { + String name = variable.getKey(); + ServerVariable serverVariable = variable.getValue(); + String value = serverVariable.defaultValue; + + if( variables != null && variables.containsKey(name) ) { + value = variables.get(name); + if( serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value) ) { + throw new IllegalArgumentException( + "The variable " + name + " in the server URL has invalid value " + value + "."); + } + } + url = url.replace("{" + name + "}", value); + } + return url; + } + + /** + * Format URL template using default server variables. + * + * @return Formatted URL. + */ + public String URL() + { + return URL(null); + } +} diff --git a/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/ServerVariable.java b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/ServerVariable.java new file mode 100644 index 000000000..e2e4a3d06 --- /dev/null +++ b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/ServerVariable.java @@ -0,0 +1,40 @@ +/* + * Prompt Registry API + * Prompt Storage service for Design time & Runtime prompt templates. + * + * The version of the OpenAPI document: 0.0.1 + * + * + * 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.services.openapi.apache; + +import java.util.HashSet; + +/** + * Representing a Server Variable for server URL template substitution. + */ +public class ServerVariable +{ + public String description; + public String defaultValue; + public HashSet enumValues = null; + + /** + * @param description + * A description for the server variable. + * @param defaultValue + * The default value to use for substitution. + * @param enumValues + * An enumeration of string values to be used if the substitution options are from a limited set. + */ + public ServerVariable( String description, String defaultValue, HashSet enumValues ) + { + this.description = description; + this.defaultValue = defaultValue; + this.enumValues = enumValues; + } +} diff --git a/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/StringUtil.java b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/StringUtil.java new file mode 100644 index 000000000..8fe49ac89 --- /dev/null +++ b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/StringUtil.java @@ -0,0 +1,91 @@ +/* + * Prompt Registry API + * Prompt Storage service for Design time & Runtime prompt templates. + * + * The version of the OpenAPI document: 0.0.1 + * + * + * 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.services.openapi.apache; + +import java.util.Collection; +import java.util.Iterator; + +public class StringUtil +{ + /** + * Check if the given array contains the given value (with case-insensitive comparison). + * + * @param array + * The array + * @param value + * The value to search + * @return true if the array contains the value + */ + public static boolean containsIgnoreCase( String[] array, String value ) + { + for( String str : array ) { + if( value == null && str == null ) { + return true; + } + if( value != null && value.equalsIgnoreCase(str) ) { + return true; + } + } + return false; + } + + /** + * Join an array of strings with the given separator. + *

+ * Note: This might be replaced by utility method from commons-lang or guava someday if one of those libraries is + * added as dependency. + *

+ * + * @param array + * The array of strings + * @param separator + * The separator + * @return the resulting string + */ + public static String join( String[] array, String separator ) + { + int len = array.length; + if( len == 0 ) { + return ""; + } + + StringBuilder out = new StringBuilder(); + out.append(array[0]); + for( int i = 1; i < len; i++ ) { + out.append(separator).append(array[i]); + } + return out.toString(); + } + + /** + * Join a list of strings with the given separator. + * + * @param list + * The list of strings + * @param separator + * The separator + * @return the resulting string + */ + public static String join( Collection list, String separator ) + { + Iterator iterator = list.iterator(); + StringBuilder out = new StringBuilder(); + if( iterator.hasNext() ) { + out.append(iterator.next()); + } + while( iterator.hasNext() ) { + out.append(separator).append(iterator.next()); + } + return out.toString(); + } +} diff --git a/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/auth/ApiKeyAuth.java b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/auth/ApiKeyAuth.java new file mode 100644 index 000000000..87f4fe832 --- /dev/null +++ b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/auth/ApiKeyAuth.java @@ -0,0 +1,86 @@ +/* + * Prompt Registry API + * Prompt Storage service for Design time & Runtime prompt templates. + * + * The version of the OpenAPI document: 0.0.1 + * + * + * 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.services.openapi.apache.auth; + +import java.util.List; +import java.util.Map; + +import com.sap.cloud.sdk.services.openapi.apache.Pair; + +public class ApiKeyAuth implements Authentication +{ + private final String location; + private final String paramName; + + private String apiKey; + private String apiKeyPrefix; + + public ApiKeyAuth( String location, String paramName ) + { + this.location = location; + this.paramName = paramName; + } + + public String getLocation() + { + return location; + } + + public String getParamName() + { + return paramName; + } + + public String getApiKey() + { + return apiKey; + } + + public void setApiKey( String apiKey ) + { + this.apiKey = apiKey; + } + + public String getApiKeyPrefix() + { + return apiKeyPrefix; + } + + public void setApiKeyPrefix( String apiKeyPrefix ) + { + this.apiKeyPrefix = apiKeyPrefix; + } + + @Override + public + void + applyToParams( List queryParams, Map headerParams, Map cookieParams ) + { + if( apiKey == null ) { + return; + } + String value; + if( apiKeyPrefix != null ) { + value = apiKeyPrefix + " " + apiKey; + } else { + value = apiKey; + } + if( "query".equals(location) ) { + queryParams.add(new Pair(paramName, value)); + } else if( "header".equals(location) ) { + headerParams.put(paramName, value); + } else if( "cookie".equals(location) ) { + cookieParams.put(paramName, value); + } + } +} diff --git a/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/auth/Authentication.java b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/auth/Authentication.java new file mode 100644 index 000000000..92d1e48b2 --- /dev/null +++ b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/auth/Authentication.java @@ -0,0 +1,33 @@ +/* + * Prompt Registry API + * Prompt Storage service for Design time & Runtime prompt templates. + * + * The version of the OpenAPI document: 0.0.1 + * + * + * 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.services.openapi.apache.auth; + +import java.util.List; +import java.util.Map; + +import com.sap.cloud.sdk.services.openapi.apache.Pair; + +public interface Authentication +{ + /** + * Apply authentication settings to header and query params. + * + * @param queryParams + * List of query parameters + * @param headerParams + * Map of header parameters + * @param cookieParams + * Map of cookie parameters + */ + void applyToParams( List queryParams, Map headerParams, Map cookieParams ); +} diff --git a/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/auth/HttpBasicAuth.java b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/auth/HttpBasicAuth.java new file mode 100644 index 000000000..fc48507f6 --- /dev/null +++ b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/auth/HttpBasicAuth.java @@ -0,0 +1,59 @@ +/* + * Prompt Registry API + * Prompt Storage service for Design time & Runtime prompt templates. + * + * The version of the OpenAPI document: 0.0.1 + * + * + * 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.services.openapi.apache.auth; + +import java.nio.charset.StandardCharsets; +import java.util.Base64; +import java.util.List; +import java.util.Map; + +import com.sap.cloud.sdk.services.openapi.apache.Pair; + +public class HttpBasicAuth implements Authentication +{ + private String username; + private String password; + + public String getUsername() + { + return username; + } + + public void setUsername( String username ) + { + this.username = username; + } + + public String getPassword() + { + return password; + } + + public void setPassword( String password ) + { + this.password = password; + } + + @Override + public + void + applyToParams( List queryParams, Map headerParams, Map cookieParams ) + { + if( username == null && password == null ) { + return; + } + String str = (username == null ? "" : username) + ":" + (password == null ? "" : password); + headerParams + .put("Authorization", "Basic " + Base64.getEncoder().encodeToString(str.getBytes(StandardCharsets.UTF_8))); + } +} diff --git a/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/auth/HttpBearerAuth.java b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/auth/HttpBearerAuth.java new file mode 100644 index 000000000..886915d6e --- /dev/null +++ b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apache/auth/HttpBearerAuth.java @@ -0,0 +1,80 @@ +/* + * Prompt Registry API + * Prompt Storage service for Design time & Runtime prompt templates. + * + * The version of the OpenAPI document: 0.0.1 + * + * + * 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.services.openapi.apache.auth; + +import java.util.List; +import java.util.Map; +import java.util.function.Supplier; + +import com.sap.cloud.sdk.services.openapi.apache.Pair; + +public class HttpBearerAuth implements Authentication +{ + private final String scheme; + private Supplier tokenSupplier; + + public HttpBearerAuth( String scheme ) + { + this.scheme = upperCaseBearer(scheme); + } + + /** + * Gets the token, which together with the scheme, will be sent as the value of the Authorization header. + * + * @return The bearer token + */ + public String getBearerToken() + { + return tokenSupplier.get(); + } + + /** + * Sets the token, which together with the scheme, will be sent as the value of the Authorization header. + * + * @param bearerToken + * The bearer token to send in the Authorization header + */ + public void setBearerToken( String bearerToken ) + { + this.tokenSupplier = () -> bearerToken; + } + + /** + * Sets the supplier of tokens, which together with the scheme, will be sent as the value of the Authorization + * header. + * + * @param tokenSupplier + * The supplier of bearer tokens to send in the Authorization header + */ + public void setBearerToken( Supplier tokenSupplier ) + { + this.tokenSupplier = tokenSupplier; + } + + @Override + public + void + applyToParams( List queryParams, Map headerParams, Map cookieParams ) + { + String bearerToken = tokenSupplier != null ? tokenSupplier.get() : null; + if( bearerToken == null ) { + return; + } + headerParams.put("Authorization", (scheme != null ? scheme + " " : "") + bearerToken); + } + + private static String upperCaseBearer( String scheme ) + { + return "bearer".equalsIgnoreCase(scheme) ? "Bearer" : scheme; + } +} diff --git a/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/libraries/apache-httpclient/api.mustache b/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/libraries/apache-httpclient/api.mustache new file mode 100644 index 000000000..becb08a14 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/libraries/apache-httpclient/api.mustache @@ -0,0 +1,245 @@ +{{>licenseInfo}} +package {{package}}; + +import com.fasterxml.jackson.core.type.TypeReference; + +import {{invokerPackage}}.ApiException; +import {{invokerPackage}}.ApiClient; +import {{invokerPackage}}.BaseApi; +import {{invokerPackage}}.Configuration; +{{#models.0}} + import {{modelPackage}}.*; +{{/models.0}} +import {{invokerPackage}}.Pair; + +{{#imports}}import {{import}}; +{{/imports}} + + +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; + +{{#useBeanValidation}} + import {{javaxPackage}}.validation.constraints.*; + import {{javaxPackage}}.validation.Valid; + +{{/useBeanValidation}} +{{!>generatedAnnotation}} + +{{#operations}} + public class {{classname}} extends BaseApi { + + public {{classname}}() { + super(Configuration.getDefaultApiClient()); + } + + public {{classname}}(ApiClient apiClient) { + super(apiClient); + } + + {{#operation}} + /** + * {{summary}} + * {{notes}} + {{#allParams}} + * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}} + {{/allParams}} + {{#returnType}} + * @return {{returnType}} + {{/returnType}} + * @throws ApiException if fails to make API call + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{>nullable_var_annotations}} {{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException { + {{#returnType}}return {{/returnType}}this.{{operationId}}({{#allParams}}{{paramName}}, {{/allParams}}Collections.emptyMap()); + } + + + /** + * {{summary}} + * {{notes}} + {{#allParams}} + * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}} + {{/allParams}} + * @param additionalHeaders additionalHeaders for this call + {{#returnType}} + * @return {{returnType}} + {{/returnType}} + * @throws ApiException if fails to make API call + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{>nullable_var_annotations}} {{{dataType}}} {{paramName}}, {{/allParams}}Map additionalHeaders) throws ApiException { + Object localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}; + {{#allParams}}{{#required}} + // verify the required parameter '{{paramName}}' is set + if ({{paramName}} == null) { + throw new ApiException(400, "Missing the required parameter '{{paramName}}' when calling {{operationId}}"); + } + {{/required}}{{/allParams}} + // create path and map variables + String localVarPath = "{{{path}}}"{{#pathParams}} + .replaceAll("\\{" + "{{baseName}}" + "\\}", apiClient.escapeString(apiClient.parameterToString({{{paramName}}}))){{/pathParams}}; + + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + {{#queryParams}} + {{#isDeepObject}} + localVarQueryParameterBaseName = "{{{baseName}}}"; + {{#isArray}} + for (int i=0; i < {{paramName}}.size(); i++) { + localVarQueryStringJoiner.add({{paramName}}.get(i).toUrlQueryString(String.format(Locale.ROOT, "{{baseName}}[%d]", i))); + } + {{/isArray}} + {{^isArray}} + localVarQueryStringJoiner.add({{paramName}}.toUrlQueryString("{{baseName}}")); + {{/isArray}} + {{/isDeepObject}} + {{^isDeepObject}} + {{#isExplode}} + {{#hasVars}} + {{#vars}} + {{#isArray}} + localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "{{baseName}}", {{paramName}}.{{getter}}())); + {{/isArray}} + {{^isArray}} + localVarQueryParams.addAll(apiClient.parameterToPair("{{baseName}}", {{paramName}}.{{getter}}())); + {{/isArray}} + {{/vars}} + {{/hasVars}} + {{^hasVars}} + {{#isModel}} + localVarQueryStringJoiner.add({{paramName}}.toUrlQueryString()); + {{/isModel}} + {{^isModel}} + {{#collectionFormat}}localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("{{{collectionFormat}}}", {{/collectionFormat}}{{^collectionFormat}}localVarQueryParams.addAll(apiClient.parameterToPair({{/collectionFormat}}"{{baseName}}", {{paramName}})); + {{/isModel}} + {{/hasVars}} + {{/isExplode}} + {{^isExplode}} + {{#collectionFormat}}localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("{{{collectionFormat}}}", {{/collectionFormat}}{{^collectionFormat}}localVarQueryParams.addAll(apiClient.parameterToPair({{/collectionFormat}}"{{baseName}}", {{paramName}})); + {{/isExplode}} + {{/isDeepObject}} + {{/queryParams}} + {{#headerParams}}if ({{paramName}} != null) + localVarHeaderParams.put("{{baseName}}", apiClient.parameterToString({{paramName}})); + {{/headerParams}} + + localVarHeaderParams.putAll(additionalHeaders); + + {{#cookieParams}}if ({{paramName}} != null) + localVarCookieParams.put("{{baseName}}", apiClient.parameterToString({{paramName}})); + {{/cookieParams}} + + {{#formParams}}if ({{paramName}} != null) + localVarFormParams.put("{{baseName}}", {{paramName}}); + {{/formParams}} + + final String[] localVarAccepts = { + {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { {{#authMethods}}"{{name}}"{{^-last}}, {{/-last}}{{/authMethods}} }; + + {{#returnType}} + TypeReference<{{{returnType}}}> localVarReturnType = new TypeReference<{{{returnType}}}>() {}; + return apiClient.invokeAPI( + {{/returnType}} + {{^returnType}} + apiClient.invokeAPI( + {{/returnType}} + localVarPath, + "{{httpMethod}}", + localVarQueryParams, + localVarCollectionQueryParams, + localVarQueryStringJoiner.toString(), + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAccept, + localVarContentType, + localVarAuthNames, + {{#returnType}}localVarReturnType{{/returnType}}{{^returnType}}null{{/returnType}} + ); + } + + {{#-last}} + @Override + public T invokeAPI(String url, String method, Object request, TypeReference returnType, Map additionalHeaders) throws ApiException { + String localVarPath = url.replace(apiClient.getBaseURL(), ""); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + localVarHeaderParams.putAll(additionalHeaders); + + final String[] localVarAccepts = { + {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { {{#authMethods}}"{{name}}"{{^-last}}, {{/-last}}{{/authMethods}} }; + + return apiClient.invokeAPI( + localVarPath, + method, + localVarQueryParams, + localVarCollectionQueryParams, + localVarQueryStringJoiner.toString(), + request, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAccept, + localVarContentType, + localVarAuthNames, + returnType + ); + } + {{/-last}} + {{/operation}} + } +{{/operations}} \ No newline at end of file diff --git a/datamodel/openapi/pom.xml b/datamodel/openapi/pom.xml index f3565a5b1..689e6a0c3 100644 --- a/datamodel/openapi/pom.xml +++ b/datamodel/openapi/pom.xml @@ -34,6 +34,7 @@ openapi-generator openapi-generator-maven-plugin openapi-api-sample + openapi-api-apache-sample scm:git:git://github.com/SAP/cloud-sdk-java.git @@ -63,6 +64,7 @@ openapi-api-sample + openapi-api-apache-sample diff --git a/module-inventory.json b/module-inventory.json index e5cecad8f..03840ca6e 100644 --- a/module-inventory.json +++ b/module-inventory.json @@ -406,6 +406,17 @@ "parentArtifactId": "openapi-parent", "excludeFromBlackDuckScan": false }, + { + "groupId": "com.sap.cloud.sdk.datamodel", + "artifactId": "openapi-api-apache-sample", + "packaging": "jar", + "releaseAudience": "None", + "releaseMaturity": "Stable", + "pomFile": "datamodel/openapi/openapi-api-apache-sample/pom.xml", + "parentGroupId": "com.sap.cloud.sdk.datamodel", + "parentArtifactId": "openapi-parent", + "excludeFromBlackDuckScan": false + }, { "groupId": "com.sap.cloud.sdk.datamodel", "artifactId": "openapi-core", diff --git a/pom.xml b/pom.xml index 2509418c0..681c891f3 100644 --- a/pom.xml +++ b/pom.xml @@ -703,6 +703,7 @@ com.sap.cloud.sdk.datamodel:odata-api-sample com.sap.cloud.sdk.datamodel:odata-v4-api-sample com.sap.cloud.sdk.datamodel:openapi-api-sample + com.sap.cloud.sdk.datamodel:openapi-api-apache-sample