models

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoint

type Endpoint struct {
	Method string
	Path   string
}

Endpoint is a description of a function HTTP endpoint.

func (Endpoint) HandlerPath

func (e Endpoint) HandlerPath() string

HandlerPath returns the endpoint's method and path as a string.

type Field

type Field struct {
	Name     string
	TypeExpr string
}

Field is a named field of a specific type.

func (Field) IsError

func (f Field) IsError() bool

IsError checks if the field is an error.

func (Field) JSONTag

func (f Field) JSONTag() string

JSONTag returns the field's JSON tag.

func (Field) NameCapitalized

func (f Field) NameCapitalized() string

NameCapitalized returns the field's name with the first letter uppercased.

type Function

type Function struct {
	Name     string
	Params   Params
	Results  Results
	Endpoint Endpoint
}

Function is the comlete infomation about a function and a corresponding HTTP endpoint.

func (Function) HandlerName

func (f Function) HandlerName() string

HandlerName returns the function's endpoint handler name.

type Functions

type Functions []Function

Functions is a list of Function.

func (Functions) Map

func (fs Functions) Map() map[string]Function

Map returns a map of Function by their names.

type Import

type Import struct {
	Path  string
	Alias string
}

Import is a description of a single Golang import.

func (Import) Render

func (i Import) Render() string

Render returns the import's source code form as a string.

type Param

type Param struct {
	Field

	Type   ParamType
	Origin ParamOrigin
}

Param is a param of a function.

func (Param) NameOrigin

func (p Param) NameOrigin() string

NameOrigin returns the param's name joined with its origin.

type ParamOrigin

type ParamOrigin string

ParamOrigin is an origin of Param.

const (
	Path  ParamOrigin = "Path"
	Query ParamOrigin = "Query"
	Body  ParamOrigin = "Body"
)

func GetParamOrigin

func GetParamOrigin(originName string) (ParamOrigin, error)

GetParamOrigin parses a param origin from string.

type ParamType

type ParamType string

ParamType is a type of Param.

const (
	Int    ParamType = "int"
	Float  ParamType = "float"
	String ParamType = "string"
	Bool   ParamType = "bool"
	Error  ParamType = "error"
	Any    ParamType = "any"
	Map    ParamType = "map"
	Slice  ParamType = "slice"
	Custom ParamType = "custom"
)

func (ParamType) CustomOf

func (pt ParamType) CustomOf() ParamType

CustomOf returns a new custom type that equals to the current type.

func (ParamType) Is

func (pt ParamType) Is(paramType ParamType) bool

Is checks if the param type equals to another type or is more specific.

func (ParamType) MapOf

func (pt ParamType) MapOf() ParamType

MapOf returns a new map type with values of the current type.

func (ParamType) SliceOf

func (pt ParamType) SliceOf() ParamType

SliceOf returns a new slice type with values of the current type.

type Params

type Params []Param

Params is a list of Param.

func (Params) Map

func (ps Params) Map() map[string]Param

Map returns a map of Param by name.

type Result

type Result struct {
	Field
}

Result is a result of a function.

type Results

type Results []Result

Results is a list of Result.

Jump to

Keyboard shortcuts

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