Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ protected static <T, U> Schema<T> addSchema(Schema<T> schema, Schema<U> fromSche
if (fromSchema.getMinItems() != null) {
schema.setMinItems(fromSchema.getMinItems());
}
if (fromSchema.getItems() != null) {
schema.setItems(fromSchema.getItems());
}
if (fromSchema.getMaxProperties() != null) {
schema.setMaxProperties(fromSchema.getMaxProperties());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.openapitools.openapidiff.core.compare.schemadiffresult;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.openapidiff.core.compare.OpenApiDiff;
import org.openapitools.openapidiff.core.model.ChangedSchema;
Expand All @@ -22,9 +21,6 @@ public <T extends Schema<X>, X> DeferredChanged<ChangedSchema> diff(
T left,
T right,
DiffContext context) {
ArraySchema leftArraySchema = (ArraySchema) left;
ArraySchema rightArraySchema = (ArraySchema) right;

DeferredChanged<ChangedSchema> superSchemaDiff =
super.diff(refSet, leftComponents, rightComponents, left, right, context)
.flatMap(
Expand All @@ -34,8 +30,8 @@ public <T extends Schema<X>, X> DeferredChanged<ChangedSchema> diff(
.getSchemaDiff()
.diff(
refSet,
leftArraySchema.getItems(),
rightArraySchema.getItems(),
left.getItems(),
right.getItems(),
context.copyWithRequired(true));
itemsDiff.ifPresent(changedSchema::setItems);
return itemsDiff;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.openapitools.openapidiff.core;

import static org.assertj.core.api.Assertions.assertThatCode;
import static org.openapitools.openapidiff.core.TestUtils.assertOpenApiAreEquals;

import org.junit.jupiter.api.Test;

public class Issue887Test {

private final String ALLOF_ARRAY = "issue-887-1.yaml";
private final String DIRECT_ARRAY = "issue-887-2.yaml";

@Test
public void testAllOfArrayToDirectArrayDoesNotThrow() {
assertThatCode(() -> OpenApiCompare.fromLocations(ALLOF_ARRAY, DIRECT_ARRAY))
.doesNotThrowAnyException();
}

@Test
public void testDirectArrayToAllOfArrayDoesNotThrow() {
assertThatCode(() -> OpenApiCompare.fromLocations(DIRECT_ARRAY, ALLOF_ARRAY))
.doesNotThrowAnyException();
}

@Test
public void testAllOfArrayToDirectArrayAreEquals() {
assertOpenApiAreEquals(ALLOF_ARRAY, DIRECT_ARRAY);
}
}
32 changes: 32 additions & 0 deletions core/src/test/resources/issue-887-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
openapi: 3.0.3
info:
title: Test API
version: 1.0.0

paths:
/test:
get:
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/TestResponse'

components:
schemas:
TestResponse:
type: object
properties:
valuations:
allOf:
- $ref: '#/components/schemas/Valuations'

Valuations:
type: array
items:
type: object
properties:
value:
type: string
31 changes: 31 additions & 0 deletions core/src/test/resources/issue-887-2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
openapi: 3.0.3
info:
title: Test API
version: 1.0.0

paths:
/test:
get:
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/TestResponse'

components:
schemas:
TestResponse:
type: object
properties:
valuations:
type: array
items:
$ref: '#/components/schemas/Valuation'

Valuation:
type: object
properties:
value:
type: string