Skip to content

Commit 8d804d4

Browse files
authored
fix: Adding response media type is breaking change (#328)
Adding a response media type is a non-breaking change, as long as preexisting ones are still compatible. Clients still can requests all existing media type via `Accept` header as they have done before. Removing an existing media type on the over hand is a breaking change, because existing client's requesting this response representation (again via `Accept` header) will probably get a `406 Not Acceptable`.
1 parent 4faa09b commit 8d804d4

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

core/src/main/java/org/openapitools/openapidiff/core/model/ChangedContent.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public DiffResult isCoreChanged() {
3131
if (increased.isEmpty() && missing.isEmpty()) {
3232
return DiffResult.NO_CHANGES;
3333
}
34-
if (context.isRequest() && missing.isEmpty() || context.isResponse() && increased.isEmpty()) {
34+
if (context.isRequest() && missing.isEmpty() || context.isResponse() && missing.isEmpty()) {
3535
return DiffResult.COMPATIBLE;
3636
}
3737
return DiffResult.INCOMPATIBLE;

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ public void testAddedResponseContentTypeDiff() {
3333
ChangedOpenApi changedOpenApi =
3434
OpenApiCompare.fromLocations(
3535
"content_type_response_add_1.yaml", "content_type_response_add_2.yaml");
36-
assertThat(changedOpenApi.isCompatible()).isFalse();
36+
assertThat(changedOpenApi.isCompatible()).isTrue();
3737
}
3838

3939
@Test
4040
public void testRemovedResponseContentTypeDiff() {
4141
ChangedOpenApi changedOpenApi =
4242
OpenApiCompare.fromLocations(
4343
"content_type_response_add_2.yaml", "content_type_response_add_1.yaml");
44-
assertThat(changedOpenApi.isCompatible()).isTrue();
44+
assertThat(changedOpenApi.isCompatible()).isFalse();
4545
}
4646

4747
@Test

0 commit comments

Comments
 (0)