Closed Jazzman123 closed 6 years ago
You can use SwaggerResponse attribute, I believe
For List;
[SwaggerResponse(HttpStatusCode.OK, Type = typeof(ODataResponse<List<YourClass>>))]
public async Task<IHttpActionResult> Get()
For Single Item;
[SwaggerResponse(HttpStatusCode.OK, Type = typeof(YourClass))]
public IHttpActionResult Get([FromODataUri] int key)
Thanks, adding that attribute makes it work.
For our OData implementation, the Get method on our controllers returns IHttpActionResult. Because of this, the Swagger docs for these controllers (as generated by Swashbuckle.OData) lists the return type as "object" for these methods. If I change the return type to the actual entity type (IQueryable for the query and SingleResult for the single-item get) then the correct types show up in the Swagger docs.
Is Swashbuckle.OData using reflection to generate the docs? I thought it would use the metadata from the OData endpoint, and the metadata is the same regardless of what return types are specified in the code.
We would like to use IHttpActionResult as the return types. Is it possible to tell Swashbuckle.OData what the correct return types should be in this case?