Documentation Index
Fetch the complete documentation index at: https://docs.mellob.in/llms.txt
Use this file to discover all available pages before exploring further.
π§Ύ apigen β API Documentation Generator
The karma/apigen package helps you auto-generate OpenAPI-style REST documentation directly from Go structs. It supports dynamic path params, field overrides, global variables, reusable request/response bodies, and inline headers.
Itβs ideal for documenting internal or external APIs with zero OpenAPI spec learning curve.
π Quick Start
π¦ Installation
β Create a New API Definition
π Add Global Variables
These are available as$variables in your documentation templates:
π Request and Response Bodies
π§± Generate Request Body from Struct
Use
FieldOverride to provide examples, override descriptions, or exclude specific fields.Example override:
π¦ Generate Response from Struct
π§© Define Endpoints
UseAddEndpoint to declare a REST endpoint with method, path, headers, params, and expected responses.
Example β POST /projects/{project_id}/issues
π Authentication Example: Auth APIs
Example β POST /auth/login
π Export Documentation
./docs/gitlab_issues.md or .html depending on config).
π§ Tips
PathParamscan be defined explicitly or inferred from{}in path strings.- Headers are centralized via
KarmaHeadersconstants. - Use
FieldOverride.Excludeto hide internal struct fields (e.g.,TableName,Id,CreatedAt). - Combine multiple
APIDefinitionblocks for different modules (e.g. Auth, Admin, Public APIs).
π¦ Constants Reference
apigen.ContentTypeJSON:"application/json"apigen.HeaderAccept:"Accept"apigen.HeaderContentType:"Content-Type"apigen.HeaderPrivateToken:"PRIVATE-TOKEN"
π§ͺ Real Example Output
The example generates documentation for:GET /projects/{project_id}/issuesPOST /projects/{project_id}/issuesGET /projects/{project_id}/issues/{issue_id}POST /auth/loginPOST /auth/verify_otpPOST /auth/register