Skip to content

Commit 9813779

Browse files
committed
Add testSameTypeResponseSchemaDIff based on issue OpenAPITools#192.
1 parent 9949e4c commit 9813779

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

core/src/test/java/org/openapitools/openapidiff/core/RequestDiffTest.java

+11
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package org.openapitools.openapidiff.core;
22

3+
import static org.assertj.core.api.Assertions.assertThat;
34
import static org.openapitools.openapidiff.core.TestUtils.assertOpenApiChangedEndpoints;
45

56
import org.junit.jupiter.api.Test;
7+
import org.openapitools.openapidiff.core.model.ChangedOpenApi;
68

79
public class RequestDiffTest {
810
private final String OPENAPI_DOC1 = "request_diff_1.yaml";
@@ -12,4 +14,13 @@ public class RequestDiffTest {
1214
public void testDiffDifferent() {
1315
assertOpenApiChangedEndpoints(OPENAPI_DOC1, OPENAPI_DOC2);
1416
}
17+
18+
@Test
19+
public void testSameTypeResponseSchemaDIff() {
20+
ChangedOpenApi changedOpenApi =
21+
OpenApiCompare.fromLocations(
22+
"response_schema_simple_object_type.yaml",
23+
"response_schema_simple_object_type_with_alloff.yaml");
24+
assertThat(changedOpenApi.isCompatible()).isTrue();
25+
}
1526
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
openapi: "3.0.0"
2+
info:
3+
title: Sample API
4+
description: API description in Markdown.
5+
version: 1.0.0
6+
servers: []
7+
paths:
8+
/test:
9+
get:
10+
summary: Your GET endpoint
11+
tags: []
12+
responses:
13+
'200':
14+
description: OK
15+
content:
16+
application/json:
17+
schema:
18+
$ref: '#/components/schemas/working'
19+
components:
20+
schemas:
21+
working:
22+
type: object
23+
properties:
24+
foo:
25+
type: string
26+
bar:
27+
type: integer
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
openapi: 3.0.0
2+
info:
3+
title: Sample API
4+
description: API description in Markdown.
5+
version: 1.1.0
6+
servers: []
7+
paths:
8+
/test:
9+
get:
10+
summary: Your GET endpoint
11+
tags: []
12+
responses:
13+
'200':
14+
description: OK
15+
content:
16+
application/json:
17+
schema:
18+
$ref: '#/components/schemas/working'
19+
operationId: get-test
20+
components:
21+
schemas:
22+
working:
23+
allOf:
24+
- type: object
25+
properties:
26+
foo:
27+
type: string
28+
- $ref: '#/components/schemas/bar'
29+
bar:
30+
type: object
31+
properties:
32+
bar:
33+
type: integer

0 commit comments

Comments
 (0)