@braydenyang/fdoc

Embeddable OpenAPI 3.x documentation & debug UI
6,243
Install
npm install @braydenyang/fdoc
Latest Version:0.1.38
Vue:3
License:MIT
Last Updated:Jun 30, 2026
Links: npm
Maintainer: braydenyang

fdoc

Embeddable OpenAPI 3.x documentation & debug UI.

Supports OpenAPI 3.0 / 3.1 / 3.2. Works as a standalone HTML file, an npm package, or a server-side handler (Gin, etc.).


Usage

1. CDN (script tag)

The quickest way — no build step required.

<!doctype html>
<html>
<head>
  <link rel="stylesheet" href="https://unpkg.com/@braydenyang/fdoc@0.1.3/dist/lib/style.css">
  <style>html, body { margin: 0; height: 100% }</style>
</head>
<body>
  <div id="fdoc" style="height: 100vh"></div>
  <script src="https://unpkg.com/@braydenyang/fdoc@0.1.3/dist/lib/fdoc.iife.js"></script>
  <script>
    Fdoc.mount('#fdoc', { url: '/openapi.json' })
  </script>
</body>
</html>

url is optional. If omitted, the UI starts empty and the user can import a spec manually.


2. npm (ES module)

npm install @braydenyang/fdoc
import { mount } from '@braydenyang/fdoc'
import '@braydenyang/fdoc/style.css'

const unmount = mount('#fdoc', { url: '/openapi.json' })

// later, to tear down:
unmount()

mount accepts a CSS selector string or an HTMLElement.


3. Gin (Go)

Copy docs/gin/fdoc.go into your project and use fdoc.Handler to serve the docs page.

package main

import (
    "github.com/gin-gonic/gin"
    "yourmodule/fdoc"
)

func main() {
    r := gin.Default()

    // Serve the OpenAPI spec
    r.GET("/openapi.json", func(c *gin.Context) {
        c.File("./openapi.json")
    })

    // Serve the docs UI — spec is loaded automatically
    r.GET("/docs", gin.WrapF(fdoc.Handler("/openapi.json")))

    r.Run(":8080")
}

To customise the page title:

r.GET("/docs", gin.WrapF(fdoc.HandlerWithOpts(fdoc.Opts{
    SpecURL: "/openapi.json",
    Title:   "My API Docs",
})))

fdoc.go has no external dependencies beyond the Go standard library.


API

mount(el, options?)

Parameter Type Description
el string | HTMLElement Mount target. A CSS selector or DOM element.
options.url string (optional) URL of the OpenAPI JSON to fetch and load on mount.

Returns an unmount function.


Build

# Development server
pnpm dev

# Library build (dist/lib/)
pnpm build:lib

# Standalone single-file HTML build (dist/cdn/)
pnpm build -- --mode cdn

Related Packages

@scalar/swagger-editor

an editor which is tailored to write OpenAPI spec

58,866 16,316
@koumoul/vue-openapi

Display API documentation that follow the OpenAPI 3.0 Specification

1,110 94
@scalar/api-reference

Generate beautiful API references from OpenAPI documents

21,031,808 16,329
@comet-cli/plugin-documentation

Plugin for generating API documentation

6,405 0
vitepress-openapi-docs

Interactive OpenAPI documentation for VitePress. Lightweight, Vue-native, compos...

3,376 6

Version History

Version Released Vue License
0.1.38 ^3.5.13 MIT
0.1.37 ^3.5.13 MIT
0.1.36 ^3.5.13 MIT
0.1.35 ^3.5.13 MIT
0.1.34 ^3.5.13 MIT