load

package
v0.0.0-...-584abe6 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package load provides utilities to read the ACP JSON schema and accompanying metadata into minimal structures used by the generator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MergeStableAndUnstable

func MergeStableAndUnstable(stableMeta *Meta, stableSchema *Schema, unstableMeta *Meta, unstableSchema *Schema) (*Meta, *Schema, error)

MergeStableAndUnstable combines stable and unstable schema inputs without mutating either.

The merged output keeps all stable definitions and method maps unchanged, while adding:

  • Unstable-only methods (present only in unstable meta)
  • Unstable-only $defs copied from the unstable schema under an "Unstable" prefix

Unstable-only RPC root types (Request/Response/Notification) are always copied with the Unstable prefix to avoid changing the stable API surface.

Types

type Definition

type Definition struct {
	Description string                 `json:"description"`
	Type        any                    `json:"type"`
	Properties  map[string]*Definition `json:"properties"`
	Required    []string               `json:"required"`
	Enum        []any                  `json:"enum"`
	Items       *Definition            `json:"items"`
	Ref         string                 `json:"$ref"`
	AnyOf       []*Definition          `json:"anyOf"`
	OneOf       []*Definition          `json:"oneOf"`
	AllOf       []*Definition          `json:"allOf"`
	DocsIgnore  bool                   `json:"x-docs-ignore"`
	Title       string                 `json:"title"`
	Const       any                    `json:"const"`
	XSide       string                 `json:"x-side"`
	XMethod     string                 `json:"x-method"`
	// Default holds the JSON Schema default value, when present.
	// Used by generators to synthesize defaulting behavior.
	Default any `json:"default"`
	// Discriminator specifies which property name distinguishes union variants.
	// Part of JSON Schema's discriminator object support.
	Discriminator *Discriminator `json:"discriminator,omitempty"`
	// contains filtered or unexported fields
}

Definition is a partial JSON Schema node the generator cares about.

func (*Definition) UnmarshalJSON

func (d *Definition) UnmarshalJSON(b []byte) error

UnmarshalJSON allows Definition to decode both object and boolean JSON Schema forms.

type Discriminator

type Discriminator struct {
	PropertyName string `json:"propertyName"`
}

Discriminator specifies which property distinguishes union variants. Part of JSON Schema discriminator object support.

type Meta

type Meta struct {
	Version int `json:"version"`

	AgentMethods    map[string]string `json:"agentMethods"`
	ClientMethods   map[string]string `json:"clientMethods"`
	ProtocolMethods map[string]string `json:"protocolMethods,omitempty"`
}

Meta mirrors schema/meta.json for method maps and version.

func ReadMeta

func ReadMeta(schemaDir string) (*Meta, error)

ReadMeta loads schema/meta.json.

func ReadMetaUnstable

func ReadMetaUnstable(schemaDir string) (*Meta, bool, error)

ReadMetaUnstable loads schema/meta.unstable.json when present. The returned boolean indicates whether the file was found.

type Schema

type Schema struct {
	Defs map[string]*Definition `json:"$defs"`
}

Schema is a minimal view over schema/schema.json definitions used by the generator.

func ReadSchema

func ReadSchema(schemaDir string) (*Schema, error)

ReadSchema loads schema/schema.json.

func ReadSchemaUnstable

func ReadSchemaUnstable(schemaDir string) (*Schema, bool, error)

ReadSchemaUnstable loads schema/schema.unstable.json when present. The returned boolean indicates whether the file was found.

Jump to

Keyboard shortcuts

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