diff --git a/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/modelInnerEnum.mustache b/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/modelInnerEnum.mustache index 2472a72c4..2616c83c5 100644 --- a/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/modelInnerEnum.mustache +++ b/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/modelInnerEnum.mustache @@ -65,7 +65,7 @@ {{#jackson}} @JsonCreator {{/jackson}} - @Nonnull public static {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(@Nonnull final {{{dataType}}} value) { + {{#isNullable}}@Nullable{{/isNullable}}{{^isNullable}}@Nonnull{{/isNullable}} public static {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(@Nonnull final {{{dataType}}} value) { for ({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { if (b.value.{{^isString}}equals{{/isString}}{{#isString}}{{#useEnumCaseInsensitive}}equalsIgnoreCase{{/useEnumCaseInsensitive}}{{^useEnumCaseInsensitive}}equals{{/useEnumCaseInsensitive}}{{/isString}}(value)) { return b; diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/input/sodastore.json b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/input/sodastore.json index 4e54046e1..fdacd7c85 100644 --- a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/input/sodastore.json +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/input/sodastore.json @@ -179,6 +179,11 @@ "type": "number", "format": "float" }, + "diet": { + "type": "string", + "enum": ["sugar", "zero", "light"], + "nullable": true + }, "embedding":{ "type": "array", "items": { diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/model/Soda.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/model/Soda.java index 227e98086..9ac503193 100644 --- a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/model/Soda.java +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/model/Soda.java @@ -63,6 +63,68 @@ public class Soda @JsonProperty("price") private Float price; + /** + * Gets or Sets diet + */ + public enum DietEnum { + /** + * The SUGAR option of this Soda + */ + SUGAR("sugar"), + + /** + * The ZERO option of this Soda + */ + ZERO("zero"), + + /** + * The LIGHT option of this Soda + */ + LIGHT("light"); + + private String value; + + DietEnum(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 + @Nullable public static DietEnum fromValue(@Nonnull final String value) { + for (DietEnum b : DietEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return null; + } + } + + @JsonProperty("diet") + private DietEnum diet; + @JsonProperty("embedding") private float[] embedding; @@ -244,6 +306,35 @@ public void setPrice( @Nonnull final Float price) { this.price = price; } + /** + * Set the diet of this {@link Soda} instance and return the same instance. + * + * @param diet The diet of this {@link Soda} + * @return The same instance of this {@link Soda} class + */ + @Nonnull public Soda diet( @Nullable final DietEnum diet) { + this.diet = diet; + return this; + } + + /** + * Get diet + * @return diet The diet of this {@link Soda} instance. + */ + @Nullable + public DietEnum getDiet() { + return diet; + } + + /** + * Set the diet of this {@link Soda} instance. + * + * @param diet The diet of this {@link Soda} + */ + public void setDiet( @Nullable final DietEnum diet) { + this.diet = diet; + } + /** * Set the embedding of this {@link Soda} instance and return the same instance. * @@ -315,6 +406,7 @@ public Map toMap() if( isAvailable != null ) declaredFields.put("isAvailable", isAvailable); if( flavor != null ) declaredFields.put("flavor", flavor); if( price != null ) declaredFields.put("price", price); + if( diet != null ) declaredFields.put("diet", diet); if( embedding != null ) declaredFields.put("embedding", embedding); return declaredFields; } @@ -348,12 +440,13 @@ public boolean equals(@Nullable final java.lang.Object o) { Objects.equals(this.isAvailable, soda.isAvailable) && Objects.equals(this.flavor, soda.flavor) && Objects.equals(this.price, soda.price) && + Objects.equals(this.diet, soda.diet) && Arrays.equals(this.embedding, soda.embedding); } @Override public int hashCode() { - return Objects.hash(id, name, brand, isAvailable, flavor, price, Arrays.hashCode(embedding), cloudSdkCustomFields); + return Objects.hash(id, name, brand, isAvailable, flavor, price, diet, Arrays.hashCode(embedding), cloudSdkCustomFields); } @Override @@ -366,6 +459,7 @@ public int hashCode() { sb.append(" isAvailable: ").append(toIndentedString(isAvailable)).append("\n"); sb.append(" flavor: ").append(toIndentedString(flavor)).append("\n"); sb.append(" price: ").append(toIndentedString(price)).append("\n"); + sb.append(" diet: ").append(toIndentedString(diet)).append("\n"); sb.append(" embedding: ").append(toIndentedString(embedding)).append("\n"); cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); sb.append("}");