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
I get a NullPointerException when I try to compare two schemas defined as a oneOf, if one of them is referred to via a allOf and the other one is referred to via a $ref. Let me show you a test case:
So, in the old version we refer to the schema Foo via a direct "$ref": "#/components/schemas/Foo", whereas in the new version we use an "allOf": [{ "$ref": "#/components/schemas/Foo" }]. The allOf trick is useful because it allows us to add additional information about the referenced schemas (see the default value in my example).
If I try to diff both documents, I get the following stack trace:
$ docker run --rm -t \
-v $(pwd):/specs:ro \
openapitools/openapi-diff:latest /specs/old-open-api.json /specs/new-open-api.json
Unexpected exception. Reason: null
java.lang.NullPointerException
at org.openapitools.openapidiff.core.compare.schemadiffresult.ComposedSchemaDiffResult.getMapping(ComposedSchemaDiffResult.java:100)
at org.openapitools.openapidiff.core.compare.schemadiffresult.ComposedSchemaDiffResult.diff(ComposedSchemaDiffResult.java:62)
at org.openapitools.openapidiff.core.compare.SchemaDiff.computeDiff(SchemaDiff.java:316)
at org.openapitools.openapidiff.core.compare.SchemaDiff.computeDiff(SchemaDiff.java:27)
at org.openapitools.openapidiff.core.compare.ReferenceDiffCache.cachedDiff(ReferenceDiffCache.java:51)
at org.openapitools.openapidiff.core.compare.SchemaDiff.diff(SchemaDiff.java:282)
at org.openapitools.openapidiff.core.compare.schemadiffresult.SchemaDiffResult.diff(SchemaDiffResult.java:70)
at org.openapitools.openapidiff.core.compare.SchemaDiff.computeDiff(SchemaDiff.java:316)
at org.openapitools.openapidiff.core.compare.SchemaDiff.computeDiff(SchemaDiff.java:27)
at org.openapitools.openapidiff.core.compare.ReferenceDiffCache.cachedDiff(ReferenceDiffCache.java:44)
at org.openapitools.openapidiff.core.compare.SchemaDiff.diff(SchemaDiff.java:282)
at org.openapitools.openapidiff.core.compare.ContentDiff.diff(ContentDiff.java:33)
at org.openapitools.openapidiff.core.compare.RequestBodyDiff.computeDiff(RequestBodyDiff.java:77)
at org.openapitools.openapidiff.core.compare.RequestBodyDiff.computeDiff(RequestBodyDiff.java:17)
at org.openapitools.openapidiff.core.compare.ReferenceDiffCache.cachedDiff(ReferenceDiffCache.java:51)
at org.openapitools.openapidiff.core.compare.RequestBodyDiff.diff(RequestBodyDiff.java:34)
at org.openapitools.openapidiff.core.compare.OperationDiff.diff(OperationDiff.java:42)
at org.openapitools.openapidiff.core.compare.PathDiff.diff(PathDiff.java:35)
at org.openapitools.openapidiff.core.compare.PathsDiff.lambda$diff$2(PathsDiff.java:67)
at java.util.LinkedHashMap$LinkedKeySet.forEach(LinkedHashMap.java:559)
at org.openapitools.openapidiff.core.compare.PathsDiff.diff(PathsDiff.java:40)
at org.openapitools.openapidiff.core.compare.OpenApiDiff.compare(OpenApiDiff.java:95)
at org.openapitools.openapidiff.core.compare.OpenApiDiff.compare(OpenApiDiff.java:66)
at org.openapitools.openapidiff.core.OpenApiCompare.fromSpecifications(OpenApiCompare.java:101)
at org.openapitools.openapidiff.core.OpenApiCompare.fromLocations(OpenApiCompare.java:90)
at org.openapitools.openapidiff.core.OpenApiCompare.fromLocations(OpenApiCompare.java:77)
at org.openapitools.openapidiff.cli.Main.main(Main.java:156)
I get a
NullPointerException
when I try to compare two schemas defined as aoneOf
, if one of them is referred to via aallOf
and the other one is referred to via a$ref
. Let me show you a test case:Old OpenAPI:
}
}
New OpenAPI:
}
}
The difference between both is just that:
So, in the old version we refer to the schema
Foo
via a direct"$ref": "#/components/schemas/Foo"
, whereas in the new version we use an"allOf": [{ "$ref": "#/components/schemas/Foo" }]
. TheallOf
trick is useful because it allows us to add additional information about the referenced schemas (see thedefault
value in my example).If I try to diff both documents, I get the following stack trace:
Which points to this line.
It seems openapi-diff expects the “right” schema to always be a
oneOf
with a mapping, but this is not the case here (only the “left” one is aoneOf
).The text was updated successfully, but these errors were encountered: