Closed
Description
I am doing a test with a schema containing a oneOf schema (see documentation Data Models (Schemas) > oneOf, anyOf, allOf, not)
I think my specification is valid and makes sense (please do not hesitate to discuss it)
In this test case, one of the oneOf
referenced schemas was removed between the old and the new version. Depending on the operation (GET or POST) the ComposedSchema
is located:
- in the input (request body of the POST method)
- in the output (answer of the GET method).
My feeling is that a removal in the output is still backward compatible (GET Operation), and not in the input (POST Operation).
But for the moment the diff tool is crashing before (see stacktrace)
Old Spec:
openapi: 3.0.1
info:
title: oneOf test
version: '1.0'
servers:
- url: 'http://localhost:8000/'
paths:
/state:
get:
operationId: getState
responses:
'200':
description: OK
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/A'
- $ref: '#/components/schemas/B'
- $ref: '#/components/schemas/C'
post:
operationId: update
requestBody:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/A'
- $ref: '#/components/schemas/B'
- $ref: '#/components/schemas/C'
required: true
responses:
'201':
description: OK
components:
schemas:
A:
type: object
properties:
message:
type: string
B:
type: object
properties:
description:
type: string
code:
type: integer
format: int32
C:
type: object
properties:
case:
type: integer
format: int64
New Spec:
openapi: 3.0.1
info:
title: oneOf test
version: '1.0'
servers:
- url: 'http://localhost:8000/'
paths:
/state:
get:
operationId: getState
responses:
'200':
description: OK
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/A'
- $ref: '#/components/schemas/B'
post:
operationId: update
requestBody:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/A'
- $ref: '#/components/schemas/B'
required: true
responses:
'201':
description: OK
components:
schemas:
A:
type: object
properties:
message:
type: string
B:
type: object
properties:
description:
type: string
code:
type: integer
format: int32
C:
type: object
properties:
case:
type: integer
format: int64
Stacktrace:
Exception in thread "main" java.lang.IllegalArgumentException: discriminator or property not found for oneOf schema
at com.qdesrame.openapi.diff.compare.schemadiffresult.ComposedSchemaDiffResult.diff(ComposedSchemaDiffResult.java:41)
at com.qdesrame.openapi.diff.compare.SchemaDiff.computeDiff(SchemaDiff.java:90)
at com.qdesrame.openapi.diff.compare.SchemaDiff.computeDiff(SchemaDiff.java:16)
at com.qdesrame.openapi.diff.compare.ReferenceDiffCache.cachedDiff(ReferenceDiffCache.java:39)
at com.qdesrame.openapi.diff.compare.SchemaDiff.diff(SchemaDiff.java:62)
at com.qdesrame.openapi.diff.compare.ContentDiff.diff(ContentDiff.java:38)
at com.qdesrame.openapi.diff.compare.ResponseDiff.computeDiff(ResponseDiff.java:38)
at com.qdesrame.openapi.diff.compare.ResponseDiff.computeDiff(ResponseDiff.java:15)
at com.qdesrame.openapi.diff.compare.ReferenceDiffCache.cachedDiff(ReferenceDiffCache.java:39)
at com.qdesrame.openapi.diff.compare.ResponseDiff.diff(ResponseDiff.java:28)
at com.qdesrame.openapi.diff.compare.ApiResponseDiff.diff(ApiResponseDiff.java:32)
at com.qdesrame.openapi.diff.compare.OperationDiff.diff(OperationDiff.java:41)
at com.qdesrame.openapi.diff.compare.PathDiff.diff(PathDiff.java:31)
at com.qdesrame.openapi.diff.compare.PathsDiff.lambda$diff$2(PathsDiff.java:50)
at java.util.LinkedHashMap$LinkedKeySet.forEach(LinkedHashMap.java:559)
at com.qdesrame.openapi.diff.compare.PathsDiff.diff(PathsDiff.java:36)
at com.qdesrame.openapi.diff.compare.OpenApiDiff.compare(OpenApiDiff.java:92)
at com.qdesrame.openapi.diff.compare.OpenApiDiff.compare(OpenApiDiff.java:66)
at com.qdesrame.openapi.diff.OpenApiCompare.fromSpecifications(OpenApiCompare.java:99)
at com.qdesrame.openapi.diff.OpenApiCompare.fromLocations(OpenApiCompare.java:88)
at com.qdesrame.openapi.diff.OpenApiCompare.fromFiles(OpenApiCompare.java:65)
at com.qdesrame.openapi.diff.OpenApiCompare.fromFiles(OpenApiCompare.java:53)