{"id":19969310,"url":"https://github.com/vmarchaud/jsdoc-http-plugin","last_synced_at":"2025-05-04T01:30:29.834Z","repository":{"id":57284257,"uuid":"92508414","full_name":"vmarchaud/jsdoc-http-plugin","owner":"vmarchaud","description":"Document your http endpoints with JSDoc","archived":false,"fork":false,"pushed_at":"2019-12-20T15:36:16.000Z","size":30,"stargazers_count":40,"open_issues_count":3,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-24T20:07:19.842Z","etag":null,"topics":["documentation","jsdoc","nodejs","tool"],"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/vmarchaud.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":"2017-05-26T12:26:48.000Z","updated_at":"2024-01-29T10:53:14.000Z","dependencies_parsed_at":"2022-09-16T22:40:35.220Z","dependency_job_id":null,"html_url":"https://github.com/vmarchaud/jsdoc-http-plugin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmarchaud%2Fjsdoc-http-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmarchaud%2Fjsdoc-http-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmarchaud%2Fjsdoc-http-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmarchaud%2Fjsdoc-http-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vmarchaud","download_url":"https://codeload.github.com/vmarchaud/jsdoc-http-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252276955,"owners_count":21722447,"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":["documentation","jsdoc","nodejs","tool"],"created_at":"2024-11-13T02:49:32.853Z","updated_at":"2025-05-04T01:30:29.432Z","avatar_url":"https://github.com/vmarchaud.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# This is a fork\n\nThis project is a fork of https://github.com/bvanderlaan/jsdoc-route-plugin\nCurrently, bvanderlaan doesn't seems to be available to maintain the project so i'll continue here.\n\n# JsDoc HTTP Plugin\n\nThis is a plugin for [JsDoc](http://usejsdoc.org/) which is a tool to generate HTML documentation from comment blocks.\nJsDoc will scan your code files looking for comment blocks then generate a nicely formated HTML document.\n\nJsDoc supports a number of tags to help document a number of things such as each parameter in a function or what the function will return.\nThese tags are picked up by JsDoc and used when generating the HTML documentation; for example function parameters are shown in a table.\n\nThis plugin adds custom tags to JsDoc that work with the default document template. The custom tags are meant to help document HTTP endpoints.\n\n\n## How to install\n\nFirst you need to install JsDoc\n```console\nnpm install jsdoc --save-dev\n```\n\nThen you need to install the JsDoc Route Plugin\n\n```console\nnpm install jsdoc-http-plugin --save-dev\n```\n\nNext you need to tell [JsDoc](http://usejsdoc.org/) to enable the plugin.\n\nYou can do this by adding a `jsdoc.conf` file and telling [JsDoc](http://usejsdoc.org/) to use it when you run it.\n\n**Example jsdoc.conf**\n```js\n{\n    \"tags\": {\n        \"allowUnknownTags\": true,\n        \"dictionaries\": [\"jsdoc\",\"closure\"]\n    },\n    \"source\": {\n        \"include\": [ \".\" ],\n        \"exclude\": [ \"node_modules\" ],\n        \"includePattern\": \".+\\\\.js(doc|x)?$\",\n        \"excludePattern\": \"(^|\\\\/|\\\\\\\\)_\"\n    },\n    \"plugins\": [\"jsdoc-http-plugin\"],\n    \"templates\": {\n        \"cleverLinks\": false,\n        \"monospaceLinks\": false\n    },\n    \"opts\": {\n      \"recurse\": true\n    }\n}\n```\n\nNow run [JsDoc](http://usejsdoc.org/) with the `--config` flag.\n```console\njsdoc --config jsdoc.conf\n```\n\n## Caveats\n\n - when used with markdown plugin, it should be put before `jsdoc-http-plugin`\n \n    \u003e \"plugins\": [\"plugins/markdown\", \"jsdoc-http-plugin\"],\n \n## Example\n\nIf you want to see an example of this plugin in action run the `npm run example1` command.\nThat will run [JsDoc](http://usejsdoc.org/) against a sample Express app located in `examples` and produce HTML documentation in the `out` folder.\nTo view the documentation open `out/index.html` in a browser.\n\n## What are the new Tags\n\nThe new tags are all about documenting Express routes.\nFind a list of them and how they are to be used below.\n\n## @path\n\nBecause JsDoc does not know about routes we need to decorate the route documentation with the `@name` tag to make JsDoc think you are documenting a member of the given module.\nThis will add an entry under the **Members** section in the HTML document; however, if we used only the `@name` tag to describe the route verb and path it might look a bit odd as it would show up like this:\n\u003e *(inner)* POST /v1/files\n\nTo make documenting a route a bit nicer I suggest using the `@name` tag to define a common name for the route, such as File Upload, and the `@path` tag to define the verb and route path.\nUsing the `@path` tag will also change the method attribute from *(inner)* to *(path)*.\n\n```js\n/**\n * Upload a file.\n *\n * @name File Upload\n * @path {POST} /v1/file\n */\nserver.post({\n  url: '/v1/file',\n}, (req, res, next) =\u003e {...}\n```\n\nThe `@path` tag will add a table showing the HTTP verb (i.e. POST, PUT, DEL, GET), and the route path (i.e. /v1/files) for the route you are documenting just under the friendly name of the route above the details section.\n\nOnly one `@path` tag is expected per endpoint document.\n\n## @auth\n\nThe `@auth` tag allows you to state what authentication a route requires.\n\n```js\n/**\n * Upload a file.\n *\n * @name File Upload\n * @path {POST} /v1/file\n * @auth This route requires HTTP Basic Authentication. If authentication fails it will return a 401 error.\n */\nserver.post({\n  url: '/v1/file',\n}, (req, res, next) =\u003e {...}\n```\n\nIt will result in a new sub-heading called **Authentication** with whatever text you provided to the tag beneath it.\n\nOnly one `@auth` tag is expected per endpoint document.\n\n## @header\n\nThe `@header` allows you to document any parameters which are passed via the header of the HTTP request.\n\nWith this tag you need to provide the name and a description. The name is the first word of the text following the tag.\n* `@header MyName And this part is the description`\n\nYou can also optionally provide a type for the parameter.\n* `@header {String} MyName And this part is the description`\n\n```js\n/**\n * Upload a file.\n *\n * @name File Upload\n * @path {POST} /v1/file\n * @header authorization is the identification information for the request\n * @header {String} user-id is the unique User Id to assign to the file\n */\nserver.post({\n  url: '/v1/file',\n}, (req, res, next) =\u003e {...}\n```\n\nThe above would add a table under the route description that lists all the header parameters.\nYou can use the `@header` tag as many times as you have parameters in your request header you wish to document.\n\n\n## @body\n\nThe `@body` allows you to document any parameters which are passed via the body of the HTTP request.\n\nWith this tag you need to provide the name and a description. The name is the first word of the text following the tag.\n* `@body MyName And this part is the description`\n\nYou can also optionally provide a type for the parameter.\n* `@body {String} MyName And this part is the description`\n\nYou can also specify that the parameter is optional by placing the name within square brackets.\n* `@body {String} [MyName] And this part is the description`\n\nLastly you can define a default value for the parameter. The idea is to document the value which will be used if the parameter is not provided.\n* `@body {String} [MyName=Phillip] And this part is the description`\n\n\n```js\n/**\n * Upload a file.\n *\n * @name File Upload\n * @path {POST} /v1/file\n * @body {String} userId is the unique identifier for the user we are uploading the file to.\n * @body {Boolean} [sync=false] when true the route will be synchronous otherwise the route\n * is asynchronous.\n */\nserver.post({\n  url: '/v1/file',\n}, (req, res, next) =\u003e {...}\n```\n\nThe above would add a table under the route description that lists all the body parameters.\n\nYou can use the `@bodyparam` tag as many times as you have parameters in your request body you wish to document.\n\n## @params\n\nThe `@params` allows you to document any parameters which make up part of the route path.\n\nWith this tag you need to provide the name and a description. The name is the first word of the text following the tag.\n* `@params MyName And this part is the description`\n\nYou can also optionally provide a type for the parameter.\n* `@params {String} MyName And this part is the description`\n\n```js\n/**\n * Download a file.\n *\n * @name Download File\n * @path {GET} /v1/files/:fileId\n * @params {String} :fileId is the unique identifier for the file to download.\n */\nserver.get({\n  url: '/v1/files/:fileId',\n}, (req, res, next) =\u003e {...}\n```\n\nThe above would add a table under the route description that lists all the route parameters.\n\nYou can use the `@params` tag as many times as you have parameters in your route path.\n\n## @query\n\nThe `@query` allows you to document any parameters which are passed via HTTP request url.\n\nWith this tag you need to provide the name and a description. The name is the first word of the text following the tag.\n* `@query MyName And this part is the description`\n\nYou can also optionally provide a type for the parameter.\n* `@query {String} MyName And this part is the description`\n\nYou can also specify that the parameter is optional by placing the name within square brackets.\n* `@query {String} [MyName] And this part is the description`\n\nLastly you can define a default value for the parameter. The idea is to document the value which will be used if the parameter is not provided.\n* `@query {String} [MyName=Phillip] And this part is the description`\n\n\n```js\n/**\n * Download files.\n *\n * @name Download Files\n * @path {GET} /v1/files\n * @query {String} [fileType] will limit the download to just these file types.\n */\nserver.get({\n  url: '/v1/files',\n}, (req, res, next) =\u003e {...}\n```\n\nThe above would add a table under the route description that lists all the query parameters.\n\nYou can use the `@query` tag as many times as you have parameters in your request url you wish to document.\n\n## @response\n\nThe `@response` allows you to document the response that your route will make\n\nWith this tag you need to provide the name and a description. The name is the first word of the text following the tag.\n* `@response MyName And this part is the description`\n\nYou can also optionally provide a type for the parameter.\n* `@response {String} MyName And this part is the description`\n\nYou can also specify that the response is optional by placing the name within square brackets.\n* `@response {String} [MyName] And this part is the description`\n\nLastly you can define a default value for the parameter.\n* `@response {String} [MyName=Phillip] And this part is the description`\n\n\n```js\n/**\n * Download files.\n *\n * @name Download Files\n * @path {GET} /v1/files\n * @response {Object} metadata\n * @response {String} metadata.name\n * @response {String} metadata.link\n */\nserver.get({\n  url: '/v1/files',\n}, (req, res, next) =\u003e {...}\n```\n\nThe above would add a table under the route description that lists that the route answer with a json document containing the `name` and `link` key.\n\nYou can use the `@response` tag as many times as you have parameters in your response you wish to document.\n\n\n## @code\n\nThe `@code` allows you to document the http response code that your route will make\n\nWith this tag you need to provide the number like this\n* `@code {200} and then you document why this code is happening`\n\n```js\n/**\n * Download files.\n *\n * @name Download Files\n * @path {GET} /v1/files\n * @code {200} if the request is successful\n * @code {500} if the request fail because the database isn't accesible \n * @response {Object} metadata\n * @response {String} metadata.name\n * @response {String} metadata.link\n */\nserver.get({\n  url: '/v1/files',\n}, (req, res, next) =\u003e {...}\n```\n\nThe above would add a table under the route description that lists that the route answer with a json document containing the `name` and `link` key.\n\nYou can use the `@response` tag as many times as you have parameters in your response you wish to document.\n\n## @service\n\nThe `@service` allows you to document the host used to make a the request, in the time of microservice, you may have to hit a specific host to reach a specific microservice, you may say that they must be behind a load balancer, but in localhost thats not always the case.\n\nWith this tag you need to provide the number like this\n* `@service API`\n\n```js\n/**\n * Download files.\n *\n * @name Download Files\n * @service DOWNLOAD\n * @path {GET} /v1/files\n * @code {200} if the request is successful\n * @code {500} if the request fail because the database isn't accesible \n * @response {Object} metadata\n * @response {String} metadata.name\n * @response {String} metadata.link\n */\nserver.get({\n  url: '/v1/files',\n}, (req, res, next) =\u003e {...}\n```\n\n## @chain\n\nThe `@chain` allows you to document the sequence of handlers which will handle the request before current endpoint or middleware,  for e.g it may be the express.js middlewares. \n\nWith this tag you may provide @link or human-friendly name of chain element. It is important to keep order of @chain declarations same as real request handling order.\n* `@chain {@link module:\u003cfull-path-to-module-member\u003e} || @chain \u003chuman-friendly-endpoint-name\u003e`\n\n```js\n/**\n * Handlers chain - example middleware\n *\n * @name SomeMiddleware\n * @path {POST} /v1/chain\n * @version v1\n * @since v1\n */\napp.get('/v1/chain', function (request, response, next) {\n  ...\n  next()\n})\n\n/**\n * Handlers chain - endpoint after the middleware\n *\n * @name SomeEndpoint\n * @path {POST} /v1/chain\n * @version v1\n * @since v1\n * @code 200\n * @chain {@link module:MyRoutes.SomeMiddleware}\n * @chain This handler\n */\napp.get('/v1/chain', function (request, response) {\n  ...\n})\n```\n\nThe above would add a table under the route description that lists that the route answer with a json document containing the `name` and `link` key.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/vmarchaud/jsdoc-http-plugin. This project is intended to be a safe, welcoming space for\ncollaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe library is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvmarchaud%2Fjsdoc-http-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvmarchaud%2Fjsdoc-http-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvmarchaud%2Fjsdoc-http-plugin/lists"}