0

I am trying to return an object which is structured as below:

public class ApiRouteDocument
{
    //controllername tag
    public string ControllerName { get; set; }
    public string ControllerDescription { get; set; }
    public IList<RoutePath> Paths;
}
public class RoutePath
{
    //get
    public string Method { get; set; }

    //operationid
    public string Name { get; set; }

    //summary
    public string Description { get; set; }

    //path
    public string Path { get; set; }
}

I am returning in the following way from the controller:

[HttpGet("all")]
public IActionResult GetRoute()
{
    var endPoint = _apiExplorer.GetndpointDescription();
    return Json(endPoint);
}

But the action returns only the parent properties, the child properties public IList<RoutePath> Paths; are never returned to the browser. I did try sending the request from different applications but the child properties are never returned.

The JSON which is returned in the browser:

[{"controllerName": "Contact", "controllerDescription": "Contacts"}, {"controllerName": "Transaction", "controllerDescription": null}]

Am I missing anything on my startup? do I have to add anything for the JSON return objects?

Rasik
  • 1,961
  • 3
  • 35
  • 72

0 Answers0