-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fully Expand Models in ApiExplorer #2378
Comments
Awesome - this will really simplify things in Swashbuckle! You should have a quick read over this issue if you get a chance. It's related to the way in which I implemented a workaround for lack of the above up to this point. |
In that case, what we recommend for the app developer is that you use the attributes to specify precisely what you mean. Due to compat with MVC's ability to handle form posts, model binding always tries first to use the parameter name as a prefix and then again with the empty string as a prefix. So for the example in the bug:
There are three equally valid ways to set
This is great for MVC/browser scenarios, but for an API it's better to be precise. Many users don't realize that all of these are valid, and the risk is that an innocent-looking refactor will break existing clients. For that reason we recommend that you be explict when defining an API about the behavior re:prefixes
|
I'm not 100% sure that this guidance is relevant for a WebAPI 2 user, but this case is something we definitely want to support precision on in the next release. |
This change dramatically simplifies the parameter discovery logic in DefaultApiDescriptionProvider. Instead of surfacing POCO objects as parameters, we now fully expand every model. The rationale is that we want to show every key/value that can be set by the user and not force consumers of ApiDescription to do that themselves. Tests are cleaned up to match the new behavior.
This is feedback from @domaindrivendev:
Today we'd describe
address
as a single parameter, despite the fact that it maps to different query string keys (address.zipcode
,address.state
, etc...). The feedback is that Swashbuckle (and other consumers) would always want this data to be broken down as much as possible (today it's as brief as possible).We should either break this down fully (by property) or break down the first level (by property).
We'd of course apply cycle-breaking, and terminate on any type with a type-converter from string.
The text was updated successfully, but these errors were encountered: