Search code examples
yamlswaggerswagger-php

Converting Swagger specification JSON to HTML documentation


For some REST APIs written in PHP, I was asked to create Swagger documentation, and since I was not aware of any easy way of annotating those existing APIs and create such a documentation, I used this editor to generate some for now.

I saved the JSON and YAML files created using that editor, and now I need to create the "interactive" Swagger documentation from there.

Can someone please let me know how I can convert the Swagger JSON specification file to an actual Swagger documentation?

I am on the Windows platform and do not know anything about Ant/Maven.


Solution

  • Update May 17, 2023

    Seems redoc-cli has been deprecated. so use https://www.npmjs.com/package/@redocly/cli instead. [Credit : @Dave]

    Try to use redoc-cli.

    I was using bootprint-openapi by which I was generating a bunch of files (bundle.js, bundle.js.map, index.html, main.css and main.css.map) and then you can convert it into a single .html file using html-inline to generate a simple index.html file.

    Then I found redoc-cli very easy to to use and output is really-2 awesome, a single and beautiful index.html file.

    Installation:

    npm install -g redoc-cli
    

    Usage:

    redoc-cli bundle -o index.html swagger.json