swagger-node-runner is a middleware engine designed to integrate Swagger (now OpenAPI) definitions with various Node.js web frameworks, including Connect, Express, Restify, Hapi, and Sails. It handles the loading and processing of API definitions, routing, and applying middleware based on the specification. The package is currently at version 0.7.3, with its last known release in October 2016. Its primary differentiation from earlier solutions was the complete replacement of `swagger-tools` with the `Sway` library starting from version 0.6.0, which was further updated to `Sway 1.0` in version 0.7.0. Due to its age and lack of recent updates, the project appears to be abandoned, meaning it does not receive new features, bug fixes, or security patches. Developers should exercise caution regarding its compatibility with modern Node.js versions and potential security vulnerabilities in its outdated dependencies.
npm install swagger-node-runnerVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up a basic Express application with `swagger-node-runner`. It loads an OpenAPI (Swagger 2.0) definition, registers the middleware for API routing and handling, and includes commented examples for a basic Swagger YAML file, a controller, and API key authentication.
Review the v0.6.0 release notes on GitHub for detailed upgrade instructions and adapt your code to `Sway`'s API or `swagger-node-runner`'s new middleware structure.
Test your application thoroughly after upgrading to v0.7.0 to identify any regressions or behavioral changes due to `Sway 1.0`. Consult `Sway`'s release notes for specific breaking changes.
Replace `cors` with `swagger-cors` in your middleware pipe (e.g., in `config/default.yaml`) and ensure your `fittingsDirs` configuration includes your `node_modules` path if `swagger-cors` is a direct dependency.
Consider migrating to a modern OpenAPI/Swagger framework or middleware, such as `express-openapi`, `fastify-swagger`, or manually integrating `swagger-ui-express` with a routing library, to ensure ongoing support and security.
Be aware that `x-private: true` tags will hide parts of your API from the served Swagger definition. If you need to override this, check the `privateTags` configuration option for `swagger_raw`.
Ensure the package is installed using `npm install swagger-node-runner` and that your `require('swagger-node-runner')` statement points to the correct module.Carefully review the validation error messages provided by the runner. Use a Swagger/OpenAPI editor (e.g., Swagger Editor online) to validate your API definition file and correct any syntax or schema issues.
Update your application code to use `swagger-node-runner`'s new API methods or `Sway`'s API for parsing and validation, as direct calls to `swagger-tools` functionality are no longer supported by `swagger-node-runner` itself.