#Postman.WebApi.MsBuildTask
####What is it?
An MSBuild task to automatically generate documented Postman 3 collections from your ApiController derived classes
####What does it do?
MSBuild executes
Postman.WebApi.MsBuildTask.Generator as an AfterBuild task to create a JSON Postman collection file containing folders (ApiControllers) and requests (HTTP verbs) within a project. It utilizes standard .NET documentation comments and attributes to document your Postman requests.
- Runs automatically after project build so your APIs and test requests stay in sync
- No run time dependency (only compile time)
- Won't muck up your project with MVC or
Microsoft.AspNet.WebApi.HelpPagedependencies - Documents
ResponseTypeattributes so you can useIHttpActionresponses - Documents
AuthorizeandObsoleteattributes - Documents OData
EnableQueryattribute - You can use tags like
<c>,<code>,<para>,<example>,<exception>,<paramref>,<see>,<seealso>,<typeparamref>
####How do I use it?
- Install the NuGet package
- Make sure you have checked the "XML Documentation file" checkbox in the build properties for the project containing your ApiControllers
- Build your project to create the
<AssemblyName>.postman.jsonfile in your project root - Open Postman and import the collection file
- Add a new Postman environment and set key to
urland value to your http api endpoint root e.g.http://localhost:3000/myapp
####How do I configure it?
You can override the default configuration by modifying the .targets file located in the packages directory. Note that removing/upgrading the package will set the configuration back to the defaults.
| Option | Description | Default | Required |
|---|---|---|---|
OutputDirectory |
The directory to write the output Postman .json file | $(ProjectDir) |
Yes |
AssemblyFilePath |
The complete path and file name to the project target assembly | $(TargetPath) |
Yes |
EnvironmentKey |
The Postman environment key variable | url |
No |
RouteTemplate |
The HTTP route template used to setup route maps | api/{controller} |
No |
Please do! PRs are welcome. Just follow the conventions in the source code.
- The XML documentation file must be located in the same folder as the project assembly target and have the same name. For example, if your project assembly is called
myproject.dll, the XML documentation file must be namedmyproject.xmland be located in the same directory (e.g.bin\debug). - Errors, warnings and messages from the Postman build task can be viewed in the Output | Build window and the build Error List
- Only Postman version 3 is supported at this time
- There are some limitations with Postman markdown that prevent the use of certain Markdown (tables, icons and inline html).
[1]: Thanks to @azzlack for the source to his XmlDocumentationProvider
Please open an issue if you have any problems or questions.