-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
[Java/Core] Adds properties to ComposedSchema models when they exist #4482
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1787,6 +1787,17 @@ public CodegenModel fromModel(String name, Schema schema) { | |
Map<String, Schema> allProperties = new LinkedHashMap<String, Schema>(); | ||
List<String> allRequired = new ArrayList<String>(); | ||
|
||
// if schema has properties outside of allOf/oneOf/anyOf also add them to m | ||
if (schema.getProperties() != null) { | ||
addVars(m, unaliasPropertySchema(schema.getProperties()), schema.getRequired(), null, null); | ||
} | ||
|
||
// uncomment this when https://github.com/swagger-api/swagger-parser/issues/1252 is resolved | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my comment on the example spec document in this PR. |
||
// if schema has additionalproperties outside of allOf/oneOf/anyOf also add it to m | ||
// if (schema.getAdditionalProperties() != null) { | ||
// addAdditionPropertiesToCodeGenModel(m, schema); | ||
// } | ||
|
||
// parent model | ||
final String parentName = ModelUtils.getParentName(composed, allDefinitions); | ||
final List<String> allParents = ModelUtils.getAllParentsName(composed, allDefinitions); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,9 @@ components: | |
oneOf: | ||
- $ref: '#/components/schemas/apple' | ||
- $ref: '#/components/schemas/banana' | ||
# additionalProperties: | ||
# type: string | ||
# uncomment this when https://github.com/swagger-api/swagger-parser/issues/1252 is resolved | ||
Comment on lines
+25
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't imagine this will get fixed anytime soon in swagger-parser for the 3.0 specification (the revision versions 3.0.1/3.0.2 are supposedly documentation-only changes). The behavior you're seeing where this returns The requested behavior is undefined, as there's not enough clarity in the specification around constraints of using
Meaning your example is only a valid object if it is exactly The Ideally, a spec with |
||
apple: | ||
title: apple | ||
type: object | ||
|
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.
@wing328 See my other comment in this PR. Constraints around structures containing
oneOf
aren't very clearly defined in OAS 3.x, since the extension to includediscriminator
makes it look like any Schema properties are valid.Do you think we should log a warning here, or wrap it the a ! strict spec check, or both? I've commented elsewhere as well that we might want to add to the validate and/or recommends about this.