arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2410.23873cs.SE
收藏

从Java源代码生成准确的OpenAPI描述

Generating Accurate OpenAPI Descriptions from Java Source Code

Department of Informatics Systems University of Klagenfurt(克拉根福大学信息系统系)

Alexander Lercher, Christian Macho, Clemens Bauer, Martin Pinzger

AI总结:

针对现有从字节码或运行时信息生成OpenAPI描述的方法存在的不足,提出直接从Java源码检测REST端点等信息的AutoOAS方法,在7个真实项目上的表现优于三种现有最先进方法,且是唯一支持配置文件、数据模型描述最准确详细的方法。

摘要:

开发者需要准确的表述性状态转移(REST)应用程序编程接口(API)描述,以实现Web服务之间的成功交互。OpenAPI规范(OAS)已成为记录REST API的事实标准。手动创建OpenAPI描述耗时且易出错,因此已有多种方法被提出,用于从字节码或运行时信息自动生成这类描述。本文首先研究了三种最先进的方法:Respector、Prophet和springdoc-openapi,并阐述和讨论了它们的不足。随后,我们提出了AutoOAS,这是我们为解决这些不足而开发的、用于生成准确OpenAPI描述的方法。它直接从Java源代码中检测暴露的REST端点路径、对应的HTTP方法、HTTP响应码,以及请求参数和响应的数据模型。我们在7个真实世界的Spring Boot项目上评估了AutoOAS,并将其性能与三种最先进的方法进行了比较。基于手动构建的基准真值(ground truth),AutoOAS在识别REST端点路径、HTTP方法、参数和响应时取得了最高的精确率和召回率。在识别参数方面,它的精确率比排名第二的Respector高39%,召回率高35%;在识别响应方面,精确率高29%,召回率高11%。此外,AutoOAS是唯一支持配置配置文件(configuration profiles)的方法,并且它对REST API中使用的数据模型提供了最准确、最详细的描述。

英文摘要:

Developers require accurate descriptions of REpresentational State Transfer (REST) Application Programming Interfaces (APIs) for a successful interaction between web services. The OpenAPI Specification (OAS) has become the de facto standard for documenting REST APIs. Manually creating an OpenAPI description is time-consuming and error-prone, and therefore several approaches were proposed to automatically generate them from bytecode or runtime information. In this paper, we first study three state-of-the-art approaches, Respector, Prophet, and springdoc-openapi, and present and discuss their shortcomings. Next, we introduce AutoOAS, our approach addressing these shortcomings to generate accurate OpenAPI descriptions. It detects exposed REST endpoint paths, corresponding HTTP methods, HTTP response codes, and the data models of request parameters and responses directly from Java source code. We evaluated AutoOAS on seven real-world Spring Boot projects and compared its performance with the three state-of-the-art approaches. Based on a manually created ground truth, AutoOAS achieved the highest precision and recall when identifying REST endpoint paths, HTTP methods, parameters, and responses. It outperformed the second-best approach, Respector, with a 39% higher precision and 35% higher recall when identifying parameters and a 29% higher precision and 11% higher recall when identifying responses. Furthermore, AutoOAS is the only approach that handles configuration profiles, and it provided the most accurate and detailed description of the data models that were used in the REST APIs.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑