This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
Add IsRequired, DefaultValue to ApiParameterDescription #7563
Labels
3 - Done
bug
cost: M
Will take from 3 - 5 days to complete
PRI: 1 - Required
Must be handled in a reasonable time
Milestone
This is low hanging fruit that we just missed for whatever reason. This means that Swashbuckle/NSwag and other libraries that produce swagger can't see default values when they apply to query string parameters, and can't tell when a parameter should be documented as 'required'.
This makes a lot more sense for us to add now that we have validation on parameters.
We currently only support default values for route parameters via https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNetCore.Mvc.Abstractions/ApiExplorer/ApiParameterDescription.cs
The fix for would look like:
ApiParameterDescription.IsRequired
andApiParameterDescription.DefaultValue
ApiParameterRouteInfo.DefaultValue
- the new parameter handles more casesDefaultApiDescriptionProvider
to add new logic to set theseBy default most parameters will be optional because that's the truth of MVC.
Now that we support validation of parameter nodes we can actually provide this data. A parameter should be considered required if it:
[FromBody]
[BindRequired]
We may need to polish that list of conditions a bit, but that's a good start.
The text was updated successfully, but these errors were encountered: