registry

package
v0.0.0-...-5d89b0e Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Alias      string            // Primary key - unique identifier
	SourceType SourceType        // Origin: "file" or "virtual"
	FilePath   string            // Source file path (empty for virtual specs)
	Checksum   string            // SHA256 hash of spec content
	Spec       *openapi3.T       // The actual spec
	Metadata   map[string]string // Custom metadata
	LoadedAt   time.Time         // When the spec was loaded
}

Entry represents a single OpenAPI specification in the registry.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry manages a collection of OpenAPI specifications in memory.

func New

func New() *Registry

New creates a new empty registry.

func (*Registry) Add

func (r *Registry) Add(alias, filePath string, spec *openapi3.T, metadata map[string]string) error

Add adds or updates a spec entry in the registry. FilePath should be empty string for virtual specs.

Collision detection logic: - Alias must be globally unique (regardless of source type) - File + File with same alias but different path: collision error - File + File with same alias, same path, same checksum: idempotent no-op - File + File with same alias, same path, different checksum: update - Virtual + Virtual with same alias, different checksum: update - Virtual + Virtual with same alias, same checksum: idempotent no-op - File + Virtual or Virtual + File with same alias: collision error.

func (*Registry) Clear

func (r *Registry) Clear()

Clear removes all specs from the registry.

func (*Registry) Count

func (r *Registry) Count() int

Count returns the number of specs in the registry.

func (*Registry) GetByAlias

func (r *Registry) GetByAlias(alias string) (*Entry, error)

GetByAlias retrieves a spec entry by alias. Returns an error if the spec doesn't exist.

func (*Registry) List

func (r *Registry) List() []*Entry

List returns all spec entries in the registry, sorted by LoadedAt descending (most recent first).

func (*Registry) Remove

func (r *Registry) Remove(alias string) error

Remove removes a spec entry from the registry by alias. Returns an error if the spec doesn't exist.

type SourceType

type SourceType string

SourceType represents the origin of a spec entry.

const (
	// SourceTypeFile represents a spec loaded from a file.
	SourceTypeFile SourceType = "file"
	// SourceTypeVirtual represents a spec created by transformations.
	SourceTypeVirtual SourceType = "virtual"
)

Jump to

Keyboard shortcuts

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