schema

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NumOfFieldTypes = 15 // Supported number of field types
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Name        string
	Description string
	Type        FieldType
	Format      string
	Nested      *Message
	IsVariable  bool
}

Field represents a single field within a message.

type FieldType

type FieldType int

FieldType enumerates the supported concrete field types.

const (
	FieldTypeUint64 FieldType = iota
	FieldTypeInt64
	FieldTypeFloat64
	FieldTypeUint32
	FieldTypeInt32
	FieldTypeFloat32
	FieldTypeString // uint32 length prefix in fixed header
	FieldTypeBytes  // uint32 length prefix in fixed header
	FieldTypeObject // uint32 length prefix in fixed header
	FieldTypeArray  // uint32 length prefix in fixed header
	FieldTypeUint16
	FieldTypeInt16
	FieldTypeUint8
	FieldTypeInt8
	FieldTypeBool
)

func (FieldType) Alignment

func (ft FieldType) Alignment() int

Alignment returns the natural alignment requirement for this type.

func (FieldType) CType

func (ft FieldType) CType() string

CType returns the C type string for this field type.

func (FieldType) GoType

func (ft FieldType) GoType() string

GoType returns the Go type string for this field type.

func (FieldType) IsVariable

func (ft FieldType) IsVariable() bool

IsVariable returns true if the field type has variable length.

func (FieldType) Size

func (ft FieldType) Size() int

Size returns the fixed byte size of the field type.

type Message

type Message struct {
	Name       string
	TypeID     uint16
	Fields     []*Field
	Properties map[string]*Field
}

Message represents a single struct/message type.

type Schema

type Schema struct {
	Messages []*Message
}

Schema represents a parsed collection of message types from an OpenAPI spec.

func ParseFile

func ParseFile(path string) (*Schema, error)

ParseFile reads and parses an OpenAPI YAML file, extracting message schemas. It returns a Schema object containing the parsed messages or an error if parsing fails. This function doesn't support array types and will return an error if any schema contains an array property.

Jump to

Keyboard shortcuts

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