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

[rust] Fix generation for optional and nullable fields (double option pattern) #13177

Merged
merged 2 commits into from
Oct 17, 2022

Conversation

jacob-pro
Copy link
Contributor

@jacob-pro jacob-pro commented Aug 13, 2022

Solution to: #13174

Where a field is both nullable and not-required it will now be represented using the double optional pattern. This is useful for partial update APIs where ignoring a field and setting it to null are two very different things.

It also makes a technical correction to the unusual case where a field is both required and nullable, such that deserializing now requires the field to be present in the JSON (though it can be null).

Rust technical committee tags:
@frol (2017/07) @farcaller (2017/08) @richardwhiuk (2019/07) @paladinzh (2020/05)

For context, this feature is already supported in rust-server, however rust-server uses a special purpose utility crate. In the case of the Rust client I think it makes sense to use the general purpose serde extension serde_with.

@jacob-pro jacob-pro requested a review from jimschubert as a code owner October 9, 2022 18:37
@jacob-pro jacob-pro changed the base branch from 7.0.x to master October 9, 2022 18:37
@jacob-pro jacob-pro changed the title [Rust] Issue 13174: Fix generation for optional and nullable fields (double option pattern) [rust] Issue 13174: Fix generation for optional and nullable fields (double option pattern) Oct 9, 2022
@jacob-pro
Copy link
Contributor Author

Hey @wing328 - I have updated this PR and it is now ready for review :)

@wing328 wing328 changed the title [rust] Issue 13174: Fix generation for optional and nullable fields (double option pattern) [rust] Fix generation for optional and nullable fields (double option pattern) Oct 17, 2022
@wing328
Copy link
Member

wing328 commented Oct 17, 2022

@wing328 wing328 merged commit c1c9cb2 into OpenAPITools:master Oct 17, 2022
@jacob-pro jacob-pro deleted the Issue-13174 branch October 17, 2022 20:21
@jacob-pro
Copy link
Contributor Author

thanks @wing328

@wing328 wing328 added this to the 6.2.1 milestone Nov 1, 2022
@iacore
Copy link

iacore commented Jul 26, 2023

How do I disable this behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants