generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 14
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
feat(openapi-generator): Allow for primitives in anyOf/oneOf component schema definitions #681
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
5ddd3c4
Initial
a-d 393c6dd
Update test
a-d 5bcd134
update sample project
a-d c0fc2b4
Merge branch 'main' into oneof
newtork ac7a992
Fix test assertion
a-d 172ce3b
Improve Javadoc
a-d 5055d5d
Update sample
a-d ef59d1b
Minor code improvement; Add feature toggle "useOneOfCreators"
a-d 12d9bb4
Fix test setup
a-d 5453058
Add feature toggle for disabling additional properties
a-d a46e816
Add nonnull / final annotations to mustache
a-d 75c5c27
Update code quality
a-d fe1d03c
Update test assertions
a-d 6805f6c
Fix PMD warnings
a-d d94cf19
Fix PMD warning
a-d 78ccbd3
Fix PMD warning
a-d 533a6dd
Merge remote-tracking branch 'origin/main' into oneof
a-d 95d7243
Fix merge conflicts
a-d 9584837
Merge branch 'main' into oneof
newtork d196f43
Update release_notes.md
newtork 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 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 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 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 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
85 changes: 85 additions & 0 deletions
85
...pi-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/FantaFlavor.java
This file contains 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,85 @@ | ||
/* | ||
* 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.sample.model; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
|
||
/** | ||
* FantaFlavor | ||
*/ | ||
public interface FantaFlavor | ||
{ | ||
/** | ||
* Helper class to create a Integer that implements {@link FantaFlavor}. | ||
*/ | ||
record InnerInteger(@com.fasterxml.jackson.annotation.JsonValue @Nonnull Integer value) implements FantaFlavor {} | ||
|
||
/** | ||
* Creator to enable deserialization of a 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 a FantaFlavorOneOf that implements {@link FantaFlavor}. | ||
*/ | ||
record InnerFantaFlavorOneOf(@com.fasterxml.jackson.annotation.JsonValue @Nonnull FantaFlavorOneOf value) implements FantaFlavor {} | ||
|
||
/** | ||
* Creator to enable deserialization of a FantaFlavorOneOf. | ||
* | ||
* @param val | ||
* the value to use | ||
* @return a new instance of {@link InnerFantaFlavorOneOf}. | ||
*/ | ||
@com.fasterxml.jackson.annotation.JsonCreator | ||
@Nonnull | ||
static InnerFantaFlavorOneOf create( @Nonnull final FantaFlavorOneOf val ) | ||
{ | ||
return new InnerFantaFlavorOneOf(val); | ||
} | ||
|
||
/** | ||
* Helper class to create a String that implements {@link FantaFlavor}. | ||
*/ | ||
record InnerString(@com.fasterxml.jackson.annotation.JsonValue @Nonnull String value) implements FantaFlavor {} | ||
|
||
/** | ||
* Creator to enable deserialization of a 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); | ||
} | ||
|
||
} |
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.
Why were the other classes (
OneOf
,AnyOf
) not affected by this change?Why wasn't it there in the first place?
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.
Omg, I went deep into the rabbit hole. I found that our check for (unsupported)
anyof
/oneof
was not sufficient!oneOf
andanyOf
are not checked when they are part of schema root; only when they are deeper in object hierarchy, e.g. when being part ofproperties
fieldsSee #checkForValidatorsInSchema(JsonNode)
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.
I think this was intentional, because on the root level the generation was already working for some cases. IIRC