{"id":18535290,"url":"https://github.com/tinyhttp/swagger","last_synced_at":"2025-04-09T15:32:03.613Z","repository":{"id":48772012,"uuid":"379547057","full_name":"tinyhttp/swagger","owner":"tinyhttp","description":"📚 Swagger integration for tinyhttp","archived":false,"fork":false,"pushed_at":"2023-10-19T09:40:34.000Z","size":254,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T08:47:19.600Z","etag":null,"topics":["docs","http","nodejs","nodejs-api","nodejs-modules","swagger","swagger-documentation","swagger-ui","tinyhttp"],"latest_commit_sha":null,"homepage":"https://npm.im/@tinyhttp/swagger","language":"TypeScript","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/tinyhttp.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,"governance":null}},"created_at":"2021-06-23T09:20:26.000Z","updated_at":"2023-10-26T16:03:00.000Z","dependencies_parsed_at":"2024-06-09T19:32:50.089Z","dependency_job_id":null,"html_url":"https://github.com/tinyhttp/swagger","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Fswagger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Fswagger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Fswagger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Fswagger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tinyhttp","download_url":"https://codeload.github.com/tinyhttp/swagger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247773742,"owners_count":20993633,"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":["docs","http","nodejs","nodejs-api","nodejs-modules","swagger","swagger-documentation","swagger-ui","tinyhttp"],"created_at":"2024-11-06T19:21:52.287Z","updated_at":"2025-04-09T15:32:03.607Z","avatar_url":"https://github.com/tinyhttp.png","language":"TypeScript","readme":"\u003cdiv align=\"center\"\u003e\n\u003cbr /\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/tinyhttp/swagger/master/logo.svg\" width=\"200px\" alt=\"@tinyhttp/swagger\" /\u003e\u003cbr /\u003e\u003cbr /\u003e\n\n[![NPM][npm-badge]][npm-url] [![NPM][dl-badge]][npm-url] [![GitHub Workflow Status][actions-img]][github-actions] [![Coverage][cov-img]][cov-url]\n\n\u003c/div\u003e\n\u003cbr /\u003e\n\n[Swagger](https://swagger.io/) integration for [tinyhttp](https://github.com/tinyhttp/tinyhttp). This library allows you to easily generate documentation for your API.\n\n## Install\n\n```sh\npnpm i @tinyhttp/swagger\n```\n\n## Example\n\n```js\nimport { App } from '@tinyhttp/app'\nimport { addToDocs, serveDocs } from '@tinyhttp/swagger'\n\n// In case the value for a given field is an object, @tinyhttp/swagger only uses the type, optional or items (in case type is array)\n// Other fields are ignored and are shown here only to imply that the same schema object can be used for validation by the fastest-validator package\nconst schema = {\n  id: { type: 'number', positive: true, integer: true },\n  name: { type: 'string', min: 3, max: 255 },\n  status: 'boolean'\n}\n\nconst app = new App()\n\napp\n  .get('/docs/:docId', addToDocs({ params: { docId: 'number' } }), (req, res) =\u003e {\n    res.status(200).send('done')\n  })\n  .post(\n    '/docs/:docId',\n    addToDocs(\n      {\n        headers: { authorization: 'string' },\n        params: { docId: 'number' },\n        body: schema\n      },\n      ['docs']\n    ),\n    (req, res) =\u003e void res.status(200).send('done')\n  )\n  .get('/users', addToDocs({ query: { userId: { type: 'number', optional: true } } }, ['users']), (req, res) =\u003e {\n    res.status(200).send('done')\n  })\n  .get('/:userId/:docId', addToDocs({ params: { userId: 'number', docId: 'number' } }), (req, res) =\u003e {\n    res.status(200).send('done')\n  })\n\n// Only title is required. if servers and description are not provided, nothing is shown. version and prefix have default values of 0.1 and docs.\nserveDocs(app, {\n  title: 'example',\n  version: '1.0',\n  prefix: 'api-docs',\n  description: 'this is an example for @tinyhttp/swagger',\n  servers: ['www.host1.com/api/v1', 'api.host2.org/v1']\n})\napp.listen(3000)\n```\n\n[npm-badge]: https://img.shields.io/npm/v/@tinyhttp/swagger?style=for-the-badge\u0026color=50A237\u0026label=\u0026logo=npm\n[npm-url]: https://npmjs.com/package/@tinyhttp/swagger\n[dl-badge]: https://img.shields.io/npm/dt/@tinyhttp/swagger?style=for-the-badge\u0026color=50A237\n[actions-img]: https://img.shields.io/github/actions/workflow/status/tinyhttp/swagger/ci.yml?style=for-the-badge\u0026logo=github\u0026label=\u0026color=50A237\n[github-actions]: https://github.com/tinyhttp/swagger/actions\n[cov-img]: https://img.shields.io/coveralls/github/tinyhttp/swagger?style=for-the-badge\u0026color=50A237\u0026a\n[cov-url]: https://coveralls.io/github/tinyhttp/swagger\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinyhttp%2Fswagger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftinyhttp%2Fswagger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinyhttp%2Fswagger/lists"}