Public Swagger UI
Production: https://leaflock.app/swagger
Local: http://localhost:8080/swagger
Browse and test API endpoints directly in your browser with the Swagger UI interface.
LeafLock provides comprehensive OpenAPI 3.0 (Swagger) documentation for all REST API endpoints. This documentation is interactive, automatically generated from code annotations, and includes request/response examples.
Public Swagger UI
Production: https://leaflock.app/swagger
Local: http://localhost:8080/swagger
Browse and test API endpoints directly in your browser with the Swagger UI interface.
API Documentation
Production: https://leaflock.app/api/v1/docs
Local: http://localhost:8080/api/v1/docs
Alternative Swagger UI path under the /api/v1 prefix.
OpenAPI JSON (Public)
Production: https://leaflock.app/swagger/openapi.json
Local: http://localhost:8080/swagger/openapi.json
Machine-readable OpenAPI 3.0 specification for API clients and code generation tools.
OpenAPI JSON (API)
Production: https://leaflock.app/api/v1/docs/openapi.json
Local: http://localhost:8080/api/v1/docs/openapi.json
Alternative OpenAPI spec path under the /api/v1 prefix.
Primary URL: https://leaflock.app/swagger ✨
Test API endpoints directly from the Swagger UI:
Authenticate your Swagger UI session:
Bearer YOUR_JWT_TOKENView detailed schemas for:
Each endpoint includes:
Tag: Authentication
POST /auth/register - Register new userPOST /auth/login - Authenticate userPOST /auth/logout - End sessionPOST /auth/refresh - Refresh JWT tokenGET /auth/mfa/status - Check MFA statusPOST /auth/mfa/setup - Setup MFAPOST /auth/mfa/verify - Verify MFA codePOST /auth/mfa/disable - Disable MFATag: Notes
GET /notes - List all notesPOST /notes - Create noteGET /notes/{id} - Get notePUT /notes/{id} - Update noteDELETE /notes/{id} - Delete noteGET /notes/shared - List shared notesGET /notes/trash - List trashed notesPOST /notes/{id}/restore - Restore noteTag: Collaboration
POST /notes/{id}/share - Share noteDELETE /notes/{id}/share/{user_id} - UnshareGET /notes/{id}/shares - List sharesPUT /notes/{id}/share/{user_id} - Update permissionsTags: Tags, Folders
GET /tags - List tagsPOST /tags - Create tagDELETE /tags/{id} - Delete tagGET /folders - List foldersPOST /folders - Create folderDELETE /folders/{id} - Delete folderTag: Admin
GET /admin/users - List usersGET /admin/users/{id} - Get user detailsPUT /admin/users/{id}/admin - Grant/revoke adminPOST /admin/users/{id}/roles - Assign roleDELETE /admin/users/{id}/roles/{role} - Remove roleGET /admin/registration - Get registration statusPUT /admin/registration - Enable/disable registrationThe OpenAPI specification is available in multiple formats:
/api/v1/docs/openapi.jsonSize: ~13KB Use: API clients, code generators, validation tools
/api/v1/docs/swagger.yamlSize: ~5.7KB Use: Human-readable format, easier to diff
/api/v1/docs/swagger.jsonSize: ~11.6KB Use: Tools that require Swagger 2.0 instead of OpenAPI 3.0
Generate API clients from the OpenAPI spec:
# Using openapi-generator-clinpx @openapitools/openapi-generator-cli generate \ -i http://localhost:8080/api/v1/docs/openapi.json \ -g typescript-fetch \ -o ./generated-client# Using openapi-generatoropenapi-generator-cli generate \ -i http://localhost:8080/api/v1/docs/openapi.json \ -g python \ -o ./python-client# Using oapi-codegenoapi-codegen \ -package api \ http://localhost:8080/api/v1/docs/openapi.json \ > client.goLeafLock uses swaggo/swag to generate Swagger documentation from code annotations:
// @Summary Register a new user// @Description Register a new user with email and password// @Tags Authentication// @Accept json// @Produce json// @Param request body RegisterRequest true "Registration data"// @Success 201 {object} RegisterResponse "User registered successfully"// @Failure 400 {object} ErrorResponse "Invalid request"// @Failure 409 {object} ErrorResponse "Email already exists"// @Router /auth/register [post]func (h *AuthHandler) Register(c *fiber.Ctx) error { // Implementation}The Swagger UI is served at /api/v1/docs via embedded HTML:
func swaggerUIHandler(c *fiber.Ctx) error { const tpl = `<!doctype html> <html> <head> <title>LeafLock API Docs</title> <link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@5/swagger-ui.css" /> </head> <body> <div id="swagger-ui"></div> <script src="https://unpkg.com/swagger-ui-dist@5/swagger-ui-bundle.js"></script> <script> SwaggerUIBundle({ url: '/api/v1/docs/openapi.json', dom_id: '#swagger-ui', }); </script> </body> </html>` // ...}To regenerate Swagger docs after adding/modifying endpoints:
cd backendswag init --parseDependency --parseInternal --output ./docs/swaggerThis scans all @ annotations in Go files and generates:
docs.go - Embedded docs for the Go binaryswagger.json - Swagger 2.0 formatswagger.yaml - YAML formatThe API uses JWT Bearer authentication:
securityDefinitions: BearerAuth: type: apiKey name: Authorization in: header description: 'Type "Bearer" followed by a space and JWT token.'POST /auth/loginBearer eyJhbGciOiJIUzI1...All subsequent requests will include the Authorization header automatically.
| Code | Meaning | When It Occurs |
|---|---|---|
| 200 | OK | Successful GET/PUT request |
| 201 | Created | Successful POST (resource created) |
| 204 | No Content | Successful DELETE |
| 400 | Bad Request | Invalid request body or parameters |
| 401 | Unauthorized | Missing or invalid JWT token |
| 403 | Forbidden | Valid token but insufficient permissions |
| 404 | Not Found | Resource doesn’t exist |
| 409 | Conflict | Duplicate resource (e.g., email already registered) |
| 500 | Internal Server Error | Server-side error |
# Get OpenAPI speccurl http://localhost:8080/api/v1/docs/openapi.json
# Test endpoint with JWTcurl -H "Authorization: Bearer YOUR_TOKEN" \ http://localhost:8080/api/v1/notesValidate the OpenAPI spec:
# Using swagger-clinpx swagger-cli validate http://localhost:8080/api/v1/docs/openapi.json
# Using openapi-generator-clinpx @openapitools/openapi-generator-cli validate \ -i http://localhost:8080/api/v1/docs/openapi.json/api/v1/docs in your browser