model

package
v0.0.48 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ruleify

func Ruleify(left, right *DrDocument)

Ruleify efficiently copies rule results from a left document (contains RuleResults) to a right document (needs RuleResults) by matching nodes and transferring their rule results.

Parameters:

  • left: The source DrDocument containing nodes with RuleResults
  • right: The target DrDocument where RuleResults will be added

The function modifies the right document in-place.

func SanitizeGraph

func SanitizeGraph(nodes []*drV3.Node, santizePaths []string)

Types

type DrConfig

type DrConfig struct {
	BuildGraph         bool
	RenderChanges      bool
	UseSchemaCache     bool
	DeterministicPaths bool // When true, schemas always return their definition-site path
}

type DrDocument

type DrDocument struct {
	BuildErrors    []*drV3.BuildError
	Schemas        []*drV3.Schema
	SkippedSchemas []*drV3.Schema
	Parameters     []*drV3.Parameter
	Headers        []*drV3.Header
	MediaTypes     []*drV3.MediaType
	V3Document     *drV3.Document
	Nodes          []*drV3.Node
	Edges          []*drV3.Edge
	StorageRoot    string
	// contains filtered or unexported fields
}

DrDocument is a turbocharged version of the libopenapi Document model. The doctor provides a much more powerful way to navigate an OpenAPI document.

DrDocument also absorbs results from vacuum rules, and allows them to be attached contextually to the models they represent.

The doctor is the library we wanted all along. The doctor is the library we deserve.

func NewDrDocument

func NewDrDocument(document *libopenapi.DocumentModel[v3.Document]) *DrDocument

NewDrDocument Create a new DrDocument from an OpenAPI v3+ document

func NewDrDocumentAndGraph

func NewDrDocumentAndGraph(document *libopenapi.DocumentModel[v3.Document]) *DrDocument

NewDrDocumentAndGraph Create a new DrDocument from an OpenAPI v3+ document, and create a graph of the model.

func NewDrDocumentWithConfig

func NewDrDocumentWithConfig(document *libopenapi.DocumentModel[v3.Document], config *DrConfig) *DrDocument

NewDrDocumentWithConfig Create a new DrDocument from an OpenAPI v3+ document and a configuration struct

func (*DrDocument) BuildGraphMap

func (w *DrDocument) BuildGraphMap() map[int]string

func (*DrDocument) BuildObjectLocationMap

func (w *DrDocument) BuildObjectLocationMap() map[int]any

BuildObjectLocationMap builds a map of line numbers to models in the document.

func (*DrDocument) GetIndex

func (w *DrDocument) GetIndex() *index.SpecIndex

func (*DrDocument) LocateModel

func (w *DrDocument) LocateModel(node *yaml.Node) ([]drV3.Foundational, error)

LocateModel finds the model represented by the line number of the supplied node.

func (*DrDocument) LocateModelByLine

func (w *DrDocument) LocateModelByLine(line int) ([]drV3.Foundational, error)

LocateModelByLine finds the model represented by the line number of the supplied node.

func (*DrDocument) LocateModelsByKeyAndValue

func (w *DrDocument) LocateModelsByKeyAndValue(key, value *yaml.Node) ([]drV3.Foundational, error)

LocateModelsByKeyAndValue finds the model represented by the line number of the supplied node. This method will locate every model that points to the supplied key and value node. There could be many models that point to the same key and value node, so this method will return a slice of models.

func (*DrDocument) Release added in v0.0.48

func (d *DrDocument) Release()

Release nils all fields that can pin YAML node trees, SpecIndex maps, or libopenapi documents in memory. This includes unexported fields (index, lineObjects) that callers outside this package cannot reach directly. Call this once all serialization work is done with the DrDocument.

type GraphResponse

type GraphResponse struct {
	Nodes          []interface{}              `json:"nodes,omitempty"`
	Edges          []interface{}              `json:"edges,omitempty"`
	NodesRendered  []interface{}              `json:"nodesRendered,omitempty"`
	NodeChangeTree *v3.Node                   `json:"nodeChangeTree,omitempty"`
	Changes        []*whatChangedModel.Change `json:"changes,omitempty"`
	GraphMap       map[int]string             `json:"graphMap,omitempty"`
	Stripped       bool                       `json:"stripped,omitempty"`
	StrippedCount  int                        `json:"strippedCount,omitempty"`
	FileUUID       string                     `json:"graphId,omitempty"`
	RevisionUUID   string                     `json:"graphRevisionId,omitempty"`
}

type HasValue

type HasValue interface {
	GetValue() interface{}
}

Directories

Path Synopsis
high
v2
v3

Jump to

Keyboard shortcuts

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