Integrates swagger-jsdoc into Webpack to automatically generate a swagger.json file from JSDoc comments in your source files during the build process. The stable version is 2.1.0 (released 2022-12-17). It provides a convenient way to keep API documentation in sync with code by leveraging Webpack's compilation pipeline. Unlike manual generation scripts, this plugin integrates seamlessly into existing Webpack configs, supports custom output filenames, and passes all options directly to swagger-jsdoc. Ships TypeScript types. Note that the plugin had no releases after 2022 and may require manual dependency updates for security fixes.
npm install swagger-jsdoc-webpack-pluginVerified import paths — ran on the pinned version, not inferred.
Configures the SwaggerJSDocWebpackPlugin in webpack.config.js to generate a swagger.json file from JSDoc annotations in source files, specifying OpenAPI metadata.
Set webpack configuration 'cache: false' or use 'watchOptions.ignored' to invalidate cache on JSDoc changes, or use webpack's snapshot management.
Upgrade to v2.1.0 or later to use custom output paths, or manually move/rename the generated file in a lifecycle hook.
Ensure apis patterns do not include node_modules (e.g., by using './src/**/*.js' instead of './**/*.js') or set the 'exclude' option if available.
Replace 'const { SwaggerJSDocWebpackPlugin } = require(...)' with 'const SwaggerJSDocWebpackPlugin = require(...)' if upgrading from v1.x.Pin swagger-jsdoc to version 6.2.x (as used in v2.0.2+) or check the plugin's repository for newer commits.
Run 'npm install swagger-jsdoc-webpack-plugin --save-dev' (Webpack plugins are typically dev dependencies).
Use 'const SwaggerJSDocWebpackPlugin = require('swagger-jsdoc-webpack-plugin');' or if using ESM, use dynamic import: 'await import('swagger-jsdoc-webpack-plugin').then(m => new m.default(...))'.Check the swagger-jsdoc options format; ensure 'definition' and 'apis' are correct. See swagger-jsdoc documentation for valid OpenAPI definition properties.
Upgrade to swagger-jsdoc-webpack-plugin@2.1.0 or later.