Question

I'm documenting an API and I'm wondering how to link the response format to the ViewModel I've created. The ViewModel has annotations which I want the user to browse. The problem being my controller returns HttpResponseMessage not the actual model itself, so the WebAPI help page skips over documenting this;

API Help page

In the HelpPageConfig.cs I've added the following;

config.SetSampleResponse(xmloutput.ToString(), new MediaTypeHeaderValue("text/xml"), 
   "Course", "Get", new[] { "Id" });

How can I work around this, and create a link in the Help page using the APIExplorer. Or does this have to be done manually?

Example controller;

[HttpGet]
public HttpResponseMessage Get(string id)        {
   var obj = new Course(id);
   return this.Request.CreateResponse<Course>(HttpStatusCode.OK, obj);
}
Was it helpful?

Solution

I've found out how to do this, with the recently introduced ResponseType attribute;

 [HttpGet]
 [ResponseType(typeof(CourseModel))]
 public HttpResponseMessage GetById(string id)
 {
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top