Skip to content

Commit

Permalink
Add testSameTypeResponseSchemaDIff based on issue OpenAPITools#192.
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoit Brayer committed Feb 18, 2022
1 parent 9949e4c commit 9813779
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package org.openapitools.openapidiff.core;

import static org.assertj.core.api.Assertions.assertThat;
import static org.openapitools.openapidiff.core.TestUtils.assertOpenApiChangedEndpoints;

import org.junit.jupiter.api.Test;
import org.openapitools.openapidiff.core.model.ChangedOpenApi;

public class RequestDiffTest {
private final String OPENAPI_DOC1 = "request_diff_1.yaml";
Expand All @@ -12,4 +14,13 @@ public class RequestDiffTest {
public void testDiffDifferent() {
assertOpenApiChangedEndpoints(OPENAPI_DOC1, OPENAPI_DOC2);
}

@Test
public void testSameTypeResponseSchemaDIff() {
ChangedOpenApi changedOpenApi =
OpenApiCompare.fromLocations(
"response_schema_simple_object_type.yaml",
"response_schema_simple_object_type_with_alloff.yaml");
assertThat(changedOpenApi.isCompatible()).isTrue();
}
}
27 changes: 27 additions & 0 deletions core/src/test/resources/response_schema_simple_object_type.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
openapi: "3.0.0"
info:
title: Sample API
description: API description in Markdown.
version: 1.0.0
servers: []
paths:
/test:
get:
summary: Your GET endpoint
tags: []
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/working'
components:
schemas:
working:
type: object
properties:
foo:
type: string
bar:
type: integer
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
openapi: 3.0.0
info:
title: Sample API
description: API description in Markdown.
version: 1.1.0
servers: []
paths:
/test:
get:
summary: Your GET endpoint
tags: []
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/working'
operationId: get-test
components:
schemas:
working:
allOf:
- type: object
properties:
foo:
type: string
- $ref: '#/components/schemas/bar'
bar:
type: object
properties:
bar:
type: integer

0 comments on commit 9813779

Please sign in to comment.