swagger-ui
Transform OpenAPI specifications into interactive, browser-based API documentation that developers and consumers can explore and test live.
Swagger UI converts OpenAPI (formerly Swagger) Specification files into a rich, interactive web interface that lets anyone — developers, QA engineers, or end users — visualize and exercise an API without writing a single line of client code. By pointing it at a spec URL or file, teams instantly get browsable endpoint documentation with inline request forms, live response inspection, and authentication flows.
The project ships as three distinct npm packages to cover different integration scenarios: swagger-ui for Webpack/Browserify single-page applications, swagger-ui-dist as a self-contained bundle for server-side or static deployments, and swagger-ui-react as a first-class React component. All three are backed by the same core system built on Redux with ImmutableJS state, a plugin-injection architecture, and pluggable layout support.
Swagger UI supports OpenAPI 2.0, 3.0.x, 3.1.x, and the newly introduced 3.2.0 specification, with dedicated plugin layers for each major revision. The JSON Schema 2020-12 support lands as a separate plugin that renders every keyword — allOf, anyOf, oneOf, if/then/else, unevaluatedProperties, and more — as an interactive UI element aware of schema semantics. Dark mode, deep linking, request snippet generation, syntax highlighting, OAuth2 flows, and a safe-render error-boundary system are all implemented as first-class, replaceable plugins.
Originally created by SmartBear Software and now part of the OpenAPI Initiative ecosystem, Swagger UI has become the de-facto standard for API documentation presentation, with hundreds of millions of npm downloads and active Docker images. The project is actively maintained with a release cadence averaging two-plus releases per month.
What You Get
- Interactive Request Execution - Expand any endpoint, fill parameters via auto-generated form fields, hit ‘Try it out’, and view real HTTP responses with status codes and headers displayed inline.
- OpenAPI 3.2.0 Support - Full compatibility with the latest OpenAPI 3.2.0 specification alongside 2.0, 3.0.x, and 3.1.x, with dedicated plugin layers per major version ensuring backward compatibility.
- JSON Schema 2020-12 Rendering - A dedicated plugin renders every JSON Schema keyword (
allOf,anyOf,oneOf,if/then/else,unevaluatedProperties, etc.) as interactive, collapsible UI components with live schema-aware validation display. - OAuth2 and API Key Authentication - Built-in authorization UI dynamically renders the security flows declared in the spec — OAuth2 (implicit, authorization code, client credentials, password), API key, HTTP bearer, and OpenID Connect.
- Deep Linking - URL fragments track the currently expanded operation, enabling direct shareable links to specific endpoints that survive page reloads and can be used in issue trackers or tutorials.
- Dark Mode - A built-in dark mode toggle reads
prefers-color-schemeon load and allows manual override, storing user preference locally. - Request Snippet Generator - Automatically generates curl, Node.js, Python, and other code snippets for any request, so developers can copy working client calls directly from the documentation.
- Plugin API for Full Customization - The entire UI is built on a composable plugin system; any component, selector, action, or reducer can be replaced or wrapped, and new plugins can be injected at runtime without forking core code.
Common Use Cases
- Public API portals - A SaaS company embeds Swagger UI on its developer portal, pointing it at a hosted OpenAPI spec so customers can explore endpoints and generate sample requests before writing integration code.
- Internal API discovery - Platform teams host a Swagger UI instance in their internal developer portal, consolidating specs from multiple services so engineers across teams can discover and test endpoints without environment setup.
- API contract validation in CI - QA engineers run automated Cypress tests against the deployed Swagger UI to verify that spec changes render correctly and that live try-it-out calls against a staging backend return expected schemas.
- Documentation for generated SDKs - SDK generators like Swagger Codegen and OpenAPI Generator ship a Swagger UI bundle alongside generated client libraries, giving consumers a live reference alongside the generated code.
- Educational API sandboxes - API training courses embed Swagger UI with a pre-loaded petstore or custom teaching spec, letting learners explore REST concepts and experiment with real HTTP calls in a guided environment.
Under The Hood
Architecture Swagger UI is built around a central store system that acts as a micro-kernel for plugin composition. The Store class (backed by Redux with ImmutableJS) bootstraps a bare state, then iterates registered plugins to merge their components, action creators, reducers, selectors, and root injects into a unified bound system that is passed to every component via a system context. This factory-injection model means the core never hard-codes UI concerns — even the base layout, authorization panel, and schema renderers arrive as plugins that can be fully replaced. Plugins wrap existing components using a higher-order pattern, substitute whole slices of Redux state, or add entirely new UI regions without forking core code. A safe-render layer wraps a configurable list of critical components in React error boundaries, isolating rendering failures to individual panels instead of crashing the whole page. The result is a clean separation between the spec-parsing pipeline, immutable state shape, and view layer with strictly unidirectional data flow.
Tech Stack The codebase is pure JavaScript with React as the rendering layer and Redux backed by ImmutableJS for centralized, immutable state management. Webpack handles multi-target bundling into three published packages — a Webpack-compatible module, a dependency-free dist bundle, and a React component wrapper. Babel transforms modern JavaScript, ESLint enforces code style, and SCSS with Stylelint handles all styling compiled into a standalone CSS bundle. The production deployment artifact is an Alpine-based Nginx Docker image configured entirely through environment variable injection at startup. Testing spans Jest for unit and integration coverage and Cypress for comprehensive end-to-end scenarios against real OpenAPI sample specs. An automated CI pipeline via GitHub Actions and Jenkins covers linting, unit tests, Cypress runs, CodeQL security scanning, Docker image builds, and multi-package npm releases.
Code Quality The project maintains extensive test coverage across unit, integration, and end-to-end layers — unit tests in Jest covering core utilities, reducers, selectors, and component rendering, plus more than a hundred Cypress end-to-end tests validating full UI behavior against real OpenAPI fixtures. The Flux Standard Actions convention is applied consistently across all state plugins, making action payloads predictable and reducers straightforward to trace. The safe-render plugin wraps every critical UI panel in an error boundary, preventing a single malformed spec section from taking down the entire documentation page. Code style is enforced through ESLint and Prettier with automated CI gates, and dependency audits run on a separate scheduled Jenkins pipeline. The codebase shows consistent use of functional patterns, lodash utilities, and named action constants across a large surface area, though the absence of TypeScript means type safety relies on JSDoc annotations and runtime validation rather than compile-time guarantees.
What Makes It Unique
Swagger UI’s defining technical achievement is treating the OpenAPI specification not as a static data structure to display but as a living schema that drives dynamic, keyword-aware UI composition. The JSON Schema 2020-12 plugin renders every schema keyword — including conditional keywords like if/then/else, applicators like unevaluatedProperties, and anchors like $dynamicRef — as an interactive, collapsible UI element that reflects actual validation semantics rather than a flat property list. The OAS 3.2.0 plugin extends this further by layering OpenAPI-specific extensions on top of the base JSON Schema rendering. Deep linking encodes the full UI navigation state into URL fragments, making every expanded operation directly addressable. The plugin system goes further than typical extension points by allowing total replacement of reducers, selectors, and components at any layer — enabling downstream projects to ship Swagger UI flavors with completely different layouts while retaining the full spec-parsing and request-execution core.
Self-Hosting
Swagger UI is released under the Apache License 2.0, a permissive open-source license that allows commercial use, modification, and distribution without requiring derivative works to be open-sourced. The only obligations are preserving copyright notices and the NOTICE file when distributing the software. This makes it safe for embedding in proprietary products, internal portals, or SaaS platforms without any copyleft implications for surrounding code.
Running Swagger UI yourself is operationally lightweight. The official Docker image is based on Alpine-nginx and weighs in at a small footprint; configuring it is done entirely through environment variables documented in the repository. Static deployments are even simpler — download the /dist folder from a release, drop it behind any web server, and point SWAGGER_JSON or url at your spec. Updates require replacing static assets or pulling a new Docker tag; there is no database, no background services, and no persistent state to manage. The operational burden scales with the number of specs and deployment environments an organization maintains, not with the complexity of the tool itself.
SmartBear offers SwaggerHub as a managed cloud platform built on top of Swagger UI with additional capabilities: spec hosting and versioning with Git-style branching, team collaboration and commenting, design-time linting against API style guides, auto-generated mock servers, and integrated access control. SwaggerHub adds an API registry, changelogs, and enterprise SSO that self-hosted Swagger UI does not provide. Organizations that only need rendered interactive documentation get everything they need from the open-source tool; those requiring spec governance, centralized discovery across many APIs, or SLA-backed hosting should evaluate SwaggerHub’s paid tiers.
Related Apps
Ollama
AI Development · Developer Tools
Run Llama, Gemma, DeepSeek, and other open LLMs on your own machine with one command and an OpenAI-compatible API.
Ollama
MITDify
No Code Platforms · AI Development · Developer Tools
Visual LLM workflow platform with RAG pipelines, agent capabilities, and model management for building production AI applications.
Dify
OtherFirecrawl
AI Development · Developer Tools
Turn any website into clean, LLM-ready data with a single API call — no proxy headaches, no scraping complexity.