Swagger Implementation Details
This page explains how Swagger/OpenAPI is wired in the HANA CLI web server and how route documentation is discovered.
Implementation Overview
Swagger is configured in routes/swagger.js and mounted when the web server starts via base.webServerSetup().
Key behavior:
- Builds an OpenAPI 3.0 definition (
swagger-jsdoc) - Reads API annotations from route files (
routes/*.js) - Serves interactive docs at
/api-docs - Serves raw JSON spec at
/api-docs.json - Applies UI options (filtering, request duration, syntax highlighting)
Source of Truth
The API specification is generated from @swagger JSDoc annotations embedded in route handlers, including:
routes/index.jsroutes/hanaList.jsroutes/hanaInspect.jsroutes/docs.jsroutes/excel.jsroutes/dfa.jsroutes/static.jsroutes/webSocket.jsroutes/swagger.js(for/api-docs.json)
Runtime Entry Points
To start the web server and access Swagger:
hana-cli UIAliases:
hana-cli ui
hana-cli serverSwagger URLs:
OpenAPI Metadata
Swagger metadata is configured in routes/swagger.js and includes:
- OpenAPI version:
3.0.0 - API title/description/license/contact from i18n bundle keys
- API version read from
package.json - Server entries for
http://localhost:3010and variable port form
Notes on Tagging
The Swagger setup defines core tags (Configuration, HANA System, HANA Objects, HANA Inspect, HDI, Cloud Services, Documentation, Export, Digital First Adoption, WebSockets).
Some route annotations also use additional tag names (for example BTP System, HANA Procedures), which may appear in the rendered documentation.
Adding or Updating Endpoint Docs
When adding an endpoint:
- Add or update the route handler in
routes/*.js - Add
@swaggerJSDoc above the handler - Include method, path, tags, summary, parameters (if any), and responses
- Restart the server and verify
/api-docsand/api-docs.json
Troubleshooting
If Swagger is unavailable:
- Confirm the server is running on the expected host/port
- Check for route/JSDoc syntax errors in
routes/*.js - Verify Swagger dependencies are installed
- Open
/api-docs.jsonfirst to isolate UI-only issues