sampleapi

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() huma.API

New builds a fully-wired huma.API and returns it, so callers can extract its contract without knowing huma's setup details.

Types

type GetUserInput

type GetUserInput struct {
	ID string `path:"id" doc:"ID of the user to fetch"` // doc -> description (the prose aspect)
}

GetUserInput declares what the request accepts. path:"id" -> a required path parameter in OpenAPI.

type GetUserOutput

type GetUserOutput struct {
	Body User
}

GetUserOutput: the type in the Body field becomes the 200 response schema. huma convention: the top-level Body field is the response body.

type User

type User struct {
	UserID string `json:"userId"`               // exposed as "userId"; renaming changes the contract
	Email  string `json:"email" format:"email"` // format:"email" is emitted as a schema constraint
}

User becomes components/schemas/User in the emitted spec. The struct tags here ARE the contract — drift is detected against them.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL