Documentation ¶
Overview ¶
Package parser provides the ability of the parser to generate IDC descriptions from specified files.
Index ¶
- func CheckSECVEnabled(nfd *descriptor.FileDescriptor) bool
- func GetPackage(fd *descriptor.FileDescriptor, language string) (string, error)
- func GetPbPackage(fd *descriptor.FileDescriptor, fileOption string) (string, error)
- func LoadDescriptorSet(descriptorSetInFile, protofile string, opts ...Option) (*descriptor.FileDescriptor, error)
- func Parse(protofile string, dirs []string, typ config.IDLType, opts ...Option) (*descriptor.FileDescriptor, error)
- func ParseFlatbuffers(protofile string, protodirs []string, opts ...Option) (*descriptor.FileDescriptor, error)
- func ParseProtoFile(protofile string, protodirs []string, opts ...Option) (*descriptor.FileDescriptor, error)
- type HttpRule
- type Option
- type SwaggerParam
- type SwaggerRule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckSECVEnabled ¶
func CheckSECVEnabled(nfd *descriptor.FileDescriptor) bool
CheckSECVEnabled checks if validation rules are defined in the pb.
func GetPackage ¶
func GetPackage(fd *descriptor.FileDescriptor, language string) (string, error)
GetPackage combines the package directive and option $lang_package to get a valid package name. The package directive is like package trpc.testapp.testserver;. The option $lang_package is like option go_package="trpc.group/trpcprotocol/testapp/testserver";.
func GetPbPackage ¶
func GetPbPackage(fd *descriptor.FileDescriptor, fileOption string) (string, error)
GetPbPackage retrieves the path where the protobuf files are located. When a file option (such as go_package) has a corresponding value in fd.FileOptions, the returned pbPackage will be in the form of "trpc.group/trpcprotocol/testapp/testserver". Otherwise, pbPackage will be in the form of "trpc.testapp.testserver".
func LoadDescriptorSet ¶
func LoadDescriptorSet(descriptorSetInFile, protofile string, opts ...Option) (*descriptor.FileDescriptor, error)
LoadDescriptorSet loads the file descriptor from the given file name.
func Parse ¶
func Parse(protofile string, dirs []string, typ config.IDLType, opts ...Option) (*descriptor.FileDescriptor, error)
Parse parses the given file, which can be either a Protocol Buffer or FlatBuffers file.
func ParseFlatbuffers ¶
func ParseFlatbuffers(protofile string, protodirs []string, opts ...Option) (*descriptor.FileDescriptor, error)
ParseFlatbuffers parses a flatbuffers file and returns a FileDescriptor object that can be used for template filling.
func ParseProtoFile ¶
func ParseProtoFile(protofile string, protodirs []string, opts ...Option) (*descriptor.FileDescriptor, error)
ParseProtoFile parses a proto file and returns a constructed FileDescriptor object that can be used for template filling.
ParseProtoFile is responsible for: - parsing the pb file to get the original description information - checking project constraints, such as whether custom constraints such as go_option and method option are specified.
Types ¶
type HttpRule ¶
type HttpRule[HR any] interface { *annotations.HttpRule GetAdditionalBindings() []HR GetBody() string GetResponseBody() string }
HttpRule provide interface for http rule.
type Option ¶
type Option func(*options)
Option parse option
func WithAPPName ¶
WithAPPName specifies app name to use in stub code.
func WithAliasAsClientRPCName ¶
WithAliasAsClientRPCName sets alias as client rpc name.
func WithLanguage ¶
WithLanguage specify language for further checking
func WithMultiVersion ¶
WithMultiVersion enable multi-version support.
func WithServerName ¶
WithServerName specifies server name to use in stub code.
type SwaggerParam ¶
type SwaggerParam interface { *swagger.SwaggerParam GetName() string GetRequired() bool GetDefault() string }
type SwaggerRule ¶
type SwaggerRule[SP SwaggerParam] interface { *swagger.SwaggerRule GetTitle() string GetDescription() string GetMethod() string GetParams() []SP }