REST APIs, based on the REpresentational State Transfer (REST) architecture, are the primary type of Web API. The OpenAPI Specification (OAS) serves as the de facto standard for describing REST APIs and is crucial for multiple software engineering tasks. However, developers face challenges in writing and maintaining OAS. Although static analysis shows potential for OAS generation, it is limited to specific programming languages and development frameworks. The powerful code understanding capabilities of LLMs offer new opportunities for OAS generation, yet they are constrained by context limitations and hallucinations. To address these challenges, we propose the OpenAI OpenAPI Project Scanner (OOPS), the first technology-agnostic LLM-based static analysis method for OAS generation, requiring fewer technology-specific rules and less human expert intervention. OOPS is implemented as an LLM agent workflow comprising two key steps: endpoint method extraction and OAS generation. By constructing an API dependency graph, it establishes necessary file associations to address LLMs' context limitations. Through multi-stage generation and self-refine, it mitigates both syntactic and semantic hallucinations during OAS generation. We evaluated OOPS on 12 real-world REST APIs spanning 5 programming languages and 8 development frameworks. Experimental results demonstrate that OOPS accurately generates high-quality OAS for REST APIs implemented with diverse technologies, achieving an average F1-score exceeding 98% for endpoint method inference, 97% for both request parameter and response inference, and 92% for parameter constraint inference. The input tokens average below 5.6K with a maximum of 16.2K, while the output tokens average below 0.9K with a maximum of 7.7K.


翻译:基于表述性状态转移(REST)架构的REST API是Web API的主要类型。OpenAPI规范(OAS)作为描述REST API的事实标准,对多项软件工程任务至关重要。然而,开发者在编写和维护OAS方面面临挑战。尽管静态分析在OAS生成方面展现出潜力,但其仅限于特定的编程语言和开发框架。大语言模型强大的代码理解能力为OAS生成提供了新机遇,但仍受限于上下文约束与幻觉问题。为应对这些挑战,我们提出了OpenAI OpenAPI项目扫描器(OOPS),这是首个与技术栈无关、基于大语言模型的OAS生成静态分析方法,该方法需要更少的技术特定规则和人工专家干预。OOPS被实现为一个包含两个关键步骤的大语言模型智能体工作流:端点方法提取与OAS生成。通过构建API依赖图,该方法建立了必要的文件关联以应对大语言模型的上下文限制。通过多阶段生成与自我优化机制,有效缓解了OAS生成过程中的语法与语义幻觉问题。我们在涵盖5种编程语言和8种开发框架的12个真实REST API上对OOPS进行了评估。实验结果表明,OOPS能够为采用不同技术实现的REST API准确生成高质量的OAS,在端点方法推断方面平均F1分数超过98%,请求参数与响应推断均达到97%,参数约束推断达到92%。输入令牌数平均低于5.6K(最高16.2K),输出令牌数平均低于0.9K(最高7.7K)。

0
下载
关闭预览

相关内容

应用程序接口(简称 API),又称为应用编程接口,就是软件系统不同组成部分衔接的约定。
OpenAI“开放权重模型”即将进入美军作战体系
专知会员服务
26+阅读 · 2025年11月20日
大型语言模型对齐技术综述:RLHF、RLAIF、PPO、DPO 等
专知会员服务
55+阅读 · 2024年7月24日
使用 OpenLLM 构建和部署大模型应用
专知会员服务
55+阅读 · 2024年1月4日
OpenAI更新促进应用生态繁荣,应用端产品落地进程加速
专知会员服务
35+阅读 · 2023年11月9日
OpenNRE 2.0:可一键运行的开源关系抽取工具包
PaperWeekly
22+阅读 · 2019年10月30日
GitHub超9千星:一个API调用27个NLP预训练模型
新智元
17+阅读 · 2019年7月22日
OpenAI官方发布:强化学习中的关键论文
专知
14+阅读 · 2018年12月12日
【干货】通过OpenFace来理解人脸识别
专知
56+阅读 · 2018年1月23日
资源 | 清华大学开源OpenKE:知识表示学习平台
机器之心
10+阅读 · 2017年11月4日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
11+阅读 · 2013年12月31日
VIP会员
相关基金
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
11+阅读 · 2013年12月31日
Top
微信扫码咨询专知VIP会员