Documentation
¶
Index ¶
- func MarshalFieldsJSON(fields []Field) ([]byte, error)
- func MarshalFieldsYAML(fields []Field) (*yaml.Node, error)
- type ElementBase
- type Field
- type HookFunc
- type Location
- type MarshalFieldsProvider
- type NodeSource
- type ParseError
- type Ref
- func (r *Ref[T]) Circular() bool
- func (r *Ref[T]) Done() <-chan struct{}
- func (r *Ref[T]) InitDone()
- func (r *Ref[T]) MarkDone()
- func (r *Ref[T]) MarshalJSON() ([]byte, error)
- func (r *Ref[T]) MarshalYAML() (interface{}, error)
- func (r *Ref[T]) RawCircular() bool
- func (r *Ref[T]) RawValue() *T
- func (r *Ref[T]) RefInfo() (ref string, value interface{})
- func (r *Ref[T]) ResolveErr() error
- func (r *Ref[T]) SetCircular(c bool)
- func (r *Ref[T]) SetResolveErr(err error)
- func (r *Ref[T]) SetValue(v *T)
- func (r *Ref[T]) Value() *T
- type RefWithMeta
- func (r *RefWithMeta[T]) Circular() bool
- func (r *RefWithMeta[T]) Done() <-chan struct{}
- func (r *RefWithMeta[T]) InitDone()
- func (r *RefWithMeta[T]) MarkDone()
- func (r *RefWithMeta[T]) MarshalJSON() ([]byte, error)
- func (r *RefWithMeta[T]) MarshalYAML() (interface{}, error)
- func (r *RefWithMeta[T]) RawCircular() bool
- func (r *RefWithMeta[T]) RawValue() *T
- func (r *RefWithMeta[T]) RefInfo() (ref string, value interface{})
- func (r *RefWithMeta[T]) ResolveErr() error
- func (r *RefWithMeta[T]) SetCircular(c bool)
- func (r *RefWithMeta[T]) SetResolveErr(err error)
- func (r *RefWithMeta[T]) SetValue(v *T)
- func (r *RefWithMeta[T]) Value() *T
- type Trix
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalFieldsJSON ¶
MarshalFieldsJSON marshals an ordered list of fields as a JSON object. Fields whose values are considered empty (nil, zero-length, zero-value) are omitted.
Types ¶
type ElementBase ¶
type ElementBase struct {
VendorExtensions map[string]interface{} `json:"-" yaml:"-"`
Trix Trix `json:"-" yaml:"-"`
}
ElementBase is embedded in all OpenAPI types to provide vendor extensions and library metadata.
type Field ¶
type Field struct {
Key string
Value interface{}
}
Field is a key-value pair for ordered marshalling.
func AppendExtensions ¶
AppendExtensions appends sorted vendor extension entries to a field list.
type HookFunc ¶
HookFunc is called before a field is set. Return a non-nil error to reject the change.
type Location ¶
type Location struct {
Line int `json:"-" yaml:"-"` // 1-based line number
Column int `json:"-" yaml:"-"` // 1-based column number
}
Location represents a position in the source file.
type MarshalFieldsProvider ¶
type MarshalFieldsProvider interface {
MarshalFields() []Field
}
MarshalFieldsProvider is implemented by model types that support field-based marshalling. Used by the export package to build serializable trees with ref inlining.
type NodeSource ¶
type NodeSource struct {
Start Location `json:"-" yaml:"-"` // Start position
End Location `json:"-" yaml:"-"` // End position
Raw interface{} `json:"-" yaml:"-"` // Raw parsed data (map/slice/scalar)
}
NodeSource contains source location and raw parsed data for a node.
type ParseError ¶
type ParseError struct {
Message string `json:"-" yaml:"-"` // Human-readable error message
Path []string `json:"-" yaml:"-"` // JSON path where the error occurred
Kind string `json:"-" yaml:"-"` // Error kind: "error" or "unknown_field"
}
ParseError represents a parsing error associated with a specific node.
type Ref ¶
type Ref[T any] struct { ElementBase Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"` // contains filtered or unexported fields }
Ref represents a JSON Reference ($ref) or an inline value of type T. Used by OpenAPI 2.0 and 3.0 models where $ref has no additional fields.
func (*Ref[T]) Circular ¶
Circular returns true if a circular reference was detected, blocking if resolution is in progress.
func (*Ref[T]) Done ¶
func (r *Ref[T]) Done() <-chan struct{}
Done returns the done channel for waiting on resolution.
func (*Ref[T]) InitDone ¶
func (r *Ref[T]) InitDone()
InitDone initializes the done channel, signaling this ref needs async resolution.
func (*Ref[T]) MarkDone ¶
func (r *Ref[T]) MarkDone()
MarkDone closes the done channel, unblocking any waiters. Safe to call multiple times; only closes once.
func (*Ref[T]) MarshalJSON ¶
MarshalJSON serializes the ref: if $ref is set, emits {"$ref":"..."}; if an inline value is set, delegates to the value; otherwise emits null.
func (*Ref[T]) MarshalYAML ¶
MarshalYAML serializes the ref to YAML.
func (*Ref[T]) RawCircular ¶
RawCircular returns the circular flag without blocking. For use by the resolver.
func (*Ref[T]) RawValue ¶
func (r *Ref[T]) RawValue() *T
RawValue returns the value without blocking. For use by the resolver.
func (*Ref[T]) RefInfo ¶
RefInfo returns the $ref string and the resolved value (or nil). Used by the export package to inspect refs without blocking.
func (*Ref[T]) ResolveErr ¶
ResolveErr returns the resolution error, blocking if resolution is in progress.
func (*Ref[T]) SetCircular ¶
SetCircular sets the circular flag.
func (*Ref[T]) SetResolveErr ¶
SetResolveErr sets the resolution error and adds it to Trix.Errors so it appears in ParseResult.Errors.
type RefWithMeta ¶
type RefWithMeta[T any] struct { ElementBase Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"` Summary string `json:"summary,omitempty" yaml:"summary,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` // contains filtered or unexported fields }
RefWithMeta is like Ref but adds Summary and Description fields as permitted by OpenAPI 3.1's extended $ref syntax.
func NewRefWithMeta ¶
func NewRefWithMeta[T any](ref string) *RefWithMeta[T]
NewRefWithMeta creates a new RefWithMeta with the given $ref string.
func (*RefWithMeta[T]) Circular ¶
func (r *RefWithMeta[T]) Circular() bool
Circular returns true if a circular reference was detected, blocking if resolution is in progress.
func (*RefWithMeta[T]) Done ¶
func (r *RefWithMeta[T]) Done() <-chan struct{}
Done returns the done channel for waiting on resolution.
func (*RefWithMeta[T]) InitDone ¶
func (r *RefWithMeta[T]) InitDone()
InitDone initializes the done channel, signaling this ref needs async resolution.
func (*RefWithMeta[T]) MarkDone ¶
func (r *RefWithMeta[T]) MarkDone()
MarkDone closes the done channel, unblocking any waiters. Safe to call multiple times; only closes once.
func (*RefWithMeta[T]) MarshalJSON ¶
func (r *RefWithMeta[T]) MarshalJSON() ([]byte, error)
MarshalJSON serializes the ref: if $ref is set, emits {"$ref":"...", "summary":"...", "description":"..."}; if an inline value is set, delegates to the value; otherwise emits null.
func (*RefWithMeta[T]) MarshalYAML ¶
func (r *RefWithMeta[T]) MarshalYAML() (interface{}, error)
MarshalYAML serializes the ref to YAML, including summary and description when present.
func (*RefWithMeta[T]) RawCircular ¶
func (r *RefWithMeta[T]) RawCircular() bool
RawCircular returns the circular flag without blocking. For use by the resolver.
func (*RefWithMeta[T]) RawValue ¶
func (r *RefWithMeta[T]) RawValue() *T
RawValue returns the value without blocking. For use by the resolver.
func (*RefWithMeta[T]) RefInfo ¶
func (r *RefWithMeta[T]) RefInfo() (ref string, value interface{})
RefInfo returns the $ref string and the resolved value (or nil). Used by the export package to inspect refs without blocking.
func (*RefWithMeta[T]) ResolveErr ¶
func (r *RefWithMeta[T]) ResolveErr() error
ResolveErr returns the resolution error, blocking if resolution is in progress.
func (*RefWithMeta[T]) SetCircular ¶
func (r *RefWithMeta[T]) SetCircular(c bool)
SetCircular sets the circular flag.
func (*RefWithMeta[T]) SetResolveErr ¶
func (r *RefWithMeta[T]) SetResolveErr(err error)
SetResolveErr sets the resolution error and adds it to Trix.Errors so it appears in ParseResult.Errors.
func (*RefWithMeta[T]) SetValue ¶
func (r *RefWithMeta[T]) SetValue(v *T)
SetValue sets the resolved value.
func (*RefWithMeta[T]) Value ¶
func (r *RefWithMeta[T]) Value() *T
Value returns the resolved value, blocking if background resolution is in progress.
type Trix ¶
type Trix struct {
Source NodeSource `json:"-" yaml:"-"` // Source location info
Errors []ParseError `json:"-" yaml:"-"` // Parsing errors attached to this node
// contains filtered or unexported fields
}
Trix contains all library-level metadata and functionality. Everything under Trix is provided by the apitrix library, not part of the OpenAPI specification itself.