Installations
npm install swagger-editor-dist
Score
66.7
Supply Chain
78.4
Quality
90.3
Maintenance
100
Vulnerability
87.6
License
Releases
v5.0.0-alpha.98
Published on 11 Nov 2024
v5.0.0-alpha.97
Published on 06 Nov 2024
Swagger Editor v4.14.0 Released!
Published on 06 Nov 2024
Swagger Editor v4.13.1 Released!
Published on 11 Jun 2024
Swagger Editor v4.13.0 Released!
Published on 11 Jun 2024
v5.0.0-alpha.96
Published on 28 May 2024
Contributors
Developer
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
18.17.1
NPM Version
9.6.7
Statistics
8,951 Stars
4,898 Commits
2,257 Forks
260 Watching
22 Branches
146 Contributors
Updated on 27 Nov 2024
Languages
JavaScript (94.7%)
Less (2.74%)
HTML (1.64%)
Shell (0.82%)
Dockerfile (0.1%)
Total Downloads
Cumulative downloads
Total Downloads
7,133,170
Last day
-23.7%
2,868
Compared to previous day
Last week
-13.4%
18,519
Compared to previous week
Last month
13.4%
81,346
Compared to previous month
Last year
-47.7%
780,487
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
⏰️ Looking for the next generation version of Swagger Editor?
SwaggerEditor is now released under two major release channels:
- SwaggerEditor@4 - released from master branch and deployed at https://editor.swagger.io/
- SwaggerEditor@5 - released from next branch and deployed at https://editor-next.swagger.io/
Only SwaggerEditor@5 supports OpenAPI 3.1.0. SwaggerEditor@4 will not receive OpenAPI 3.1.0 support and is considered legacy at this point. The plan is to continually migrate fully to SwaggerEditor@5 and deprecate the SwaggerEditor@4 in the future.
🕰️ Looking for the older version of Swagger Editor? Refer to the 2.x or 3.x branches.
Swagger Editor lets you edit OpenAPI API definitions (OpenAPI 2.0 and OpenAPI 3.0.3) in JSON or YAML format inside your browser and to preview documentations in real time. Valid OpenAPI definitions can then be generated and used with the full Swagger tooling (code generation, documentation, etc).
As a brand-new version, written from the ground up, there are some known issues and unimplemented features. Check out the Known Issues section for more details.
This repository publishes to two different NPM modules:
- swagger-editor is a traditional npm module intended for use in single-page applications that are capable of resolving dependencies (via Webpack, Browserify, etc).
- swagger-editor-dist is a dependency-free module that includes everything you need to serve Swagger Editor in a server-side project, or a web project that can't resolve npm module dependencies.
If you're building a single-page application, using swagger-editor
is strongly recommended, since swagger-editor-dist
is significantly larger.
Anonymized analytics
Swagger Editor uses Scarf to collect anonymized installation analytics. These analytics help support the maintainers of this library and ONLY run during installation. To opt out, you can set the scarfSettings.enabled
field to false
in your project's package.json
:
// package.json
{
// ...
"scarfSettings": {
"enabled": false
}
// ...
}
Alternatively, you can set the environment variable SCARF_ANALYTICS
to false
as part of the environment that installs your npm packages, e.g., SCARF_ANALYTICS=false npm install
.
Helpful scripts
Any of the scripts below can be run by typing npm run <script name>
in the project's root directory.
Developing
Script name | Description |
---|---|
dev | Spawn a hot-reloading dev server on port 3200. |
deps-check | Generate a size and licensing report on Swagger Editors's dependencies. |
lint | Report ESLint style errors and warnings. |
lint-errors | Report ESLint style errors, without warnings. |
lint-fix | Attempt to fix style errors automatically. |
watch | Rebuild the core files in /dist when the source code changes. Useful for npm link . |
Building
Script name | Description |
---|---|
build | Build a new set of JS and CSS assets, and output them to /dist . |
build:bundle | Build swagger-editor-bundle.js only (commonJS). |
build:core | Build swagger-editor.(js|css) only (commonJS). |
build:standalone | Build swagger-editor-standalone-preset.js only (commonJS). |
build:stylesheets | Build swagger-editor.css only. |
build:es:bundle | Build swagger-editor-es-bundle.js only (es2015). |
build:es:bundle:core | Build swagger-editor-es-bundle-core.js only (es2015). |
Testing
Script name | Description |
---|---|
test | Run unit tests in Node, run Cypress end-to-end tests, and run ESLint in errors-only mode. |
test:unit-mocha | Run Mocha-based unit tests in Node. |
test:unit-jest | Run Jest-based unit tests in Node. |
e2e | Run end-to-end browser tests with Cypress. |
lint | Run ESLint test |
test:artifact | Run list of bundle artifact tests in Jest |
test:artifact:umd:bundle | Run unit test that confirms swagger-editor-bundle exports as a Function |
test:artifact:es:bundle | Run unit test that confirms swagger-editor-es-bundle exports as a Function |
test:artifact:es:bundle:core | Run unit test that confirms swagger-editor-es-bundle-core exports as a Function |
Running locally
Prerequisites
- git, any version
- Node.js >=20.3.0 and npm >=9.6.7 are the minimum required versions that this repo runs on, but we always recommend using the latest version of Node.js.
1 $ npm i --legacy-peer-deps
If you have Node.js and npm installed, you can run npm start
to spin up a static server.
Otherwise, you can open index.html
directly from your filesystem in your browser.
If you'd like to make code changes to Swagger Editor, you can start up a Webpack hot-reloading dev server via npm run dev
.
Browser support
Swagger Editor works in the latest versions of Chrome, Safari, Firefox, and Edge.
Known Issues
To help with the migration, here are the currently known issues with 3.X. This list will update regularly, and will not include features that were not implemented in previous versions.
- Everything listed in Swagger UI's Known Issues.
- The integration with the codegen is still missing.
Docker
Running the image from DockerHub
There is a docker image published in DockerHub.
To use this, run the following:
docker pull swaggerapi/swagger-editor
docker run -d -p 80:8080 swaggerapi/swagger-editor
This will run Swagger Editor (in detached mode) on port 80 on your machine, so you can open it by navigating to http://localhost
in your browser.
- You can provide a URL pointing to an API definition (may not be available if some security policies such as CSP or CORS are enforced):
docker run -d -p 80:8080 -e URL="https://petstore3.swagger.io/api/v3/openapi.json" swaggerapi/swagger-editor
- You can provide your own
json
oryaml
definition file from your local host:
docker run -d -p 80:8080 -v $(pwd):/tmp -e SWAGGER_FILE=/tmp/swagger.json swaggerapi/swagger-editor
Note: When both URL
and SWAGGER_FILE
environment variables are set, URL
has priority and SWAGGER_FILE
is ignored.
- You can specify a different base url via
BASE_URL
variable for accessing the application - for example if you want the application to be available athttp://localhost/swagger-editor/
:
docker run -d -p 80:8080 -e BASE_URL=/swagger-editor swaggerapi/swagger-editor
- You can specify a different port via
PORT
variable for accessing the application, default is8080
.
docker run -d -p 80:80 -e PORT=80 swaggerapi/swagger-editor
- You can specify Google Tag Manager ID via
GTM
variable for tracking the usage of the swagger-editor.
docker run -d -p 80:8080 -e GTM=GTM-XXXXXX swaggerapi/swagger-editor
You can also customize the different endpoints used by the Swagger Editor with the following environment variables. For instance, this can be useful if you have your own Swagger generator server:
Environment variable | Default value |
---|---|
URL_SWAGGER2_GENERATOR | https://generator.swagger.io/api/swagger.json |
URL_OAS3_GENERATOR | https://generator3.swagger.io/openapi.json |
URL_SWAGGER2_CONVERTER | https://converter.swagger.io/api/convert |
If you want to run the Swagger Editor locally without the Codegen features (Generate Server and Generate Client) you can set the above environment variables to null
(URL_SWAGGER2_CONVERTER=null
).
Building and running an image locally
To build and run a docker image with the code checked out on your machine, run the following from the root directory of the project:
# Install npm packages (if needed)
npm install
# Build the app
npm run build
# Build an image
docker build -t swagger-editor .
# Run the container
docker run -d -p 80:8080 swagger-editor
You can then view the app by navigating to http://localhost
in your browser.
Documentation
Using older version of React
[!IMPORTANT] By older versions we specifically refer to
React >=17 <18
.
By default swagger-editor@4 npm package comes with latest version of React@18. It's possible to use swagger-editor@4 npm package with older version of React.
Let's say my application integrates with swagger-editor@4 npm package and uses React@17.0.2.
npm
In order to inform swagger-editor@4
npm package that I require it to use my React version, I need to use npm overrides.
1{ 2 "dependencies": { 3 "react": "=17.0.2", 4 "react-dom": "=17.0.2" 5 }, 6 "overrides": { 7 "swagger-editor": { 8 "react": "$react", 9 "react": "$react-dom", 10 "react-redux": "^8" 11 } 12 } 13}
[!NOTE] The React and ReactDOM override are defined as a reference to the dependency. Since react-redux@9 only supports
React >= 18
, we need to use react-redux@8.
yarn
In order to inform swagger-editor@4
npm package that I require it to use my specific React version, I need to use yarn resolutions.
1{ 2 "dependencies": { 3 "react": "17.0.2", 4 "react-dom": "17.0.2" 5 }, 6 "resolutions": { 7 "swagger-editor/react": "17.0.2", 8 "swagger-editor/react-dom": "17.0.2", 9 "swagger-editor/react-redux": "^8" 10 } 11}
[!NOTE] The React and ReactDOM resolution cannot be defined as a reference to the dependency. Unfortunately yarn does not support aliasing like
$react
or$react-dom
as npm does. You'll need to specify the exact versions.
Security contact
Please disclose any security-related issues or vulnerabilities by emailing security@swagger.io, instead of using the public issue tracker.
No vulnerabilities found.
Reason
29 commit(s) and 4 issue activity found in the last 90 days -- score normalized to 10
Reason
security policy file detected
Details
- Info: security policy file detected: SECURITY.md:1
- Info: Found linked content: SECURITY.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1
- Info: Found text in security policy: SECURITY.md:1
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0
Reason
packaging workflow detected
Details
- Info: Project packages its releases by way of GitHub Actions.: .github/workflows/docker-build-push.yml:13
Reason
SAST tool is run on all commits
Details
- Info: SAST configuration detected: CodeQL
- Info: all commits (28) are checked with a SAST tool
Reason
5 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m / GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
Reason
Found 1/5 approved changesets -- score normalized to 2
Reason
dependency not pinned by hash detected -- score normalized to 1
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:59: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/codeql.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:63: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/codeql.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:94: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/codeql.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/dependabot-merge.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/dependabot-merge.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/dependabot-merge.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/dependabot-merge.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/deploy-gh-pages.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/deploy-gh-pages.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/deploy-gh-pages.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/deploy-gh-pages.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/deploy-gh-pages.yml:48: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/deploy-gh-pages.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/docker-build-push.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/docker-build-push.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/docker-build-push.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/docker-build-push.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/docker-build-push.yml:48: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/docker-build-push.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/docker-build-push.yml:73: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/docker-build-push.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/docker-build-push.yml:76: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/docker-build-push.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/docker-build-push.yml:79: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/docker-build-push.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/docker-build-push.yml:85: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/docker-build-push.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/docker-build-push.yml:94: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/docker-build-push.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/docker-image-check.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/docker-image-check.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nightly-build.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/nightly-build.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nightly-build.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/nightly-build.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nightly-build.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/nightly-build.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nightly-build.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/nightly-build.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nightly-build.yml:61: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/nightly-build.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nightly-build.yml:67: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/nightly-build.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/nodejs.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/nodejs.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/nodejs.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/release.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/release.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:59: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:70: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:83: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:94: update your workflow using https://app.stepsecurity.io/secureworkflow/swagger-api/swagger-editor/release.yml/master?enable=pin
- Warn: containerImage not pinned by hash: Dockerfile:1: pin your Docker image by updating nginx:1.27.2-alpine to nginx:1.27.2-alpine@sha256:74175cf34632e88c6cfe206897cbfe2d2fecf9bf033c40e7f9775a3689e8adc7
- Info: 0 out of 23 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 11 third-party GitHubAction dependencies pinned
- Info: 0 out of 1 containerImage dependencies pinned
- Info: 3 out of 3 npmCommand dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Info: jobLevel 'packages' permission set to 'read': .github/workflows/codeql.yml:37
- Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql.yml:40
- Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql.yml:41
- Info: found token with 'none' permissions: .github/workflows/docker-image-check.yml:14
- Warn: no topLevel permission defined: .github/workflows/codeql.yml:1
- Warn: no topLevel permission defined: .github/workflows/dependabot-merge.yml:1
- Warn: no topLevel permission defined: .github/workflows/deploy-gh-pages.yml:1
- Warn: no topLevel permission defined: .github/workflows/deploy-rancher.yml:1
- Warn: no topLevel permission defined: .github/workflows/docker-build-push.yml:1
- Info: topLevel 'contents' permission set to 'read': .github/workflows/docker-image-check.yml:9
- Warn: no topLevel permission defined: .github/workflows/nightly-build.yml:1
- Info: topLevel 'contents' permission set to 'read': .github/workflows/nodejs.yml:15
- Warn: no topLevel permission defined: .github/workflows/release.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Score
6.2
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More