npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@rocket-doc/app

v1.0.10

Published

Rocket Doc is a React app that generates documentation from an OpenAPI 3.1 files.

Downloads

1,078

Readme

Rocket Doc

Rocket Doc is a React app that generates documentation from an OpenAPI 3.1 files.

The goal of this project is to provide a simple and easy-to-use tool, with minimal dependencies, to allow for a maintainable and customizable documentation generation.

Here is an example of the UI with Swagger Petstore example Example UI

Table of Contents

Usage

As a React Component

You can use Rocket Doc as a React component in your application. First, install the package using yarn or npm:

yarn add @rocket-doc/app openapi3-ts tailwindcss
# or
npm install @rocket-doc/app openapi3-ts tailwindcss

Then, import and use the RocketDoc component in your React application:

import React from 'react';
import ReactDOM from 'react-dom';
import { RocketDoc } from '@rocket-doc/app';

ReactDOM.render(
  <RocketDoc
    specUrl="https://api.example.com/openapi.json"
    config={{
      defaultExpandedDepth: 2,
      routerType: "hash"
    }}
  />,
  document.getElementById('root')
);

Directly in the Browser

You can also use Rocket Doc directly in the browser by including the necessary scripts and adding a <rocket-doc /> DOM element:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/png" href="/rocket-doc.png" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Rocket Doc</title>
    <script crossorigin src="https://unpkg.com/react@18/umd/react.development.js"></script>
    <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
    <script crossorigin src="https://unpkg.com/@rocket-doc/[email protected]/dist/index.umd.js"></script>
  </head>
  <body>
    <rocket-doc
     spec-url="https://api.example.com/openapi.json"
     config='{"defaultExpandedDepth": 2, "routerType": "hash"}'
     />
  </body>
</html>

Configuration

You can configure the Rocket Doc component using the following options, either as props in the React component or as attributes in the DOM element. All options are optional. Object attributes (in the DOM element) should be passed as JSON strings.

| Prop name | Attribute Name | Type | Description | | ---------------------------- | ------------------------------- | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- | | config | config | AppConfig | The application configuration object. This can include various settings to customize the behavior and appearance of the documentation. | | logo | logo | string | The URL of the logo image to be displayed in the navigation bar. | | specUrl | specUrl | string | The URL of the OpenAPI specification file to be loaded. | | specRequiredSecurity | spec-required-security | OpenAPI SecurityScheme | The security scheme required to access the OpenAPI specification. It matches the OpenAPI specification for a security scheme. | | specRequiredSecurityScopes | spec-required-security-scopes | string[] | The scopes required for the security scheme. | | showFileImport | show-file-import | boolean | A boolean flag to show or hide the file import option in the UI. | | extensions | extensions | Extensions | An object containing extensions to customize the behavior of the documentation. |

AppConfig

The AppConfig object allows you to customize various settings for the Rocket Doc application. Below are the available options:

| Option Name | Type | Default | Description | | ---------------------- | --------------------- | -------------- | ---------------------------------------------------------------------------------------- | | defaultExpandedDepth | number | 2 | The default depth to which the documentation tree should be expanded. | | routerType | 'hash' \| 'browser' | 'hash' | The type of router to use for navigation. | | basePath | string | '' | The base path for the application. Useful if the app is served from a subdirectory. | | defaultTitle | string | 'Rocket Doc' | The default title for the documentation pages. Before it is loaded from the OpenAPI file |

Extensions

The Extensions object allows you to customize the rendering of the Rocket Doc application. An extension is a function that takes arguments and returns a component to render. Below are the available options:

| Property | Type | Description | | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | fieldDetails | (req: { name: string; schema: SchemaObject; fullSpec: OpenAPIObject }) => { component: (null \| React.ComponentType); disablePadding?: boolean; } | This function is called for every field in a schema.It takes the name of the field, the OAPI schema and the OAPI fullSpec. It must return a react component (null for no row to be rendered), and an optional boolean to disable left aligment padding. |

Depencies

The goal of this project is to have minimal dependencies. The following are the dependencies used in this project:

Building blocks

For code parsing & formatting

Features

  • [x] OpenAPI 3.1 support
  • [x] Schema display
  • [x] Operations filtering
  • [x] Try it out feature
  • [x] Code generation for requests
  • [x] Syntax highlighting for requests and responses
  • [x] Support for loading OpenAPI files from URL
  • [x] Support to retain application credentials
  • [x] Support for authenticated routes to get OpenAPI files
  • [x] Support for OpenAPI extensions
  • [ ] Support for webhooks
  • [ ] Support for OAuth 2.0
  • [ ] Customizable theme

Contributing

Feel free to submit issues or pull requests for any improvements or bug fixes.

Installation

To install the necessary dependencies, run:

yarn

Running the Application

To start the development server, run:

yarn dev

This will start the application and you can view it in your browser.

License

This project is licensed under the MIT License.