I have configured Swagger for my asp.net webapi which is similar to one shown below
[HttpGet]
[Route("search")]
public async Task<HttpResponseMessage> Get([FromUri]SearchCriteria searchCriteria)
When i see the swagger documentation for the webapi , the parameter is displaying as
searchCriteria.sortField searchCriteria.sortDirection and so on... being the sortField, sortDirection are properties of SearchCriteria
How to get the parameter names without the object.propertyname format?
Can anyone help how to fix this? Thanks
When you pass parameter
Name = ""
to theFormUri
attribute Swashbuckle generates parameter names in unqualified form e.g.sortField
instead ofsearchCriteria.sortField
.I assume you are using Swashbuckle.
Look at
DocumentFilters
andOperationFilters
. You can extend Swashbuckle to intervene at the document or operation level to modify the output.Read through the Swashbuckle documentation, it is fairly straight forward to implement either of these two interfaces.
Here's an
OperationFilter
I once used to remove the class name from query parameters.Add it to you
SwaggerConfig
like this:BTW: The regex is inspired by https://stackoverflow.com/a/7794128/502395