ir

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package ir is the version-agnostic intermediate representation used by codegen.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildStruct

func BuildStruct(goName string, schema map[string]any) (Struct, []Enum, error)

BuildStruct converts a JSON Schema object into an IR Struct plus any enums it declares inline. Enum names are derived from the field's Go name.

func BuildStructTree

func BuildStructTree(rootName string, schema map[string]any) ([]Struct, []Enum, error)

BuildStructTree converts a schema and all nested object types into a flat list of Structs, with the root struct first, plus all inline enums.

Types

type Enum

type Enum struct {
	GoName string
	Values []string // wire values
}

Enum is a named string enum with allowed values.

type Field

type Field struct {
	GoName    string // exported Go field name
	JSONName  string // wire name
	Type      Kind
	ElemType  Kind   // for TypeSlice
	EnumName  string // for TypeEnumRef
	StructRef string // for TypeStructRef
	Required  bool
	MaxLength int // 0 = none
}

Field is one property of a message or nested struct.

func (Field) GoType

func (f Field) GoType() string

GoType renders the Go type expression for this field.

type File

type File struct {
	Version  string // "v16"
	Package  string // "messages"
	Structs  []Struct
	Enums    []Enum
	Messages []Message
}

File is the full IR for one version, ready to render.

type Kind

type Kind int

Kind enumerates the scalar/composite kinds the generator understands.

const (
	TypeString Kind = iota
	TypeInt32
	TypeInt64
	TypeNumber // decimal
	TypeBool
	TypeDateTime
	TypeEnumRef
	TypeStructRef
	TypeSlice
	TypeMap
)

type Message

type Message struct {
	Action         string
	Direction      string // "SentByCP" or "SentByCSMS"
	Request        string // request struct GoName
	Response       string // response struct GoName ("" for SEND)
	RequestSchema  string // request schema filename
	ResponseSchema string // response schema filename ("" for SEND)
	IsSend         bool   // OCPP 2.1 SEND: unconfirmed, no response
}

Message binds a request/response struct pair to an action and direction.

type Struct

type Struct struct {
	GoName string
	Fields []Field
}

Struct is a generated message or nested object.

Jump to

Keyboard shortcuts

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