asyncapi

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package asyncapi contains vacuum's AsyncAPI execution context and document detection helpers. It intentionally keeps the parsing contract small: command code can cheaply detect AsyncAPI, while motor and rule functions receive the full libasyncapi document graph when linting AsyncAPI 3.x documents.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildSpecInfo

func BuildSpecInfo(spec []byte, root *yaml.Node, version, format string) *datamodel.SpecInfo

BuildSpecInfo creates libopenapi-compatible metadata for AsyncAPI documents. The metadata is intentionally limited to parser-neutral fields used by vacuum: raw bytes, root node, document type, version and format.

func DetectFormat

func DetectFormat(spec []byte) (string, error)

DetectFormat returns vacuum's AsyncAPI format for spec bytes. It only recognizes AsyncAPI 3.x and returns an error for AsyncAPI 2.x or invalid AsyncAPI version strings. Non-AsyncAPI documents return an empty format.

func FormatForVersion

func FormatForVersion(version string) (string, error)

FormatForVersion maps an AsyncAPI version string onto vacuum's format constants. AsyncAPI 2.x is intentionally unsupported.

func HasMarker

func HasMarker(spec []byte) bool

HasMarker reports whether the raw bytes contain an AsyncAPI root marker. It is intentionally cheap and parse-independent so malformed AsyncAPI documents can still be routed away from OpenAPI-only processing.

func IsDocument

func IsDocument(spec []byte) (bool, error)

IsDocument reports whether spec bytes have an AsyncAPI root marker. It does not require the version to be supported, making it suitable for command surfaces that simply need to reject AsyncAPI input.

Types

type Context

type Context struct {
	Spec         []byte
	SpecFileName string
	SpecInfo     *datamodel.SpecInfo
	Document     libasyncapi.Document
	RootNode     *yaml.Node
	Version      string
	Format       string
	Index        *index.SpecIndex
	Rolodex      *index.Rolodex
	// contains filtered or unexported fields
}

Context is the AsyncAPI equivalent of vacuum's OpenAPI document context. It carries the raw YAML tree, parsed document and index metadata used by AsyncAPI rules.

func NewContext

func NewContext(spec []byte, specFileName string, config *libasyncapi.DocumentConfiguration) (*Context, error)

NewContext parses spec bytes into a libasyncapi document and builds the metadata vacuum needs for format filtering, locations and reports.

func (*Context) DocumentErrors

func (c *Context) DocumentErrors() []error

DocumentErrors returns libasyncapi document validation errors.

func (*Context) NodePath

func (c *Context) NodePath(node *yaml.Node) (string, bool)

NodePath returns the exact vacuum JSONPath for node. The path index is built once per AsyncAPI context and reused by all rule functions.

func (*Context) Root

func (c *Context) Root() *yaml.Node

Root returns the parsed YAML document root.

Jump to

Keyboard shortcuts

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