-
-
Notifications
You must be signed in to change notification settings - Fork 239
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
Behavior change in 0.8.19 with default
, required
, and skip_serializing_if
#292
Comments
This is an interesting case, and frankly I'm not 100% sure what the "correct" behaviour here is with this complicated combination of In any case, I think this does what you want, and works in all versions: #[derive(JsonSchema)]
pub struct WithoutNullable {
#[schemars(default, with = "String")]
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<String>,
} Does that solve your problem? |
Sure! Or we can hand roll a |
Thanks for reporting this, I've now released 0.8.20 which restores the previous behaviour |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [schemars](https://graham.cool/schemars/) ([source](https://togithub.com/GREsau/schemars)) | dependencies | patch | `0.8.19` -> `0.8.21` | --- ### Release Notes <details> <summary>GREsau/schemars (schemars)</summary> ### [`v0.8.21`](https://togithub.com/GREsau/schemars/blob/HEAD/CHANGELOG.md#0821---2024-05-23) [Compare Source](https://togithub.com/GREsau/schemars/compare/v0.8.20...v0.8.21) ##### Fixed: - Fix `null` default not being set on generated schemas ([https://github.com/GREsau/schemars/issues/295](https://togithub.com/GREsau/schemars/issues/295) / [https://github.com/GREsau/schemars/pull/296](https://togithub.com/GREsau/schemars/pull/296)) ### [`v0.8.20`](https://togithub.com/GREsau/schemars/blob/HEAD/CHANGELOG.md#0820---2024-05-18) [Compare Source](https://togithub.com/GREsau/schemars/compare/v0.8.19...v0.8.20) ##### Fixed: - Revert unintentional change in behaviour when combining `default` and `required` attributes ([https://github.com/GREsau/schemars/issues/292](https://togithub.com/GREsau/schemars/issues/292)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/bitwarden/sdk). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNjguMTAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4zNjguMTAiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbXX0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
We use
schemars
for our OpenAPI document generation. We have a type with an optional property. With the OpenAPI generation this comes out asnullable
:We don't want the
nullable
in the spec and found prior to 0.8.19 that this combination got what we wanted:Which produces this in 0.8.17
However, in 0.8.19 we see this:
Is this behavior change from 0.8.17 to 0.8.19 intentional?
The text was updated successfully, but these errors were encountered: