parser

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StringType  = "String"
	FloatType   = "Float"
	DoubleType  = "Double"
	BoolType    = "Bool"
	Int32Type   = "Int32"
	Int64Type   = "Int64"
	UInt32Type  = "UInt32"
	UInt64Type  = "UInt64"
	BytesType   = "Bytes"
	Float32Type = "Float32"
	Float64Type = "Float64"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConversionMode

type ConversionMode int32
const (
	ConversionMode_ProtoToModel ConversionMode = iota
	ConversionMode_ModelToProto
)

type Enum

type Enum struct {
	Name    string
	Prefix  string
	Entries []*EnumEntry
}

func LoadEnums

func LoadEnums(file *protogen.File) []Enum

type EnumEntry

type EnumEntry struct {
	ProtoName string
	Name      string
}

type Field

type Field struct {
	GoName    string
	GoType    string
	JsonName  string
	ProtoName string
	IsArray   bool
	Type      descriptor.FieldDescriptorProto_Type
	Location  FieldLocation
	// contains filtered or unexported fields
}

func NewField

func NewField(
	packageName string,
	field *descriptor.FieldDescriptorProto,
	fieldSchema *protogen.Field,
	details *endpointDetails,
) *Field

func (*Field) GetAppendFieldValue

func (f *Field) GetAppendFieldValue(loopName string) string

GetAppendFieldValue gives the call, in a string format, that must be used to append this Field into a slice of the name type.

func (*Field) GetEnumFromStringCall

func (f *Field) GetEnumFromStringCall() string

func (*Field) GetExpandConverter

func (f *Field) GetExpandConverter(receiver string) string

func (*Field) GetFormFieldFileNames

func (f *Field) GetFormFieldFileNames() string

func (*Field) GetFormFieldValueNames

func (f *Field) GetFormFieldValueNames() string

func (*Field) GetMapEnumRealValueType

func (f *Field) GetMapEnumRealValueType() string

func (*Field) GetMapFieldKeyType

func (f *Field) GetMapFieldKeyType() string

func (*Field) GetMapFieldKeyValueType

func (f *Field) GetMapFieldKeyValueType() string

func (*Field) GetMapValueType

func (f *Field) GetMapValueType() string

func (*Field) GetModelConverter

func (f *Field) GetModelConverter(receiver string) string

func (*Field) GetModelTag

func (f *Field) GetModelTag() string

GetModelTag retrieves the field type by checking if it has a different value defined in some of our extensions.

func (*Field) GetName

func (f *Field) GetName() string

GetName retrieves the field name by checking if it has a different name defined in some of our extensions.

func (*Field) GetProtoConverter

func (f *Field) GetProtoConverter(receiver string) string

func (*Field) GetProtoType

func (f *Field) GetProtoType() string

func (*Field) GetResponseConverter

func (f *Field) GetResponseConverter(receiver string) string

GetResponseConverter gives the call, in a string format, that must be used to convert the Field when used inside a response structure.

func (*Field) GetResponseTag

func (f *Field) GetResponseTag() string

GetResponseTag retrieves the field type by checking if it has a different value defined in some of our extensions.

func (*Field) GetType

func (f *Field) GetType() string

GetType retrieves the field type by checking if it has a different type defined in some of our extensions.

func (*Field) GetValidationDefinition

func (f *Field) GetValidationDefinition() *extension.Validation

func (*Field) GetValidator

func (f *Field) GetValidator() string

GetValidator returns the Field validator source syntax call to be used by an ozzo validation call.

func (*Field) GoEnumType

func (f *Field) GoEnumType() string

func (*Field) GoMessageType

func (f *Field) GoMessageType() string

GoMessageType returns just the message type name, without the package prefix.

func (*Field) HasMultipartFormFiles

func (f *Field) HasMultipartFormFiles() bool

func (*Field) HasMultipartFormValues

func (f *Field) HasMultipartFormValues() bool

func (*Field) HasValidatorTag

func (f *Field) HasValidatorTag() bool

HasValidatorTag checks if the Field is using the protobuf validator tag in its declaration.

func (*Field) IsEnum

func (f *Field) IsEnum() bool

IsEnum checks if the Field is an enum or not.

func (*Field) IsInternalMessage

func (f *Field) IsInternalMessage() bool

IsInternalMessage checks by looking at the Field name if it corresponds to an internal message or not.

func (*Field) IsMap

func (f *Field) IsMap() bool

func (*Field) IsMessage

func (f *Field) IsMessage() bool

func (*Field) IsMultipartForm

func (f *Field) IsMultipartForm() bool

func (*Field) IsMultipartFormRequired

func (f *Field) IsMultipartFormRequired() bool

func (*Field) IsPointer

func (f *Field) IsPointer() bool

func (*Field) IsProtobufTimestamp

func (f *Field) IsProtobufTimestamp() bool

func (*Field) MapToEnum

func (f *Field) MapToEnum() bool

func (*Field) MapToMessage

func (f *Field) MapToMessage() bool

func (*Field) NeedsAddressNotation

func (f *Field) NeedsAddressNotation() bool

NeedsAddressNotation checks if the current field needs to use the address notation (&) when validating it.

func (*Field) NeedsOzzoIsPackage

func (f *Field) NeedsOzzoIsPackage() bool

func (*Field) Validate

func (f *Field) Validate() error

Validate acts a validator for the choices the user has made for this field by checking if everything is going to work and is supported.

type FieldLocation

type FieldLocation int32
const (
	FieldLocation_Unknown FieldLocation = iota
	FieldLocation_Body
	FieldLocation_Query
	FieldLocation_Path
	FieldLocation_Header
)

func (FieldLocation) String

func (l FieldLocation) String() string

type FieldMapEntry

type FieldMapEntry struct {
	Key string
	// contains filtered or unexported fields
}

func (*FieldMapEntry) GetDefaultValue

func (e *FieldMapEntry) GetDefaultValue() string

type HttpRule

type HttpRule struct {
	Method   string
	Endpoint string
}

type Message

type Message struct {
	HasHttpResponseModel bool
	DontExport           bool
	Name                 string
	Fields               []*Field
	// contains filtered or unexported fields
}

func LoadEntities

func LoadEntities(file *protogen.File, packageName string) ([]*Message, error)

LoadEntities loads all messages from a protogen.File and set them as entity kind.

func LoadMessages

func LoadMessages(file *protogen.File) ([]*Message, error)

func NewMessage

func NewMessage(options *NewMessageOptions) (*Message, error)

NewMessage creates a new Message structure according a few options. After successfully creating a new one, it loads all internal custom proto definitions, the extension API, for all fields and for itself.

func (*Message) ArrayFields

func (m *Message) ArrayFields() []*Field

func (*Message) BodyArgumentsFields

func (m *Message) BodyArgumentsFields() []*Field

BodyArgumentsFields gives a slice of Field that must be parsed from the request body.

func (*Message) BodyRequired

func (m *Message) BodyRequired() bool

BodyRequired checks if the message has at least one field that should be parsed from the request body.

func (*Message) EntityValidate

func (m *Message) EntityValidate() error

EntityValidate validates if the Message is currently in the expected format to be an entity.

func (*Message) Export

func (m *Message) Export() bool

Export checks if we are going to export the message or not.

func (*Message) FullParseFromBody

func (m *Message) FullParseFromBody() bool

FullParseFromBody checks if the whole message must be parsed from the request body.

func (*Message) GetEntityName

func (m *Message) GetEntityName() string

GetEntityName returns the message name in the entity format, i.e., without the Proto suffix.

func (*Message) GetFormFieldFileNames

func (m *Message) GetFormFieldFileNames() string

func (*Message) GetFormFieldValueNames

func (m *Message) GetFormFieldValueNames() string

func (*Message) GetReceiverName

func (m *Message) GetReceiverName() string

GetReceiverName retrieves the receiver name to be used for function declarations.

func (*Message) HasArrayField

func (m *Message) HasArrayField() bool

HasArrayField checks if the message has any array field.

func (*Message) HasCommonSettings

func (m *Message) HasCommonSettings() bool

func (*Message) HasEnumField

func (m *Message) HasEnumField() bool

HasEnumField checks if the message has at least one enum Field.

func (*Message) HasFieldWithValidation

func (m *Message) HasFieldWithValidation() bool

func (*Message) HasHeaderArguments

func (m *Message) HasHeaderArguments() bool

HasHeaderArguments checks if the message has any Field that must be parsed from the request header.

func (*Message) HasIDField

func (m *Message) HasIDField() bool

func (*Message) HasInternalMessageFields

func (m *Message) HasInternalMessageFields() bool

func (*Message) HasMapField

func (m *Message) HasMapField() bool

func (*Message) HasMessageField

func (m *Message) HasMessageField() bool

HasMessageField checks if the message has at least one message Field.

func (*Message) HasMultipartField

func (m *Message) HasMultipartField() bool

func (*Message) HasQueryArguments

func (m *Message) HasQueryArguments() bool

HasQueryArguments checks if the message has any Field that must be parsed from the request query.

func (*Message) HeaderArgumentsFields

func (m *Message) HeaderArgumentsFields() []*Field

HeaderArgumentsFields gives a slice of Field that must be parsed from the request header.

func (*Message) InternalMessageFields

func (m *Message) InternalMessageFields() []*Field

func (*Message) IsCommonSettings

func (m *Message) IsCommonSettings() bool

func (*Message) IsEntity

func (m *Message) IsEntity() bool

func (*Message) IsRpcRequestArgument

func (m *Message) IsRpcRequestArgument() bool

IsRpcRequestArgument checks if the message is the argument of an RPC.

func (*Message) Kind

func (m *Message) Kind() MessageKind

func (*Message) MapFields

func (m *Message) MapFields() []*Field

func (*Message) NonArrayFields

func (m *Message) NonArrayFields() []*Field

func (*Message) PathArgumentsFields

func (m *Message) PathArgumentsFields() []*Field

PathArgumentsFields gives a slice of Field that must be parsed from the request path.

func (*Message) QueryArgumentsFields

func (m *Message) QueryArgumentsFields() []*Field

QueryArgumentsFields gives a slice of Field that must be parsed from the request query.

func (*Message) SettingsValidate

func (m *Message) SettingsValidate() error

SettingsValidate validates if the Message is currently in the expected format to be a settings entity.

func (*Message) SimpleFields

func (m *Message) SimpleFields() []*Field

SimpleFields gives back only fields that are not array, messages or maps.

type MessageKind

type MessageKind int32
const (
	MessageKind_Unknown MessageKind = iota
	MessageKind_Entity
	MessageKind_Input
	MessageKind_Output
	MessageKind_External
)

type Method

type Method struct {
	Name                  string
	HTTPMethod            string
	Endpoint              string
	ContentType           string
	Request               Request
	Returns               Returns
	Scopes                []string
	AdditionalHTTPMethods []HttpRule
	// contains filtered or unexported fields
}

func LoadMethods

func LoadMethods(file *protogen.File, entitiesFile *protogen.File, packageName string) []*Method

LoadMethods loads all RPC methods from a service declaration if the protobuf file has one.

func (*Method) AuthVersion

func (m *Method) AuthVersion() int

func (*Method) BodyField

func (m *Method) BodyField() string

func (*Method) EchoEndpoint

func (m *Method) EchoEndpoint() string

func (*Method) GetScopes

func (m *Method) GetScopes() string

func (*Method) IsHTTPEndpoint

func (m *Method) IsHTTPEndpoint() bool

func (*Method) IsMultipartFormData

func (m *Method) IsMultipartFormData() bool

func (*Method) IsTextPlain

func (m *Method) IsTextPlain() bool

func (*Method) Validate

func (m *Method) Validate() error

type MsgFieldDefaultValue

type MsgFieldDefaultValue struct {
	FieldName string
	// contains filtered or unexported fields
}

func (*MsgFieldDefaultValue) GetDefaultValue

func (m *MsgFieldDefaultValue) GetDefaultValue() string

type NewMessageOptions

type NewMessageOptions struct {
	PackageName   string
	Message       *descriptor.DescriptorProto
	Fields        []*Field
	MessageSchema *protogen.Message
	Kind          MessageKind
	Responses     *responseMessages
}

NewMessageOptions is a structure to be used when we need to create a new Message.

type Request

type Request struct {
	Name     string
	Messages []*Message
}

type Returns

type Returns struct {
	Name     string
	Messages []*Message
}

Jump to

Keyboard shortcuts

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