Converting OpenAPI to DITA XML and Publishing to WebHelp (Experimental)
14 Mar 2022
Read time: 2 minute(s)
OpenAPI documentation is usually stored in JSON or YAML formats. In this topic, we will attempt to convert OpenAPI documentation to Markdown using widdershins, convert Markdown to DITA content using the Oxygen Batch Converter add-on, and then publish to WebHelp Responsive output.
- Download the Yaml or JSON representation of an OpenAPI specification to the local disk. For this example, I used the OpenAPI documentation from the Oxygen Content Fusion server: https://fusion.oxygenxml.com/api/swagger.json.
- Download and install widdershins.
- From a command prompt or terminal, produce a Markdown representation of the original
API
file:
widdershins --search false --language_tabs 'ruby:Ruby' 'python:Python' --summary /../swagger.json -o swagger.md
-
In the Oxygen application, use the
conversion to convert the Markdown file to a DITA Map. - Once you have the DITA Map, you can publish it to WebHelp Responsive or integrate it as part of a larger DITA Map. The map can be further modified by adding chunking attributes to avoid breaking the published output in too many HTML files.
- When publishing the swagger.ditamap to WebHelp, we set the
validate
parameter tono
because the produced DITA content had some invalid content inside. - The resulting WebHelp output is available here: https://blog.oxygenxml.com/resources/open-api-webhelp/returns_the_current_user%27s_details.html. Codeblocks that contain sample source code are divided into multiple tabs using this plugin: Show Consecutive DITA Code Blocks in Separate Tabs.