spec_ingester

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 13 Imported by: 0

README

Spec Ingester (pkg/core/tools/spec_ingester)

The Spec Ingester Module is the entry point for ZAP's knowledge of your API.

Key Tool: ingest_spec

This tool parses OpenAPI (Swagger) or Postman collection files and transforms them into ZAP's internal API Knowledge Graph.

Features
  • Format Support: Handles JSON/YAML OpenAPI v2/v3 and Postman Collections.
  • Graph Construction: Builds a queryable graph of endpoints, schemas, and parameters.
  • Validation: Checks the spec for basic syntax errors during ingestion.

Usage

Run this tool first to teach ZAP about your API.

Example Prompts

Trigger this tool by asking:

  • "Ingest the OpenAPI spec from docs/openapi.yaml."
  • "Load the Postman collection located at ./postman/v1.json."
  • "Parse the API specification to build the knowledge graph."

Documentation

Overview

Package spec_ingester provides API specification parsing and knowledge graph building for ZAP.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GraphBuilder

type GraphBuilder struct {
	FalconDir string
}

GraphBuilder is responsible for transforming intermediate ParsedSpec into the final APIKnowledgeGraph used by Falcon.

func NewGraphBuilder

func NewGraphBuilder(falconDir string) *GraphBuilder

func (*GraphBuilder) BuildGraph

func (b *GraphBuilder) BuildGraph(spec *ParsedSpec, context shared.ProjectContext) (*shared.APIKnowledgeGraph, error)

BuildGraph takes parsing results and fuses them into a single graph.

func (*GraphBuilder) LoadGraph

func (b *GraphBuilder) LoadGraph() (*shared.APIKnowledgeGraph, error)

LoadGraph loads the graph from .falcon/spec.yaml.

func (*GraphBuilder) SaveGraph

func (b *GraphBuilder) SaveGraph(graph *shared.APIKnowledgeGraph) error

SaveGraph persists the graph to .falcon/spec.yaml (human-readable YAML).

type IngestParams

type IngestParams struct {
	Action string `json:"action"` // "index", "update", "status"
	Source string `json:"source"` // file path or URL
}

IngestParams checks inputs for file path or URL

type IngestSpecTool

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

IngestSpecTool provides commands to index API specifications

func NewIngestSpecTool

func NewIngestSpecTool(llmClient llm.LLMClient, falconDir string) *IngestSpecTool

NewIngestSpecTool creates a new spec ingestion tool

func (*IngestSpecTool) Description

func (t *IngestSpecTool) Description() string

func (*IngestSpecTool) Execute

func (t *IngestSpecTool) Execute(args string) (string, error)

func (*IngestSpecTool) Name

func (t *IngestSpecTool) Name() string

func (*IngestSpecTool) Parameters

func (t *IngestSpecTool) Parameters() string

type OpenAPIParser

type OpenAPIParser struct{}

OpenAPIParser implements the SpecParser for OpenAPI 3.x and Swagger 2.0

func (*OpenAPIParser) DetectFormat

func (p *OpenAPIParser) DetectFormat(content []byte) bool

func (*OpenAPIParser) Parse

func (p *OpenAPIParser) Parse(content []byte) (*ParsedSpec, error)

type ParsedEndpoint

type ParsedEndpoint struct {
	Method      string
	Path        string
	Summary     string
	Description string
	Parameters  []ParsedParameter
	// Simplified representation of request/response for initial indexing
	HasBody   bool
	Responses []int
}

ParsedEndpoint represents a single API operation found in the spec

type ParsedParameter

type ParsedParameter struct {
	Name     string
	In       string // query, path, header, etc.
	Required bool
	Type     string
}

type ParsedSpec

type ParsedSpec struct {
	Format    string // "openapi3", "swagger2", "postman2.1"
	Version   string
	Endpoints []ParsedEndpoint
}

ParsedSpec is an intermediate representation of a parsed API spec

type PostmanParser

type PostmanParser struct{}

PostmanParser implements the SpecParser for Postman Collections v2.1

func (*PostmanParser) DetectFormat

func (p *PostmanParser) DetectFormat(content []byte) bool

func (*PostmanParser) Parse

func (p *PostmanParser) Parse(content []byte) (*ParsedSpec, error)

type SpecParser

type SpecParser interface {
	// DetectFormat returns true if the parser can handle the given content
	DetectFormat(content []byte) bool

	// Parse converts the raw content into a unified APIKnowledgeGraph structure
	// It basically extracts endpoints and models but returns them in a generic map first
	// to be later processed by the GraphBuilder
	Parse(content []byte) (*ParsedSpec, error)
}

SpecParser defines the interface for parsing API specifications

Jump to

Keyboard shortcuts

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