If I create a method as follows:
/// <summary>
/// Summary here
/// </summary>
/// <returns>THIS DOES NOT SHOW ANYWHERE</returns>
/// <remarks>Remarks here</remarks>
public async Task<string> MyMethod()
{
return "Hello World";
}
And I have Swashbuckle.AspNetCore installed and setup, then the documentation is generated correctly, except the value in the <returns>
block does not get generated into anything in the json:
"/api/v1.0/Exhibits/TestMethod1": {
"get": {
"tags": [
"Blah"
],
"summary": "Summary here",
"description": "Remarks here",
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"type": "string"
}
},
"application/json": {
"schema": {
"type": "string"
}
},
"text/json": {
"schema": {
"type": "string"
}
}
}
}
}
}
},
How can I persuade it to export this to a relevant field, or is this not possible?
The return description is different, depend on status code in each response. so you need to specify what is description for each status code.
Swagger use one or more <response code="xxx">
instead of single <returns>
your document should be look like this
/// <summary>
/// Retrieves a specific product by unique id
/// </summary>
/// <remarks>Awesomeness!</remarks>
/// <response code="200">return Product with spacific id</response>
/// <response code="400">Product Not found</response>
/// <response code="500">Oops! Can't Found your product right now due to internal error</response>
[HttpGet("{id}")]
[ProducesResponseType(typeof(Product), 200)]
[ProducesResponseType(typeof(IDictionary<string, string>), 400)]
[ProducesResponseType(500)]
public Product GetById(int id)
read How to add method description in Swagger UI in WebAPI Application for more
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With