The Semantic Graph Extractor is a TypeScript tool that analyzes OpenAPI specifications with semantic type annotations to build operation dependency graphs. This is Phase One of a test generation project that will ultimately help generate comprehensive test scenarios for APIs.
- Parses OpenAPI Specifications: Reads and analyzes
rest-api.domain.yamlwhich contains semantic type annotations usingx-semantic-typeextensions - Extracts Semantic Types: Identifies all semantic types (like
ProcessInstanceKey,UserTaskKey, etc.) and their relationships - Analyzes Operations: Examines all API operations to understand their input parameters and response schemas
- Builds Dependency Graph: Creates a graph showing how operations depend on each other through shared semantic types
- Generates Analysis: Produces detailed reports about the API structure and dependencies
From the Camunda OpenAPI specification analysis:
- 144 operations across the API
- 18 semantic types that create relationships between operations
- 6,291 dependencies between operations
- 122 entry points (operations that can be called without dependencies)
- Average of 43.69 dependencies per operation
- ProcessInstanceKey (3,720 dependencies) - Central to process management
- ProcessDefinitionKey (1,449 dependencies) - Key for process templates
- ElementInstanceKey (1,027 dependencies) - Individual process elements
index.ts: Main extraction logic and entry pointtypes.ts: TypeScript definitions for OpenAPI and graph structuresschema-analyzer.ts: Analyzes OpenAPI schemas and extracts semantic informationgraph-builder.ts: Builds dependency graphs and performs analysisanalyze.ts: Generates human-readable analysis reports
The dependency graph is saved as JSON with the following structure:
{
"operations": [...], // Array of all API operations
"semanticTypes": [...], // Array of all semantic types
"edges": [...], // Array of dependency relationships
"metadata": { // Extraction metadata
"extractedAt": "2025-08-13T...",
"totalOperations": 144,
"totalSemanticTypes": 18,
"totalDependencies": 6291
}
}Dependencies are classified by strength:
- REQUIRED: Target operation cannot be called without source
- OPTIONAL: Target operation benefits from source but can work without it
- CONDITIONAL: Dependency depends on specific conditions
cd api-test
npm installnpm run extract-graphThis will:
- Parse
rest-api.domain.yaml - Extract semantic types and operations
- Build the dependency graph
- Save to
generated/<config>/graph/operation-dependency-graph.json
npm run analyze-graphThis will:
- Load the previously generated graph
- Perform analysis to find entry points, sinks, clusters
- Generate
generated/<config>/graph/dependency-graph-analysis.md - Display key statistics in the console
Here are some example dependencies discovered:
- Process Creation → Process Querying:
createProcessInstanceproducesProcessInstanceKeythat can be used bysearchProcessInstances - Job Activation → Job Completion:
activateJobsproducesJobKeythat is required bycompleteJob - Element Navigation: Various operations produce
ElementInstanceKeythat enables drilling down into specific process elements
The tool identifies several important graph characteristics:
Operations that don't depend on others (122 found):
getTopology,getLicense,getAuthenticationactivateJobs,createTenant,createUser- Search operations that can work without specific filters
Operations that don't produce outputs used by others (111 found):
- Status/info operations like
getTopology - Completion operations like
completeJob - Create operations for standalone entities
Groups of operations with mutual dependencies:
- Main workflow cluster: Search operations, process creation, document handling
- Decision cluster: Decision definition and evaluation operations
This semantic graph extractor is designed to support the following phases:
Build a complete map of the API to reason about test coverage
Generate test scenarios that traverse the dependency graph to achieve maximum coverage
JSON was chosen for the dependency graph format because:
- Readability: Easy to inspect and debug
- Interoperability: Can be consumed by various tools
- Completeness: Preserves all extracted information
- Future-proof: Easy to extend with additional metadata
The tool looks for x-semantic-type annotations in:
- Schema definitions (
components/schemas) - Parameter schemas
- Request body schemas
- Response schemas
- Nested object properties
- The tool processes large OpenAPI specs efficiently
- Graph construction is O(n²) in operations but optimized for practical sizes
- Memory usage scales linearly with spec complexity
{
"operationId": "createProcessInstance",
"method": "POST",
"path": "/process-definitions/{processDefinitionKey}/instances",
"parameters": [
{
"name": "processDefinitionKey",
"location": "path",
"semanticType": "ProcessDefinitionKey",
"required": true
}
],
"responseSemanticTypes": {
"200": [
{
"semanticType": "ProcessInstanceKey",
"fieldPath": "processInstanceKey",
"required": true
}
]
}
}{
"sourceOperationId": "createProcessInstance",
"targetOperationId": "searchProcessInstances",
"semanticType": "ProcessInstanceKey",
"sourceFieldPath": "processInstanceKey",
"targetFieldPath": "query.processInstanceKey",
"strength": "optional",
"description": "searchProcessInstances can filter by ProcessInstanceKey from createProcessInstance"
}This foundation enables sophisticated test generation strategies in future phases by providing a complete understanding of how API operations relate to each other through their data dependencies.