compiler

package
v0.0.0-...-21fe71f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2023 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Overview

Package compiler provides the compiles into Protocol Buffers structure from the OpenAPI definitions.

Index

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

func WithAnnotation(useAnnotation bool) Option

WithAnnotation sets whether the add "google.api.http" annotation to the compiled Protocol Buffers.

func WithPackageName

func WithPackageName(packageName string) Option

WithPackageName specifies the package name when compiling the Protocol Buffers.

func WithPrefixEnums

func WithPrefixEnums(usePrefixEnum bool) Option

WithPrefixEnums prefix enum values with their enum name to prevent protobuf namespacing issues.

func WithSkipDeprecatedRPC

func WithSkipDeprecatedRPC(skipDeprecatedRPC bool) Option

WithSkipDeprecatedRpcs creates a new Option to specify if we should.

Skips generating rpcs for endpoints marked as deprecated.

func WithSkipRPC

func WithSkipRPC(skipRPC bool) Option

WithSkipRPC creates a new Option to specify if we should generate services and rpcs in addition to messages.

func WithWrapPrimitives

func WithWrapPrimitives(wrapPrimitives bool) Option

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL