The catch? You can publish only to web.postman.co, where it must either be a public collection or be private to you. Getting an enterprise account could probably give you more flexibility, and I have not had an opportunity to look at that.
At any rate, I have worked for many clients who want API documentation on their Wiki which, if you take the defaults, looks pretty sad. But that is not the biggest problem. The biggest problem is, how do you get all those nice, tested API calls from your Postman collection into Wiki?
Well, even that is not a big problem, if you write your own little script to generate Confluence Wiki markup from Postman collections. Which is what I did.
And the pages it generates are way easier on the eye than the standard issue Confluence look. But beware, it is a quick hack for a very specific purpose. So it has all the limitations you would expect from a quick hack for a very specific purpose.
The documentation workflow looks like this:
- Create API documentation in Postman as a Collection. Use Variables to parameterize all API calls and make sure the markdown you use within Postman is also part of Confluence Wiki markup. Execute each request and save the results as examples
- Export the collection in the
- Edit lines 10 and 11 in the following python script to set your input file and output directory
- Then, run it to generate Confluence Wiki markup. It generates a separate file for each
Vrb-APIcombination. For instance, if you have
/user, it will generate two files:
1.user-GET.txt and 2.user-POST.txt
- Upload the following into your Wiki as a CSS file attachment to your API pages’ root
- Insert a CSS macro the top of your Wiki page and point its URL attribute to this CSS file. Then, select the
markupmenu option and simply copy-paste the contents of these files into it as Confluence Markup
Here is what it will look like:
That is it! Nothing earth-shattering, just a piece of useful code that I thought might save you some time!