When an OData controller action has an ODataQueryOptions parameter this seems to cause the ODataQueryOptions type to be picked up as a normal input parameter, which the gets defined in the the Swagger JSON definitions/params. This also results in the Swagger UI expecting the OData options to be supplied as a parameter.
E.g. Amending the CustomersController in the Samples projects as follows:
[EnableQuery(PageSize = 5)]
public async Task<IHttpActionResult> Get(ODataQueryOptions<Customer> options)
{
var customers = await _db.Customers.ToListAsync();
return Ok(customers);
}
... results in this Swagger output
In the Swagger UI this is manifested as an extra parameter on the Action. E.g.
I've got a simple fix for this, with a covering test. Happy to put in a PR if that helps. It's a one-line fix to ODataActionDescriptorMapperBase.CreateParameterDescriptions to check parameterBinding.Descriptor.IsODataLibraryType() before adding.
When an OData controller action has an
ODataQueryOptions
parameter this seems to cause the ODataQueryOptions type to be picked up as a normal input parameter, which the gets defined in the the Swagger JSON definitions/params. This also results in the Swagger UI expecting the OData options to be supplied as a parameter.E.g. Amending the CustomersController in the Samples projects as follows:
... results in this Swagger output
In the Swagger UI this is manifested as an extra parameter on the Action. E.g.
I've got a simple fix for this, with a covering test. Happy to put in a PR if that helps. It's a one-line fix to ODataActionDescriptorMapperBase.CreateParameterDescriptions to check
parameterBinding.Descriptor.IsODataLibraryType()
before adding.