redoc-asyncapi
TypeScript icon, indicating that this package has built-in type declarations

2.1.1 • Public • Published
ReDoc logo

OpenAPI/Swagger/AsyncAPI-generated API Reference Documentation

This is README for an ReDoc extension which supports AsyncAPI

Live demo

ReDoc demo

Features

  • OpenAPI support.
  • Basic support for AsyncAPI pub/sub operations.
    • Paremetres, Protocol and Properties for Async API channels.
  • It supports discriminator feature for both, Open and Async API.
  • The following protocols can be used: AMQP
  • Availabilty to collapse

Roadmap

Releases

Version Guidance

Aync ReDoc Release OpenAPI Specification AsyncAPI Specification
0.0.7 3.0, 2.0 2.0

Deployment

TL;DR

<!DOCTYPE html>
<html lang="en">
  <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-asyncapi/bundles/redoc.standalone.js"> </script>
  </body>
</html>

That's all folks!

IMPORTANT NOTE: if you work with untrusted user spec, use untrusted-spec option to prevent XSS security risks.

1. Install ReDoc (skip this step for CDN)

Install using npm:

npm i redoc-asyncapi

or using yarn:

yarn add redoc-asyncapi

2. Reference redoc script in HTML

For CDN:

<script src="https://cdn.jsdelivr.net/npm/redoc-asyncapi/bundles/redoc.standalone.js"> </script>

For npm:

<script src="node_modules/redoc-asyncapi/bundles/redoc.standalone.js"> </script>

3. Add <redoc> element to your page

<redoc spec-url="url/to/your/spec"></redoc>

4. Enjoy 😄

Usage as a React component

Install peer dependencies required by ReDoc if you don't have them installed already:

npm i react react-dom mobx styled-components core-js

Import RedocStandalone component from 'redoc' module:

import { RedocStandalone } from 'redoc';

and use it somewhere in your component:

<RedocStandalone specUrl="url/to/your/spec"/>

or

<RedocStandalone spec={/* spec as an object */}/>

Also you can pass options:

<RedocStandalone
  specUrl="http://rebilly.github.io/RebillyAPI/openapi.json"
  options={{
    nativeScrollbars: true,
    theme: { colors: { primary: { main: '#dd5522' } } },
  }}
/>

Here are detailed options docs.

You can also specify onLoaded callback which will be called each time Redoc has been fully rendered or when error occurs (with an error as the first argument). NOTE: It may be called multiply times if you change component properties

<RedocStandalone
  specUrl="http://rebilly.github.io/RebillyAPI/openapi.json"
  onLoaded={error => {
    if (!error) {
      console.log('Yay!');
    }
  }}
/>

IE11 Support Notes

Package Sidebar

Install

npm i redoc-asyncapi

Weekly Downloads

31

Version

2.1.1

License

MIT

Unpacked Size

7.44 MB

Total Files

180

Last publish

Collaborators

  • ivamuno