Installations
npm install @surveylegend/hapi-docs
Developer Guide
Typescript
No
Module System
ESM
Min. Node Version
>=14
Node Version
18.11.0
NPM Version
9.6.6
Score
56.3
Supply Chain
98.4
Quality
79.8
Maintenance
50
Vulnerability
98.9
License
Contributors
Unable to fetch Contributors
Languages
Vue (68.82%)
JavaScript (27.44%)
SCSS (3%)
HTML (0.7%)
Procfile (0.05%)
Developer
surveylegend
Download Statistics
Total Downloads
13,692
Last Day
8
Last Week
25
Last Month
108
Last Year
1,319
GitHub Statistics
64 Stars
617 Commits
11 Forks
9 Watching
6 Branches
2 Contributors
Bundle Size
165.94 kB
Minified
46.72 kB
Minified + Gzipped
Package Meta Information
Latest Version
3.0.0
Package Id
@surveylegend/hapi-docs@3.0.0
Unpacked Size
1.99 MB
Size
568.58 kB
File Count
30
NPM Version
9.6.6
Node Version
18.11.0
Publised On
09 May 2023
Total Downloads
Cumulative downloads
Total Downloads
13,692
Last day
700%
8
Compared to previous day
Last week
-58.3%
25
Compared to previous week
Last month
61.2%
108
Compared to previous month
Last year
-37.2%
1,319
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
1
Dev Dependencies
19
Introduction
NOTE: Version 3.x of this project is in pure ESM and can not be used in CommonJS projects. If you want to use this project in a CommonJS project, please use v2.x. Version 2 and 3 are at feature parity, it's jst the imports and exports that differ. This is to support those who have not made the switch to ESM yet.
hapi-docs is perhaps the best and most modern API Documentation Generator out there. From your code blocks to description texts, you simply type everything in Markdown. Then all you need to do is to enjoy a blazing fast single-page responsive documentation, which smartly supports linkability, Syntax highlighting, RTL languages, and perfectionist eyes. hapi-docs is an open-source library brought to you by SurveyLegend®.
Features
-
Intuitive design — Inspired by Stripe’s API docs. The description of your API resides on the left part of the documentation, while all of the code examples reside on the right. Of course the layout is fully responsive and flawlessly adapts to tablets and phones.
-
Single page — The whole documentation resides on a single page, without sacrificing linkability. As you scroll through the documentation, your browser’s hash will update to the nearest section, which means linking to a particular point in the documentation remains natural and easy.
-
Scroll spy — Thanks to our custom and optimized scroll spy script, the far left navigation will smartly display your current position in the documentation, while scrolling through the documentation. It's swift and remains excellent even for larger documents.
-
Dark theme — Seamless switching between light and dark theme using a toggle. Supports
prefers-color-scheme
media query for automatic switching as well. -
Markdown support — Use Markdown to describe your API. Markdown makes it easy to articulate your documentation.
-
Code examples in multiple languages — Configurable support for multiple languages. Easily choose which language to currently display in your documentation by switching between tabs.
-
Syntax highlighting — Supports over 100 languages out of the box.
-
RTL Support — Full Right-to-Left support for languages such as Arabic, Persian (Farsi), Hebrew, etc.
-
Anchor tags — With one click, users can easily link to a parameter, thanks to auto generated anchor tags.
Installation
This package can be used in hapi v19 or higher.
You can install the package via yarn:
1$ yarn add @surveylegend/hapi-docs
Usage
Note Inert is a required dependency for hapi-docs to work properly.
1import Hapi from '@hapi/hapi' 2import Inert from '@hapi/inert' 3import Joi from 'joi' 4import HapiDocs from '@surveylegend/hapi-docs' 5import { version } from './package' 6 7const options = { 8 info: { 9 title: 'Test API Reference', 10 version 11 } 12} 13 14const startServer = async () => { 15 const server = Hapi.server({ 16 host: 'localhost', 17 port: 3000 18 }) 19 20 await server.register([ 21 { 22 plugin: Inert 23 }, 24 { 25 plugin: HapiDocs, 26 options 27 } 28 ]) 29 30 await server.start() 31 32 console.log(`Server listening on ${server.info.uri}`) 33} 34 35startServer().catch(console.error)
Demo
You can see a live demo version of hapi-docs
. Check it out at hapi-docs
Documentation
Plugin Options
endpoint
: (string) The path of the documentation - default:/docs
basePath
: (string) The base path before the API, i.e./v2
- default:/
templatePath
: (string) The absolute path to the template folder, i.e./template
host
: (string) The hostname or IP serving the API, i.e.localhost:3000
scheme
: (string) The transfer protocol of the API, i.e.http
,https
pathPrefixSize
: (number) The segment of the URL path that is used to group endpoints - default:1
sortTags
: (string) The sort method for groups, i.e.name
,ordered
- default:name
sortEndpoints
: (string) The sort method for endpoints, i.e.path
,method
,ordered
- default:path
info
title
: (string) The title of the documentation - default:API Reference
version
: (string) The version number of the API - default:0.0.1
descriptions
: (array) The description of the API.
tags
: (array) Contains tag objectsname
: (string) The name of the group.descriptions
: (array) The description of the group.order
: (int) The order which groups are sorted by.deprecated
: (boolean) Whether a group is deprecated - default:false
internal
: (boolean) Whether a group is internal - default:false
uppercase
: (boolean) Whether a group name is uppercase - default:false
errors
:descriptions
: (array) The description of the errors.codes
: (array) Contains error code objectsstatus
: (string) The status of the error code, i.e.418 - I'm A Teapot
description
: (string) The description of the error code.
auth
: (boolean, string or object) The security strategy used for plugin resources - default:false
Route Options
order
: (int) The order which endpoints are sorted by.deprecated
: (boolean) Whether an endpoint is deprecated - default:false
internal
: (boolean) Whether an endpoint is internal - default:false
Tagging API Routes
If you want a route to appear in the documentation, you have to set tags: [api]
for this specific route.
Here is an example snippet of a route option:
1{ 2 method: 'GET', 3 path: '/route', 4 options: { 5 handler: [...], 6 [...] 7 tags: ['api'] 8 } 9}
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security-related issues, please email henrik@surveylegend.com instead of using the issue tracker.
Credits
Developed and designed by:
hapi-docs is inspired by hapi-swagger, lout, and Stripe’s API docs; and fully sponsored by SurveyLegend®.
License
The MIT License (MIT). Please see License File for more information.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE.md:0
- Info: FSF or OSI recognized license: MIT License: LICENSE.md:0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
24 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-5j4c-8p2g-v4jx
- Warn: Project is vulnerable to: GHSA-g3ch-rx76-35fx
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986
- Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
1.7
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More