Skip to content

Helpful scripts

Any of the scripts below can be run by typing npm run <script name> in the project’s root directory.

Developing

Script nameDescription
devSpawn a hot-reloading dev server on port 3200.
deps-checkGenerate a size and licensing report on Swagger UI’s dependencies.
lintReport ESLint style errors and warnings.
lint-errorsReport ESLint style errors, without warnings.
lint-fixAttempt to fix style errors automatically.
watchRebuild the core files in /dist when the source code changes. Useful for npm link with Swagger Editor.

Building

Script nameDescription
buildBuild a new set of JS and CSS assets, and output them to /dist.
build-bundleBuild swagger-ui-bundle.js only (commonJS).
build-coreBuild swagger-ui.(js|css) only (commonJS).
build-standaloneBuild swagger-ui-standalone-preset.js only (commonJS).
build-stylesheetsBuild swagger-ui.css only.
build:es:bundleBuild swagger-ui-es-bundle.js only (es2015).
build:es:bundle:coreBuild swagger-ui-es-bundle-core.js only (es2015).

Testing

Script nameDescription
testRun unit tests in Node, run Cypress end-to-end tests, and run ESLint in errors-only mode.
test:unitRun Jest unit tests in Node.
e2eRun end-to-end tests (requires JDK and Selenium).
e2e-cypressRun end-to-end browser tests with Cypress.
dev-e2e-cypressDev mode, open Cypress runner and manually select tests to run.
lintRun ESLint test
test:artifactRun list of bundle artifact tests in Jest
test:artifact:umd:bundleRun unit test that confirms swagger-ui-bundle exports as a Function
test:artifact:es:bundleRun unit test that confirms swagger-ui-es-bundle exports as a Function
test:artifact:es:bundle:coreRun unit test that confirms swagger-ui-es-bundle-core exports as a Function