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

Treat new PUT request properties as compatible again #538

Merged
merged 2 commits into from
Jul 25, 2023

Conversation

westse
Copy link
Contributor

@westse westse commented Jun 28, 2023

Effectively reverts change for #136 (and PR #137) which appear invalid in intent, implementation, and test.

  • Invalid in intent: Invalid backward compatibility result for new read-only property in PUT operations #136 claims that adding a readOnly property to the request body of a PUT request is a breaking change because clients will begin to omit it and the server will interpret the omission as a directive to delete the property. This is incorrect because the server should expect, per the OAS spec, that readOnly properties "SHOULD NOT be sent as part of the request". So it would be a bug for the server to delete any data associated with the readOnly property. Regardless, the API is left unbroken if the server simply ignores readOnly properties.
  • Invalid in implementation: the code treats as incompatible any new PUT request property, not just readOnly properties.
  • Invalid in test: no readOnly properties are tested.

In theory one could argue that some servers might enforce the "SHOULD NOT" language of the spec by returning validation errors where they didn't before, and this would constitute an API breakage. But that should be discussed in a different issue.

Fixes #537
Refs #136
Refs #137

}

@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

Effectively reverts change for OpenAPITools#136 which appears invalid in intent, implementation, and test.
- Invalid in intent: OpenAPITools#136 claims that adding a readOnly property to the request body of a PUT request is a breaking change because clients will begin to omit it and the server will interpret the omission as a directive to delete the property. This is incorrect because the server should expect, [per the OAS spec](https://spec.openapis.org/oas/v3.0.3#fixed-fields-19), that readOnly properties "SHOULD NOT be sent as part of the request". So it would be a bug for the server to delete any data associated with the readOnly property. Regardless, the API is left unbroken if the server simply ignores readOnly properties.
- Invalid in implementation: the code treats as incompatible any PUT request property, not just readOnly properties.
- Invalid in test: no readOnly properties are tested.

In theory one could argue that some servers might enforce the "SHOULD NOT" language of the spec by returning validation errors where they didn't before, and this would constitute an API breakage. But that should be discussed in a different issue.
@joschi joschi changed the title Fix #537 Treat new PUT request properties as compatible. Treat new PUT request properties as compatible again Jul 25, 2023
@joschi joschi added this to the 2.1.0 milestone Jul 25, 2023
@joschi joschi added the bug label Jul 25, 2023
Copy link
Collaborator

@joschi joschi left a comment

Choose a reason for hiding this comment

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

@westse Thanks for your contribution!
@mas-chen Thanks a lot for the additional review! ❤️

@joschi joschi merged commit 3c026ef into OpenAPITools:master Jul 25, 2023
5 checks passed
joschi added a commit that referenced this pull request Jul 25, 2023
@westse westse deleted the read-only-prop-put branch July 26, 2023 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Treat new PUT request properties as compatible
3 participants