How to post Swagger API documentation to Atlassian Confluence programmatically? (Usage of Swagger Confluence tool and Confluence REST API)

霸气de小男生 提交于 2019-12-05 04:49:19

Well, turns out even though http://<server>:<port>/confluence/rest/api/ returned HTTP 200 OK, the URL was wrong. The above is the so called "URL with context" (the /confluence/ part) and what I needed was the URL without context (no /confluence/ in the URL).

Here's how I tested the URL working by receiving the 200, Headers (-v) and page content as JSON response: curl -v -u user:pass http://<server>:<port>/rest/api/content/{id}
The page ID can be checked by pressing (or mouse-overing) the "Edit" button on the Confluence page.

And here's how I finally got the automatic Confluence upload working:
java -jar <system path root>/swagger-confluence-cli-all-2.2-RELEASE.jar -u "http(s)://<server>:<port>/rest/api/" -b "<base64 encoded userid:password string>" -a "<parent page id>" -k "<space key>" -g "true" -i "true" -s "<myschema.json>" -t "<Title for generated page>" -m "single"

The Swagger Confluence tool is awesome, by the way, and the results are as good as in the demo!

[Edited to add]:
Confirmed the Swagger Confluence library/tool (v2.2) to work on both my target Confluence Servers, versions 5.8.14 and 5.9.2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!