{"id":14986696,"url":"https://github.com/johnhof/swagger-injector","last_synced_at":"2025-04-11T20:31:43.290Z","repository":{"id":33986993,"uuid":"37738675","full_name":"johnhof/swagger-injector","owner":"johnhof","description":"Delivering swagger docs through Node middleware","archived":false,"fork":false,"pushed_at":"2022-12-07T09:30:28.000Z","size":3354,"stargazers_count":23,"open_issues_count":1,"forks_count":46,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-07T02:37:22.020Z","etag":null,"topics":["express","koa","openapi","openapi-specification","swagger"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johnhof.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-19T18:22:37.000Z","updated_at":"2023-03-10T11:54:37.000Z","dependencies_parsed_at":"2023-01-15T03:49:59.470Z","dependency_job_id":null,"html_url":"https://github.com/johnhof/swagger-injector","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnhof%2Fswagger-injector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnhof%2Fswagger-injector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnhof%2Fswagger-injector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnhof%2Fswagger-injector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnhof","download_url":"https://codeload.github.com/johnhof/swagger-injector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248476313,"owners_count":21110255,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["express","koa","openapi","openapi-specification","swagger"],"created_at":"2024-09-24T14:13:22.294Z","updated_at":"2025-04-11T20:31:38.268Z","avatar_url":"https://github.com/johnhof.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swagger Injector\n\n[![Build Status](https://travis-ci.org/johnhof/swagger-injector.svg?branch=master)](https://travis-ci.org/johnhof/swagger-injector)\n\nAdaptation of [swagger ui](https://github.com/swagger-api/swagger-ui) to render the swagger view of a server's swagger documentation for a specified route.\n\nIf you're unfamiliar with swagger, I highly recommend [checking it out](http://swagger.io/).\n\n\u003cimg src=\"http://i.imgur.com/lR2qpnE.png\" width=\"600\"\u003e\n\n# Key\n\n- [Usage](#usage)\n  - [Koa](#koa)\n  - [Express](#express)\n- [Defaults](#defaults)\n- [Configuration](#configuration)\n\n# Usage\n\n## Koa\n\n**Build for ^2.x**\n\n* Assume ./swagger.json is a valid json file\n* [Working example](https://github.com/johnhof/swagger-injector/tree/master/examples/koa.js)\n  * Run `$ npm install \u0026\u0026 node examples/koa`\n  * Request `localhost:3000/swagger`\n\n```javascript\nlet Koa = require('koa');\nlet swagger = require('swagger-injector');\n\nlet app = new Koa();\n\napp.use(swagger.koa({\n  path: `${__dirname}/swagger.json`,\n}));\n\napp.listen(3000);\n```\n\n## Express\n\n* Assume ./swagger.json is a valid json file\n* NOTE: authentication requires `cookie-parser`\n* [Working example](https://github.com/johnhof/swagger-injector/tree/master/examples/express.js)\n  * Run `$ npm install \u0026\u0026 node examples/express`\n  * Request `localhost:3000/swagger`\n\n```javascript\nlet express = require('express');\nlet cookieParser = require('cookie-parser');\nlet swagger = require('swagger-injector');\n\nlet app = express();\n\napp.use(cookieParser()); // REQUIRED\napp.use(swagger.express({\n  path: `${__dirname}/swagger.json`\n}));\n\napp.listen(3000);\n```\n\n# Configuration\n\nThe following configuration example is a copy of the default configuration\n\n```javascript\n{\n  path: './swagger.json', // Path to swagger file\n  swagger: false, // swagger json. If not set, it is read from the `path` file\n  prefix: '', // Prefix applied to all routes\n  assets: '/_swagger_', // Prefix for all assets, appended to prefix\n  route: '/swagger', // Router to serve documentation\n  css: false, // Path to the css OR css string\n  unauthorized: false, // Unauth handler\n  dist: '/dist', // Path to dist directory\n  authentication: {\n    sources: ['query', 'body'], // Accepted sources of auth\n    key: false, // Key for the auth\n    value: false // Value for the auth\n  }\n}\n```\n\n# Author\n\n  - [John Hofrichter](https://github.com/johnhof)\n\n# License\n\n  MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnhof%2Fswagger-injector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnhof%2Fswagger-injector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnhof%2Fswagger-injector/lists"}