Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion datamodel/openapi/openapi-api-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@
<artifactId>jackson-databind</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand All @@ -108,7 +113,7 @@
</execution>
</executions>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/sodastore.json</inputSpec>
<inputSpec>${project.basedir}/src/main/resources/sodastore.yaml</inputSpec>
Copy link
Contributor

Choose a reason for hiding this comment

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

(Question)

Why did you change from json to yaml?
Only for flavor, or does anyof/oneof not work for json?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Flavor, the file is shorter

<apiPackage>com.sap.cloud.sdk.datamodel.openapi.sample.api</apiPackage>
<modelPackage>com.sap.cloud.sdk.datamodel.openapi.sample.model</modelPackage>
<apiMaturity>released</apiMaturity>
Expand All @@ -119,6 +124,7 @@
<pojoBuilderMethodName>create</pojoBuilderMethodName>
<pojoBuildMethodName />
<pojoConstructorVisibility>protected</pojoConstructorVisibility>
<useOneOfInterfaces>true</useOneOfInterfaces>
<enumUnknownDefaultCase>true</enumUnknownDefaultCase>
</additionalProperties>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ public SodaWithId sodasIdGet( @Nonnull final Long id )
* <p>
* <b>200</b> - The updated soda product
* <p>
* <b>404</b> - Soda product not found
* <p>
* <b>204</b> - Nothing has changed
* <p>
* <b>404</b> - Soda product not found
*
* @param sodaWithId
* The updated soda product
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,270 @@
/*
* Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved.
*/

/*
* SodaStore API
* API for managing soda products and orders in SodaStore.
*
* The version of the OpenAPI document: 1.0.0
*
*
* 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.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;

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

@JsonProperty( "caffeine" )
private Boolean caffeine;

@JsonProperty( "color" )
private String color;

@JsonAnySetter
@JsonAnyGetter
private final Map<String, Object> 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 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;
}

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

/**
* Get the value of an unrecognizable property of this {@link AllOf} instance.
*
* @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
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);
}

/**
* 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.color, allOf.color);
}

@Override
public int hashCode()
{
return Objects.hash(sodaType, caffeine, color, 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(" color: ").append(toIndentedString(color)).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 ");
}

/**
* Create a new {@link AllOf} instance. No arguments are required.
*/
public static AllOf create()
{
return new AllOf();
}

}
Loading
Loading