Forum Discussion

nagarajan's avatar
New Contributor
4 years ago

Creating SwaggerUI with pre existing swagger.json document

I have already created a swagger.json from an open-source library since my API doesn't support creating one due to HAPI-link and libraries. Now what I do is copy the JSON and load into an online Swag...
  • char0n's avatar
    4 years ago

    Allow your swagger.json file to be servable as static asset via your HAPI.js server. Let's say your server runs on and your swagger.json file is accesible on Then create a following HTML file called api.html and again make it servable as static asset via your HAPI.js server. Now when you access, SwaggerUI will render the swagger.json file.

    <!DOCTYPE html>
    <html lang="en">
    <meta charset="UTF-8">
    <title>My Api</title>
    <link rel="stylesheet" href="//" />
    <script src="//"></script>
    <div id="root" class="swagger-ui" />
    const ui = SwaggerUIBundle({
    url: '',
    dom_id: '#root'


  • nagarajan's avatar
    4 years ago

    Yep, char0n did exactly the same but hosted in an s3 bucket and then used Cloudfront. Also, another approach that we did was to use the swagger macro in confluence and load directly from the s3 bucket. Both worked like a charm.