Documentation ¶
Index ¶
- func IsWellKnownType(typeName string) bool
- type Binding
- type Body
- type Enum
- type Field
- type FieldPath
- type FieldPathComponent
- type File
- type GoPackage
- type GrpcAPIService
- type Message
- type Method
- type Parameter
- type Registry
- func (r *Registry) AddExternalHTTPRule(qualifiedMethodName string, rule *annotations.HttpRule)
- func (r *Registry) AddPkgMap(file, protoPkg string)
- func (r *Registry) GetAllFQENs() []string
- func (r *Registry) GetAllFQMNs() []string
- func (r *Registry) GetAllowColonFinalSegments() bool
- func (r *Registry) GetDisableDefaultErrors() bool
- func (r *Registry) GetEnumsAsInts() bool
- func (r *Registry) GetMergeFileName() string
- func (r *Registry) GetRepeatedPathParamSeparator() rune
- func (r *Registry) GetRepeatedPathParamSeparatorName() string
- func (r *Registry) GetSimpleOperationIDs() bool
- func (r *Registry) GetUseFQNForSwaggerName() bool
- func (r *Registry) GetUseGoTemplate() bool
- func (r *Registry) GetUseJSONNamesForFields() bool
- func (r *Registry) IsAllowMerge() bool
- func (r *Registry) IsAllowRepeatedFieldsInBody() bool
- func (r *Registry) IsIncludePackageInTags() bool
- func (r *Registry) Load(req *plugin.CodeGeneratorRequest) error
- func (r *Registry) LoadGrpcAPIServiceFromYAML(yamlFile string) error
- func (r *Registry) LookupEnum(location, name string) (*Enum, error)
- func (r *Registry) LookupExternalHTTPRules(qualifiedMethodName string) []*annotations.HttpRule
- func (r *Registry) LookupFile(name string) (*File, error)
- func (r *Registry) LookupMsg(location, name string) (*Message, error)
- func (r *Registry) ReserveGoPackageAlias(alias, pkgpath string) error
- func (r *Registry) SetAllowColonFinalSegments(use bool)
- func (r *Registry) SetAllowDeleteBody(allow bool)
- func (r *Registry) SetAllowMerge(allow bool)
- func (r *Registry) SetAllowRepeatedFieldsInBody(allow bool)
- func (r *Registry) SetDisableDefaultErrors(use bool)
- func (r *Registry) SetEnumsAsInts(enumsAsInts bool)
- func (r *Registry) SetImportPath(importPath string)
- func (r *Registry) SetIncludePackageInTags(allow bool)
- func (r *Registry) SetMergeFileName(mergeFileName string)
- func (r *Registry) SetPrefix(prefix string)
- func (r *Registry) SetRepeatedPathParamSeparator(name string) error
- func (r *Registry) SetSimpleOperationIDs(use bool)
- func (r *Registry) SetUseFQNForSwaggerName(use bool)
- func (r *Registry) SetUseGoTemplate(use bool)
- func (r *Registry) SetUseJSONNamesForFields(use bool)
- func (r *Registry) UnboundExternalHTTPRules() []string
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsWellKnownType ¶ added in v1.3.1
IsWellKnownType returns true if the provided fully qualified type name is considered 'well-known'.
Types ¶
type Binding ¶
type Binding struct { // Method is the method which the endpoint is bound to. Method *Method // Index is a zero-origin index of the binding in the target method Index int // PathTmpl is path template where this method is mapped to. PathTmpl httprule.Template // HTTPMethod is the HTTP method which this method is mapped to. HTTPMethod string // PathParams is the list of parameters provided in HTTP request paths. PathParams []Parameter // Body describes parameters provided in HTTP request body. Body *Body // ResponseBody describes field in response struct to marshal in HTTP response body. ResponseBody *Body }
Binding describes how an HTTP endpoint is bound to a gRPC method.
func (*Binding) ExplicitParams ¶
ExplicitParams returns a list of explicitly bound parameters of "b", i.e. a union of field path for body and field paths for path parameters.
type Body ¶
type Body struct { // FieldPath is a path to a proto field which the (request|response) body is mapped to. // The (request|response) body is mapped to the (request|response) type itself if FieldPath is empty. FieldPath FieldPath }
Body describes a http (request|response) body to be sent to the (method|client). This is used in body and response_body options in google.api.HttpRule
func (Body) AssignableExpr ¶ added in v1.4.0
AssignableExpr returns an assignable expression in Go to be used to initialize method request object. It starts with "msgExpr", which is the go expression of the method request object.
type Enum ¶
type Enum struct { // File is the file where the enum is defined File *File // Outers is a list of outer messages if this enum is a nested type. Outers []string *descriptor.EnumDescriptorProto Index int }
Enum describes a protocol buffer enum types
type Field ¶
type Field struct { // Message is the message type which this field belongs to. Message *Message // FieldMessage is the message type of the field. FieldMessage *Message *descriptor.FieldDescriptorProto }
Field wraps descriptor.FieldDescriptorProto for richer features.
type FieldPath ¶
type FieldPath []FieldPathComponent
FieldPath is a path to a field from a request message.
func (FieldPath) AssignableExpr ¶ added in v1.4.0
AssignableExpr is an assignable expression in Go to be used to assign a value to the target field. It starts with "msgExpr", which is the go expression of the method request object.
func (FieldPath) IsNestedProto3 ¶
IsNestedProto3 indicates whether the FieldPath is a nested Proto3 path.
type FieldPathComponent ¶
type FieldPathComponent struct { // Name is a name of the proto field which this component corresponds to. // TODO(yugui) is this necessary? Name string // Target is the proto field which this component corresponds to. Target *Field }
FieldPathComponent is a path component in FieldPath
func (FieldPathComponent) AssignableExpr ¶ added in v1.4.0
func (c FieldPathComponent) AssignableExpr() string
AssignableExpr returns an assignable expression in go for this field.
func (FieldPathComponent) ValueExpr ¶ added in v1.4.0
func (c FieldPathComponent) ValueExpr() string
ValueExpr returns an expression in go for this field.
type File ¶
type File struct { *descriptor.FileDescriptorProto // GoPkg is the go package of the go file generated from this file.. GoPkg GoPackage // Messages is the list of messages defined in this file. Messages []*Message // Enums is the list of enums defined in this file. Enums []*Enum // Services is the list of services defined in this file. Services []*Service }
File wraps descriptor.FileDescriptorProto for richer features.
type GoPackage ¶
type GoPackage struct { // Path is the package path to the package. Path string // Name is the package name of the package Name string // Alias is an alias of the package unique within the current invokation of grpc-gateway generator. Alias string }
GoPackage represents a golang package
type GrpcAPIService ¶ added in v1.4.0
type GrpcAPIService struct { // Http Rule. Named Http in the actual proto. Changed to suppress linter warning. HTTP *annotations.Http `protobuf:"bytes,9,opt,name=http" json:"http,omitempty"` }
GrpcAPIService represents a stripped down version of google.api.Service . Compare to https://github.com/googleapis/googleapis/blob/master/google/api/service.proto The original imports 23 other protobuf files we are not interested in. If a significant subset (>50%) of these start being reproduced in this file we should swap to using the full generated version instead.
For the purposes of the gateway generator we only consider a small subset of all available features google supports in their service descriptions. Thanks to backwards compatibility guarantees by protobuf it is safe for us to remove the other fields. We also only implement the absolute minimum of protobuf generator boilerplate to use our simplified version. These should be pretty stable too.
func (*GrpcAPIService) ProtoMessage ¶ added in v1.4.0
func (*GrpcAPIService) ProtoMessage()
ProtoMessage returns an empty GrpcAPIService element
func (*GrpcAPIService) Reset ¶ added in v1.4.0
func (m *GrpcAPIService) Reset()
Reset resets the GrpcAPIService
func (*GrpcAPIService) String ¶ added in v1.4.0
func (m *GrpcAPIService) String() string
String returns the string representation of the GrpcAPIService
type Message ¶
type Message struct { // File is the file where the message is defined File *File // Outers is a list of outer messages if this message is a nested type. Outers []string *descriptor.DescriptorProto Fields []*Field // Index is proto path index of this message in File. Index int }
Message describes a protocol buffer message types
type Method ¶
type Method struct { // Service is the service which this method belongs to. Service *Service *descriptor.MethodDescriptorProto // RequestType is the message type of requests to this method. RequestType *Message // ResponseType is the message type of responses from this method. ResponseType *Message Bindings []*Binding }
Method wraps descriptor.MethodDescriptorProto for richer features.
type Parameter ¶
type Parameter struct { // FieldPath is a path to a proto field which this parameter is mapped to. FieldPath // Target is the proto field which this parameter is mapped to. Target *Field // Method is the method which this parameter is used for. Method *Method }
Parameter is a parameter provided in http requests
func (Parameter) ConvertFuncExpr ¶
ConvertFuncExpr returns a go expression of a converter function. The converter function converts a string into a value for the parameter.
func (Parameter) IsEnum ¶ added in v1.5.0
IsEnum returns true if the field is an enum type, otherwise false is returned.
func (Parameter) IsProto2 ¶ added in v1.5.0
IsProto2 returns true if the field is proto2, otherwise false is returned.
func (Parameter) IsRepeated ¶ added in v1.5.0
IsRepeated returns true if the field is repeated, otherwise false is returned.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is a registry of information extracted from plugin.CodeGeneratorRequest.
func (*Registry) AddExternalHTTPRule ¶ added in v1.4.0
func (r *Registry) AddExternalHTTPRule(qualifiedMethodName string, rule *annotations.HttpRule)
AddExternalHTTPRule adds an external http rule for the given fully qualified service method name
func (*Registry) GetAllFQENs ¶
GetAllFQENs returns a list of all FQENs
func (*Registry) GetAllFQMNs ¶
GetAllFQMNs returns a list of all FQMNs
func (*Registry) GetAllowColonFinalSegments ¶ added in v1.9.2
GetAllowColonFinalSegments returns allowColonFinalSegments
func (*Registry) GetDisableDefaultErrors ¶ added in v1.14.1
GetDisableDefaultErrors returns disableDefaultErrors
func (*Registry) GetEnumsAsInts ¶ added in v1.14.4
GetEnumsAsInts returns enumsAsInts
func (*Registry) GetMergeFileName ¶ added in v1.4.1
GetMergeFileName return the target merge swagger file name
func (*Registry) GetRepeatedPathParamSeparator ¶ added in v1.5.0
GetRepeatedPathParamSeparator returns a rune spcifying how path parameter repeated fields are separated.
func (*Registry) GetRepeatedPathParamSeparatorName ¶ added in v1.5.0
GetRepeatedPathParamSeparatorName returns the name path parameter repeated fields repeatedFieldSeparator. I.e. 'csv', 'pipe', 'ssv' or 'tsv'
func (*Registry) GetSimpleOperationIDs ¶ added in v1.14.4
GetSimpleOperationIDs returns simpleOperationIDs
func (*Registry) GetUseFQNForSwaggerName ¶ added in v1.8.0
GetUseFQNForSwaggerName returns useFQNForSwaggerName
func (*Registry) GetUseGoTemplate ¶ added in v1.12.0
GetUseGoTemplate returns useGoTemplate
func (*Registry) GetUseJSONNamesForFields ¶ added in v1.5.0
GetUseJSONNamesForFields returns useJSONNamesForFields
func (*Registry) IsAllowMerge ¶ added in v1.4.1
IsAllowMerge whether generation one swagger file out of multiple protos
func (*Registry) IsAllowRepeatedFieldsInBody ¶ added in v1.5.0
IsAllowRepeatedFieldsInBody checks if repeated field can be used in `body` and `response_body` (`google.api.http` annotation option) field path or not
func (*Registry) IsIncludePackageInTags ¶ added in v1.8.0
IsIncludePackageInTags checks whether the package name defined in the `package` directive in the proto file can be prepended to the gRPC service name in the `Tags` field of every operation.
func (*Registry) Load ¶
func (r *Registry) Load(req *plugin.CodeGeneratorRequest) error
Load loads definitions of services, methods, messages, enumerations and fields from "req".
func (*Registry) LoadGrpcAPIServiceFromYAML ¶ added in v1.4.0
LoadGrpcAPIServiceFromYAML loads a gRPC API Configuration from the given YAML file and registers the HttpRule descriptions contained in it as externalHTTPRules in the given registry. This must be done before loading the proto file.
You can learn more about gRPC API Service descriptions from google's documentation at https://cloud.google.com/endpoints/docs/grpc/grpc-service-config
Note that for the purposes of the gateway generator we only consider a subset of all available features google supports in their service descriptions.
func (*Registry) LookupEnum ¶
LookupEnum looks up a enum type by "name". It tries to resolve "name" from "location" if "name" is a relative enum name.
func (*Registry) LookupExternalHTTPRules ¶ added in v1.4.0
func (r *Registry) LookupExternalHTTPRules(qualifiedMethodName string) []*annotations.HttpRule
LookupExternalHTTPRules looks up external http rules by fully qualified service method name
func (*Registry) LookupFile ¶
LookupFile looks up a file by name.
func (*Registry) LookupMsg ¶
LookupMsg looks up a message type by "name". It tries to resolve "name" from "location" if "name" is a relative message name.
func (*Registry) ReserveGoPackageAlias ¶
ReserveGoPackageAlias reserves the unique alias of go package. If succeeded, the alias will be never used for other packages in generated go files. If failed, the alias is already taken by another package, so you need to use another alias for the package in your go files.
func (*Registry) SetAllowColonFinalSegments ¶ added in v1.9.2
SetAllowColonFinalSegments sets allowColonFinalSegments
func (*Registry) SetAllowDeleteBody ¶ added in v1.2.0
SetAllowDeleteBody controls whether http delete methods may have a body or fail loading if encountered.
func (*Registry) SetAllowMerge ¶ added in v1.4.1
SetAllowMerge controls whether generation one swagger file out of multiple protos
func (*Registry) SetAllowRepeatedFieldsInBody ¶ added in v1.5.0
SetAllowRepeatedFieldsInBody controls whether repeated field can be used in `body` and `response_body` (`google.api.http` annotation option) field path or not
func (*Registry) SetDisableDefaultErrors ¶ added in v1.14.1
SetDisableDefaultErrors sets disableDefaultErrors
func (*Registry) SetEnumsAsInts ¶ added in v1.14.4
SetEnumsAsInts set enumsAsInts
func (*Registry) SetImportPath ¶ added in v1.3.1
SetImportPath registers the importPath which is used as the package if no input files declare go_package. If it contains slashes, everything up to the rightmost slash is ignored.
func (*Registry) SetIncludePackageInTags ¶ added in v1.8.0
SetIncludePackageInTags controls whether the package name defined in the `package` directive in the proto file can be prepended to the gRPC service name in the `Tags` field of every operation.
func (*Registry) SetMergeFileName ¶ added in v1.4.1
SetMergeFileName controls the target swagger file name out of multiple protos
func (*Registry) SetPrefix ¶
SetPrefix registers the prefix to be added to go package paths generated from proto package names.
func (*Registry) SetRepeatedPathParamSeparator ¶ added in v1.5.0
SetRepeatedPathParamSeparator sets how path parameter repeated fields are separated. Allowed names are 'csv', 'pipe', 'ssv' and 'tsv'.
func (*Registry) SetSimpleOperationIDs ¶ added in v1.14.4
SetSimpleOperationIDs sets simpleOperationIDs
func (*Registry) SetUseFQNForSwaggerName ¶ added in v1.8.0
SetUseFQNForSwaggerName sets useFQNForSwaggerName
func (*Registry) SetUseGoTemplate ¶ added in v1.12.0
SetUseGoTemplate sets useGoTemplate
func (*Registry) SetUseJSONNamesForFields ¶ added in v1.5.0
SetUseJSONNamesForFields sets useJSONNamesForFields
func (*Registry) UnboundExternalHTTPRules ¶ added in v1.14.4
UnboundExternalHTTPRules returns the list of External HTTPRules which does not have a matching method in the registry
type Service ¶
type Service struct { // File is the file where this service is defined. File *File *descriptor.ServiceDescriptorProto // Methods is the list of methods defined in this service. Methods []*Method }
Service wraps descriptor.ServiceDescriptorProto for richer features.