generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 23
OpenAPI oneOf support #647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
578b214
OpenAPI oneOf support
CharlesDuboisSAP 6173eaa
Added USE_ONE_OF_INTERFACES true as default, revert non required=null…
CharlesDuboisSAP 1bfe9bc
Added more cases in oneOf spec
CharlesDuboisSAP 4d01a85
Fix test
CharlesDuboisSAP bd14470
Remove warning
CharlesDuboisSAP fedc13f
Revert checkstyle changes
CharlesDuboisSAP 2f1d938
Removed JsonTypeName
CharlesDuboisSAP f933754
Added generateApis option
CharlesDuboisSAP fe47d04
Added javadoc
CharlesDuboisSAP 3d9c948
Added release notes
CharlesDuboisSAP 834375f
Fixed tests
CharlesDuboisSAP 45398d1
Removed useOneOfInterfaces from release notes
CharlesDuboisSAP 64173e3
Updated integration test
CharlesDuboisSAP 51e083e
Fixed spec
CharlesDuboisSAP 0a7ec0e
Fixed spec
CharlesDuboisSAP 18336c8
Added sample deserialization test
CharlesDuboisSAP 676031b
Apply suggestions from code review
CharlesDuboisSAP 3dcd5a9
Merge branch 'main' into oneOf
CharlesDuboisSAP ec30ac4
format
CharlesDuboisSAP File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
270 changes: 270 additions & 0 deletions
270
...napi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/AllOf.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,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(); | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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