Skip to content

huma-engineering/huma-redoc

Repository files navigation

HUMA-REDOC

**This is a fork of Redoc. This version includes styling changes and implementation of the Execute section for a Huma project.

About Huma Redoc

Original Redoc is an open-source tool for generating documentation from OpenAPI (fka Swagger) definitions. The current version inludes additional features:

  • Authentication modal
  • Execute section in the right panel

By default Redoc offers a three-panel, responsive layout:

  • The left panel contains a search bar and navigation menu.
  • The central panel contains the documentation.
  • The right panel contains request and response examples.

Redoc demo

New view

Redoc demo 2

Authentication modal

Redoc authintication

Execute section

Redoc execute

Features

Development

npm install
npm start

Build

npm run bundle

Publish NPM Package

Authenticating with a personal access token

To authenticate by adding your personal access token to your ~/.npmrc file, edit the ~/.npmrc file for your project to include the following line, replacing GITHUB_TOKEN with your personal access token. Create a new ~/.npmrc file if one doesn't exist.

//npm.pkg.github.com/:_authToken=GITHUB_TOKEN

Publishing a package

Add to an .npmrc file to include a line specifying GitHub Packages URL and the account owner.

@huma-engineering:registry=https://npm.pkg.github.com

Publish the package:

npm publish

Customization options

  • High-level grouping in side-menu with the x-tagGroups specification extension
  • Branding/customizations using the theme option

Support

  • OpenAPI v3.0 support
  • Basic OpenAPI v3.1 support
  • Broad OpenAPI v2.0 feature support (yes, it supports even discriminator)
  • Code samples support (via vendor extension)

Version Guidance

Huma Redoc Release OpenAPI Specification
1.0.0 3.1, 3.0.x, 2.0

Lint OpenAPI definitions

Redocly's OpenAPI CLI is an open source command-line tool that you can use to lint your OpenAPI definition. Linting helps you to catch errors and inconsistencies in your OpenAPI definition before publishing.

Refer to Lint configuration in the OpenAPI documentation for more information.

Final code example

To render your OpenAPI definition using Redoc, use the following HTML code sample and replace the spec-url attribute with the url or local file address to your definition.

<!DOCTYPE html>
<html>
  <head>
    <title>Redoc</title>
    <!-- needed for adaptive design -->
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">

    <!--
    Redoc doesn't change outer page styles
    -->
    <style>
      body {
        margin: 0;
        padding: 0;
      }
    </style>
  </head>
  <body>
    <redoc spec-url='http://petstore.swagger.io/v2/swagger.json'></redoc>
    <script src="https://cdn.jsdelivr.net/npm/redoc@latest/bundles/redoc.standalone.js"> </script>
  </body>
</html>

For step-by-step instructions for how to get started using Redoc to render your OpenAPI definition, refer to the Redoc quickstart guide.

See IE11 Support Notes for information on IE support for Redoc.


The original redoc repository