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

After upgrading to 5.4.0 when using Newtonsoft serialization [JsonRequired] fields are marked as nullable #1645

Closed
RedwoodForest opened this issue Apr 29, 2020 · 2 comments

Comments

@RedwoodForest
Copy link

After upgrading from 4.x to 5.4.0 (including enabling Newtonsoft serializer support) model object fields marked with [JsonRequired] are marked as nullable in the swagger.json (and shown as nullable in the UI).

[JsonProperty(Required = Required.Always)]``` works as expected (these fields are not marked as nullable).

Code:

public class TestDto {
    [JsonRequired]
    public String jsonRequired;
  
    [JsonProperty(Required = Required.Always)]
    public String jsonProperty;
}

swagger.json:

"jsonRequired": {
  "type": "string",
  "nullable": true
},
"jsonProperty": {
  "type": "string"
}

For now I've worked around this issue by converting all our models to use the JsonProperty approach.

@domaindrivendev
Copy link
Owner

This is indeed a regression that was introduced in the 5.x line. I just pushed c4dcb1b to fix it. Preparing a v5.4.1 patch release now ...

@RedwoodForest
Copy link
Author

Thanks!

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

No branches or pull requests

2 participants