proto

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildMessages

func BuildMessages(entries []*parser.SchemaEntry, ctx *Context) (*internal.DependencyGraph, error)

BuildMessages processes all schemas and returns messages and dependency graph

func Generate

func Generate(packageName string, packagePath string, ctx *Context) ([]byte, error)

Generate creates proto3 output from messages and enums in order

func MapScalarType

func MapScalarType(ctx *Context, typ, format string) (string, error)

MapScalarType maps OpenAPI type+format to proto3 scalar type.

func ProtoType

func ProtoType(schema *base.Schema, propertyName string, propProxy *base.SchemaProxy, ctx *Context, parentMsg *ProtoMessage) (string, bool, []string, error)

ProtoType returns the proto3 type for an OpenAPI schema. Returns type name, whether it's repeated, enum values (for string enums), and error. For inline enums and objects, hoists them appropriately in the context. parentMsg is used for nested messages (can be nil for top-level).

func ResolveArrayItemType

func ResolveArrayItemType(schema *base.Schema, propertyName string, propProxy *base.SchemaProxy, ctx *Context, parentMsg *ProtoMessage) (string, []string, error)

ResolveArrayItemType determines the proto3 type for array items. Returns type name, enum values (for string enums), and error. For inline objects/enums: validates property name is not plural.

Types

type Context

type Context struct {
	Tracker       *internal.NameTracker
	Messages      []*ProtoMessage
	Enums         []*ProtoEnum
	Definitions   []interface{} // Mixed enums and messages in processing order
	UsesTimestamp bool
}

Context holds state during conversion

func NewContext

func NewContext() *Context

NewContext creates a new conversion context

type ProtoEnum

type ProtoEnum struct {
	Name        string
	Description string
	Values      []*ProtoEnumValue
}

ProtoEnum represents a proto3 enum definition

type ProtoEnumValue

type ProtoEnumValue struct {
	Name   string
	Number int
}

ProtoEnumValue represents an enum value

type ProtoField

type ProtoField struct {
	Name        string
	Type        string
	Number      int
	JSONName    string
	Description string
	Repeated    bool
	EnumValues  []string
}

ProtoField represents a proto3 field

type ProtoMessage

type ProtoMessage struct {
	Name           string
	Description    string
	Fields         []*ProtoField
	Nested         []*ProtoMessage
	OriginalSchema string // Original schema name before name tracker renaming
}

ProtoMessage represents a proto3 message definition

Jump to

Keyboard shortcuts

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