You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
java.lang.NullPointerException: Cannot invoke "java.util.List.iterator()" because the return value of "io.swagger.v3.oas.models.media.ComposedSchema.getOneOf()" is null
at org.openapitools.openapidiff.core.compare.schemadiffresult.ComposedSchemaDiffResult.getMapping(ComposedSchemaDiffResult.java:120)
at org.openapitools.openapidiff.core.compare.schemadiffresult.ComposedSchemaDiffResult.diff(ComposedSchemaDiffResult.java:68)
at org.openapitools.openapidiff.core.compare.SchemaDiff.computeDiffForReal(SchemaDiff.java:354)
at org.openapitools.openapidiff.core.compare.SchemaDiff.computeDeferredDiff(SchemaDiff.java:330)
at org.openapitools.openapidiff.core.compare.SchemaDiff.diff(SchemaDiff.java:309)
at org.openapitools.openapidiff.core.compare.SchemaDiff.diff(SchemaDiff.java:301)
at org.openapitools.openapidiff.core.compare.ContentDiff.lambda$diff$1(ContentDiff.java:44)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
at org.openapitools.openapidiff.core.compare.ContentDiff.diff(ContentDiff.java:32)
at org.openapitools.openapidiff.core.compare.ResponseDiff.computeDiff(ResponseDiff.java:60)
at org.openapitools.openapidiff.core.compare.ResponseDiff.computeDiff(ResponseDiff.java:16)
at org.openapitools.openapidiff.core.compare.ReferenceDiffCache.cachedDiff(ReferenceDiffCache.java:52)
at org.openapitools.openapidiff.core.compare.ResponseDiff.diff(ResponseDiff.java:42)
at org.openapitools.openapidiff.core.compare.ApiResponseDiff.diff(ApiResponseDiff.java:35)
at org.openapitools.openapidiff.core.compare.OperationDiff.diff(OperationDiff.java:91)
at org.openapitools.openapidiff.core.compare.PathDiff.diff(PathDiff.java:39)
[...]
The direct reason seems to be that in ComposedSchemaDiffResult#diff there is this check:
if (CollectionUtils.isNotEmpty(leftComposedSchema.getOneOf())
|| CollectionUtils.isNotEmpty(rightComposedSchema.getOneOf())) {
and later, in getMapping(rightComposedSchema) it's assumed that both left and right contain oneOf, which is incorrect as the check here is an OR instead of an AND.
Changing || to && fixes this particular issue and the tests pass, however I'm not certain that this is the correct fix as I don't understand the logic enough to be able to tell if I'm not breaking anything else.
Additionally, the way that anyOf is handled seems to be merging all schema alternatives into one, which includes merging their required options, which seems incorrect. If a schema is anyOf(A, B), where A has required property propA and B has required property propB, after the merge the result would be a schema that requires both propA and propB instead of propA OR propB.
Do you think that the || to && is a valid fix for the issue, or should the anyOf handling be changed somehow?
The text was updated successfully, but these errors were encountered:
I observed a NullPointerException when a response schema changes from using
oneOf
toanyOf
. Here is a test that reproduces the issue.The error is as follows:
The direct reason seems to be that in
ComposedSchemaDiffResult#diff
there is this check:and later, in
getMapping(rightComposedSchema)
it's assumed that both left and right containoneOf
, which is incorrect as the check here is an OR instead of an AND.Changing
||
to&&
fixes this particular issue and the tests pass, however I'm not certain that this is the correct fix as I don't understand the logic enough to be able to tell if I'm not breaking anything else.Additionally, the way that
anyOf
is handled seems to be merging all schema alternatives into one, which includes merging theirrequired
options, which seems incorrect. If a schema is anyOf(A, B), where A has required property propA and B has required property propB, after the merge the result would be a schema that requires both propA and propB instead of propA OR propB.Do you think that the
||
to&&
is a valid fix for the issue, or should the anyOf handling be changed somehow?The text was updated successfully, but these errors were encountered: