Model Properties - Default Values
See original GitHub issueHi, First of all, brilliant work. I’m new to Swagger and Swashbuckle made life very easy for us to integrate into our API, a few well written comments later and we’re good.
We are facing one minor issue in which our models assume default values which don’t look that appealing. See the image attached.
Is there a way to specify a default value for model properties? I have had no luck using default value attributes so far e.g.
[System.ComponentModel.DefaultValue("My Default String Value")]
public string Value { get; set; }
Issue Analytics
- State:
- Created 9 years ago
- Comments:15 (5 by maintainers)
Top Results From Across the Web
c# - implementing default values in a Model
Assuming it's a POCO, I've always found the constructor is fine for establishing default values. I usually take that opportunity to declare ...
Read more >Set Default Value to Property in C#
Here you will learn how to assign the default value to a property or auto-implemented property in a class.
Read more >Property Default Values - SoftFluent
In the Business Object Model layer, the default value of a property is the initialization value that takes this property in its parent...
Read more >DefaultValueAttribute Class (System.ComponentModel)
You can create a DefaultValueAttribute with any value. A member's default value is typically its initial value. A visual designer can use the...
Read more >Using Spring @Value with Defaults
A quick and practical guide to setting default values when using the @Value annotation in Spring.
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
Is Swashbuckle available for EclipseEE?
This extension of @AndyPook’s code also flags optional parameters as
"required": false
in the Swagger file, as well as including the default value.