{"id":48244,"library":"jsdoc-rest-api","title":"jsdoc-rest-api","description":"jsdoc-rest-api v3.6.3 generates a map of REST API endpoints from JSDoc annotations and automatically attaches them to an Express.js app. It reads source files with custom tags like @apiType, @apiPath, @apiBody, @apiKey, and @apiDescription, producing route registrations so developers never need to write app.get(), app.post(), etc. The package exports two functions: generateRoutes() returns the route map, and attachExpressAppEndpoints() binds them to an Express instance. It is a niche automation tool for Node.js/Express projects using JSDoc comments; updates are infrequent (last release 2020).","status":"maintenance","version":"3.6.3","language":"javascript","source_language":"en","source_url":"https://github.com/Lwdthe1/jsdoc-rest-api","tags":["javascript","jsdoc","rest api","nodejs","expressjs","documentation","automation","code generator","api generator"],"install":[{"cmd":"npm install jsdoc-rest-api","lang":"bash","label":"npm"},{"cmd":"yarn add jsdoc-rest-api","lang":"bash","label":"yarn"},{"cmd":"pnpm add jsdoc-rest-api","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"The library attaches endpoints to an Express app instance","package":"express","optional":false},{"reason":"Used internally to find source files matching the provided pattern","package":"glob","optional":false}],"imports":[{"note":"ESM default import; the package does not ship TypeScript types. CommonJS require also works.","wrong":"jsdocRestApi = require('jsdoc-rest-api')","symbol":"jsdocRestApi","correct":"import jsdocRestApi from 'jsdoc-rest-api'"},{"note":"Named export available via destructuring; do not use subpath imports.","wrong":"const generateRoutes = require('jsdoc-rest-api/generateRoutes')","symbol":"generateRoutes","correct":"const { generateRoutes } = require('jsdoc-rest-api')"},{"note":"Both named and default import of the object containing both functions work. TypeScript users should use require or skip type checking.","wrong":"import { attachExpressAppEndpoints } from 'jsdoc-rest-api'","symbol":"attachExpressAppEndpoints","correct":"const { attachExpressAppEndpoints } = require('jsdoc-rest-api')"}],"quickstart":{"code":"const express = require('express');\nconst { attachExpressAppEndpoints } = require('jsdoc-rest-api');\n\nconst app = express();\napp.use(express.json());\n\nattachExpressAppEndpoints({\n  app: app,\n  source: 'api/controllers/**/*Controller.js'\n});\n\napp.all('*', (req, res) => {\n  res.status(404).send('Not found');\n});\n\nconst PORT = process.env.PORT || 3100;\napp.listen(PORT, () => {\n  console.log(`REST API server running on port ${PORT}`);\n});","lang":"javascript","description":"Initializes Express, attaches endpoints from JSDoc-annotated controller files, and starts the server."},"warnings":[{"fix":"Write @apiBody as a JSON-like string, e.g., @apiBody {\"title\": \"String\"}. Validate that the library parses it correctly.","message":"The @apiBody annotation expects a JSON object description string, not actual JSON; incorrect parsing can cause route handlers to fail.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Ensure @apiPath is like /api/resource/:id, not api/resource/:id or /api/resource/{id}.","message":"The @apiPath must start with a forward slash and can include Express-style route parameters (`:id`); otherwise routes may not match.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use attachExpressAppEndpoints() instead of manually calling generateRoutes() and wiring routes.","message":"The generateRoutes() method is considered lower-level; attachExpressAppEndpoints() is the recommended entry point.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Use module.exports = MyController in your controller files.","message":"All controller files must be CommonJS modules exporting a class or function; ES module exports are not supported.","severity":"gotcha","affected_versions":">=3.0.0"}],"env_vars":null,"search_vec":"'/express':81 '2020':91 'annot':19 'api':4,8,15,95,102 'apibodi':38 'apidescript':41 'apikey':39 'apipath':37 'apityp':36 'app':27 'app.get':51 'app.post':52 'attach':22 'attachexpressappendpoint':65 'autom':76,99 'automat':21 'bind':66 'code':100 'comment':85 'custom':33 'develop':46 'document':98 'endpoint':16 'etc':53 'export':56 'express':70 'express.js':26 'expressj':97 'file':31 'function':58 'generat':10,101,103 'generaterout':59 'infrequ':88 'instanc':71 'javascript':92 'jsdoc':2,6,18,84,93 'jsdoc-rest-api':1,5 'last':89 'like':35 'map':12,63 'need':48 'never':47 'nich':75 'node.js':80 'node.js/express':79 'nodej':96 'packag':55 'produc':42 'project':82 'read':29 'registr':44 'releas':90 'rest':3,7,14,94 'return':60 'rout':43,62 'sourc':30 'tag':34 'tool':77 'two':57 'updat':86 'use':83 'v3.6.3':9 'write':50","created_at":"2026-06-07T16:55:38.290756+00:00","updated_at":"2026-06-07T16:55:38.290756+00:00","problems":[{"fix":"Ensure the argument is `{ app: expressApp, source: 'path' }`.","cause":"Passing an object without the 'app' key to attachExpressAppEndpoints.","error":"TypeError: Cannot read property 'app' of undefined"},{"fix":"Verify the source path relative to the project root, e.g., 'api/controllers/**/*Controller.js'.","cause":"The glob pattern provided does not match any existing files.","error":"Error: No source files found matching glob pattern"},{"fix":"Check that @apiBody contains valid JSON-like string, e.g., @apiBody {\"field\": \"String\"}.","cause":"Invalid or missing @apiBody annotation causing JSON parsing failure.","error":"SyntaxError: Unexpected token u in JSON at position 0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/Lwdthe1/jsdoc-rest-api#readme","github":"https://github.com/Lwdthe1/jsdoc-rest-api","docs":null,"changelog":null,"pypi":null,"npm":"jsdoc-rest-api","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}