Documentation ¶
Index ¶
- func Load(ds *descriptorpb.FileDescriptorSet) map[string]Type
- func SetSkipValidations(flag bool)
- type ContainerType
- type Enum
- func (e *Enum) GetEnum() *Enum
- func (e *Enum) GetMessage() *Message
- func (b *Enum) IsTopLevel() bool
- func (e *Enum) Map() map[string]string
- func (b *Enum) Name() string
- func (e *Enum) NameForFirstValue() string
- func (b *Enum) NestedName() string
- func (b *Enum) Package() string
- func (b *Enum) QualifiedName() string
- func (e *Enum) ReverseMap() map[string]string
- func (e *Enum) ValueMap() map[string]string
- type Field
- func (f *Field) AllowedNames() []string
- func (f *Field) Constraints() map[string]interface{}
- func (f *Field) ContainerType() ContainerType
- func (f *Field) FieldType() FieldType
- func (f *Field) IsList() bool
- func (f *Field) IsMap() bool
- func (f *Field) IsRequired() bool
- func (f *Field) Name() string
- func (f *Field) OneOfGroup() string
- func (f *Field) SetterName() string
- func (f *Field) TypeName() string
- func (f *Field) ValidationRules() *validate.FieldRules
- type FieldMeta
- type FieldType
- type Message
- func (m *Message) FieldMeta() map[string]FieldMeta
- func (m Message) Fields() []*Field
- func (m *Message) GetEnum() *Enum
- func (m *Message) GetMessage() *Message
- func (b *Message) IsTopLevel() bool
- func (b *Message) Name() string
- func (m *Message) NestedEnums() []*Enum
- func (m *Message) NestedMessages() []*Message
- func (b *Message) NestedName() string
- func (m *Message) OneOfs() []*OneOf
- func (b *Message) Package() string
- func (b *Message) QualifiedName() string
- type OneOf
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Load ¶
func Load(ds *descriptorpb.FileDescriptorSet) map[string]Type
Load returns the types found in the specified descriptor set keyed by fully qualified name.
func SetSkipValidations ¶
func SetSkipValidations(flag bool)
Types ¶
type ContainerType ¶
type ContainerType string
ContainerType indicates if the field is a container type with values none (empty string), "list", and "map"
const ( ContainerTypeNone ContainerType = "" ContainerTypeList ContainerType = "list" ContainerTypeMap ContainerType = "map" )
type Enum ¶
type Enum struct {
// contains filtered or unexported fields
}
Enum is a protobuf enum definition.
func (*Enum) GetMessage ¶
GetMessage implements the Type interface.
func (*Enum) IsTopLevel ¶
func (b *Enum) IsTopLevel() bool
IsTopLevel returns true if the type definition is not nested under a message.
func (*Enum) NameForFirstValue ¶
NameForFirstValue returns the name for the first value defined in the enum.
func (*Enum) NestedName ¶
func (b *Enum) NestedName() string
NestedName returns the qualified name not including package.
func (*Enum) Package ¶
func (b *Enum) Package() string
Package returns the package name in which the type is defined or the empty string if there is no package.
func (*Enum) QualifiedName ¶
func (b *Enum) QualifiedName() string
QualifiedName returns the qualified name of the type including the package name.
func (*Enum) ReverseMap ¶
ReverseMap returns a map of names keyed by enum values converted to strings.
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
Field is a field in a message.
func (*Field) AllowedNames ¶
AllowedNames returns the set of names allowed to refer to this field.
func (*Field) Constraints ¶
Constraints returns field rules as a JSON string.
func (*Field) ContainerType ¶
func (f *Field) ContainerType() ContainerType
ContainerType returns the container type for the field.
func (*Field) IsRequired ¶
IsRequired returns true if the field is required to be present.
func (*Field) OneOfGroup ¶
OneOfGroup returns the name of the one-of if the field participates in one.
func (*Field) SetterName ¶
SetterName returns the name of the setter to be used for this type in generated code.
func (*Field) TypeName ¶
TypeName returns the fully qualified type name for messages or a primitive type name. All numeric types are represented as a "number" string.
func (*Field) ValidationRules ¶
func (f *Field) ValidationRules() *validate.FieldRules
ValidationRules returns any field rules defined for this type using the protoc-gen-validate package.
type FieldMeta ¶
type FieldMeta struct { Type string `json:"type"` // the type name of the field as returned by AllowedNames []string `json:"allowedNames"` // the allowed names for the field ContainerType ContainerType `json:"containerType,omitempty"` // the container type Required bool `json:"required,omitempty"` // whether it is required Constraints map[string]interface{} `json:"constraints,omitempty"` // type constraints associated with the field }
FieldMeta returns the attributes for a field needed in generated code.
type FieldType ¶
type FieldType string
FieldType indicates the type of field, "primitive", "enum" or "message".
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message represents a protobuf message.
func (*Message) GetMessage ¶
GetMessage implements the Type interface.
func (*Message) IsTopLevel ¶
func (b *Message) IsTopLevel() bool
IsTopLevel returns true if the type definition is not nested under a message.
func (*Message) NestedEnums ¶
NestedEnums returns the enums nested under this type.
func (*Message) NestedMessages ¶
NestedMessages returns the messages nested under this type.
func (*Message) NestedName ¶
func (b *Message) NestedName() string
NestedName returns the qualified name not including package.
func (*Message) Package ¶
func (b *Message) Package() string
Package returns the package name in which the type is defined or the empty string if there is no package.
func (*Message) QualifiedName ¶
func (b *Message) QualifiedName() string
QualifiedName returns the qualified name of the type including the package name.
type OneOf ¶
type OneOf struct { Fields []string `json:"fields"` // the field names that constitute the one-of Required bool `json:"required"` // whether it is required in the enclosing message Group string `json:"group"` // the name of the one-of field. }
OneOf represents a one-of field.
type Type ¶
type Type interface { Name() string // Leaf name for the type Package() string // Package in which type is declared IsTopLevel() bool // returns true if this is a type not nested in a message NestedName() string // the qualified name of the type not including package name QualifiedName() string // the qualified name of the type including package name GetMessage() *Message // the underlying message if the type represents a message, or nil GetEnum() *Enum // the underlying Enum if the type represents an enum, or nil }
Type is an abstraction over a protobuf message or enum. It exposes the common attributes for each. The GetMessage and GetEnum methods respectively return a non-nil Message or Enum object based on what the underlying type is.