# <img src="https://raw.githubusercontent.com/swagger-api/swagger.io/wordpress/images/assets/SWE-logo-clr.png" height="80">
[![NPM version](https://badge.fury.io/js/swagger-ui.svg)](http://badge.fury.io/js/swagger-editor)
[![Build Status](https://jenkins.swagger.io/buildStatus/icon?job=oss-swagger-editor-master)](https://jenkins.swagger.io/job/oss-swagger-editor-master/)
[![Code Climate](https://codeclimate.com/github/swagger-api/swagger-editor/badges/gpa.svg)](https://codeclimate.com/github/swagger-api/swagger-editor)
[![Build Status](https://jenkins.swagger.io/view/OSS%20-%20JavaScript/job/oss-swagger-editor-master/badge/icon?subject=jenkins%20build)](https://jenkins.swagger.io/view/OSS%20-%20JavaScript/job/oss-swagger-editor-master/)
**ð°ï¸ Looking for the older version of Swagger Editor?** Refer to the [*2.x* branch](https://github.com/swagger-api/swagger-editor/tree/2.x).
Swagger Editor lets you edit [OpenAPI API definitions](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md) in YAML inside your browser and to preview documentations in real time.
Valid Swagger JSON descriptions 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](#known-issues) section for more details.
This repository publishes to two different NPM modules:
* [swagger-editor](https://www.npmjs.com/package/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](https://www.npmjs.com/package/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.
For the older version of swagger-editor, refer to the [*2.x branch*](https://github.com/swagger-api/swagger-editor/tree/2.x).
## 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
- NPM >=7.x
Generally, we recommend the following guidelines from [Node.js Releases](https://nodejs.org/en/about/releases/) to only use Active LTS or Maintenance LTS releases.
Current Node.js:
- Node.js 16.x
- NPM >=7.10.x
Current Node.js Active LTS:
- Node.js 14.x
- NPM >=7.x.x
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](https://github.com/swagger-api/swagger-ui/blob/master/README.md#known-issues).
- The integration with the codegen is still missing.
## Docker
### Running the image from DockerHub
There is a docker image published in [DockerHub](https://hub.docker.com/r/swaggerapi/swagger-editor/).
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` or `yaml` 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 at `http://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 is `8080`.
```
docker run -d -p 80:80 -e PORT=80 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
* [Importing your OpenAPI document](docs/import.md)
* [Contributing](https://github.com/swagger-api/.github/blob/master/CONTRIBUTING.md)
## Security contact
Please disclose any security-related issues or vulnerabilities by emaili
没有合适的资源?快使用搜索试试~ 我知道了~
swagger-editor-4.10.0最新版本
共304个文件
js:170个
yaml:25个
jsx:25个
需积分: 0 1 下载量 145 浏览量
2023-06-20
18:06:25
上传
评论
收藏 12.09MB ZIP 举报
温馨提示
swagger-editor-4.10.0最新版本
资源推荐
资源详情
资源评论
收起资源包目录
swagger-editor-4.10.0最新版本 (304个子文件)
rejected.file.1 2B
rejected.file.2 2B
.agignore 6B
commit-msg 60B
nginx.conf 528B
swagger-editor.css 206KB
style.css 0B
Dockerfile 412B
.dockerignore 87B
.editorconfig 171B
.eslintrc 1012B
.eslintrc 183B
.eslintrc 183B
.eslintrc 183B
.eslintrc 148B
.eslintrc 127B
.eslintrc 37B
.eslintrc 0B
drag-and-drop.gif 6.07MB
.gitignore 136B
index.html 4KB
index.html 4KB
index.html 3KB
oauth2-redirect.html 2KB
.huskyrc 105B
swagger-editor-bundle.js 2.57MB
swagger-editor-es-bundle.js 2.57MB
swagger-editor-standalone-preset.js 864KB
swagger-editor.js 369KB
swagger-editor-es-bundle-core.js 368KB
index.js 38KB
schemas.js 35KB
parameters.js 29KB
selectors.js 25KB
refs.js 22KB
refs.js 22KB
form-data.js 18KB
editor.js 18KB
paths.js 16KB
schema.js 16KB
schemas.js 15KB
selectors.js 13KB
form-objects.js 11KB
editor.js 9KB
ast.js 8KB
paths.js 8KB
ast-manager.js 8KB
refs.js 7KB
oas3-objects.js 6KB
components.js 6KB
path-translator.js 6KB
security.js 6KB
index.js 5KB
parameters.js 5KB
form-data-helpers.js 5KB
refs.js 5KB
keyword-map.js 5KB
index.js 5KB
schemas.js 5KB
refs.js 4KB
parameters.js 4KB
form-data.js 4KB
_config-builder.js 4KB
get-keywords-for-path.js 4KB
get-keywords-for-path.js 4KB
validation-helpers.js 4KB
babel.config.js 4KB
index.js 4KB
security.js 4KB
tags.js 4KB
snippets.js 4KB
form-validation.js 3KB
jsonSchema.js 3KB
ace.js 3KB
index.js 3KB
dev.babel.js 3KB
operation-object.js 3KB
ace.js 3KB
e2e.babel.js 3KB
index.js 3KB
operations.js 3KB
parameters.js 3KB
operations.js 3KB
server-variable-object.js 3KB
index.js 3KB
1862.js 3KB
condense-errors.js 3KB
form-data-helpers.js 3KB
info-object.js 2KB
spec.js 2KB
index.js 2KB
layout.js 2KB
paths.js 2KB
fn.js 2KB
servers-object.js 2KB
schema.js 2KB
validate-helper.js 2KB
security.js 2KB
spec-selectors.js 2KB
path-translator.js 2KB
共 304 条
- 1
- 2
- 3
- 4
资源评论
Jasonyeahjk
- 粉丝: 0
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功