Skip to content
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
@@ -1,6 +1,5 @@
package org.openapitools.openapidiff.core.model;

import io.swagger.v3.oas.models.PathItem;
import io.swagger.v3.oas.models.media.Schema;
import java.util.*;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -157,9 +156,6 @@ private DiffResult calculateCoreChanged() {
}

private boolean compatibleForRequest() {
if (PathItem.HttpMethod.PUT.equals(context.getMethod()) && !increasedProperties.isEmpty()) {
return false;
}
return (oldSchema != null || newSchema == null);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package org.openapitools.openapidiff.core;

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

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

public class AddPropPutDiffTest {
private final String OPENAPI_DOC1 = "add-prop-put-1.yaml";
Expand All @@ -15,7 +16,10 @@ public void testDiffSame() {
}

@Test
public void testDiffDifferent() {
Copy link

@mas-chen mas-chen Jul 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should remove this test. In fact it should be kept to check that the two docs are indeed compatible.

So we should have a testFieldAdditionalInPutApiIsCompatible or something similar

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mas-chen Good point about not losing a test. I think my #546 PR will address this.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to keep changes isolated. Since this PR is introducing a new fix, that particular test should be included here, to validate your change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. I've made your suggested changes. Look ok?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me but I'm not a contributor, would be good to get the help of one to merge this fix

assertOpenApiBackwardIncompatible(OPENAPI_DOC1, OPENAPI_DOC2);
public void testFieldAdditionalInPutApiIsCompatible() {
// See https://github.com/OpenAPITools/openapi-diff/pull/537
ChangedOpenApi changedOpenApi = OpenApiCompare.fromLocations(OPENAPI_DOC1, OPENAPI_DOC2);
assertThat(changedOpenApi.isDifferent()).isTrue();
assertThat(changedOpenApi.isCompatible()).isTrue();
}
}