
API documentation is no longer optional — it is the backbone of any well-maintained software project. If you work with REST APIs, you already know that navigating dozens of endpoints without a clear, interactive reference wastes time and creates friction between teams. That is exactly where Swagger steps in. This guide walks you through everything you need to know about how to install Swagger on Debian 13, from system preparation all the way to a production-ready Nginx deployment. Whether you are a backend developer, a DevOps engineer, or a sysadmin, this tutorial gives you a clean, reliable path forward.
What Is Swagger and Why Should You Use It?
Before touching the terminal, it helps to understand what Swagger actually is — because the name gets used in more than one way. Swagger originated as an API specification format in 2010, but in 2015 it was donated to the OpenAPI Initiative and renamed the OpenAPI Specification (OAS). Today, Swagger refers to the collection of open-source tools built around that specification.
The relationship is simple: OpenAPI is the blueprint, and Swagger is the toolbox. The Swagger ecosystem consists of three primary tools:
- Swagger UI — A browser-based interface that renders your OpenAPI specification as interactive, visual documentation. Developers can read endpoint details and test API calls directly from the browser.
- Swagger Editor — A browser-hosted or locally-served editor for writing and validating OpenAPI specs in YAML or JSON format.
- go-swagger — A Swagger 2.0 implementation for the Go programming language, available as a native Debian package.
As of 2025, the latest stable release is OpenAPI 3.1.x, and Swagger UI supports it fully. Teams use Swagger because it eliminates manual curl requests, reduces onboarding time, generates client SDKs automatically, and ensures APIs follow global standards.
Why Debian 13 “Trixie”?
Debian 13, codenamed Trixie, was officially released on August 9, 2025 and is the current stable version of Debian. It ships with the Linux kernel 6.12 LTS, which brings enhanced hardware support, improved security features, and better driver compatibility. For server environments, Trixie also introduces APT 3.0 with the Solver3 dependency resolver, making package installations smoother and conflict-free.
Notable package versions included in Debian 13 that matter to this guide include Node.js, npm, Python 3.13, and systemd 257 — all of which are either used directly or support the tools installed here. If you are running a fresh Debian 13 server and want to set up a modern API documentation stack, you are in the right place.
Prerequisites Before You Begin
Getting the prerequisites right saves you from cryptic errors mid-installation. Make sure you have the following before proceeding:
- A machine running Debian 13 “Trixie” (server or desktop)
- A user account with sudo privileges or direct root access
- An active internet connection for downloading packages and repository keys
- Basic familiarity with the Linux command line
- curl, gnupg, and git available (installable via
aptif missing) - At least 512 MB RAM for a headless server setup (1 GB or more recommended)
- Optional: a pre-existing OpenAPI spec file in JSON or YAML format to test against after installation
Step 1 — Update Your Debian 13 System
Always start any new installation by updating your package list and upgrading existing packages. This prevents dependency conflicts and ensures you are pulling from the latest repository mirrors.
sudo apt update && sudo apt upgrade -y
Once complete, if a new kernel was installed, reboot the system:
sudo reboot
After rebooting, confirm your Debian version:
cat /etc/os-release
You should see VERSION="13 (trixie)" in the output. With a clean, up-to-date base, proceed to the next step.
Step 2 — Install Node.js and npm on Debian 13
Swagger UI and Swagger Editor rely on Node.js and npm to install dependencies and run development servers. Debian 13’s default repository includes Node.js, but the NodeSource repository provides a newer, more stable LTS version.
Method A — Install from Debian’s Default Repository
This is the quickest method and works fine for most use cases:
sudo apt install nodejs npm -y
Verify the installation:
node -v
npm -v
This installs Node.js v20.x from Debian 13’s official repository.
Method B — Install Latest LTS via NodeSource (Recommended)
For the most current stable release, use the NodeSource setup script. This installs Node.js 22.x LTS, which is more feature-complete and longer-supported:
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo bash -
sudo apt install nodejs -y
npm is bundled with Node.js 22, so no separate install is needed. Confirm everything is working:
node -v # Should show v22.x
npm -v # Should show 10.x or newer
Use Method B if you are planning to use Swagger as part of a larger Node.js application or if you need swagger-ui-express integration later.
Step 3 — Install Swagger UI on Debian 13
Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically render API documentation from an OpenAPI-compliant spec file. There are two main approaches: cloning the source repository and building it, or installing the pre-built swagger-ui-dist npm package.
Option A — Clone the GitHub Repository and Build
First, install Git if it is not already present:
sudo apt install git -y
Clone the official Swagger UI repository from GitHub:
git clone https://github.com/swagger-api/swagger-ui.git
cd swagger-ui
Install all Node.js dependencies:
npm install
This downloads all packages listed in package.json. You may see some deprecation warnings during this step — those are safe to ignore for most setups.
Start the development server to verify the installation works:
npm run dev
Wait a few seconds, then open your browser and navigate to:
http://localhost:3200/
You should see the Swagger UI interface loaded with the default Petstore API demo. That confirms the installation is working.
Option B — Build and Serve Static Files
For a production-ready deployment, build the static distribution:
npm run build
This generates a /dist folder inside the swagger-ui directory. The /dist folder contains all the HTML, CSS, and JavaScript needed to run Swagger UI on any web server without requiring Node.js at runtime.
For quick local testing, serve the /dist folder using Python’s built-in HTTP server:
cd dist
python3 -m http.server 8080
Access it at http://localhost:8080. Once confirmed, you can copy the /dist contents to your web server root.
Option C — Install via npm Package
If you want to embed Swagger UI in an existing Node.js project, install the dist package directly:
npm install swagger-ui-dist
Then serve the static assets from your app using the getAbsoluteFSPath helper:
const swaggerUiAssetPath = require("swagger-ui-dist").getAbsoluteFSPath();
// Pass swaggerUiAssetPath to your static file server
Step 4 — Install Swagger Editor Locally
Swagger Editor is the companion tool for writing and validating OpenAPI specifications. It is a web application that requires an HTTP server to run — it does not come as a standalone executable.
Install http-server globally to serve it:
npm install -g http-server
Clone the Swagger Editor repository:
git clone https://github.com/swagger-api/swagger-editor.git
cd swagger-editor
npm install
Start the editor:
http-server -p 8080 .
Open http://localhost:8080 in your browser. You should see the Swagger Editor with a blank YAML canvas ready for input.
Tip: If port 8080 is already in use by another process, switch to a different port: http-server -p 9090 .
Alternatively, if you only need the editor occasionally and do not want to host it locally, the hosted version at editor.swagger.io is always available for free.
Step 5 — Install go-swagger on Debian 13 (Optional)
If you are building APIs in Go (Golang), go-swagger is the Swagger 2.0 implementation you need. It installs cleanly as a native Debian package.
First, install the required prerequisite packages:
sudo apt update
sudo apt install -y apt-transport-https gnupg curl \
debian-keyring debian-archive-keyring
Register the go-swagger GPG signing key:
curl -1sLf 'https://dl.cloudsmith.io/public/go-swagger/go-swagger/gpg.2F8CB673971B5C9E.key' \
| sudo gpg --dearmor -o \
/usr/share/keyrings/go-swagger-go-swagger-archive-keyring.gpg
Add the repository source list:
curl -1sLf \
'https://dl.cloudsmith.io/public/go-swagger/go-swagger/config.deb.txt?distro=debian&codename=any-version' \
| sudo tee /etc/apt/sources.list.d/go-swagger-go-swagger.list
Install swagger:
sudo apt update
sudo apt install swagger
Verify the installation:
swagger version
The binary is placed in /usr/bin, so it is available globally on your system path. You can now generate server stubs, validate specs, and scaffold Go API projects directly from the command line.
Step 6 — Serve Swagger UI with Nginx
Running Swagger UI on localhost is fine for development, but for a team environment or a staging server, you want it available via a web server. Nginx is the go-to choice for serving Swagger UI as a static site or as a reverse proxy.
Install Nginx
sudo apt install nginx -y
sudo systemctl enable --now nginx
Verify Nginx is running:
sudo systemctl status nginx
Deploy the Swagger UI /dist Files
Copy the previously built /dist folder to your Nginx web root:
sudo mkdir -p /var/www/html/swagger
sudo cp -r ~/swagger-ui/dist/* /var/www/html/swagger/
Configure Nginx to Serve Swagger UI
Create a new Nginx server block configuration file:
sudo nano /etc/nginx/sites-available/swagger
Add the following configuration:
server {
listen 80;
server_name your-domain.com;
location /swagger/ {
root /var/www/html;
index index.html;
try_files $uri $uri/ =404;
}
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
Enable the configuration and test for syntax errors:
sudo ln -s /etc/nginx/sites-available/swagger /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
Navigate to http://your-domain.com/swagger/ in a browser. Swagger UI should load immediately.
Point Swagger UI to Your OpenAPI Spec
By default, Swagger UI loads the public Petstore demo spec. To load your own API documentation, open the initializer file:
sudo nano /var/www/html/swagger/swagger-initializer.js
Replace the default URL with your OpenAPI spec path:
SwaggerUIBundle({
url: "https://your-domain.com/api/openapi.json",
dom_id: '#swagger-ui',
presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset],
layout: "StandaloneLayout"
})
Save the file and reload the page. Your own API endpoints will now appear in the Swagger UI interface.
Alternative: Install Swagger UI Using Docker
Docker is the fastest way to get a fully working Swagger UI instance running with zero build steps. This method is ideal for containerized environments or when you want a clean, isolated deployment.
Install Docker on Debian 13:
sudo apt install docker.io -y
sudo systemctl enable --now docker
Pull and run the official Swagger UI Docker image:
docker pull swaggerapi/swagger-ui
docker run -p 80:8080 swaggerapi/swagger-ui
This starts Nginx inside the container with Swagger UI accessible on port 80. Open http://localhost in your browser to confirm.
To load a custom OpenAPI spec from your host machine:
docker run -p 80:8080 \
-e SWAGGER_JSON=/foo/swagger.json \
-v /path/to/your/swagger.json:/foo/swagger.json \
swaggerapi/swagger-ui
To serve Swagger UI under a specific URL path (e.g., /swagger):
docker run -p 80:8080 \
-e BASE_URL=/swagger \
-e SWAGGER_JSON=/foo/swagger.json \
-v /bar:/foo swaggerapi/swagger-ui
Step 7 — Verify the Installation
Once Swagger UI is live through any of the methods above, open a browser and navigate to the appropriate URL — http://localhost:3200, http://localhost:8080, or http://your-domain.com/swagger/ depending on your setup.
Check each of the following to confirm everything is working correctly:
- The Swagger UI interface loads fully without blank pages or errors
- The default Petstore API (or your custom spec) renders with endpoint sections visible
- The “Try it out” button is clickable for each endpoint
- The “Execute” button sends a request and returns a response with a status code
If the page loads but assets look broken, verify that mime.types is properly configured in your Nginx installation. If the UI is completely blank, check the browser console (F12) for JavaScript errors — this often points to an incorrect file path or a missing swagger-initializer.js. Allow port 80 through the firewall if needed:
sudo ufw allow 80
sudo ufw allow 443
Troubleshooting Common Swagger Installation Issues
Even with a clean setup, a few errors show up regularly. Here is how to handle the most common ones:
| Error | Likely Cause | Fix |
|---|---|---|
webpack: not found during build |
webpack not globally installed | Run npm install webpack -g before building |
npm: command not found |
Node.js not properly installed | Reinstall Node.js via NodeSource method |
| Swagger UI loads white/blank | JS/CSS assets not found or blocked | Check Nginx mime.types, verify /dist was copied correctly |
| Port 8080 already in use | Another service is occupying the port | Use http-server -p 9090 . to change port |
| GPG key error during go-swagger install | Outdated or missing key | Re-run the curl GPG key import command |
not signed repository error |
Cloudsmith key not dearmored properly | Follow the full key registration steps in Step 5 |
| CORS error in Nginx + Swagger | Missing CORS headers in proxy config | Add add_header 'Access-Control-Allow-Origin' '*'; to Nginx block |
For persistent Nginx proxy issues, always use proxy_http_version 1.1 and include the Host, X-Forwarded-For, and X-Forwarded-Proto headers in your server block. These settings are essential when Swagger UI sits behind a reverse proxy.
Congratulations! You have successfully installed Swagger. Thanks for using this tutorial for installing Swagger on Debian 13 “Trixie” Linux system. For additional help or useful information, we recommend you check the official Swagger website.