genopenapi

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FieldNameMode

type FieldNameMode uint8
const (
	FieldNameModeJSON FieldNameMode = iota
	FieldNameModeProto
)

func (*FieldNameMode) Set

func (f *FieldNameMode) Set(value string) error

func (FieldNameMode) String

func (f FieldNameMode) String() string

type FieldNullableMode

type FieldNullableMode uint8
const (
	FieldNullableModeDisabled FieldNullableMode = iota
	FieldNullableModeOptionalLabel
	FieldNullableModeNonRequired
)

func (*FieldNullableMode) Set

func (f *FieldNullableMode) Set(value string) error

func (FieldNullableMode) String

func (f FieldNullableMode) String() string

type FieldRequiredMode

type FieldRequiredMode uint8
const (
	FieldRequiredModeDisabled FieldRequiredMode = iota
	FieldRequiredModeRequireNonOptional
	FieldRequiredModeRequireNonOptionalScalar
)

func (*FieldRequiredMode) Set

func (f *FieldRequiredMode) Set(value string) error

func (FieldRequiredMode) String

func (f FieldRequiredMode) String() string

type Generator

type Generator struct {
	Options
	// contains filtered or unexported fields
}

func New

func New(descriptorRegistry *descriptor.Registry, options Options) *Generator

func (*Generator) Generate

func (g *Generator) Generate(targets []*descriptor.File) ([]*descriptor.ResponseFile, error)

func (*Generator) LookupFile

func (g *Generator) LookupFile(file *descriptor.File) internal.OpenAPIDocument

type OperationIDMode

type OperationIDMode uint8
const (
	OperationIDModeFQN OperationIDMode = iota
	OperationIDModeServiceAndMethod
	OperationIDModeMethod
)

func (*OperationIDMode) Set

func (o *OperationIDMode) Set(value string) error

func (OperationIDMode) String

func (o OperationIDMode) String() string

type Options

type Options struct {
	// RepeatedPathParameterSeparator determines how repeated fields should be split when used in path segments.
	RepeatedPathParameterSeparator descriptor.PathParameterSeparator

	// AllowPatchFeature determines whether to use PATCH feature involving update masks
	// (using using google.protobuf.FieldMask).
	AllowPatchFeature bool

	// IncludeServicesOnly generates OpenAPI output only for bound service endpoints and will omit all unused models.
	IncludeServicesOnly bool

	// OutputMode indicates the mode of OpenAPI output generation, to merge all definitions into one file, per service or
	// per proto file.
	OutputMode OutputMode

	// OperationIDMode determines the mode of operation IDs that get generated.
	OperationIDMode OperationIDMode

	// OutputFileName is the OpenAPI output file name after merging all files.
	// Only applicable when output mode is "merge".
	OutputFileName string

	// OutputFormat is the resulting OpenAPI format.
	OutputFormat OutputFormat

	// FieldNameMode determines what naming convention the fields in the OpenAPI schemas get.
	FieldNameMode FieldNameMode

	// IncludePackageInTags includes the fully qualified service name (FQSN) in the tags of each operation.
	IncludePackageInTags bool

	// DisableServiceTags disables generation of service tags in OpenAPI, useful to avoid exposing gRPC services.
	DisableServiceTags bool

	// SchemaNamingStrategy holds the naming strategy for schema names in generated OpenAPI output.
	SchemaNamingStrategy SchemaNamingStrategy

	// UseGoTemplate allows using templates for summary, description, tags and links.
	//
	// TODO: include a link to the context avaialble for the evaluation.
	UseGoTemplate bool

	// GoTemplateArgs are additional template args that can be set. GoTemplate must be enabled in order to utilize this.
	GoTemplateArgs TemplateArgs

	// If set to true, proto doc strings get ignored.
	IgnoreComments bool

	// If set to true, all comment lines that start with (-- and end with --) get excluded.
	RemoveInternalComments bool

	// If set to true, the default error response does not get added to the responses.
	DisableDefaultErrors bool

	// If set to true, the default 200 successful response does not get added to the responses.
	DisableDefaultResponses bool

	// UseEnumNumbers uses numerical value of enums instead of strings.
	UseEnumNumbers bool

	// GlobalOpenAPIConfigFile points to the file that can be used to define global OpenAPI config file.
	GlobalOpenAPIConfigFile string

	// ConfigSearchPath holds the search path to use for looking up OpenAPI configs.
	ConfigSearchPath string

	// LocalPackageMode limits the config files to only targetting objects from their own proto package.
	LocalPackageMode bool

	// OpenAPIConfigFilePattern holds the file pattern for loading OpenAPI config files.
	//
	// This pattern must not include the extension and the priority is yaml, yml and finally json.
	OpenAPIConfigFilePattern string

	// OpenAPISeedFile holds an OpenAPI file in YAML/JSON format that will be used as a seed that will be merged
	// with the generated OpenAPI files.
	OpenAPISeedFile string

	// OmitEnumDefaultValue omits the default/unknown enum value.
	OmitEnumDefaultValue bool

	// VisibilitySelectors are a list of visibility selectors.
	VisibilitySelectors SelectorMap

	// MergeWithOverwrite will overwrite lists instead of appending.
	MergeWithOverwrite bool

	// OmitEmptyFiles avoids writing OpenAPI document files if the file does not contain at least one model or path.
	OmitEmptyFiles bool

	// FieldNullableMode configures the generation of nullable fields in the OpenAPI schemas.
	FieldNullableMode FieldNullableMode

	// FieldRequiredMode configures the generation of required field in the OpenAPI schemas.
	FieldRequiredMode FieldRequiredMode

	// WarnOnBrokenSelectors writes a warning instead of reporting errors when selectors to unmatching proto types is
	// used in config files.
	WarnOnBrokenSelectors bool
}

Options are the options for the code generator.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns the default options.

type OutputFormat

type OutputFormat uint8
const (
	OutputFormatJSON OutputFormat = iota
	OutputFormatYAML
)

func (*OutputFormat) Set

func (o *OutputFormat) Set(value string) error

func (OutputFormat) String

func (o OutputFormat) String() string

type OutputMode

type OutputMode uint8
const (
	OutputModePerService OutputMode = iota
	OutputModePerProtoFile
	OutputModeMerge
)

func (*OutputMode) Set

func (o *OutputMode) Set(value string) error

func (OutputMode) String

func (o OutputMode) String() string

type SchemaNamingStrategy

type SchemaNamingStrategy uint8
const (
	SchemaNamingStrategySimple SchemaNamingStrategy = iota
	SchemaNamingStrategyFQN
	SchemaNamingStrategySimpleWithVersion
)

func (*SchemaNamingStrategy) Set

func (s *SchemaNamingStrategy) Set(value string) error

func (SchemaNamingStrategy) String

func (s SchemaNamingStrategy) String() string

type SelectorMap

type SelectorMap map[string]bool

func (*SelectorMap) Set

func (s *SelectorMap) Set(value string) error

func (SelectorMap) String

func (s SelectorMap) String() string

type Session

type Session struct {
	*Generator
	Document *openapiv3.Document
	// contains filtered or unexported fields
}

type TemplateArg

type TemplateArg struct {
	Key   string
	Value string
}

func (*TemplateArg) Set

func (t *TemplateArg) Set(value string) error

func (TemplateArg) String

func (t TemplateArg) String() string

type TemplateArgs

type TemplateArgs []TemplateArg

func (*TemplateArgs) Set

func (t *TemplateArgs) Set(value string) error

func (TemplateArgs) String

func (t TemplateArgs) String() string

Directories

Path Synopsis
Package openapimap provides code to map openapi config from the proto messages to openapiv3 types.
Package openapimap provides code to map openapi config from the proto messages to openapiv3 types.
Package pathfilter provides a trie-like structure that allows marking fields that are selected or contain children that are selected.
Package pathfilter provides a trie-like structure that allows marking fields that are selected or contain children that are selected.

Jump to

Keyboard shortcuts

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