Created
April 21, 2021 07:45
-
-
Save theletterf/951897825d4c10d2e9078bbf60d89983 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Takes the OpenAPI file | |
Param( | |
[parameter(mandatory=$true)][string]$file | |
) | |
$name = [System.IO.Path]::GetFileNameWithoutExtension($file) | |
# Converts OpenAPI to Markdown documentation | |
npm install -g widdershins | |
widdershins $file --search false --expandBody --summary -o markdown.md | |
# Converts Widdershin's markdown output to HTML, then to DocBook5 | |
pandoc markdown.md -f markdown+raw_html -t html -o html.html | |
pandoc html.html -f html -t docbook5 -o docbook5.xml | |
# Injects required tags | |
'<?xml version="1.0" encoding="UTF-8"?><article xmlns="http://docbook.org/ns/docbook" xmlns:xl="http://www.w3.org/1999/xlink" version="5.0" xml:lang="en"><info><title>OpenAPI Import</title></info>' + (Get-Content docbook5.xml -Raw) | Set-Content docbook5.xml | |
Add-Content -Path docbook5.xml -Value '</article>' | |
# Compress the file | |
Compress-Archive -Path docbook5.xml -DestinationPath import.zip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment