{"id":41284049,"url":"https://github.com/funny-bytes/hapi-swagger-static","last_synced_at":"2026-01-23T02:58:42.986Z","repository":{"id":42344581,"uuid":"115353010","full_name":"funny-bytes/hapi-swagger-static","owner":"funny-bytes","description":"A companion plugin for ´hapi-swagger´ that provides a static html page as a hapi route","archived":false,"fork":false,"pushed_at":"2025-01-16T15:43:55.000Z","size":1823,"stargazers_count":3,"open_issues_count":7,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-27T01:54:12.147Z","etag":null,"topics":["hapi","plug-in"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/funny-bytes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-12-25T17:16:43.000Z","updated_at":"2025-01-16T15:43:57.000Z","dependencies_parsed_at":"2024-06-21T16:53:12.077Z","dependency_job_id":"df922683-b5da-4365-9634-c80a95987417","html_url":"https://github.com/funny-bytes/hapi-swagger-static","commit_stats":{"total_commits":153,"total_committers":3,"mean_commits":51.0,"dds":"0.18300653594771243","last_synced_commit":"9026fa61e05e6f3d44c2c626caf4da6e8dd4ba0e"},"previous_names":["frankthelen/hapi-swagger-static"],"tags_count":43,"template":false,"template_full_name":null,"purl":"pkg:github/funny-bytes/hapi-swagger-static","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funny-bytes%2Fhapi-swagger-static","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funny-bytes%2Fhapi-swagger-static/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funny-bytes%2Fhapi-swagger-static/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funny-bytes%2Fhapi-swagger-static/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/funny-bytes","download_url":"https://codeload.github.com/funny-bytes/hapi-swagger-static/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funny-bytes%2Fhapi-swagger-static/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28679139,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T01:00:35.747Z","status":"online","status_checked_at":"2026-01-23T02:00:08.296Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hapi","plug-in"],"created_at":"2026-01-23T02:58:42.379Z","updated_at":"2026-01-23T02:58:42.982Z","avatar_url":"https://github.com/funny-bytes.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hapi-swagger-static\n\nPlugin for Hapi providing a static html documentation page.\nIt's a small companion plugin for `hapi-swagger` or `hapi-swaggered`\nto create a static page from the `/swagger.json` endpoint.\nThe static page is provided as route `/documentation.html` (can be renamed).\nIt supports most of Swagger 2.0 / Open API 2.0.\n\n![main workflow](https://github.com/funny-bytes/hapi-swagger-static/actions/workflows/main.yml/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/github/funny-bytes/hapi-swagger-static/badge.svg?branch=master)](https://coveralls.io/github/funny-bytes/hapi-swagger-static?branch=master)\n[![dependencies Status](https://david-dm.org/funny-bytes/hapi-swagger-static/status.svg)](https://david-dm.org/funny-bytes/hapi-swagger-static)\n[![Maintainability](https://api.codeclimate.com/v1/badges/f71c0020a54eefa732ef/maintainability)](https://codeclimate.com/github/funny-bytes/hapi-swagger-static/maintainability)\n[![node](https://img.shields.io/node/v/hapi-swagger-static.svg)]()\n[![code style](https://img.shields.io/badge/code_style-airbnb-brightgreen.svg)](https://github.com/airbnb/javascript)\n[![License Status](http://img.shields.io/npm/l/hapi-swagger-static.svg)]()\n\nTested with\n* Node 20/22, Hapi 19, Hapi-Swagger 12, Vision 6, Inert 6\n\n## Install\n\n```bash\nnpm install hapi-swagger-static\n```\n\n## Usage\n\nRegister the plugin with Hapi server like this:\n\n```js\nconst Hapi = require('@hapi/hapi');\nconst HapiSwagger = require('hapi-swagger');\nconst HapiSwaggerStatic = require('hapi-swagger-static');\nconst Inert = require('@hapi/inert');\nconst Vision = require('@hapi/vision');\n\nconst server = new Hapi.Server({\n  port: 3000,\n});\n\nconst provision = async () =\u003e {\n  await server.register({ plugin: Inert });\n  await server.register({ plugin: Vision });\n  // first, add your api routes to hapi\n  await server.register({ // second, register `hapi-swagger` plugin\n    plugin: HapiSwagger,\n    options: { ... },\n  });\n  await server.register({ // last, register this plugin\n    plugin: HapiSwaggerStatic,\n    options: { ... },\n  });\n  await server.start();\n};\n\nprovision();\n```\n\n## Options\n\nThe plugin provides the following options:\n\n| Option      | Default     | Description |\n|-------------|-------------|-------------|\n| `path`      | `/documentation.html` | The endpoint providing the static documentation page. |\n| `swaggerEndpoint` | `/swagger.json` | The endpoint to read the Swagger API specification from. |\n| `cache`     | `{ privacy: 'public', expiresIn: 60 * 60 * 1000 } // one hour` | Hapi's `route.options.cache` to be assigned to the static documentation endpoint. Please refer to the [Hapi docs](https://hapijs.com/api#-routeoptionscache) for more information. |\n| `auth`      |  - | Hapi's `route.options.auth` to be assigned to the static documentation endpoint. Please refer to the [Hapi docs](https://hapijs.com/api#-routeoptionsauth) for more information. By default, this option is not set, i.e., inheriting auth settings from Hapi's `server.options.routes.auth`. |\n| `headers` | `{}` | The request's `authorization` header is automatically forwarded to the `/swagger.json` endpoint. If you need any additional headers, add them through the `headers` option. |\n| `template` | - | This plugin prefers `vision` to render the api into a page. `template` is the template filename and path, relative to the templates path configured via the server views manager. The api data is provided as view context. Assuming Handlebars or Mustache as your template engine, e.g., you can use `{{api.info.title}}` in the template to get hold of the api title. Use `{{{api.html}}}` (with three curly brackets here!) in the template for rendering the api's html content. |\n| `viewOptions` | `{}` | The options passed to the view via `h.view()`. If your default layout does not provide the Bootstrap 4 CSS resources (Bootstrap's JS is not needed), you should provide a special layout for your template. See the example below. |\n| `o2hOptions` | `{}` | The options passed to `openapi2html`. Please refer to [openapi2html](https://github.com/frankthelen/openapi2html#options) for more information. |\n\n## View Example\n\nThis example assumes Handlebars or Mustache as template engine.\nIt sets the following plugin options:\n```js\n{ template: 'api', // referring to the view file `api.html` below\n  viewOptions: {\n    layout: 'api-layout' // referring to the layout file `api-layout.html` below\n  }\n}\n```\n\nView example, e.g., `api.html` to be placed into your view location:\n```html\n{{{api.html}}}\n```\n\nLayout example, e.g., `api-layout.html` to be placed into your layout location:\n```html\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cmeta charset=\"utf-8\" /\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\"\u003e\n    \u003clink href=\"https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css\" rel=\"stylesheet\"\u003e\n    \u003clink href='/public/api.css' rel='stylesheet' type='text/css' /\u003e\n    \u003ctitle\u003e{{api.info.title}}\u003c/title\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cdiv class=\"container\"\u003e\n      {{{content}}}\n      \u003cfooter\u003eYour company; for internal use only\u003c/footer\u003e\n    \u003c/div\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\nStyle example, e.g., `api.css` to be placed into `/public`, containing some minor adjustments to Bootstrap 4:\n```css\n.h2, h2 {\n  margin-top: 1rem;\n}\n.h4, h4 {\n  margin-top: .5rem;\n}\n.card {\n  margin-bottom: 1rem;\n}\n.o2h-description p {\n  color: grey;\n  margin-bottom: .5rem;\n}\n.card .card-body .h4, .card .card-body h4 {\n  border-top: 1px solid #eee;\n  margin-top: 1rem;\n  padding-top: 1rem;\n}\n.card .card-body .h5, .card .card-body h5 {\n  margin-top: 1rem;\n}\n.card .card-body .o2h-description p {\n  margin-bottom: 0;\n}\n.card .card-body .o2h-example pre {\n  background-color: #eee;\n  font-size: small;\n}\n.o2h-parameter h5 .badge {\n  font-size: small;\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunny-bytes%2Fhapi-swagger-static","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffunny-bytes%2Fhapi-swagger-static","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunny-bytes%2Fhapi-swagger-static/lists"}