@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
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 | |
| 0.1.33 | ^3.5.13 | MIT | |
| 0.1.32 | ^3.5.13 | MIT | |
| 0.1.31 | ^3.5.13 | MIT | |
| 0.1.30 | ^3.5.13 | MIT | |
| 0.1.29 | ^3.5.13 | MIT | |
| 0.1.28 | ^3.5.13 | MIT | |
| 0.1.27 | ^3.5.13 | MIT | |
| 0.1.26 | ^3.5.13 | MIT | |
| 0.1.25 | ^3.5.13 | MIT | |
| 0.1.24 | ^3.5.13 | MIT | |
| 0.1.23 | ^3.5.13 | MIT | |
| 0.1.22 | ^3.5.13 | MIT | |
| 0.1.21 | ^3.5.13 | MIT | |
| 0.1.20 | ^3.5.13 | MIT | |
| 0.1.19 | ^3.5.13 | MIT | |
| 0.1.18 | ^3.5.13 | MIT | |
| 0.1.17 | ^3.5.13 | MIT | |
| 0.1.16 | ^3.5.13 | MIT | |
| 0.1.15 | ^3.5.13 | MIT | |
| 0.1.14 | ^3.5.13 | MIT | |
| 0.1.13 | ^3.5.13 | MIT | |
| 0.1.12 | ^3.5.13 | MIT | |
| 0.1.11 | ^3.5.13 | MIT | |
| 0.1.10 | ^3.5.13 | MIT | |
| 0.1.9 | ^3.5.13 | MIT |
Showing the latest 30 of 38. See every release on npm