v3

package
v0.0.62 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: Apache-2.0 Imports: 31 Imported by: 7

Documentation

Index

Constants

View Source
const CHAR_WIDTH = 8
View Source
const DefaultSchemaWorkQueueSize = 5000

DefaultSchemaWorkQueueSize is the buffer size for pending schema walks. Set to 5000 to handle enterprise-scale OpenAPI specs out of the box.

View Source
const DefaultWalkWorkQueueSize = 5000

DefaultWalkWorkQueueSize is the buffer size for pending walk operations. Set to 5000 to handle enterprise-scale OpenAPI specs out of the box.

View Source
const HEIGHT = 25
View Source
const MAX_WIDTH = 700
View Source
const MIN_WIDTH = 150
View Source
const WIDTH = 200

Variables

This section is empty.

Functions

func AddChunkDefaultHeight

func AddChunkDefaultHeight(element any, height int) int

func BuildReference

func BuildReference(ctx *DrContext, ref low.IsReferenced)

func CompareByParentPosition

func CompareByParentPosition(a, b Foundational) bool

CompareByParentPosition returns true if a's parent comes before b's parent in document order (lower line, or same line with lower column). This is used to ensure a deterministic schema collection when the same schema is encountered via multiple concurrent paths (e.g., via anyOf/oneOf refs). A nil parent (definition site) is always considered canonical.

func CopyRuleResultsByNodeID added in v0.0.61

func CopyRuleResultsByNodeID(source, target []*Node)

CopyRuleResultsByNodeID copies owned rule results from matching source nodes to target nodes. Aggregate results forwarded to roots are skipped; adding a copied child result may still forward the aggregate copy through normal Foundation behavior.

func DefaultSchemaWorkers

func DefaultSchemaWorkers() int

DefaultSchemaWorkers returns the number of concurrent schema walkers. Scales with available CPU cores for optimal performance.

func DefaultWalkWorkers

func DefaultWalkWorkers() int

DefaultWalkWorkers returns the number of concurrent walk workers. Scales with available CPU cores for optimal performance.

func ExtractKeyNodeForLowModel

func ExtractKeyNodeForLowModel(obj any) *yaml.Node

func ExtractParameterValues added in v0.0.50

func ExtractParameterValues(params []*Parameter) []*v3.Parameter

ExtractParameterValues extracts the underlying libopenapi Parameter values from a slice of doctor Parameter wrappers, preserving order and nil entries.

func ExtractValueNodeForLowModel

func ExtractValueNodeForLowModel(obj any) *yaml.Node

func ParseSchemaSize

func ParseSchemaSize(schema *base.Schema) (height, width int)

func RefToJSONPath added in v0.0.50

func RefToJSONPath(ref string) string

RefToJSONPath converts a JSON Reference string to a JSONPath node ID. e.g., "#/components/headers/RateLimit" -> "$.components.headers['RateLimit']" Handles JSON Pointer escapes (~0 -> ~, ~1 -> /) and external refs (file.yaml#/...).

func ReleaseEdge

func ReleaseEdge(e *Edge)

ReleaseEdge returns an edge to the pool for reuse

func ReleaseNode

func ReleaseNode(n *Node)

ReleaseNode returns a node to the pool for reuse

func RuleResultOwnedByNode added in v0.0.61

func RuleResultOwnedByNode(result *RuleFunctionResult, node *Node) bool

RuleResultOwnedByNode reports whether a result belongs directly to the node, excluding copies forwarded to aggregate/root receivers.

func SourceFileForFoundational added in v0.0.61

func SourceFileForFoundational(candidate Foundational) string

SourceFileForFoundational returns the absolute spec path for a Doctor object when its underlying low model carries an index.

Types

type AcceptsRuleResults

type AcceptsRuleResults interface {
	AddRuleFunctionResult(result *RuleFunctionResult)
	GetRuleFunctionResults() []*RuleFunctionResult
}

type BuildError

type BuildError struct {
	Error         error
	SchemaProxy   *base.SchemaProxy
	DrSchemaProxy *SchemaProxy
}

type Callback

type Callback struct {
	Value      *v3.Callback
	Expression *orderedmap.Map[string, *PathItem]
	Foundation
}

func (*Callback) GetSize

func (c *Callback) GetSize() (height, width int)

func (*Callback) GetValue

func (c *Callback) GetValue() any

func (*Callback) Travel

func (c *Callback) Travel(ctx context.Context, traveller Tardis)

func (*Callback) Walk

func (c *Callback) Walk(ctx context.Context, callback *v3.Callback)

type ChangeSummary added in v0.0.50

type ChangeSummary struct {
	Additions     int `json:"additions"`
	Modifications int `json:"modifications"`
	Removals      int `json:"removals"`
	Breaking      int `json:"breaking"`
	Total         int `json:"total"`
}

ChangeSummary holds aggregated change counts for a node's subtree.

type ChildChangeSummary added in v0.0.50

type ChildChangeSummary struct {
	Label   string         `json:"label"`
	Type    string         `json:"type"`
	IdHash  string         `json:"idHash"`
	NodeId  string         `json:"nodeId"`
	Changes *ChangeSummary `json:"changes"`
}

ChildChangeSummary represents one child row in change-view rendering. Go field "ChildChangeSummaries" serializes as JSON "childChanges" via MarshalJSON.

type Companion

type Companion interface {
	Travel(ctx context.Context, tardis Tardis)
}

Companion is implemented by any visitable object. It allows the tardis to travel through it. The secret to the doctor, is his companion.

type Components

type Components struct {
	Value           *v3.Components
	Schemas         *orderedmap.Map[string, *SchemaProxy]
	Responses       *orderedmap.Map[string, *Response]
	Parameters      *orderedmap.Map[string, *Parameter]
	Examples        *orderedmap.Map[string, *Example]
	RequestBodies   *orderedmap.Map[string, *RequestBody]
	Headers         *orderedmap.Map[string, *Header]
	SecuritySchemes *orderedmap.Map[string, *SecurityScheme]
	Links           *orderedmap.Map[string, *Link]
	Callbacks       *orderedmap.Map[string, *Callback]
	PathItems       *orderedmap.Map[string, *PathItem]
	Foundation
}

func (*Components) GetSize

func (c *Components) GetSize() (height, width int)

func (*Components) GetValue

func (c *Components) GetValue() any

func (*Components) Travel

func (c *Components) Travel(ctx context.Context, tardis Tardis)

func (*Components) Walk

func (c *Components) Walk(ctx context.Context, components *v3.Components)

type Contact

type Contact struct {
	Value *base.Contact `json:"contact,omitempty" yaml:"contact,omitempty"`
	Foundation
}

func (*Contact) GetSize

func (c *Contact) GetSize() (height, width int)

func (*Contact) GetValue

func (c *Contact) GetValue() any

func (*Contact) Travel

func (c *Contact) Travel(ctx context.Context, traveler Tardis)

func (*Contact) Walk

func (c *Contact) Walk(ctx context.Context, contact *base.Contact)

type ContextKey

type ContextKey string
const Context ContextKey = "context"

type Discriminator

type Discriminator struct {
	Value *base.Discriminator
	Foundation
}

func (*Discriminator) GetValue

func (d *Discriminator) GetValue() any

type Doctor

type Doctor interface {
	LocateModelsByKeyAndValue(key, value *yaml.Node) ([]Foundational, error)
	LocateModel(node *yaml.Node) ([]Foundational, error)
	LocateModelByLine(line int) ([]Foundational, error)
}

Doctor who?

type Document

type Document struct {
	Document     *v3.Document
	Info         *Info
	Servers      []*Server
	Paths        *Paths
	Components   *Components
	Security     []*SecurityRequirement
	Tags         []*Tag
	ExternalDocs *ExternalDoc
	Webhooks     *orderedmap.Map[string, *PathItem]
	Foundation
}

func (*Document) GetSize

func (d *Document) GetSize() (height, width int)

func (*Document) GetValue

func (d *Document) GetValue() any

GetValue returns a pointer to its self, because it is the root and it is the value

func (*Document) Travel

func (d *Document) Travel(ctx context.Context, traveller Tardis)

func (*Document) Walk

func (d *Document) Walk(ctx context.Context, doc *v3.Document)

type DrContext

type DrContext struct {
	SchemaChan         chan *WalkedSchema
	ObjectChan         chan any
	SkippedSchemaChan  chan *WalkedSchema
	ParameterChan      chan *WalkedParam
	HeaderChan         chan *WalkedHeader
	MediaTypeChan      chan *WalkedMediaType
	ErrorChan          chan *BuildError
	NodeChan           chan *Node
	EdgeChan           chan *Edge
	Index              *index.SpecIndex
	Rolodex            *index.Rolodex
	V3Document         *v3.Document
	BuildGraph         bool
	RenderChanges      bool
	UseSchemaCache     bool
	SyncWalk           bool            // When true, walk everything synchronously (no goroutines)
	PooledWalk         bool            // When true, use bounded worker pools (default)
	SchemaPool         *SchemaWalkPool // Bounded worker pool for schema walks
	WalkPool           *WalkPool       // General bounded worker pool for all walk operations
	DeterministicPaths bool            // When true, component objects return definition-site paths
	SchemaCache        *sync.Map
	CanonicalPathCache *sync.Map // Maps *yaml.Node pointer -> canonical JSONPath (definition site)
	StringCache        *sync.Map // String interning for common strings
	StorageRoot        string
	WorkingDirectory   string
	Logger             *slog.Logger
}

func GetDrContext

func GetDrContext(ctx context.Context) *DrContext

func (*DrContext) BuildRefEdgeByLine

func (d *DrContext) BuildRefEdgeByLine(ctx context.Context, source *Foundation, ref string) bool

BuildRefEdgeByLine creates a reference edge from source node to a component definition using the component's canonical JSONPath as target identifier. Returns true if edge was created successfully.

func (*DrContext) RunWalk

func (d *DrContext) RunWalk(f func())

RunWalk submits work to the bounded a WalkPool or runs synchronously if SyncWalk is true. The pool automatically falls back to synchronous execution if the queue is full.

func (*DrContext) SubmitSchemaWalk

func (d *DrContext) SubmitSchemaWalk(ctx context.Context, sch *SchemaProxy, baseSchema *base.SchemaProxy, depth int)

SubmitSchemaWalk submits a schema walk to the SchemaPool, or runs synchronously.

func (*DrContext) WaitForCompletion

func (d *DrContext) WaitForCompletion()

WaitForCompletion blocks until all submitted walk operations have completed. In pooled mode, this waits for both WalkPool and SchemaPool to drain. In sync mode, this is a no-op (work already completed inline).

func (*DrContext) WalkContextForRef

func (d *DrContext) WalkContextForRef(ctx context.Context, isRef bool) context.Context

WalkContextForRef returns a context suitable for walking a $ref object. When DeterministicPaths is enabled and not rendering changes, BuildGraph is disabled to prevent creating duplicate nodes. The component definition creates the canonical node; reference usages only need edges.

type DynamicValue

type DynamicValue[A, R, S, E any] struct {
	Value *base.DynamicValue[A, R]
	A     S
	B     E
	Foundation
}

func (*DynamicValue[A, R, S, E]) GetValue

func (d *DynamicValue[A, R, S, E]) GetValue() any

func (*DynamicValue[A, R, S, E]) Walk

func (d *DynamicValue[A, R, S, E]) Walk(ctx context.Context)

type Edge

type Edge struct {
	Id      string   `json:"id"`
	Sources []string `json:"sources"`
	Targets []string `json:"targets"`
	Poly    string   `json:"poly,omitempty"`
	Ref     string   `json:"ref"`
}

func GenerateEdge

func GenerateEdge(sources []string, targets []string) *Edge

type Encoding

type Encoding struct {
	Value   *v3.Encoding
	Headers *orderedmap.Map[string, *Header]
	Foundation
}

func (*Encoding) GetValue

func (e *Encoding) GetValue() any

func (*Encoding) Travel

func (e *Encoding) Travel(ctx context.Context, tardis Tardis)

func (*Encoding) Walk

func (e *Encoding) Walk(ctx context.Context, encoding *v3.Encoding)

type Example

type Example struct {
	Value *base.Example
	Foundation
}

func (*Example) GetValue

func (e *Example) GetValue() any

func (*Example) Travel

func (e *Example) Travel(ctx context.Context, tardis Tardis)

func (*Example) Walk

func (e *Example) Walk(ctx context.Context, example *base.Example)

type ExternalDoc

type ExternalDoc struct {
	Value *base.ExternalDoc
	Foundation
}

func (*ExternalDoc) GetValue

func (ed *ExternalDoc) GetValue() any

func (*ExternalDoc) Travel

func (ed *ExternalDoc) Travel(ctx context.Context, tardis Tardis)

func (*ExternalDoc) Walk

func (ed *ExternalDoc) Walk(ctx context.Context, externalDoc *base.ExternalDoc)

type Foundation

type Foundation struct {
	PathSegment      string
	InstanceType     string
	IsIndexed        bool
	Index            *int
	Key              string
	PolyType         string
	Parent           any
	NodeParent       any
	RuleResults      []*RuleFunctionResult
	JSONPath         string
	Mutex            sync.RWMutex
	PathSegmentMutex sync.RWMutex // Separate mutex for PathSegment
	JSONPathOnce     sync.Once
	Node             *Node
	NodeReference    *Node // if the chain was broken, keep a reference
	Edges            []*Edge
	KeyNode          *yaml.Node
	ValueNode        *yaml.Node
	Changes          []*NodeChange
	CacheSplit       bool
}

func (*Foundation) AddChange

func (f *Foundation) AddChange(change *NodeChange)

func (*Foundation) AddChanges

func (f *Foundation) AddChanges(changes []*NodeChange)

func (*Foundation) AddEdge

func (f *Foundation) AddEdge(edge *Edge)

func (*Foundation) AddRuleFunctionResult

func (f *Foundation) AddRuleFunctionResult(result *RuleFunctionResult)

func (*Foundation) BuildNode

func (f *Foundation) BuildNode(ctx context.Context, label, nodeType string, arrayType bool, arrayCount, arrayIndex int, drModel any) *Node

func (*Foundation) BuildNodesAndEdges

func (f *Foundation) BuildNodesAndEdges(ctx context.Context, label, nodeType string, model high.GoesLowUntyped, drModel any)

func (*Foundation) BuildNodesAndEdgesWithArray

func (f *Foundation) BuildNodesAndEdgesWithArray(ctx context.Context, label, nodeType string, model high.GoesLowUntyped, drModel any, arrayType bool, arrayCount int, arrayIndex *int)

func (*Foundation) BuildReferenceEdge

func (f *Foundation) BuildReferenceEdge(ctx context.Context, source, destination, ref string, poly string) *Edge

func (*Foundation) BuildSchemaNodeAndEdge

func (f *Foundation) BuildSchemaNodeAndEdge(ctx context.Context, label string, model high.GoesLowUntyped, drModel any)

func (*Foundation) GenerateJSONPath

func (f *Foundation) GenerateJSONPath() string

func (*Foundation) GenerateJSONPathWithLevel

func (f *Foundation) GenerateJSONPathWithLevel(level int) string

func (*Foundation) GetChanges

func (f *Foundation) GetChanges() []*NodeChange

func (*Foundation) GetEdges

func (f *Foundation) GetEdges() []*Edge

func (*Foundation) GetIndexValue

func (f *Foundation) GetIndexValue() *int

func (*Foundation) GetInstanceType

func (f *Foundation) GetInstanceType() string

func (*Foundation) GetKeyNode

func (f *Foundation) GetKeyNode() *yaml.Node

func (*Foundation) GetKeyValue

func (f *Foundation) GetKeyValue() string

func (*Foundation) GetNode

func (f *Foundation) GetNode() *Node

func (*Foundation) GetNodeParent

func (f *Foundation) GetNodeParent() Foundational

func (*Foundation) GetParent

func (f *Foundation) GetParent() Foundational

func (*Foundation) GetPathSegment

func (f *Foundation) GetPathSegment() string

func (*Foundation) GetRefNode

func (f *Foundation) GetRefNode() *Node

func (*Foundation) GetRoot

func (f *Foundation) GetRoot() Foundational

func (*Foundation) GetRuleFunctionResults

func (f *Foundation) GetRuleFunctionResults() []*RuleFunctionResult

func (*Foundation) GetSize added in v0.0.50

func (f *Foundation) GetSize() (height, width int)

func (*Foundation) GetValueNode

func (f *Foundation) GetValueNode() *yaml.Node

func (*Foundation) ProcessNodesAndEdges

func (f *Foundation) ProcessNodesAndEdges(ctx context.Context, label, nodeType string, model high.GoesLowUntyped, drModel any, arrayType bool, arrayCount int, arrayIndex *int, schema bool)

func (*Foundation) SetInstanceType

func (f *Foundation) SetInstanceType(instanceType string)

func (*Foundation) SetNode

func (f *Foundation) SetNode(node *Node)

func (*Foundation) SetPathSegment

func (f *Foundation) SetPathSegment(segment string)

func (*Foundation) SetRefNode

func (f *Foundation) SetRefNode(node *Node)

type Foundational

type Foundational interface {
	GetParent() Foundational
	GetNodeParent() Foundational
	GetPathSegment() string
	GetKeyValue() string
	GetIndexValue() *int
	GenerateJSONPath() string
	GenerateJSONPathWithLevel(level int) string
	GetRoot() Foundational
	SetNode(node *Node)
	AddEdge(edge *Edge)
	GetNode() *Node
	GetRefNode() *Node
	GetEdges() []*Edge
	GetKeyNode() *yaml.Node
	GetValueNode() *yaml.Node
	GetInstanceType() string
	SetInstanceType(instanceType string)
	GetChanges() []*NodeChange
	AddChanges(changes []*NodeChange)
	AddChange(changes *NodeChange)
}

Foundational is the base interface for all models in the doctor. It provides a way to navigate the model

type HasIndex

type HasIndex interface {
	GetIndex() *index.SpecIndex
}

type HasSize

type HasSize interface {
	GetSize() (height, width int)
}

type HasValue

type HasValue interface {
	GetValue() any
}
type Header struct {
	Value    *v3.Header
	Schema   *SchemaProxy
	Examples *orderedmap.Map[string, *Example]
	Content  *orderedmap.Map[string, *MediaType]
	Foundation
}

func (*Header) GetSize

func (h *Header) GetSize() (height, width int)

func (*Header) GetValue

func (h *Header) GetValue() any

func (*Header) Travel

func (h *Header) Travel(ctx context.Context, tardis Tardis)

func (*Header) Walk

func (h *Header) Walk(ctx context.Context, header *v3.Header)

type Info

type Info struct {
	Value   *base.Info
	Contact *Contact
	License *License
	Foundation
}

func (*Info) GetSize

func (i *Info) GetSize() (height, width int)

func (*Info) GetValue

func (i *Info) GetValue() any

func (*Info) Travel

func (i *Info) Travel(ctx context.Context, traveller Tardis)

func (*Info) Walk

func (i *Info) Walk(ctx context.Context, info *base.Info)

type IsObjectReference

type IsObjectReference interface {
	IsReference() bool
	GetReference() string
	GetReferenceNode() *yaml.Node
}

type License

type License struct {
	Value *base.License
	Foundation
}

func (*License) GetSize

func (l *License) GetSize() (height, width int)

func (*License) GetValue

func (l *License) GetValue() any

func (*License) Travel

func (l *License) Travel(ctx context.Context, traveller Tardis)

func (*License) Walk

func (l *License) Walk(ctx context.Context, license *base.License)
type Link struct {
	Value  *v3.Link
	Server *Server
	Foundation
}

func (*Link) GetSize

func (l *Link) GetSize() (height, width int)

func (*Link) GetValue

func (l *Link) GetValue() any

func (*Link) Travel

func (l *Link) Travel(ctx context.Context, tardis Tardis)

func (*Link) Walk

func (l *Link) Walk(ctx context.Context, link *v3.Link)

type MediaType

type MediaType struct {
	Value       *v3.MediaType
	SchemaProxy *SchemaProxy
	Examples    *orderedmap.Map[string, *Example]
	Encoding    *orderedmap.Map[string, *Encoding]
	Foundation
}

func (*MediaType) GetSize

func (m *MediaType) GetSize() (height, width int)

func (*MediaType) GetValue

func (m *MediaType) GetValue() any

func (*MediaType) Travel

func (m *MediaType) Travel(ctx context.Context, tardis Tardis)

func (*MediaType) Walk

func (m *MediaType) Walk(ctx context.Context, mediaType *v3.MediaType)

type Node

type Node struct {
	Value                *yaml.Node             `json:"-"`
	Id                   string                 `json:"id"`
	IdHash               string                 `json:"idHash,omitempty"`
	ParentId             string                 `json:"parentId"`
	Type                 string                 `json:"type"`
	Label                string                 `json:"label"`
	Width                int                    `json:"width"`
	Height               int                    `json:"height"`
	Children             []*Node                `json:"nodes,omitempty"`
	IsArray              bool                   `json:"isArray,omitempty"`
	IsPoly               bool                   `json:"isPoly,omitempty"`
	PolyType             string                 `json:"polyType,omitempty"`
	PropertyCount        int                    `json:"propertyCount,omitempty"`
	ArrayIndex           int                    `json:"arrayIndex,omitempty"`
	ArrayValues          int                    `json:"arrayValues,omitempty"`
	Extensions           int                    `json:"extensions,omitempty"`
	Hash                 string                 `json:"hash,omitempty"`
	OriginLocation       string                 `json:"originLocation,omitempty"`
	Origin               *index.NodeOrigin      `json:"nodeOrigin,omitempty"`
	KeyLine              int                    `json:"-"`
	ValueLine            int                    `json:"valueLine"`
	Instance             any                    `json:"instance"`
	DrInstance           any                    `json:"-"`
	Changes              []what_changed.Changed `json:"-"`
	RenderedChanges      []*model.Change        `json:"timeline,omitempty"`
	CleanedChanged       []*model.Change        `json:"cleanedChanges,omitempty"`
	SubtreeChanges       *ChangeSummary         `json:"-"`
	ChildChangeSummaries []*ChildChangeSummary  `json:"-"`
	RenderProps          bool                   `json:"-"`
	RenderChanges        bool                   `json:"-"`
	RenderProblems       bool                   `json:"-"`
	RenderProblemsAsIds  bool                   `json:"-"` // modified design to stop embedding violations in nodes, uses lookup now.
	ViolationIdMap       map[string]string      `json:"-"`
	Mutex                sync.RWMutex           `json:"-"`
	// contains filtered or unexported fields
}

func GenerateNode

func GenerateNode(parentId string, instance any, drModel any, ctx *DrContext) *Node

func NewSyntheticNode added in v0.0.50

func NewSyntheticNode(id, parentId, label, nodeType string) *Node

NewSyntheticNode creates a minimal Node for use outside the normal model walk. It is sufficient for tree/explorer rendering and the report path, but does not participate in ELK layout, edges, or object channel emission.

func (*Node) AppendChange

func (n *Node) AppendChange(change what_changed.Changed)

func (*Node) GetChanges

func (n *Node) GetChanges() []what_changed.Changed

Node methods for thread-safe access to Changes field

func (*Node) GetInstance

func (n *Node) GetInstance() any

func (*Node) MarshalJSON

func (n *Node) MarshalJSON() ([]byte, error)

func (*Node) SetInstance

func (n *Node) SetInstance(instance any)

type NodeChange

type NodeChange struct {
	Id         string               `json:"id,omitempty"`
	IdHash     string               `json:"idHash,omitempty"`
	Type       string               `json:"type,omitempty"`
	Label      string               `json:"label,omitempty"`
	Path       string               `json:"path,omitempty"`
	Children   []*Node              `json:"nodes,omitempty"`
	ArrayIndex int                  `json:"arrayIndex,omitempty"`
	Changes    what_changed.Changed `json:"timeline,omitempty"`
	Mutex      sync.RWMutex         `json:"-"`
}

func (*NodeChange) GetAllChanges

func (n *NodeChange) GetAllChanges() []*model.Change

func (*NodeChange) GetHash

func (n *NodeChange) GetHash() string

func (*NodeChange) GetLabel

func (n *NodeChange) GetLabel() string

func (*NodeChange) GetPath

func (n *NodeChange) GetPath() string

func (*NodeChange) GetPropertyChanges

func (n *NodeChange) GetPropertyChanges() []*model.Change

func (*NodeChange) GetType

func (n *NodeChange) GetType() string

func (*NodeChange) PropertiesOnly

func (n *NodeChange) PropertiesOnly()

func (*NodeChange) SetChanges

func (n *NodeChange) SetChanges(changes what_changed.Changed)

func (*NodeChange) TotalBreakingChanges

func (n *NodeChange) TotalBreakingChanges() int

func (*NodeChange) TotalChanges

func (n *NodeChange) TotalChanges() int

type NodeChangeable

type NodeChangeable interface {
	GetType() string
	GetLabel() string
	GetHash() string
	GetPath() string
}

type OAuthFlow

type OAuthFlow struct {
	Value *v3.OAuthFlow
	Foundation
}

func (*OAuthFlow) GetValue

func (o *OAuthFlow) GetValue() any

func (*OAuthFlow) Travel

func (o *OAuthFlow) Travel(ctx context.Context, tardis Tardis)

func (*OAuthFlow) Walk added in v0.0.50

func (o *OAuthFlow) Walk(ctx context.Context, flow *v3.OAuthFlow)

type OAuthFlows

type OAuthFlows struct {
	Value             *v3.OAuthFlows
	Implicit          *OAuthFlow
	Password          *OAuthFlow
	ClientCredentials *OAuthFlow
	AuthorizationCode *OAuthFlow
	Device            *OAuthFlow
	Foundation
}

func (*OAuthFlows) GetValue

func (o *OAuthFlows) GetValue() any

func (*OAuthFlows) Travel

func (o *OAuthFlows) Travel(ctx context.Context, tardis Tardis)

func (*OAuthFlows) Walk

func (o *OAuthFlows) Walk(ctx context.Context, flows *v3.OAuthFlows)

type ObjectReference

type ObjectReference struct {
	Reference string
	Node      *yaml.Node
	Foundation
}

func (*ObjectReference) GetNodes

func (r *ObjectReference) GetNodes() map[int][]*yaml.Node

func (*ObjectReference) GetReference

func (r *ObjectReference) GetReference() string

func (*ObjectReference) GetReferenceNode

func (r *ObjectReference) GetReferenceNode() *yaml.Node

func (*ObjectReference) GetValue

func (r *ObjectReference) GetValue() any

func (*ObjectReference) GoLowUntyped

func (r *ObjectReference) GoLowUntyped() any

func (*ObjectReference) IsReference

func (r *ObjectReference) IsReference() bool

type Operation

type Operation struct {
	Value        *v3.Operation
	ExternalDocs *ExternalDoc
	Parameters   []*Parameter
	RequestBody  *RequestBody
	Responses    *Responses
	Callbacks    *orderedmap.Map[string, *Callback]
	Security     []*SecurityRequirement
	Servers      []*Server
	Tags         *Foundation
	Foundation
}

func (*Operation) GetSize

func (o *Operation) GetSize() (height, width int)

func (*Operation) GetValue

func (o *Operation) GetValue() any

func (*Operation) Travel

func (o *Operation) Travel(ctx context.Context, tardis Tardis)

func (*Operation) Walk

func (o *Operation) Walk(ctx context.Context, operation *v3.Operation)

type Parameter

type Parameter struct {
	Value       *v3.Parameter
	SchemaProxy *SchemaProxy
	Examples    *orderedmap.Map[string, *Example]
	Content     *orderedmap.Map[string, *MediaType]
	Foundation
}

func (*Parameter) GetSize

func (p *Parameter) GetSize() (height, width int)

func (*Parameter) GetValue

func (p *Parameter) GetValue() any

func (*Parameter) Travel

func (p *Parameter) Travel(ctx context.Context, tardis Tardis)

func (*Parameter) Walk

func (p *Parameter) Walk(ctx context.Context, param *v3.Parameter)

type PathItem

type PathItem struct {
	Value      *v3.PathItem
	Get        *Operation
	Put        *Operation
	Post       *Operation
	Delete     *Operation
	Options    *Operation
	Head       *Operation
	Patch      *Operation
	Trace      *Operation
	Servers    []*Server
	Parameters []*Parameter
	Foundation
}

func (*PathItem) GetOperations

func (p *PathItem) GetOperations() *orderedmap.Map[string, *Operation]

func (*PathItem) GetSize

func (p *PathItem) GetSize() (height, width int)

func (*PathItem) GetValue

func (p *PathItem) GetValue() any

func (*PathItem) Travel

func (p *PathItem) Travel(ctx context.Context, tardis Tardis)

func (*PathItem) Walk

func (p *PathItem) Walk(ctx context.Context, pathItem *v3.PathItem)

type Paths

type Paths struct {
	Value     *v3.Paths
	PathItems *orderedmap.Map[string, *PathItem]
	Foundation
}

func (*Paths) GetSize

func (p *Paths) GetSize() (height, width int)

func (*Paths) GetValue

func (p *Paths) GetValue() any

func (*Paths) Travel

func (p *Paths) Travel(ctx context.Context, tardis Tardis)

func (*Paths) Walk

func (p *Paths) Walk(ctx context.Context, paths *v3.Paths)

type RequestBody

type RequestBody struct {
	Value   *v3.RequestBody
	Content *orderedmap.Map[string, *MediaType]
	Foundation
}

func (*RequestBody) GetSize

func (r *RequestBody) GetSize() (height, width int)

func (*RequestBody) GetValue

func (r *RequestBody) GetValue() any

func (*RequestBody) Travel

func (r *RequestBody) Travel(ctx context.Context, tardis Tardis)

func (*RequestBody) Walk

func (r *RequestBody) Walk(ctx context.Context, requestBody *v3.RequestBody)

type Response

type Response struct {
	Value   *v3.Response
	Headers *orderedmap.Map[string, *Header]
	Content *orderedmap.Map[string, *MediaType]
	Links   *orderedmap.Map[string, *Link]
	Foundation
}

func (*Response) GetSize

func (r *Response) GetSize() (height, width int)

func (*Response) GetValue

func (r *Response) GetValue() any

func (*Response) Travel

func (r *Response) Travel(ctx context.Context, tardis Tardis)

func (*Response) Walk

func (r *Response) Walk(ctx context.Context, response *v3.Response)

type Responses

type Responses struct {
	Value   *v3.Responses
	Codes   *orderedmap.Map[string, *Response]
	Default *Response
	Foundation
}

func (*Responses) GetSize

func (r *Responses) GetSize() (height, width int)

func (*Responses) GetValue

func (r *Responses) GetValue() any

func (*Responses) Travel

func (r *Responses) Travel(ctx context.Context, tardis Tardis)

func (*Responses) Walk

func (r *Responses) Walk(ctx context.Context, responses *v3.Responses)

type Rule

type Rule struct {
	Id           string        `json:"id,omitempty" yaml:"id,omitempty"`
	Description  string        `json:"description,omitempty" yaml:"description,omitempty"`
	Message      string        `json:"message,omitempty" yaml:"message,omitempty"`
	Recommended  bool          `json:"recommended,omitempty" yaml:"recommended,omitempty"`
	Type         string        `json:"type,omitempty" yaml:"type,omitempty"`
	Severity     string        `json:"severity,omitempty" yaml:"severity,omitempty"`
	RuleCategory *RuleCategory `json:"category,omitempty" yaml:"category,omitempty"`
	HowToFix     string        `json:"howToFix,omitempty" yaml:"howToFix,omitempty"`
}

Rule is a structure that represents a rule as part of a ruleset.

type RuleCategory

type RuleCategory struct {
	Id          string `json:"id" yaml:"id"`
	Name        string `json:"name" yaml:"name"`
	Description string `json:"description" yaml:"description"`
}

type RuleFunctionResult

type RuleFunctionResult struct {
	Message      string            `json:"message" yaml:"message"`
	Path         string            `json:"path" yaml:"path"`
	RuleId       string            `json:"ruleId" yaml:"ruleId"`
	RuleSeverity string            `json:"ruleSeverity" yaml:"ruleSeverity"`
	Origin       *index.NodeOrigin `json:"origin,omitempty" yaml:"origin,omitempty"`
	Rule         *Rule             `json:"-" yaml:"-"`
	StartNode    *yaml.Node        `json:"-" yaml:"-"`
	EndNode      *yaml.Node        `json:"-" yaml:"-"`
	ParentObject any               `json:"-" yaml:"-"`
}

RuleFunctionResult describes a failure with linting after being run through a rule

func CloneRuleFunctionResultForParent added in v0.0.61

func CloneRuleFunctionResultForParent(result *RuleFunctionResult, parent any) *RuleFunctionResult

CloneRuleFunctionResultForParent makes a shallow copy for a new owner.

func ConvertRuleResult

func ConvertRuleResult(object any) *RuleFunctionResult

type Schema

type Schema struct {
	Name                  string
	Value                 *base.Schema
	Hash                  string
	AllOf                 []*SchemaProxy
	OneOf                 []*SchemaProxy
	AnyOf                 []*SchemaProxy
	PrefixItems           []*SchemaProxy
	Discriminator         *Discriminator
	Contains              *SchemaProxy
	If                    *SchemaProxy
	Else                  *SchemaProxy
	Then                  *SchemaProxy
	DependentSchemas      *orderedmap.Map[string, *SchemaProxy]
	PatternProperties     *orderedmap.Map[string, *SchemaProxy]
	PropertyNames         *SchemaProxy
	UnevaluatedItems      *SchemaProxy
	UnevaluatedProperties *DynamicValue[*base.SchemaProxy, bool, *SchemaProxy, bool]
	Items                 *DynamicValue[*base.SchemaProxy, bool, *SchemaProxy, bool]
	Not                   *SchemaProxy
	Properties            *orderedmap.Map[string, *SchemaProxy]
	AdditionalProperties  *DynamicValue[*base.SchemaProxy, bool, *SchemaProxy, bool]
	XML                   *XML
	ExternalDocs          *ExternalDoc
	Walked                bool
	CacheCloneReady       bool

	Foundation
	// contains filtered or unexported fields
}

func (*Schema) GetSize

func (s *Schema) GetSize() (height, width int)

func (*Schema) GetValue

func (s *Schema) GetValue() any

func (*Schema) Travel

func (s *Schema) Travel(ctx context.Context, tardis Tardis)

func (*Schema) Walk

func (s *Schema) Walk(ctx context.Context, schema *base.Schema, depth int)

type SchemaProxy

type SchemaProxy struct {
	Value  *base.SchemaProxy
	Schema *Schema
	Foundation
}

func (*SchemaProxy) GetValue

func (sp *SchemaProxy) GetValue() any

func (*SchemaProxy) IsCircular

func (sp *SchemaProxy) IsCircular(ctx context.Context) bool

func (*SchemaProxy) Walk

func (sp *SchemaProxy) Walk(ctx context.Context, schemaProxy *base.SchemaProxy, depth int)

type SchemaWalkPool

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

SchemaWalkPool manages bounded concurrent schema walking to prevent goroutine explosion on large OpenAPI specs.

func NewSchemaWalkPool

func NewSchemaWalkPool(ctx context.Context, drCtx *DrContext, workers int) *SchemaWalkPool

NewSchemaWalkPool creates a pool with bounded workers. If workers <= 0, defaults to runtime.NumCPU() (one worker per core).

func (*SchemaWalkPool) DrainAndShutdown

func (p *SchemaWalkPool) DrainAndShutdown()

DrainAndShutdown waits for all work to complete, then shuts down.

func (*SchemaWalkPool) IsIdle

func (p *SchemaWalkPool) IsIdle() bool

IsIdle returns true if the pool has no work in progress.

func (*SchemaWalkPool) Shutdown

func (p *SchemaWalkPool) Shutdown()

Shutdown closes the work channel and waits for all workers to finish.

func (*SchemaWalkPool) Submit

func (p *SchemaWalkPool) Submit(sch *SchemaProxy, baseSchema *base.SchemaProxy, depth int) bool

Submit attempts to queue a schema for async walking. Returns true if queued or already cached/in-progress. Returns false if caller should walk synchronously (queue full or shutdown).

func (*SchemaWalkPool) SubmitOrWalk

func (p *SchemaWalkPool) SubmitOrWalk(sch *SchemaProxy, baseSchema *base.SchemaProxy, depth int)

SubmitOrWalk submits to pool if possible, otherwise walks synchronously.

func (*SchemaWalkPool) WaitForCompletion

func (p *SchemaWalkPool) WaitForCompletion()

WaitForCompletion blocks until all submitted work has completed. Uses sync.Cond for efficient blocking (no polling).

type SchemaWorkItem

type SchemaWorkItem struct {
	Schema     *SchemaProxy
	BaseSchema *base.SchemaProxy
	Depth      int
}

SchemaWorkItem represents a unit of work for schema walking.

type SecurityRequirement

type SecurityRequirement struct {
	Value *base.SecurityRequirement
	Foundation
}

func (*SecurityRequirement) GetValue

func (s *SecurityRequirement) GetValue() any

func (*SecurityRequirement) Travel

func (s *SecurityRequirement) Travel(ctx context.Context, tardis Tardis)

func (*SecurityRequirement) Walk

func (s *SecurityRequirement) Walk(ctx context.Context, securityRequirement *base.SecurityRequirement)

type SecurityScheme

type SecurityScheme struct {
	Value *v3.SecurityScheme
	Flows *OAuthFlows
	Foundation
}

func (*SecurityScheme) GetSize

func (s *SecurityScheme) GetSize() (height, width int)

func (*SecurityScheme) GetValue

func (s *SecurityScheme) GetValue() any

func (*SecurityScheme) Travel

func (s *SecurityScheme) Travel(ctx context.Context, tardis Tardis)

func (*SecurityScheme) Walk

func (s *SecurityScheme) Walk(ctx context.Context, securityScheme *v3.SecurityScheme)

type Server

type Server struct {
	Value     *v3.Server
	Variables *orderedmap.Map[string, *ServerVariable]
	Foundation
}

func (*Server) GetSize

func (s *Server) GetSize() (height, width int)

func (*Server) GetValue

func (s *Server) GetValue() any

func (*Server) Travel

func (s *Server) Travel(ctx context.Context, traveler Tardis)

func (*Server) Walk

func (s *Server) Walk(ctx context.Context, server *v3.Server)

type ServerVariable

type ServerVariable struct {
	Value *v3.ServerVariable
	Foundation
}

func (*ServerVariable) GetValue

func (sv *ServerVariable) GetValue() any

func (*ServerVariable) Travel

func (sv *ServerVariable) Travel(ctx context.Context, traveler Tardis)

func (*ServerVariable) Walk

func (sv *ServerVariable) Walk(ctx context.Context, serverVariable *v3.ServerVariable, key string)

type Tag

type Tag struct {
	Value        *libopenapibase.Tag
	ExternalDocs *ExternalDoc
	Foundation
}

func (*Tag) GetSize

func (t *Tag) GetSize() (height, width int)

func (*Tag) GetValue

func (t *Tag) GetValue() any

func (*Tag) Travel

func (t *Tag) Travel(ctx context.Context, tardis Tardis)

func (*Tag) Walk

func (t *Tag) Walk(ctx context.Context, tag *libopenapibase.Tag)

type Tardis

type Tardis interface {

	// Visit visit any object that implements the Companion interface
	Visit(ctx context.Context, object any)

	// GetDoctor will call the doctor, are you ready for him is the question.
	GetDoctor() Doctor
}

Tardis is a visitor pattern interface. Used in combination with Companion

type WalkPool

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

WalkPool is a bounded worker pool for executing walk operations. This prevents goroutine explosion when processing large OpenAPI specs by limiting the number of concurrent walkers to a fixed pool size.

func NewWalkPool

func NewWalkPool(workers int) *WalkPool

NewWalkPool creates a bounded pool with the specified number of workers. If workers <= 0, defaults to runtime.NumCPU() (one worker per core).

func (*WalkPool) DrainAndShutdown

func (p *WalkPool) DrainAndShutdown()

DrainAndShutdown waits for all work to complete, then shuts down.

func (*WalkPool) InFlight

func (p *WalkPool) InFlight() int64

InFlight returns the current number of work items being processed or queued.

func (*WalkPool) IsIdle

func (p *WalkPool) IsIdle() bool

IsIdle returns true if the pool has no work in progress.

func (*WalkPool) QueueLen

func (p *WalkPool) QueueLen() int

QueueLen returns the current number of pending work items.

func (*WalkPool) Shutdown

func (p *WalkPool) Shutdown()

Shutdown closes the work channel and waits for all workers to finish.

func (*WalkPool) Submit

func (p *WalkPool) Submit(fn func()) bool

Submit attempts to queue a function for async execution. Returns true if queued successfully. Returns false if the queue is full or pool is shutting down (caller should run sync).

func (*WalkPool) SubmitOrRun

func (p *WalkPool) SubmitOrRun(fn func())

SubmitOrRun submits to the pool if possible, otherwise runs synchronously.

func (*WalkPool) WaitForCompletion

func (p *WalkPool) WaitForCompletion()

WaitForCompletion blocks until all submitted work has completed. Uses sync.Cond for efficient blocking (no polling).

func (*WalkPool) Workers

func (p *WalkPool) Workers() int

Workers returns the number of workers in the pool.

type Walkable

type Walkable interface {
	Walk(context.Context, *base.SchemaProxy)
}

type WalkedHeader

type WalkedHeader struct {
	Header     any
	HeaderNode *yaml.Node
}

type WalkedMediaType

type WalkedMediaType struct {
	MediaType     any
	MediaTypeNode *yaml.Node
}

type WalkedParam

type WalkedParam struct {
	Param     any
	ParamNode *yaml.Node
}

type WalkedSchema

type WalkedSchema struct {
	Schema     *Schema
	SchemaNode *yaml.Node
}

type XML

type XML struct {
	Value *base.XML
	Foundation
}

func (*XML) GetSize

func (x *XML) GetSize() (height, width int)

func (*XML) GetValue

func (x *XML) GetValue() any

func (*XML) Travel

func (x *XML) Travel(ctx context.Context, tardis Tardis)

Jump to

Keyboard shortcuts

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