When designing a new API for a large project, developers need to make smart design choices so that their code base can grow sustainably. To ensure that new API components are well designed, developers can learn from existing API components. However, the lack of standardized methods for comparing API designs makes this learning process time-consuming and difficult. To address this gap we developed API-Miner, to the best of our knowledge, one of the first API-to-API specification recommendation engines. API-Miner retrieves relevant specification components written in OpenAPI (a widely adopted language used to describe web APIs). API-miner presents several significant contributions, including: (1) novel methods of processing and extracting key information from OpenAPI specifications, (2) innovative feature extraction techniques that are optimized for the highly technical API specification domain, and (3) a novel log-linear probabilistic model that combines multiple signals to retrieve relevant and high quality OpenAPI specification components given a query specification. We evaluate API-Miner in both quantitative and qualitative tasks and achieve an overall of 91.7% recall@1 and 56.2% F1, which surpasses baseline performance by 15.4% in recall@1 and 3.2% in F1. Overall, API-Miner will allow developers to retrieve relevant OpenAPI specification components from a public or internal database in the early stages of the API development cycle, so that they can learn from existing established examples and potentially identify redundancies in their work. It provides the guidance developers need to accelerate development process and contribute thoughtfully designed APIs that promote code maintainability and quality. Code is available on GitHub at https://github.com/jpmorganchase/api-miner.
翻译:在设计大型项目的新API时,开发者需要做出明智的设计决策,以确保代码库能够可持续发展。为保障新API组件的设计合理性,开发者可从现有API组件中学习经验。然而,由于缺乏标准化的API设计比较方法,这一学习过程耗时且困难。针对此问题,我们开发了API-Miner——据我们所知,这是首批实现API到API规范推荐的引擎之一。API-Miner能够检索用OpenAPI(一种广泛用于描述Web API的语言)编写的相关规范组件。API-Miner具有以下重要贡献:(1)从OpenAPI规范中处理和提取关键信息的新方法;(2)针对高专业性API规范领域优化的创新特征提取技术;(3)一种新颖的对数线性概率模型,该模型可结合多种信号,根据查询规范检索相关且高质量的OpenAPI规范组件。我们通过定量与定性任务对API-Miner进行评估,最终实现了91.7%的召回率@1和56.2%的F1分数,在召回率@1和F1分数上分别超越基线性能15.4%和3.2%。总体而言,API-Miner使开发者能够在API开发周期的早期阶段,从公共或内部数据库中检索相关OpenAPI规范组件,从而借鉴现有成熟案例,并可能识别工作中的冗余。它为开发者提供了加速开发进程所需的指导,助力设计出促进代码可维护性与质量的深思熟虑的API。代码已在GitHub上开源,地址为https://github.com/jpmorganchase/api-miner。