Documentation ¶
Overview ¶
Package compiler provides the compiles into Protocol Buffers structure from the OpenAPI definitions.
Index ¶
- func Compile(ctx context.Context, spec *openapi.Schema, options ...Option) (*descriptorpb.FileDescriptorProto, error)
- func IntegerFieldType(format string) *descriptorpb.FieldDescriptorProto_Type
- func NumberFieldType(format string) *descriptorpb.FieldDescriptorProto_Type
- func RegisterAdditionalMessages(descs ...*protobuf.MessageDescriptorProto)
- func RegisterDependencyProto(deps string)
- func StringFieldType(format string) *descriptorpb.FieldDescriptorProto_Type
- type Option
- func WithAdditionalMessages(additionalMessages []*protobuf.MessageDescriptorProto) Option
- func WithAnnotation(useAnnotation bool) Option
- func WithPackageName(packageName string) Option
- func WithPrefixEnums(usePrefixEnum bool) Option
- func WithSkipDeprecatedRPC(skipDeprecatedRPC bool) Option
- func WithSkipRPC(skipRPC bool) Option
- func WithWrapPrimitives(wrapPrimitives bool) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compile ¶
func Compile(ctx context.Context, spec *openapi.Schema, options ...Option) (*descriptorpb.FileDescriptorProto, error)
Compile takes an OpenAPI spec and compiles it into a protobuf file descriptor.
func IntegerFieldType ¶
func IntegerFieldType(format string) *descriptorpb.FieldDescriptorProto_Type
IntegerFieldType returns the FieldType of the underlying type of integer from the format.
func NumberFieldType ¶
func NumberFieldType(format string) *descriptorpb.FieldDescriptorProto_Type
NumberFieldType returns the FieldType of the underlying type of number from the format.
func RegisterAdditionalMessages ¶
func RegisterAdditionalMessages(descs ...*protobuf.MessageDescriptorProto)
RegisterAdditionalMessages registers additional protobuf.MessageDescriptorProto.
func RegisterDependencyProto ¶
func RegisterDependencyProto(deps string)
RegisterDependencyProto registers dependency proto.
func StringFieldType ¶
func StringFieldType(format string) *descriptorpb.FieldDescriptorProto_Type
StringFieldType returns the FieldType of the underlying type of string from the format.
Types ¶
type Option ¶
type Option func(o *option)
Option represents an idiomatic functional option pattern to compile the Protocol Buffers structure from the OpenAPI schema.
func WithAdditionalMessages ¶
func WithAdditionalMessages(additionalMessages []*protobuf.MessageDescriptorProto) Option
WithAdditionalMessages adds additional messages.
func WithAnnotation ¶
WithAnnotation sets whether the add "google.api.http" annotation to the compiled Protocol Buffers.
func WithPackageName ¶
WithPackageName specifies the package name when compiling the Protocol Buffers.
func WithPrefixEnums ¶
WithPrefixEnums prefix enum values with their enum name to prevent protobuf namespacing issues.
func WithSkipDeprecatedRPC ¶
WithSkipDeprecatedRpcs creates a new Option to specify if we should.
Skips generating rpcs for endpoints marked as deprecated.
func WithSkipRPC ¶
WithSkipRPC creates a new Option to specify if we should generate services and rpcs in addition to messages.
func WithWrapPrimitives ¶
WithWrapPrimitives wraps primitive types with their wrapper message types.
See: - https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/wrappers.proto - https://developers.google.com/protocol-buffers/docs/proto3#default