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

gh-openapi-docs-ts

v0.4.0

Published

Build ReDoc API documentation for an OpenAPI specification and host on GitHub Pages

Downloads

3

Readme

GitHub OpenAPI Docs

Build Status Coverage Status npm License

The gh-openapi-docs package can be used to build ReDoc API documentation for an OpenAPI specification (no server implementation required) and host on GitHub Pages. Some features and configuration are slightly opinionated, based on experiences developing standard APIs with the Global Alliance for Genomics & Health (GA4GH), but should be generalizable to most repos working with Swagger/OpenAPI.

Note: this package is intended to be used with an existing repo via a config file and continuous integration. To install and run locally, refer to the steps below.

This project was heavily bootstrapped with outstanding products from the Redoc.ly team:

  • redoc - OpenAPI/Swagger-generated API Reference Documentation
  • openapi-cli - OpenAPI 3 CLI toolbox with rich validation and bundling features
  • with additional inspiration and examples from create-openapi-repo

An additional shoutout to redoc-editor from @pointnet, which was greatly helpful in designing a GA4GH-specific theme.


Installation

Install command-line dependencies:

npm install -g @redocly/openapi-cli && npm install -g redoc-cli

Install CLI:

npm install -g @ga4gh/gh-openapi-docs

Configuration

You should add a file named .spec-docs.json to the top level of your repo. The following parameters can currently be configured to modify the behavior of the gh-openapi-docs build; however, I recommend leaving the defaults for everything except apiSpecPath (which will be specific to how and where you've stored the root OpenAPI file).

{
    "apiSpecPath": "openapi/openapi.yaml",
    "docsRoot": "docs",
    "defaultBranch": "master",
    "branchPathBase": "preview"
}
  • apiSpecPath: relative path to the OpenAPI spec root file | default: "openapi/openapi.yaml" (i.e., <repoRoot>/openapi/openapi.yaml)
  • docsRoot: folder dirname and path for where rendered outputs are to be stored | default: "docs" (i.e., <repoRoot>/docs/ or <repoRoot>/preview/<branchName>/docs/ depending on the active branch)
  • defaultBranch: the default branch, typically as defined in your GitHub settings for the repo; however, the package doesn't explicitly check these settings, so consider "default" to indicate which version is hosted at https://ga4gh.github.io/<repoName>/docs, whereas all content for all other branches will be hosted at https://ga4gh.github.io/<repoName>/preview/<branchName>/docs | default: "master"
  • branchPathBase: name used for the folder where content for any non-default branches will be stored and hosted | default: "preview"

Outputs

This package is designed to create artifacts in the following path(s):

  • {branchPath}/docs/index.html
  • {branchPath}/openapi.json
  • {branchPath}/openapi.yaml

Where branchPath is the repo root if the current branch is defaultBranch (typically master), otherwise preview/<branchName>.

Note: OpenAPI specs for testing can be found at test/test-spec/combined/openapi.yaml and test/test-spec/split/openapi.yaml.

Usage

Run the command...

gh-openapi-docs

You should see console logs that look like this:

Preparing docs for API spec at 'openapi/openapi.yaml' (develop)

Cloning 'gh-pages' branch into '<repo-path>/.ghpages-tmp'

Branch folder:
<repo-path>/preview/develop

API spec (root) location:
<repo-path>/openapi/openapi.yaml

Bundling API spec...

Storing bundled 'openapi.json' and 'openapi.yaml' in:
<repo-path>/preview/develop/

Generating standalone ReDoc HTML:
<repo-path>/preview/develop/docs/index.html

Done (in 5s.)