Versions in this module Expand all Collapse all v0 v0.1.6 Nov 26, 2024 Changes in this version + const DefaultServiceVersion + const RouteTypeDefault + const RouteTypeWebsocket + var ErrMissingGoMod = fmt.Errorf("unable to find 'go.mod' for project") + var ErrMultiplePackages = fmt.Errorf("multiple packages defined in input path; should be one") + var ErrMultipleServices = fmt.Errorf("do not define multiple services in a single file") + var ErrNoServices = fmt.Errorf("file does not contain any service interfaces") + var ErrTypeNotContext = fmt.Errorf("not the type 'context.Context'") + var ErrTypeNotError = fmt.Errorf("not the type 'error'") + var ErrTypeNotStructPointer = fmt.Errorf("not a pointer to a struct type") + var ErrTypeNotTwoParams = fmt.Errorf("must have two params") + var ErrTypeNotTwoReturns = fmt.Errorf("must have two return values") + var InvalidType = types.Typ[0] + func ApplyFunctionDocumentation(ctx *Context, function *ServiceFunctionDeclaration) + func FindGoDotMod(dirName string) (string, error) + func ParseDocumentation(ctx *Context) (Documentation, Tags, error) + func ParsePackageInfo(ctx *Context) (input *PackageDeclaration, output *PackageDeclaration, err error) + type Context struct + AbsolutePath string + Documentation Documentation + File *ast.File + FileSet *token.FileSet + InputPackage *PackageDeclaration + Module *ModuleDeclaration + OutputPackage *PackageDeclaration + Path string + RawTypes *packages.Package + Service *ServiceDeclaration + Tags Tags + Timestamp time.Time + Types TypeRegistry + func ParseFile(inputPath string) (*Context, error) + func (ctx Context) Scope() *types.Scope + func (ctx Context) TimestampString() string + type Documentation map[string]string + func (docs Documentation) ForField(f *FieldDeclaration) DocumentationLines + func (docs Documentation) ForFunction(f *ServiceFunctionDeclaration) DocumentationLines + func (docs Documentation) ForService(s *ServiceDeclaration) DocumentationLines + func (docs Documentation) ForType(t *TypeDeclaration) DocumentationLines + func (docs Documentation) Set(segmentsAndDoc ...string) + type DocumentationLines []string + func (docs DocumentationLines) Empty() bool + func (docs DocumentationLines) NotEmpty() bool + func (docs DocumentationLines) String() string + func (docs DocumentationLines) Trim() DocumentationLines + type FieldBindingOptions struct + Name string + Omit bool + func ParseBindingOptions(ctx *Context, field *FieldDeclaration, fieldVar *types.Var) *FieldBindingOptions + func (opts FieldBindingOptions) NotOmit() bool + type FieldDeclaration struct + Binding *FieldBindingOptions + Documentation DocumentationLines + Name string + ParentType *TypeDeclaration + Pointer bool + Type *TypeDeclaration + func ApplyFieldDocumentation(ctx *Context, field *FieldDeclaration) *FieldDeclaration + type FieldDeclarations []*FieldDeclaration + func (fields FieldDeclarations) ByBindingName(name string) *FieldDeclaration + func (fields FieldDeclarations) ByName(name string) *FieldDeclaration + func (fields FieldDeclarations) Empty() bool + func (fields FieldDeclarations) NotEmpty() bool + func (fields FieldDeclarations) TransportFields() FieldDeclarations + type GatewayParameter struct + Field *FieldDeclaration + Name string + type GatewayParameters []*GatewayParameter + func (params GatewayParameters) ByName(name string) *GatewayParameter + func (params GatewayParameters) Empty() bool + func (params GatewayParameters) NotEmpty() bool + type GatewayRoute struct + Function *ServiceFunctionDeclaration + GatewayType string + Group string + Method string + Path string + RouteType RouteType + Status int + func (route *GatewayRoute) MethodMatches(these ...string) bool + func (route *GatewayRoute) ParsePathParams() []string + func (route *GatewayRoute) PathParameters() GatewayParameters + func (route *GatewayRoute) QualifiedPath() string + func (route *GatewayRoute) QueryParameters() GatewayParameters + func (route *GatewayRoute) SupportsRequestBody() bool + type GatewayRoutes []*GatewayRoute + func (routes GatewayRoutes) API() *GatewayRoute + func (routes GatewayRoutes) Events() GatewayRoutes + func (routes GatewayRoutes) Get(gatewayType string) *GatewayRoute + type GatewayServiceOptions struct + PathPrefix string + Service *ServiceDeclaration + type ModuleDeclaration struct + Directory string + Name string + func ParseModuleInfo(ctx *Context) (*ModuleDeclaration, error) + func (module ModuleDeclaration) GoMod() string + type PackageDeclaration struct + Directory string + Import string + Name string + type RouteType string + func (t RouteType) Default() bool + func (t RouteType) Websocket() bool + type ServiceDeclaration struct + Documentation DocumentationLines + Functions ServiceFunctionDeclarations + Gateway *GatewayServiceOptions + Name string + Version string + func ApplyServiceDocumentation(ctx *Context, service *ServiceDeclaration) *ServiceDeclaration + func ParseService(ctx *Context) (*ServiceDeclaration, error) + func (service ServiceDeclaration) FunctionByName(name string) *ServiceFunctionDeclaration + func (service ServiceDeclaration) ShortName() string + func (service ServiceDeclaration) UnexportedName() string + type ServiceFunctionDeclaration struct + Documentation DocumentationLines + Name string + Request *TypeDeclaration + Response *TypeDeclaration + Roles []string + Routes GatewayRoutes + Service *ServiceDeclaration + func ParseServiceFunction(ctx *Context, service *ServiceDeclaration, funcType *types.Func) (*ServiceFunctionDeclaration, error) + func ParseServiceFunctions(ctx *Context, service *ServiceDeclaration, interfaceType *types.Interface) ([]*ServiceFunctionDeclaration, error) + func (f ServiceFunctionDeclaration) String() string + type ServiceFunctionDeclarations []*ServiceFunctionDeclaration + type Tags map[string]string + func (tags Tags) ForField(f *FieldDeclaration) reflect.StructTag + func (tags Tags) Set(model string, field string, tag *ast.BasicLit) + type TypeDeclaration struct + Basic bool + Documentation DocumentationLines + Elem *TypeDeclaration + Fields FieldDeclarations + Implements struct{ ... } + Key *TypeDeclaration + Kind reflect.Kind + Name string + Type types.Type + func ApplyTypeDocumentation(ctx *Context, t *TypeDeclaration) *TypeDeclaration + func (t TypeDeclaration) MapLike() bool + func (t TypeDeclaration) NonOmittedFields() FieldDeclarations + func (t TypeDeclaration) ObjectLike() bool + func (t TypeDeclaration) PrimitiveLike() bool + func (t TypeDeclaration) SliceLike() bool + func (t TypeDeclaration) String() string + type TypeRegistry map[string]*TypeDeclaration + func NewTypeRegistry() TypeRegistry + func ParseTypes(ctx *Context) (*packages.Package, TypeRegistry, error) + func (reg TypeRegistry) Lookup(t types.Type) (*TypeDeclaration, bool) + func (reg TypeRegistry) LookupByName(name string) (*TypeDeclaration, bool) + func (reg TypeRegistry) NonBasicTypes() []*TypeDeclaration + func (reg TypeRegistry) Register(entry *TypeDeclaration) *TypeDeclaration + func (reg TypeRegistry) WithoutInvalid() TypeRegistry