Documentation
¶
Index ¶
- func EnumExemplar(fd protoreflect.FieldDescriptor) exemplar
- func FieldExemplar(fd protoreflect.FieldDescriptor) exemplar
- func FieldValueExemplar(fd protoreflect.FieldDescriptor) exemplar
- func Generate(protoSet, methodDir string, force bool, targets []string) error
- func MessageExemplar(md protoreflect.MessageDescriptor) exemplar
- func MethodExemplar(md protoreflect.MethodDescriptor) exemplar
- func ScalarExemplar(kind protoreflect.Kind) exemplar
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnumExemplar ¶
func EnumExemplar(fd protoreflect.FieldDescriptor) exemplar
EnumExemplar returns an exemplar with a sample value for the enum. An empty exemplar is returned if the field is not an enum.
Enum exemplars are emitted as a string with the name of the second enum if there is more than one enum value, otherwise the first enum. The second enum is preferred as often the first enum is the "invalid" value for that enum.
func FieldExemplar ¶
func FieldExemplar(fd protoreflect.FieldDescriptor) exemplar
FieldExemplar returns an exemplar for a message field. It has the JSON name for the field prefixed and a comment appended to the first line describing the type of the field.
func FieldValueExemplar ¶
func FieldValueExemplar(fd protoreflect.FieldDescriptor) exemplar
FieldValueExemplar returns an exemplar for the value of a FieldDescriptor. The value is as per the exemplar form for the fields type. See the other *Exemplar functions for details of those.
Map fields are emitted as repeated key/value message pairs in the expanded backward-compatible form, as opposed to {key: value, ...} objects.
Repeated fields are emitted with a single element exemplar of the repeated type.
func Generate ¶
Generate writes exemplars for the methods specified by targets that match the methods in the protoSet file, or all methods if targets is an empty slice. Method exemplars are written to stdout if methodDir is empty, otherwise each method is written to a separate file in that directory. Existing files will not be overwritten unless force is true.
func MessageExemplar ¶
func MessageExemplar(md protoreflect.MessageDescriptor) exemplar
MessageExemplar returns an exemplar of a protobuf message as a JSON object with a field for every message field. Each field value is an exemplar of the type of the field. Oneof fields are emitted as comments as a message should not have more than one oneof specified.
func MethodExemplar ¶
func MethodExemplar(md protoreflect.MethodDescriptor) exemplar
MethodExemplar returns an exemplar for a method, with an exemplar for the input message as a comment and a function returning an exemplar of the output message as the method implementation.
func ScalarExemplar ¶
func ScalarExemplar(kind protoreflect.Kind) exemplar
ScalarExemplar returns an exemplar with a value for basic kinds that have a single value (scalars). An empty exemplar is returned for other kinds.
Types ¶
This section is empty.