Help us improve
Share bugs, ideas, or general feedback.
From gopilot
You are adding HTTP handlers for a domain. Handlers use the Huma framework which auto-generates OpenAPI from Go struct tags.
npx claudepluginhub bishwas-py/gopilot --plugin gopilotHow this skill is triggered — by the user, by Claude, or both
Slash command
/gopilot:apiThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
You are adding HTTP handlers for a domain. Handlers use the Huma framework which auto-generates OpenAPI from Go struct tags.
Generates RESTful API endpoints with routes, request validation, error handling, and CRUD operations. Supports FastAPI, Flask, Django, Express, NestJS, Hono; auto-detects stack or recommends one.
Generates REST APIs with CRUD endpoints, pagination, filtering, auth, tests for Express, FastAPI, Spring Boot, Gin from OpenAPI specs or schemas.
Generates production-ready REST API endpoints with validation, error handling, authentication, and best practices for security and scalability.
Share bugs, ideas, or general feedback.
You are adding HTTP handlers for a domain. Handlers use the Huma framework which auto-generates OpenAPI from Go struct tags.
skills/_shared/go-patterns.md for Huma conventionsbackend/internal/domain/[name]/[name].gobackend/internal/domain/[name]/service.gobackend/internal/api/router.go to see registration patternParse $ARGUMENTS as: [domain-name] [operation]
item, booking)list, get, create, update, delete, or a custom action nameCreate or update backend/internal/api/[name]_handlers.go:
Every endpoint needs input and output structs with Huma tags:
// List
type List[Name]sInput struct {
Page int `query:"page" default:"1" minimum:"1" doc:"Page number"`
PerPage int `query:"per_page" default:"20" minimum:"1" maximum:"100" doc:"Items per page"`
Search string `query:"search,omitempty" doc:"Search query"`
}
type List[Name]sOutput struct {
Body struct {
Items []domain.[Name] `json:"items" doc:"List of [name]s"`
Total int `json:"total" doc:"Total count"`
Page int `json:"page" doc:"Current page"`
}
}
// Get by ID
type Get[Name]Input struct {
ID string `path:"id" doc:"[Name] ID"`
}
type Get[Name]Output struct {
Body domain.[Name]
}
// Create
type Create[Name]Input struct {
Body struct {
// Fields with validation tags
Title string `json:"title" minLength:"3" maxLength:"200" doc:"Title"`
Description string `json:"description,omitempty" maxLength:"2000" doc:"Description"`
}
}
type Create[Name]Output struct {
Body domain.[Name]
}
// Update
type Update[Name]Input struct {
ID string `path:"id" doc:"[Name] ID"`
Body struct {
Title *string `json:"title,omitempty" minLength:"3" maxLength:"200" doc:"Title"`
Description *string `json:"description,omitempty" maxLength:"2000" doc:"Description"`
}
}
// Delete
type Delete[Name]Input struct {
ID string `path:"id" doc:"[Name] ID"`
}
func register[Name]Handlers(api huma.API, svc *domain.Service) {
huma.Register(api, huma.Operation{
OperationID: "list-[name]s",
Method: http.MethodGet,
Path: "/api/v1/[name]s",
Summary: "List [name]s",
Tags: []string{"[Name]s"},
}, func(ctx context.Context, input *List[Name]sInput) (*List[Name]sOutput, error) {
items, total, err := svc.List(ctx, input.Page, input.PerPage, input.Search)
if err != nil {
return nil, huma.Error500InternalServerError("failed to list [name]s")
}
return &List[Name]sOutput{Body: struct{ ... }{Items: items, Total: total, Page: input.Page}}, nil
})
// ... register get, create, update, delete similarly
}
| Tag | Purpose | Example |
|---|---|---|
doc: | OpenAPI description | doc:"User email address" |
format: | Format validation | format:"email" |
minLength: | Min string length | minLength:"3" |
maxLength: | Max string length | maxLength:"200" |
minimum: | Min number value | minimum:"0" |
maximum: | Max number value | maximum:"1000" |
pattern: | Regex validation | pattern:"^[a-z]+$" |
enum: | Allowed values | enum:"draft,published,archived" |
default: | Default value | default:"1" |
Add to backend/internal/api/router.go:
register[Name]Handlers(api, [name]Svc)
go vet ./...go build ./...http://localhost:8080/openapi.json includes the new endpoints/gopilot:sdk to generate the frontend SDK."GET /api/v1/[name]s → List (paginated)GET /api/v1/[name]s/{id} → Get onePOST /api/v1/[name]s → CreatePUT /api/v1/[name]s/{id} → Full updatePATCH /api/v1/[name]s/{id} → Partial updateDELETE /api/v1/[name]s/{id} → DeletePOST /api/v1/[name]s/{id}/[action] → Custom actionany or interface{} in input/output — always typed structs