Skip to content

Commit 7e010e4

Browse files
OpenAPI oneOf support (#647)
1 parent eeff442 commit 7e010e4

File tree

78 files changed

+5241
-1916
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+5241
-1916
lines changed

datamodel/openapi/openapi-api-sample/pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@
9393
<artifactId>jackson-databind</artifactId>
9494
<scope>test</scope>
9595
</dependency>
96+
<dependency>
97+
<groupId>com.fasterxml.jackson.datatype</groupId>
98+
<artifactId>jackson-datatype-jsr310</artifactId>
99+
<scope>test</scope>
100+
</dependency>
96101
</dependencies>
97102
<build>
98103
<plugins>
@@ -108,7 +113,7 @@
108113
</execution>
109114
</executions>
110115
<configuration>
111-
<inputSpec>${project.basedir}/src/main/resources/sodastore.json</inputSpec>
116+
<inputSpec>${project.basedir}/src/main/resources/sodastore.yaml</inputSpec>
112117
<apiPackage>com.sap.cloud.sdk.datamodel.openapi.sample.api</apiPackage>
113118
<modelPackage>com.sap.cloud.sdk.datamodel.openapi.sample.model</modelPackage>
114119
<apiMaturity>released</apiMaturity>
@@ -119,6 +124,7 @@
119124
<pojoBuilderMethodName>create</pojoBuilderMethodName>
120125
<pojoBuildMethodName />
121126
<pojoConstructorVisibility>protected</pojoConstructorVisibility>
127+
<useOneOfInterfaces>true</useOneOfInterfaces>
122128
<enumUnknownDefaultCase>true</enumUnknownDefaultCase>
123129
</additionalProperties>
124130
</configuration>

datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/api/SodasApi.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ public SodaWithId sodasIdGet( @Nonnull final Long id )
178178
* <p>
179179
* <b>200</b> - The updated soda product
180180
* <p>
181-
* <b>404</b> - Soda product not found
182-
* <p>
183181
* <b>204</b> - Nothing has changed
182+
* <p>
183+
* <b>404</b> - Soda product not found
184184
*
185185
* @param sodaWithId
186186
* The updated soda product
Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
/*
2+
* Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved.
3+
*/
4+
5+
/*
6+
* SodaStore API
7+
* API for managing soda products and orders in SodaStore.
8+
*
9+
* The version of the OpenAPI document: 1.0.0
10+
*
11+
*
12+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
13+
* https://openapi-generator.tech
14+
* Do not edit the class manually.
15+
*/
16+
17+
package com.sap.cloud.sdk.datamodel.openapi.sample.model;
18+
19+
import java.util.LinkedHashMap;
20+
import java.util.Map;
21+
import java.util.NoSuchElementException;
22+
import java.util.Objects;
23+
import java.util.Set;
24+
25+
import javax.annotation.Nonnull;
26+
import javax.annotation.Nullable;
27+
28+
import com.fasterxml.jackson.annotation.JsonAnyGetter;
29+
import com.fasterxml.jackson.annotation.JsonAnySetter;
30+
import com.fasterxml.jackson.annotation.JsonIgnore;
31+
import com.fasterxml.jackson.annotation.JsonProperty;
32+
33+
/**
34+
* AllOf
35+
*/
36+
// CHECKSTYLE:OFF
37+
public class AllOf
38+
// CHECKSTYLE:ON
39+
{
40+
@JsonProperty( "sodaType" )
41+
private String sodaType;
42+
43+
@JsonProperty( "caffeine" )
44+
private Boolean caffeine;
45+
46+
@JsonProperty( "color" )
47+
private String color;
48+
49+
@JsonAnySetter
50+
@JsonAnyGetter
51+
private final Map<String, Object> cloudSdkCustomFields = new LinkedHashMap<>();
52+
53+
/**
54+
* Default constructor for AllOf.
55+
*/
56+
protected AllOf()
57+
{
58+
}
59+
60+
/**
61+
* Set the sodaType of this {@link AllOf} instance and return the same instance.
62+
*
63+
* @param sodaType
64+
* The sodaType of this {@link AllOf}
65+
* @return The same instance of this {@link AllOf} class
66+
*/
67+
@Nonnull
68+
public AllOf sodaType( @Nullable final String sodaType )
69+
{
70+
this.sodaType = sodaType;
71+
return this;
72+
}
73+
74+
/**
75+
* Get sodaType
76+
*
77+
* @return sodaType The sodaType of this {@link AllOf} instance.
78+
*/
79+
@Nonnull
80+
public String getSodaType()
81+
{
82+
return sodaType;
83+
}
84+
85+
/**
86+
* Set the sodaType of this {@link AllOf} instance.
87+
*
88+
* @param sodaType
89+
* The sodaType of this {@link AllOf}
90+
*/
91+
public void setSodaType( @Nullable final String sodaType )
92+
{
93+
this.sodaType = sodaType;
94+
}
95+
96+
/**
97+
* Set the caffeine of this {@link AllOf} instance and return the same instance.
98+
*
99+
* @param caffeine
100+
* The caffeine of this {@link AllOf}
101+
* @return The same instance of this {@link AllOf} class
102+
*/
103+
@Nonnull
104+
public AllOf caffeine( @Nullable final Boolean caffeine )
105+
{
106+
this.caffeine = caffeine;
107+
return this;
108+
}
109+
110+
/**
111+
* Get caffeine
112+
*
113+
* @return caffeine The caffeine of this {@link AllOf} instance.
114+
*/
115+
@Nonnull
116+
public Boolean isCaffeine()
117+
{
118+
return caffeine;
119+
}
120+
121+
/**
122+
* Set the caffeine of this {@link AllOf} instance.
123+
*
124+
* @param caffeine
125+
* The caffeine of this {@link AllOf}
126+
*/
127+
public void setCaffeine( @Nullable final Boolean caffeine )
128+
{
129+
this.caffeine = caffeine;
130+
}
131+
132+
/**
133+
* Set the color of this {@link AllOf} instance and return the same instance.
134+
*
135+
* @param color
136+
* The color of this {@link AllOf}
137+
* @return The same instance of this {@link AllOf} class
138+
*/
139+
@Nonnull
140+
public AllOf color( @Nullable final String color )
141+
{
142+
this.color = color;
143+
return this;
144+
}
145+
146+
/**
147+
* Get color
148+
*
149+
* @return color The color of this {@link AllOf} instance.
150+
*/
151+
@Nonnull
152+
public String getColor()
153+
{
154+
return color;
155+
}
156+
157+
/**
158+
* Set the color of this {@link AllOf} instance.
159+
*
160+
* @param color
161+
* The color of this {@link AllOf}
162+
*/
163+
public void setColor( @Nullable final String color )
164+
{
165+
this.color = color;
166+
}
167+
168+
/**
169+
* Get the names of the unrecognizable properties of the {@link AllOf}.
170+
*
171+
* @return The set of properties names
172+
*/
173+
@JsonIgnore
174+
@Nonnull
175+
public Set<String> getCustomFieldNames()
176+
{
177+
return cloudSdkCustomFields.keySet();
178+
}
179+
180+
/**
181+
* Get the value of an unrecognizable property of this {@link AllOf} instance.
182+
*
183+
* @param name
184+
* The name of the property
185+
* @return The value of the property
186+
* @throws NoSuchElementException
187+
* If no property with the given name could be found.
188+
*/
189+
@Nullable
190+
public Object getCustomField( @Nonnull final String name )
191+
throws NoSuchElementException
192+
{
193+
if( !cloudSdkCustomFields.containsKey(name) ) {
194+
throw new NoSuchElementException("AllOf has no field with name '" + name + "'.");
195+
}
196+
return cloudSdkCustomFields.get(name);
197+
}
198+
199+
/**
200+
* Set an unrecognizable property of this {@link AllOf} instance. If the map previously contained a mapping for the
201+
* key, the old value is replaced by the specified value.
202+
*
203+
* @param customFieldName
204+
* The name of the property
205+
* @param customFieldValue
206+
* The value of the property
207+
*/
208+
@JsonIgnore
209+
public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue )
210+
{
211+
cloudSdkCustomFields.put(customFieldName, customFieldValue);
212+
}
213+
214+
@Override
215+
public boolean equals( @Nullable final java.lang.Object o )
216+
{
217+
if( this == o ) {
218+
return true;
219+
}
220+
if( o == null || getClass() != o.getClass() ) {
221+
return false;
222+
}
223+
final AllOf allOf = (AllOf) o;
224+
return Objects.equals(this.cloudSdkCustomFields, allOf.cloudSdkCustomFields)
225+
&& Objects.equals(this.sodaType, allOf.sodaType)
226+
&& Objects.equals(this.caffeine, allOf.caffeine)
227+
&& Objects.equals(this.color, allOf.color);
228+
}
229+
230+
@Override
231+
public int hashCode()
232+
{
233+
return Objects.hash(sodaType, caffeine, color, cloudSdkCustomFields);
234+
}
235+
236+
@Override
237+
@Nonnull
238+
public String toString()
239+
{
240+
final StringBuilder sb = new StringBuilder();
241+
sb.append("class AllOf {\n");
242+
sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n");
243+
sb.append(" caffeine: ").append(toIndentedString(caffeine)).append("\n");
244+
sb.append(" color: ").append(toIndentedString(color)).append("\n");
245+
cloudSdkCustomFields
246+
.forEach(( k, v ) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n"));
247+
sb.append("}");
248+
return sb.toString();
249+
}
250+
251+
/**
252+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
253+
*/
254+
private String toIndentedString( final java.lang.Object o )
255+
{
256+
if( o == null ) {
257+
return "null";
258+
}
259+
return o.toString().replace("\n", "\n ");
260+
}
261+
262+
/**
263+
* Create a new {@link AllOf} instance. No arguments are required.
264+
*/
265+
public static AllOf create()
266+
{
267+
return new AllOf();
268+
}
269+
270+
}

0 commit comments

Comments
 (0)