github.com/sanposhiho/openapi2proto@v0.0.0-20230521044535-d1080a134e37/compiler/options.go (about)

     1  package compiler
     2  
     3  import "github.com/sanposhiho/openapi2proto/internal/option"
     4  
     5  const (
     6  	optkeyAnnotation         = "annotation"
     7  	optkeySkipRpcs           = "skip-rpcs"
     8  	optKeySkipDeprecatedRpcs = "skip-deprecated-rpcs"
     9  	optkeyPrefixEnums        = "namespace-enums"
    10  	optkeyWrapPrimitives     = "wrap-primitives"
    11  )
    12  
    13  // WithAnnotation creates a new Option to specify if we should add
    14  // google.api.http annotation to the compiled Protocol Buffers structure
    15  func WithAnnotation(b bool) Option {
    16  	return option.New(optkeyAnnotation, b)
    17  }
    18  
    19  // WithSkipRpcs creates a new Option to specify if we should
    20  // generate services and rpcs in addition to messages
    21  func WithSkipRpcs(b bool) Option {
    22  	return option.New(optkeySkipRpcs, b)
    23  }
    24  
    25  // WithSkipDeprecatedRpcs creates a new Option to specify if we should
    26  // skip generating rpcs for endpoints marked as deprecated
    27  func WithSkipDeprecatedRpcs(b bool) Option {
    28  	return option.New(optKeySkipDeprecatedRpcs, b)
    29  }
    30  
    31  // prefix enum values with their enum name to prevent protobuf namespacing issues
    32  func WithPrefixEnums(b bool) Option {
    33  	return option.New(optkeyPrefixEnums, b)
    34  }
    35  
    36  // wrap primitive types with their wrapper message types
    37  // see https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/wrappers.proto
    38  // and https://developers.google.com/protocol-buffers/docs/proto3#default
    39  func WithWrapPrimitives(b bool) Option {
    40  	return option.New(optkeyWrapPrimitives, b)
    41  }