swagger-ui README

README проекта с github.com/swagger-api/swagger-ui. Одним файлом markdown: README.md.

NPM version Build Status security scan total GitHub contributors

monthly npm installs docker registry monthly packagist installs gzip size

Introduction

Swagger UI allows anyone — be it your development team or your end consumers — to visualize and interact with the API’s resources without having any of the implementation logic in place. It’s automatically generated from your OpenAPI (formerly known as Swagger) Specification, with the visual documentation making it easy for back end implementation and client side consumption.

General

👉🏼 Want to score an easy open-source contribution? Check out our Good first issue label.

🕰️ Looking for the older version of Swagger UI? Refer to the 2.x branch.

This repository publishes three different NPM modules:

We strongly suggest that you use swagger-ui instead of swagger-ui-dist if you're building a single-page application, since swagger-ui-dist is significantly larger.

If you are looking for plain ol' HTML/JS/CSS, download the latest release and copy the contents of the /dist folder to your server.

Compatibility

The OpenAPI Specification has undergone 5 revisions since initial creation in 2010. Compatibility between Swagger UI and the OpenAPI Specification is as follows:

Swagger UI Version Release Date OpenAPI Spec compatibility Notes
5.32.0 2026-02-27 2.0, 3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.1.0, 3.1.1, 3.1.2, 3.2.0 tag v5.32.0
5.19.0 2025-02-17 2.0, 3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.1.0, 3.1.1, 3.1.2 tag v5.19.0
5.0.0 2023-06-12 2.0, 3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.1.0 tag v5.0.0
4.0.0 2021-11-03 2.0, 3.0.0, 3.0.1, 3.0.2, 3.0.3 tag v4.0.0
3.18.3 2018-08-03 2.0, 3.0.0, 3.0.1, 3.0.2, 3.0.3 tag v3.18.3
3.0.21 2017-07-26 2.0 tag v3.0.21
2.2.10 2017-01-04 1.1, 1.2, 2.0 tag v2.2.10
2.1.5 2016-07-20 1.1, 1.2, 2.0 tag v2.1.5
2.0.24 2014-09-12 1.1, 1.2 tag v2.0.24
1.0.13 2013-03-08 1.1, 1.2 tag v1.0.13
1.0.1 2011-10-11 1.0, 1.1 tag v1.0.1

Swagger UI also renders standalone JSON Schema documents: a document whose root $schema names a supported dialect and that has none of the fields openapi, swagger, asyncapi and arazzo. A root $schema naming any other dialect is refused with a message. An embedded schema resource ($id with its own $schema) or an external file that declares another dialect is rendered with the 2020-12 meaning, because references that cross dialects are not supported.

JSON Schema dialect Root $schema Swagger UI Version
2020-12 https://json-schema.org/draft/2020-12/schema TBD

Anonymized analytics

SwaggerUI 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.

Documentation

Usage

Customization

Development

Contributing

Integration Tests

End-to-end tests use Playwright. Install the browsers once with npx playwright install chromium webkit (add --with-deps on Linux), then run the full suite locally with npm run e2e. Playwright starts the required servers itself (and reuses them if they are already running) - be sure you aren't running a dev server on the same ports when testing, unless you want it reused!

To debug or run individual specs interactively, use npm run e2e:ui (or npm run e2e:headed).

To run a single spec:

npm run e2e -- test/e2e-playwright/features/deep-linking.spec.ts

After a run, npm run e2e:report opens the HTML report.

Browser support

Swagger UI 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.

Security contact

Please disclose any security-related issues or vulnerabilities by emailing [email protected], instead of using the public issue tracker.

License

SwaggerUI is licensed under Apache 2.0 license. SwaggerUI comes with an explicit NOTICE file containing additional legal notices and information.

swagger-ui (swagger-api/swagger-ui)

Ищем в базе…

Что это такое?Swagger UI превращает спецификацию OpenAPI (раньше — Swagger) в интерактивную визуальную документацию по API: ваша команда или потребители API могут посмотреть и опробовать его возможности без единой строчки кода реализации.
Это облачный сервис или что-то, что я развертываю сам?То, что вы развертываете сами: это фронтенд-библиотека, которая распространяется в виде трёх npm-пакетов — swagger-ui для SPA со сборщиком, swagger-ui-dist без зависимостей и swagger-ui-react как React-компонент, — плюс обычные ассеты HTML/JS/CSS.
Как его запустить?Выполните npm install swagger-ui (или swagger-ui-dist, если ваша сборка не может разрешить npm-зависимости) и укажите путь к своей спецификации; для обычных HTML/JS/CSS скачайте релиз и скопируйте содержимое папки /dist на свой сервер.
Нужен ли мне ещё что-то, кроме браузера, чтобы смотреть документацию?Нет — это чистый фронтенд, просто ассеты, которые раздаются рядом со спецификацией. Работает в актуальных версиях Chrome, Safari, Firefox и Edge.
Есть ли известные ограничения, о которых стоит знать?У ветки 3.X есть задокументированные известные проблемы: доступна лишь часть ранее поддерживаемых параметров, JSON Form Editor не реализован, поддержка collectionFormat неполная, а переводов l10n нет.
Не отправляет ли установка данные наружу?Один раз: Scarf собирает обезличенную аналитику, и только во время установки через npm. Отключить можно через scarfSettings.enabled=false в package.json или переменную окружения SCARFANALYTICS=false.
Есть ли официальный Docker-образ?Да — в репозитории есть CI-процессы сборки и публикации Docker-образов, так что можно запустить Swagger UI как контейнер, а не копировать ассеты из dist на сервер вручную.
Можно настроить внешний вид документации?Да — помимо конфигурации, документация описывает Plugin API и кастомные макеты, так что можно расширять или заменять части стандартного отображения.
Работает ли он с API, защищёнными через OAuth2?Да — OAuth2 описан в документации как отдельная тема, так что после настройки защищённые эндпоинты можно опробовать прямо из интерфейса.
Какие есть похожие проекты?redoc, swagger-codegen, OpenAPI-Specification, openapi-generator, scalar, apisix, fastapi, swag
Автор
swagger-api
Размер
624.4 MB
Звёзды
29.1K
Возраст
15 г
Коммиты · 90 дней