Swagger
QvaSoft Gateway can aggregate Swagger/OpenAPI documentation from your downstream services and expose them through a unified UI.
How It Works
The gateway uses MMLib.SwaggerForOcelot to pull Swagger definitions from downstream services and present them through a single Swagger UI.
Configuration
Add SwaggerEndPoints to your ocelot.json:
{
"SwaggerEndPoints": [
{
"Key": "users-api",
"TransformByOcelotConfig": true,
"Config": [
{
"Name": "Users API",
"Version": "v1",
"Url": "http://localhost:3000/swagger/v1/swagger.json"
}
]
}
]
}
| Field | Description |
|---|---|
Key | Unique identifier for the Swagger endpoint |
TransformByOcelotConfig | Transform paths to match gateway routes |
Config[].Name | Display name in the Swagger UI dropdown |
Config[].Version | API version |
Config[].Url | URL to the downstream Swagger JSON |
Accessing Swagger UI
Navigate to:
http://localhost:4000/swagger
Managing via Admin Panel
The admin panel provides a visual interface for adding, editing, and removing Swagger endpoints without editing JSON manually.
Multiple APIs
Add multiple entries to expose several services:
{
"SwaggerEndPoints": [
{
"Key": "users-api",
"Config": [
{ "Name": "Users API", "Version": "v1", "Url": "http://users-service/swagger/v1/swagger.json" }
]
},
{
"Key": "orders-api",
"Config": [
{ "Name": "Orders API", "Version": "v1", "Url": "http://orders-service/swagger/v1/swagger.json" }
]
}
]
}
note
If no SwaggerEndPoints are configured (empty array), the Swagger UI is automatically disabled.