I have created an API method using Web API 2 (MVC 5), as shown below:
/// <summary>
/// Import all of the jobs for the given organisation. This method assumes that all of the organisation's active jobs are present in the jobs array.
/// To delete a job, simply exclude it from the jobs array. To delete all of the jobs, pass an empty array
/// </summary>
/// <param name="org">Organisation Id, provided by Shopless team</param>
/// <param name="jobs">Full list of jobs which should be imported, json array</param>
/// <response code="200">Jobs list have been queued for import (includes validation errors if any)</response>
/// <response code="401">Access to this organisation was denied</response>
/// <response code="404">Invalid organisation id</response>
[SwaggerResponse(HttpStatusCode.BadRequest)]
[SwaggerResponse(HttpStatusCode.NotFound)]
[SwaggerResponse(HttpStatusCode.Unauthorized)]
[HttpPost]
[Route("org/{org}/jobs/full-import")]
public IHttpActionResult FullImport(long org, [FromBody] List<JobApiDto> jobs)
{
if (!ModelState.IsValid)
{
return BadRequest("Jobs array is invalid");
}
else if (org < 1)
{
return NotFound("Invalid organisation id");
}
else if (!((ClaimsPrincipal)User).HasReadWriteAccessToOrganisation(org))
{
return Unauthorized("Access to this organisation was denied");
}
_apiProductUploader.Upload(org, jobs, out string message);
return Accepted(message);
}
The above methods accepts a list of JobApiDto
:
public class JobApiDto
{
/// <summary>
/// Job Id (unique id assigned to the job by the API consumer)
/// </summary>
/// <example>e5f52dae-e008-49bd-898b-47b5f1a52f40</example>
public string UniqueThirdPartyId { get; set; }
/// <summary>
/// Short description which will be displayed in search result
/// </summary>
/// <example>Competitive salary, great team, cutting edge technology!</example>
public string Synopsis { get; set; }
// more properties
And this is how the Swagger documentation looks like:
When I expand OrganisationJobs
action:
As you can see the xml documentation for the controller has generated the correct description for the API method, but I am not able to understand why the description that I have provided for my model (i.e. JobApiDto
) does not show?
Also when I click on Example Value nothing happens.