swagger

package
v0.0.0-...-0985497 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEndpoints

func GetEndpoints(pkg map[string]*ast.Package, fset *token.FileSet) map[string][]*Endpoint

Main docs

func IdentString

func IdentString(str string, ch int) string

IdentString will preprend some white-space before the string.

func SwaggerResponsesWithSuffix

func SwaggerResponsesWithSuffix(fset *token.FileSet, pkgs map[string]*ast.Package, suffix string, depth int) string

func SwaggerStructs

func SwaggerStructs(structDescr *Struct, depth int) string

func SwaggerStructsWithSuffix

func SwaggerStructsWithSuffix(fset *token.FileSet, pkgs map[string]*ast.Package, suffix string, depth int) string

Types

type Endpoint

type Endpoint struct {
	Node     ast.Node
	Info     *ast.FuncDecl
	Comments *ast.CommentGroup
	Details  EndpointDetails
	Position token.Position
}

func NewEndpoint

func NewEndpoint(node ast.Node) *Endpoint

type EndpointDetails

type EndpointDetails struct {
	URL         string
	Method      string
	URLParams   []*Parameter
	QueryParams []*Parameter
	Request     string
	Tags        []string
	Responses   []*Response
	Description string
	Summary     string
}

type Field

type Field struct {
	Tag    *Tag
	Type   ast.Expr
	Childs []*Struct
	Depth  int
}

Field is a representation of fields in Go structs.

func ParseField

func ParseField(fset *token.FileSet, n ast.Node, field *ast.Field, depth int) (*Field, error)

ParseField will parse a field from a GO struct.

type Parameter

type Parameter struct {
	Name string
	Type string
}

func ParseParameter

func ParseParameter(source string) (*Parameter, error)

type Response

type Response struct {
	Code int
	Text string
}

func ParseResponse

func ParseResponse(source string) (*Response, error)

type Struct

type Struct struct {
	Name        string
	Description string
	Fields      []*Field
	Comments    *ast.CommentGroup
	Tag         *Tag
	Position    token.Position
}

Struct is a representation of Go structs.

func ParseStruct

func ParseStruct(fset *token.FileSet, n ast.Node, structDecl *ast.StructType, name string, depth int) (*Struct, error)

ParseStruct will parse a struct in a GO implementation.

type Tag

type Tag struct {
	Name      string
	Example   string
	Required  bool
	Length    string
	MinLength string
	MaxLength string
	MinValue  string
	MaxValue  string
}

Jump to

Keyboard shortcuts

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