Skip to content

This is a tool for Web API, in .NET, to allow you to automatically build RAML documentation

License

Notifications You must be signed in to change notification settings

yui0810/RAMLsharp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RAMLSharp

This is a tool for ASP.net Web API that will allow you to build RAML documentation.

Newly added, RAMLSharp is now in F#

##Purpose The purpose of the tool is to allow a developer to code RAML documentation, using Attributes and Asp.net Web API Help Pages. This allows you to create RAML documentation using help pages behind the scenes. The workflow would be:

  1. Add attributes to each route
  2. Add some XML documentation
  3. Make an endpoint
  4. Configure XML documentation
  5. Generate RAML
  6. Enjoy RAML

##Attributes Here is a list of all the attributes so far:

  1. RequestHeaders - This is for the description of Headers on the Request.
  2. ResponseBody - This is the response body that the request may look like.
  3. All other information is filled in by XML Documentation.

If there is a feature that is missing, check out the How to Contribute section.

##Setup

  1. First, add the nuget package from https://www.nuget.org/packages/RamlSharp/:
PM> Install-Package RamlSharp
  1. To get XML Documentation, you need to add this line to your WebApiConfig.cs:
public static void Register(HttpConfiguration config)
{
    // Web API configuration and services

    config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml")));
}
  1. Enable XML documentation under the project properties of the Web API project. Click on the build tab, and make sure the path matches to step 2.

  2. The controller call for RAML is already added. You can visit your http://{Your API BaseUrl}/api/RAML

  3. Lastly, add some XML documentation to your API calls:

/// <summary>
/// This inserts a test
/// </summary>
/// <param name="testCase">The test</param>
[RequestHeaders(Name = "Accept", 
    Example = "application/json", 
    IsRequired = true,
    Type = typeof(string), 
    Description = "This is the content type we want from the server"
)]
[ResponseBody(StatusCode = HttpStatusCode.OK, ContentType = "application/json", Example = "[should be the location of this test]", Description="This is the standard request back.")]
[ResponseBody(StatusCode = HttpStatusCode.BadRequest, ContentType = "application/json", Example = "[bad request]")]
[ResponseBody(StatusCode = HttpStatusCode.InternalServerError, ContentType = "application/json", Example = "[internal server error]")]
[Route("api/tests"), HttpPost]
public void Post([FromBody]string testCase)
{
    //Inserts a test file
}

(You can check out more examples from the RAMLSharp.Sample project in the solution.)

This will allow you to take the RAML generated and view your API in something like API Designer (https://github.com/mulesoft/api-designer):

##How to Contribute

If you would like to contribute, please feel free to do a pull request.

Special thanks for contributing:

Jorden Lowe

Dominick Aleardi

Viacheslav Barashkov

About

This is a tool for Web API, in .NET, to allow you to automatically build RAML documentation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • F# 85.1%
  • C# 9.7%
  • HTML 5.1%
  • Classic ASP 0.1%