Skip to main content

OpenAPI Ingestion

OpenAPI ingestion converts Swagger 2.0 and OpenAPI 3.x sources into normalized ToolSchema objects. Each HTTP operation becomes a searchable tool with method, path, operation id, summary, parameters, schemas, security hints, semantic metadata, and IO contracts.

This page covers the engine-level ingestion path. Product concerns such as DB rows, user sessions, auth profiles, cookies, and HTTP execution belong in the adapter.

When To Use This

Use OpenAPI ingestion when:

  • your tool catalog starts from a Swagger UI URL or direct JSON/YAML spec
  • one API collection may contain hundreds or thousands of operations
  • operation descriptions are noisy and need deterministic metadata
  • you need request/response contracts for planning and execution
  • you want a stored artifact that can be inspected and validated later

Do not use ingestion to attach live credentials. Runtime auth should be resolved only when the adapter executes a plan.

Source Types

SourceSupported ShapeNotes
Direct fileopenapi.json, swagger.yamlBest for reproducible local tests
Direct URLhttps://.../openapi.jsonRemote fetch obeys URL safety options
Swagger UI URLhttps://.../swagger-ui/index.htmlThe engine discovers the backing spec URL
Python dictalready-loaded specUseful in tests and product adapters
Sequencemultiple specsUsed by collection artifact builders

Private or internal URLs are blocked by default. Pass allow_private_hosts=True only from trusted infrastructure.

Minimal Flow

Pick the entry point that matches how the artifact will be used.

from graph_tool_call import ToolGraph

graph = ToolGraph.from_url("https://petstore3.swagger.io/api/v3/openapi.json")

for tool in graph.retrieve("find pets by status", top_k=5):
print(tool.name, tool.description)

Use search for a quick source smoke test, ToolGraph.from_url() for code, and build-openapi-collection when a product needs to store the graph plus readiness, semantic, and edge-quality metadata.

Build A Collection Artifact

Use build_openapi_collection_artifact() when the result must be stored by a product adapter or inspected by a UI.

from graph_tool_call.graphify import build_openapi_collection_artifact

artifact = build_openapi_collection_artifact(
"openapi.json",
derive_semantic_metadata=True,
promote_contract_signals=True,
context_field_names={"mallNo", "siteNo"},
paging_field_names={"page", "size"},
search_filter_field_names={"keyword", "searchType"},
)

print(artifact["metadata"]["tool_count"])
print(artifact["semantic_summary"])
print(artifact["readiness_report"]["summary"])

Artifact Options

OptionDefaultPurpose
required_onlyFalseKeep only required schema fields during ingest
skip_deprecatedTrueSkip deprecated OpenAPI operations
allow_private_hostsFalsePermit private/internal URL fetches
max_response_bytes5_000_000Limit remote spec size
promote_contract_signalsTruePromote request/response fields into graph evidence
max_contract_producers_per_field3Cap producer expansion per field
derive_semantic_metadataTrueDerive action/resource/module/result-shape metadata
overwrite_ai_metadataFalsePreserve manually curated metadata by default
context_field_namesNoneAdapter-provided generic context field names
auth_field_namesNoneAdapter-provided auth field names
paging_field_namesNoneAdapter-provided paging field names
search_filter_field_namesNoneAdapter-provided search/filter field names
metadataNoneProduct-neutral metadata to attach to the artifact

Product-specific aliases should be passed as options. Do not hard-code product terms in the engine.

Output Shape

The collection artifact keeps the normal graph save shape and adds product-facing build facts.

SectionPurpose
graphSerialized NetworkX-style graph
toolsNormalized tool schemas
metadatabuild version, source, options, and collection graph version
semantic_summaryaction/resource/module/result-shape coverage
edge_quality_summarydata-flow, structural, manual, trace, and evidence counts
readiness_reportdeterministic readiness diagnostics
source_snapshot_manifestsource identity and hash information
ingest_summaryoperation and duplicate handling summary

Stable OpenAPI Metadata

OpenAPI-derived tools may include:

FieldPurpose
metadata.openapi.methodHTTP method
metadata.openapi.pathOperation path
metadata.openapi.operation_idStable operation identifier when available
metadata.openapi.parametersQuery, path, header, and cookie parameters
metadata.openapi.securityOpenAPI security hints
metadata.request_body_schemaRequest body schema summary
metadata.response_schemaResponse schema summary
metadata.api_contractEngine-level consumes, produces, and links
metadata.ai_metadataDeterministic semantic action/resource/module fields

Diagnostics

After ingestion, inspect these sections before enabling execution:

summary = artifact["readiness_report"]["summary"]
semantic = artifact["semantic_summary"]
edges = artifact["edge_quality_summary"]

print(summary["status"], summary["readiness_score"])
print(semantic["canonical_action_known_rate"])
print(edges["strong_deterministic_evidence_count"])

Important signals:

  • missing request or response schemas
  • low semantic action/resource coverage
  • weak edge evidence
  • auth required but not represented in adapter readiness
  • one module containing too many unrelated tools

Failure Modes

SymptomLikely CauseFix
No tools producedSpec URL is wrong or Swagger UI discovery failedUse a direct spec URL or allow trusted private hosts
Missing response contractsOpenAPI responses have no schema or use unsupported contentRepair the spec or add adapter-side contract repair
Too many unknown actionsOperation ids and summaries are weakAdd generic aliases or curated semantic metadata
No producer expansionResponse fields were not extractedCheck metadata.api_contract.produces
Auth appears as normal dataAuth field names are product-specificPass auth_field_names from the adapter