Click here to Skip to main content
15,880,364 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Swashbuckle can automatically generates API documentation based on code (with details return model)
public ActionResult<List<Student>> GetStudents()
    return CollegeRepository.Students;
It includes about schemas, example value as json, etc.

Is there any way to make Swashbuckle automatically generates API documentation a JsonResult?
public JsonResult GetStudents()
    var json = new JsonResult(new
        data = CollegeRepository.Students,
        message = "success"

    json.StatusCode = StatusCodes.Status200OK;

    return json;

What I have tried:

many search on google, stackoverflow

1 solution

Out of the box, you can't automatically generate API documentation for JsonResult. As you aren't returning a concrete type, with a well defined structure for a particular result, it's difficult for Swashbuckle to know what to produce. What you can do, instead, is add a SwaggerResponse to your code to say what's being returned.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900