MelleD
MelleD

Reputation: 791

ReDocly Output with embedded Javascript

Is it possible to generate html output with all embedded resources and javascript files with redoc build-docs?

Also I do not understand the section "Added the build-docs command which builds Redoc API docs into a zero-dependency HTML file."

But there is a dependency to a standalone.js file.

Upvotes: 0

Views: 596

Answers (2)

Mike
Mike

Reputation: 358

One workaround is to create a script to run the build, then replace the reference to the online standalone with the actual contents of the file. You could get fancy and have the script actually get the url, download the contents and replace it. For my purposes, I just downloaded it from the cdn and reference the file in the script.

Here's an example powershell script

$yaml="spec.yaml"
$html="output.html"
redocly build-docs "$yaml" --output "$html"
$redocStandaloneJS=(Get-Content "redoc.standalone.js" -Raw)
$redocStandaloneJS="<script>"+$redocStandaloneJS +"</script>"
(Get-Content "$html" -Raw).replace('<script src="https://cdn.redoc.ly/redoc/v2.1.3/bundles/redoc.standalone.js"></script>', $redocStandaloneJS) | Set-Content "$html"

Upvotes: 0

MelleD
MelleD

Reputation: 791

Currently not possible see here: https://github.com/Redocly/redocly-cli/issues/1035

Upvotes: 1

Related Questions