node-restify-swagger is a utility that generates API documentation in the Swagger 1.2 format for web services built with the Restify framework. Published with its latest version 0.1.8 in 2015, the package is largely unmaintained and relies on the deprecated Swagger 1.2 specification, which has since been superseded by OpenAPI Specification (OAS) 2.0 and 3.x. It integrates with `node-restify-validation` to derive documentation from validation schemas, offering basic endpoint documentation and model definitions. Due to its age, it is not recommended for new projects and is unlikely to be compatible with modern Restify versions (which are currently at 11.x and support Node.js v14.x and v16.x) or contemporary API documentation tools.
npm install node-restify-swaggerVerified import paths — ran on the pinned version, not inferred.
Sets up a basic Restify server with Swagger 1.2 documentation, including a POST route with input validation and model definitions, demonstrating how to configure and generate API specs.
Migrate to a contemporary Restify-compatible OpenAPI documentation generator like `restify-swagger-jsdoc` (for JSDoc annotations) or `swagger-restify-mw` for Swagger 2.0/OpenAPI 3.x support.
Replace this package with actively maintained alternatives. For new projects, consider other frameworks like Express with `swagger-jsdoc` or `NestJS` which have robust OpenAPI integrations.
Ensure your project is configured for CommonJS, or use dynamic `import()` if necessary within an ESM project, though full compatibility is not guaranteed. Prefer modern ESM-compatible alternatives.
Pin Restify and `node-restify-validation` to very old versions (e.g., `restify@^4.x` if compatible) or, ideally, migrate to modern tooling that supports current Restify versions or other frameworks.
Carefully review the example provided in the README and ensure all `swagger` and `models` properties on your routes conform to the package's expected structure for Swagger 1.2 definitions. Debug generated `resources.json` and specific `docPath` JSON outputs.
This package is CommonJS-only. Either revert your project to CommonJS (`.js` files with `"type": "commonjs"` or no `type` field in `package.json`) or switch to a modern, ESM-compatible Swagger integration package.
Ensure `server` is correctly initialized via `restify.createServer()` and that you are using a compatible, albeit old, version of the `restify` package. Check `restify` documentation for specific API changes across major versions.
Verify the `require('node-restify-swagger')` statement is correct and that the package is installed. Double-check for typos in the import path. If using TypeScript, ensure ambient type declarations are not misleading for a CJS package.Change the `server.listen()` port to an unused one (e.g., 3000, 8080) or terminate the process currently occupying the port.