Basic usage - AlexanderKrutov/Radish GitHub Wiki

Using of Radish for documenting your REST API is pretty simple.

Step 1

Add attributes to handler methods, like:


public class PetsController : ApiController
{
	// ... some code omitted ...

	#region Radish
	[Method("GET", "/api/pets/<id>")]
	[MethodTitle("Get pet")]
	[MethodDescription("Returns Pet object by specified id.")]
	[RequestParameter("id", "Integer", "Id of the Pet")]
	[ResponseBodyDescription("Json-serialized Pet object")]
	[ResponseBodyExample(@"{""Id"":1, ""AnimalType"":""Cat"",""Name"":""Lisa"",""Breed"":""Turkish Angora"",""Age"":2,""Color"":""White""}")]
	[ResponseCode(200, "OK. On successful result.")]
	[ResponseCode(404, "Not Found. When pet with specified id was not found.")]
	#endregion Radish

	[HttpGet]
	[Route("pets/{petId:long}")]
	[ResponseType(typeof(Pet))]
	public IHttpActionResult GetPet(int petId)
	{
		Pet pet = DataBase.Instance.GetPet(petId);
		if (pet == null)
		{
			return this.NotFound(String.Format("Pet with id = {0} not found.", petId));
		}
		return Ok(pet);
	}
}

Step 2

To obtain documentation, write:

Documentor documentor = new Documentor();
string helpContent = documentor.Content;

That's it!

To learn more about attributes used for generating documentation, read article Attributes.