parser

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateDependencyMap

GenerateDependencyMap recursively loops through dependencies and creates a map for their names and FileDescriptorProto

Types

type Comment

type Comment struct {
	Leading  string
	Trailing string
	Detached []string
}

Comment describes a comment.

type Enum

type Enum struct {
	Name    string
	Comment *Comment
	Values  []*Value
}

Enum describes an enumeration type.

type Field

type Field struct {
	Name         string
	Comment      *Comment
	Type         *Type
	JSONName     string
	FixedExample json.RawMessage
}

Field describes a proto field.

type File

type File struct {
	Swagger  *options.Swagger
	Services map[string]*Service
	Enums    map[string]*Enum
}

File is a proto parsed file.

func ParseFile

func ParseFile(file *FileDescWrapper, onlyExternal OnlyExternalOpt) (*File, error)

ParseFile parses a proto file.

func (*File) CheckSwagger

func (f *File) CheckSwagger() error

CheckSwagger checks existence of Swagger annotations, that are needed for proper generation of the markdown documentation.

func (*File) HasServices

func (f *File) HasServices() bool

HasServices returns true when file contains service definitions.

func (*File) SwaggerScheme

func (f *File) SwaggerScheme() string

SwaggerScheme gets scheme that you most probably want. The order is https - http - wss - ws. Includes "://" string if present, returns empty string if there is no valid scheme.

type FileDescWrapper

type FileDescWrapper struct {
	*descriptorpb.FileDescriptorProto
	DependencyMap map[string]*descriptorpb.FileDescriptorProto
}

FileDescWrapper is a wrapper for FileDescriptorProto for holding a map of dependencies.

type Message

type Message struct {
	Name           string
	Comment        *Comment
	Fields         []*Field
	NestedMessages []*Message
	Enums          []*Enum
	FixedExample   map[string]interface{}
}

Message describes a proto message.

type Method

type Method struct {
	Name      string
	Comment   *Comment
	Request   *Request
	Response  *Response
	Operation *options.Operation
}

Method describes a proto method.

func (*Method) HeaderID

func (m *Method) HeaderID() string

type OnlyExternalOpt

type OnlyExternalOpt int
const (
	OnlyExternalDisabled OnlyExternalOpt = iota
	OnlyExternalEnabled
)

type Request

type Request struct {
	Verb    string
	URI     string
	Body    *Message
	Query   []*Field
	Example string
}

Request describes an HTTP request.

type Response

type Response struct {
	*Message
	Example string
}

Response describes a response of a service.

type Service

type Service struct {
	Name    string
	Comment *Comment
	Methods map[string]*Method
}

Service describes a proto service.

type Type

type Type struct {
	Name          string
	QualifiedName string
	IsMessage     bool
	IsArray       bool
	IsEnum        bool
}

Type describes a field type.

type Value

type Value struct {
	Name    string
	Comment *Comment
}

Value describes an enum possible value.

Jump to

Keyboard shortcuts

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