Introduction
The proliferation of AI agents and automation tools has created a critical need for machine-readable interface definitions. The OpenAPI Specification (OAS) serves as the standard "instruction manual" for web services. However, a significant "documentation gap" exists; an analysis of the top 14 APIs on Postman reveals that approximately 65% do not provide a public OAS, relying instead on human-centric HTML documentation. These webpages are often inconsistent, unstructured, and exceed the context windows of standard Large Language Models (LLMs), making manual conversion labor-intensive and error-prone. OASBuilder addresses this by providing an automated end-to-end framework to transform unstructured HTML into valid OAS files.
Methodology
OASBuilder avoids the pitfalls of "one-shot" LLM generation by employing a multi-stage pipeline that decomposes the task into manageable sub-tasks.
The process begins with Scraping & Segmentation, using Selenium to identify "operation signatures" and isolate "minimal ancestors"—the smallest HTML blocks containing relevant API information. The system then branches into two parallel paths:
- Demonstrative OAS Generation: Focuses on code examples (e.g., cURL, JSON) to define paths, methods, and basic schemas.
- Descriptive OAS Generation: Extracts prose-based metadata such as parameter descriptions, enums, and default values from tables and text.
Finally, these components are merged and enhanced using LLMs to infer missing metadata. A human-in-the-loop UI allows developers to validate the final output, mitigating the "blank page" problem.
Evaluation
The framework was evaluated using four distinct datasets:
- Syntactic Evaluation Set: 50 diverse pages covering 189 operations.
- Scalability Set: 291 API documentation URLs.
- Semantic Evaluation Set: A ground-truth dataset of 108 operations with thousands of labeled parameters.
- Postman Popularity Check: A baseline audit of top-tier APIs to confirm the documentation gap.
Key Results
OASBuilder demonstrates high technical validity and practical utility. Using code-specific models like IBM’s Granite-Code, the system achieved 100% valid JSON and 89% valid OAS across the scalability set.
Key findings include:
- Model Specialization: Code-centric models (Granite-Code, CodeLlama) significantly outperform general-purpose models in maintaining strict OAS syntax.
- Pipeline Efficacy: Direct generation from raw HTML (e.g., via GPT-4) succeeded only 25% of the time, validating the necessity of the OASBuilder decomposition strategy.
- Semantic Precision: The system achieved precision up to 0.96 for request parameters, though recall for response objects remains a challenge due to sparse documentation in source materials.
Conclusion
OASBuilder bridges the gap between human-readable documentation and the "Agentic Web." By combining rule-based heuristics with specialized LLMs, it enables the automated onboarding of legacy services into AI ecosystems. Future work will focus on improving response documentation recall and handling increasingly complex single-page application (SPA) layouts.
Summary updated