An open API service indexing awesome lists of open source software.

https://github.com/liborm85/swagger-ui-offline-packager

Generates a self-contained HTML file from an OpenAPI definition, rendering it in Swagger UI for offline API documentation.
https://github.com/liborm85/swagger-ui-offline-packager

openapi rest rest-api swagger swagger-js swagger-ui

Last synced: about 2 months ago
JSON representation

Generates a self-contained HTML file from an OpenAPI definition, rendering it in Swagger UI for offline API documentation.

Awesome Lists containing this project

README

          

# Swagger UI Offline Packager [![npmjs](https://img.shields.io/npm/v/swagger-ui-offline-packager.svg)](https://www.npmjs.com/package/swagger-ui-offline-packager)

A tool that generates a single, self-contained HTML file from an OpenAPI definition (YAML or JSON), rendering it in Swagger UI. This allows you to view API documentation offline, without needing an internet connection or a separate web server.

## Features
- Converts OpenAPI (YAML or JSON) into a standalone Swagger UI HTML file
- The generated file works completely offline
- Supports loading the API definition from multiple files
- Supports `$ref` references in OpenAPI 3.1 specifications
- Easy to use, no external dependencies required

Perfect for sharing API documentation in a simple, portable format! 🚀

## Installation

You can install Swagger UI Offline Packager globally or locally using npm.

**Global Installation**

To install the package globally, run:

```sh
npm install -g swagger-ui-offline-packager
```
This allows you to use the `swagger-ui-offline-packager` command anywhere in your terminal. You can also use the shorter alias `sop`.

**Local Installation**

To install the package locally in your project, run:

```sh
npm install swagger-ui-offline-packager
```
You can then use it within your project scripts or via `npx`:

```sh
npx swagger-ui-offline-packager
```
or with the alias:

```sh
npx sop
```

## Usage

To generate a standalone Swagger UI HTML file, run the command with the required input file:
```
sop [output-html-file]
```

**Parameters:**
- swagger-file *(required)* – Path to the Swagger (OpenAPI) file in YAML or JSON format.
- output-html-file *(optional)* – Path to the output HTML file. If not provided, the output file will be named based on the input file.

For more information, use:
```sh
sop --help
```

## Examples:
Generate an HTML file with the default output name (generates api.html in the same directory):

```sh
sop api.yaml
```

Specify a custom output file:

```sh
sop api.yaml my-api-docs.html
```

Using npx (if installed locally):

```sh
npx sop api.json docs.html
```

## License

MIT