Documentation
¶
Index ¶
- func ExtractContract(route extractor.RawRoute, fn ast.Node, info *types.Info, ...) (model.RequestDef, []model.ResponseDef, []string)
- func ExtractHeaders(body *ast.BlockStmt, info *types.Info, paramNames resolver.HandlerParamNames) []model.ParamDef
- func ExtractPathParams(pattern string, fnBody *ast.BlockStmt, info *types.Info, ...) []model.ParamDef
- func ExtractQueryParams(body *ast.BlockStmt, info *types.Info, paramNames resolver.HandlerParamNames) []model.ParamDef
- func ExtractResponses(body *ast.BlockStmt, info *types.Info, paramNames resolver.HandlerParamNames, ...) ([]model.ResponseDef, []string)
- func ResolveStatusCode(expr ast.Expr, info *types.Info) int
- type BodyResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractContract ¶
func ExtractContract( route extractor.RawRoute, fn ast.Node, info *types.Info, paramNames resolver.HandlerParamNames, pkgs []*packages.Package, ) (model.RequestDef, []model.ResponseDef, []string)
ExtractContract is the top-level orchestrator that calls all sub-extractors in order and assembles the complete request and response contract for a single endpoint.
fn should be either *ast.FuncDecl or *ast.FuncLit.
func ExtractHeaders ¶
func ExtractHeaders(body *ast.BlockStmt, info *types.Info, paramNames resolver.HandlerParamNames) []model.ParamDef
ExtractHeaders walks a handler function body and detects header access patterns for both net/http and gin.
func ExtractPathParams ¶
func ExtractPathParams(pattern string, fnBody *ast.BlockStmt, info *types.Info, paramNames resolver.HandlerParamNames) []model.ParamDef
ExtractPathParams parses {param} segments from a route pattern and produces an initial ParamDef list. If fnBody and info are provided, the handler body is scanned for type upgrade evidence (strconv.Atoi → integer, uuid.Parse → uuid).
func ExtractQueryParams ¶
func ExtractQueryParams(body *ast.BlockStmt, info *types.Info, paramNames resolver.HandlerParamNames) []model.ParamDef
ExtractQueryParams walks a handler function body and detects query parameter access patterns for both net/http and gin.
func ExtractResponses ¶
func ExtractResponses(body *ast.BlockStmt, info *types.Info, paramNames resolver.HandlerParamNames, pkgs []*packages.Package) ([]model.ResponseDef, []string)
ExtractResponses walks a handler function body and extracts all response definitions. For gin handlers, responses are co-located (easy). For net/http handlers, branch-aware pairing is used.
Types ¶
type BodyResult ¶
type BodyResult struct {
BodyType types.Type // The resolved type of the request body struct (nil if none)
ContentType string // "application/json", "multipart/form-data", or combo
IsMultipart bool
FileParams []model.ParamDef // File params from FormFile calls
BindQueryType types.Type // Struct type from ShouldBindQuery — promotes fields to QueryParams
BindHeaderType types.Type // Struct type from ShouldBindHeader — promotes fields to Headers
Unresolved []string // Anything that couldn't be determined
}
BodyResult holds the outcome of request body extraction.
func ExtractBody ¶
func ExtractBody(body *ast.BlockStmt, info *types.Info, paramNames resolver.HandlerParamNames) BodyResult
ExtractBody walks a handler function body and detects request body patterns for both net/http (json.NewDecoder/Unmarshal) and gin (ShouldBindJSON, etc.).