openapi-renderer
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

openapi-renderer

npm version npm downloads bundle size install size

Simple OpenAPI spec to HTML renderer.

[!NOTE] This is a new project, so feel free to share your ideas and contribute. Contributions are more than welcome!

Supported Renderers

Usage

renderResponse

Using renderResponse(req, options), you can render UI into a standard Response object from an incoming Request.

Example: Using srvx (same code works with Node.js, Deno, and Bun)

import { serve } from "srvx";
import { renderResponse } from "openapi-renderer";

serve({
  fetch(req) {
    return renderResponse(req, {
      spec: "https://petstore.swagger.io/v2/swagger.json",
      allowCustomQuery: { spec: false, renderer: true },
    });
  },
});

renderHTML

Using renderHTML(options), you can render UI into an HTML string.

import { renderHTML } from "openapi-renderer";

const html = renderHTML({
  spec: "https://petstore.swagger.io/v2/swagger.json",
});

Options

  • renderer: Renderer UI. Possible values: "swagger" | "scalar" | "kong"
  • spec: URL to OpenAPI spec JSON to render
  • meta: Metadata for the OpenAPI documentation.
  • styles: Additional HTML styles.
  • scalar: Scalar UI configuration.
  • swagger: Swagger UI configuration.
  • kong: Kong Spec Renderer UI configuration.

Development

  • Clone this repository
  • Install the latest LTS version of Node.js
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run interactive tests using pnpm dev

License

💛 Published under the MIT license.

Readme

Keywords

none

Package Sidebar

Install

npm i openapi-renderer

Weekly Downloads

195

Version

0.1.1

License

MIT

Unpacked Size

12.9 kB

Total Files

5

Last publish

Collaborators

  • pi0