Don't include properties that are not required in the value
See original GitHub issueWith this schema:
{
"type": "object",
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "integer"
}
}
}
If user doesn’t put any data in, the output value should be {}
. None of the properties are required.
If a property is required, then it makes sense to fill in the value for required property with some default value:
{
"type": "object",
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "integer"
}
},
"required": ["age"]
}
This should output {"age": 0}
since "age"
is required and empty object will not conform to the schema
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Don't fail if @Value is not supplied in properties?
In general it is a good practice to fail on unknown properties (they are properties, because your application needs them to function), or...
Read more >How to ignore properties with System.Text.Json | Microsoft Learn
To ignore individual properties, use the [JsonIgnore] attribute. You can specify conditional exclusion by setting the [JsonIgnore] attribute's ...
Read more >object — Understanding JSON Schema 2020-12 documentation
By default, the properties defined by the properties keyword are not required. However, one can provide a list of required properties using the...
Read more >Create and edit properties - Knowledge Base - HubSpot
If you want to view or update values for properties, learn how to edit property values on a ... This is not required...
Read more >Title 57. Real Estate Chapter 1 Conveyances - Utah Legislature
(2) "Document" means every instrument in writing, including every conveyance, affecting, ... 57-1-2 Words of inheritance not required to pass fee.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any update on this?
Hello; For C# (.net 6 ), when you correct your bool value as follows, the false value swagger also works. public bool? IsBlock { get; set; } = false; “worked after adding a question mark”
good work