Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for content-type changes in request/response #190

Merged
merged 1 commit into from
Dec 6, 2020
Merged
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 @@ -27,4 +27,36 @@ public void testSameContentDiff() {
ChangedOpenApi changedOpenApi = OpenApiCompare.fromLocations(OPENAPI_DOC2, OPENAPI_DOC2);
assertThat(changedOpenApi.isUnchanged()).isTrue();
}

@Test
public void testAddedResponseContentTypeDiff() {
ChangedOpenApi changedOpenApi =
OpenApiCompare.fromLocations(
"content_type_response_add_1.yaml", "content_type_response_add_2.yaml");
assertThat(changedOpenApi.isCompatible()).isFalse();
}

@Test
public void testRemovedResponseContentTypeDiff() {
ChangedOpenApi changedOpenApi =
OpenApiCompare.fromLocations(
"content_type_response_add_2.yaml", "content_type_response_add_1.yaml");
assertThat(changedOpenApi.isCompatible()).isTrue();
}

@Test
public void testAddedRequestContentTypeDiff() {
ChangedOpenApi changedOpenApi =
OpenApiCompare.fromLocations(
"content_type_request_add_1.yaml", "content_type_request_add_2.yaml");
assertThat(changedOpenApi.isCompatible()).isTrue();
}

@Test
public void testRemovedRequestContentTypeDiff() {
ChangedOpenApi changedOpenApi =
OpenApiCompare.fromLocations(
"content_type_request_add_2.yaml", "content_type_request_add_1.yaml");
assertThat(changedOpenApi.isCompatible()).isFalse();
}
}
31 changes: 31 additions & 0 deletions core/src/test/resources/content_type_request_add_1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
openapi: "3.0.1"
info:
title: "Test title"
description: "This is a test metadata"
termsOfService: "http://test.com"
contact:
name: "Mark Snijder"
url: "marksnijder.nl"
email: "[email protected]"
license:
name: "To be decided"
url: "http://test.com"
version: "version 1.0"
paths:
/pets/{id}:
get:
description: Returns a user based on a single ID, if the user does not have access to the pet
operationId: find pet by id
requestBody:
content:
application/json:
schema:
type: string
responses:
'200':
description: response
content:
application/json:
schema:
type: string
34 changes: 34 additions & 0 deletions core/src/test/resources/content_type_request_add_2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
openapi: "3.0.1"
info:
title: "Test title"
description: "This is a test metadata"
termsOfService: "http://test.com"
contact:
name: "Mark Snijder"
url: "marksnijder.nl"
email: "[email protected]"
license:
name: "To be decided"
url: "http://test.com"
version: "version 1.0"
paths:
/pets/{id}:
get:
description: Returns a user based on a single ID, if the user does not have access to the pet
operationId: find pet by id
requestBody:
content:
application/json:
schema:
type: string
application/xml:
schema:
type: string
responses:
'200':
description: response
content:
application/json:
schema:
type: string
26 changes: 26 additions & 0 deletions core/src/test/resources/content_type_response_add_1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
openapi: "3.0.1"
info:
title: "Test title"
description: "This is a test metadata"
termsOfService: "http://test.com"
contact:
name: "Mark Snijder"
url: "marksnijder.nl"
email: "[email protected]"
license:
name: "To be decided"
url: "http://test.com"
version: "version 1.0"
paths:
/pets/{id}:
get:
description: Returns a user based on a single ID, if the user does not have access to the pet
operationId: find pet by id
responses:
'200':
description: response
content:
application/json:
schema:
type: string
29 changes: 29 additions & 0 deletions core/src/test/resources/content_type_response_add_2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
openapi: "3.0.1"
info:
title: "Test title"
description: "This is a test metadata"
termsOfService: "http://test.com"
contact:
name: "Mark Snijder"
url: "marksnijder.nl"
email: "[email protected]"
license:
name: "To be decided"
url: "http://test.com"
version: "version 1.0"
paths:
/pets/{id}:
get:
description: Returns a user based on a single ID, if the user does not have access to the pet
operationId: find pet by id
responses:
'200':
description: response
content:
application/json:
schema:
type: string
application/xml:
schema:
type: string