OOPS: التوليد الآلي لمواصفات واجهة برمجة التطبيقات REST عبر نماذج اللغة الكبيرة
OOPS: Automated generation of REST API specification via LLMs

شارك:
المجلة: Journal of Systems and Software، المجلد: 239
DOI: https://doi.org/10.1016/j.jss.2026.112914
تاريخ النشر: 2026-04-30
المؤلف: Hao Chen وآخرون
الموضوع الرئيسي: تقنيات هندسة البرمجيات المدفوعة بالنماذج

نظرة عامة

في هذا القسم، يقدم المؤلفون OOPS، وهو نهج جديد مستقل عن التكنولوجيا لتوليد مواصفات OpenAPI (OAS) من واجهات برمجة التطبيقات REST باستخدام نماذج اللغة الكبيرة (LLMs). تعتمد الطرق التقليدية لتوليد OAS غالبًا على قواعد محددة بالتكنولوجيا وخبرة بشرية، مما يمكن أن يكون مقيدًا. يتناول OOPS هذه التحديات من خلال استخدام سير عمل تحليل ثابت قائم على LLM يتضمن استخراج طرق نقاط النهاية وتوليد OAS، مما يلغي الحاجة للتدخل اليدوي. يقوم النهج ببناء رسم بياني للاعتماد على واجهة برمجة التطبيقات لإدارة قيود طول السياق لنماذج LLM ويستخدم تقنيات التوليد متعددة المراحل والتنقيح الذاتي لتقليل كل من الهلوسات النحوية والدلالية.

تم تقييم فعالية OOPS على 12 واجهة برمجة تطبيقات REST في العالم الحقيقي عبر خمس لغات برمجة وثمانية أطر تطوير، مما أسفر عن نتائج مثيرة للإعجاب: متوسط درجة F1 يزيد عن 98% لاستخراج طرق نقاط النهاية، و97% لاستنتاج الطلبات والاستجابات، و92% لاستنتاج قيود المعلمات. كما يحدد المؤلفون العمل المستقبلي الذي يهدف إلى تعزيز OOPS من خلال دمج دعم رموز حالة الخطأ واستغلال وكلاء LLM للتحقق الديناميكي من OAS المولدة. لن يؤدي ذلك فقط إلى تحسين دقة المواصفات ولكن أيضًا إلى توسيع قابلية تطبيق OOPS في اختبار واجهات برمجة التطبيقات REST من خلال التكامل مع طرق الاختبار الحالية القائمة على LLM.

مقدمة

تستعرض مقدمة هذه الورقة البحثية أهمية مواصفة OpenAPI (OAS) في سياق واجهات برمجة التطبيقات REST، مع تسليط الضوء على دورها كمعيار لتوثيق واجهات برمجة التطبيقات وتطبيقاتها في الاختبار الآلي واكتشاف الثغرات. على الرغم من اعتمادها على نطاق واسع، فإن إنشاء OAS يدويًا غالبًا ما يؤدي إلى عدم الدقة، مما يستدعي الحاجة إلى طرق توليد آلية. تواجه الأساليب الحالية، مثل APICARV وRespector وExpressO، قيودًا في القابلية للتعميم وتتطلب قواعد محددة بالتكنولوجيا أو تدخل بشري.

لمعالجة هذه التحديات، يقترح المؤلفون طريقة جديدة تسمى مولد OpenAPI المتوافق مع OpenAI من مشروع Source (OOPS)، والذي يستخدم نماذج اللغة الكبيرة (LLMs) لتوليد OAS. يهدف OOPS إلى إنتاج مستندات OAS صالحة من خلال تحليل مستودعات كود مصدر واجهات برمجة التطبيقات REST، مستفيدًا من LLMs للتغلب على قيود طول السياق والتخفيف من الهلوسات من خلال عملية توليد متعددة المراحل. تم تصميم الطريقة لتكون مستقلة عن التكنولوجيا، مما يظهر تحسينًا في التعميم عبر لغات برمجة وأطر مختلفة. تشير التقييمات التجريبية على تنفيذات متعددة لواجهات برمجة التطبيقات REST إلى أن OOPS يتفوق على الأساليب الحالية من حيث الدقة والاسترجاع، مما يمثل تقدمًا كبيرًا في توليد OAS الآلي.

طرق

استخدمت الدراسة منهجية تجريبية منهجية للتحقيق في الظواهر المحددة. تم تصميم التجارب للتحكم في متغيرات مختلفة، مما يضمن أن النتائج يمكن أن تُعزى إلى العوامل قيد الدراسة. شملت جمع البيانات قياسات دقيقة وملاحظات، والتي تم تحليلها لاحقًا باستخدام تقنيات إحصائية مناسبة للتحقق من النتائج.

أظهرت النتائج التجريبية اتجاهات ملحوظة تدعم الفرضيات الأولية. تضمنت النتائج الرئيسية آثارًا قابلة للقياس كانت ذات دلالة إحصائية، مما يشير إلى وجود علاقة قوية بين المتغيرات التي تم فحصها. تسهم هذه النتائج في الجسم المعرفي القائم وتقترح تداعيات محتملة للبحوث المستقبلية والتطبيقات العملية في هذا المجال.

مناقشة

في هذا القسم، تناقش الورقة هيكل وتنفيذ واجهات برمجة التطبيقات REST ومواصفة OpenAPI (OAS)، مع التركيز على التطور من OAS 2.0 إلى OAS 3.0. تسهل واجهات برمجة التطبيقات REST، التي تسهل معالجة الموارد من خلال عمليات CRUD، عادةً هيكلًا حول نقاط نهاية مختلفة تتوافق مع طرق HTTP المختلفة. توفر OAS تنسيقًا موحدًا لتوثيق هذه الواجهات، مما يسمح بفهم أفضل وتوافق أكبر. يقدم الانتقال إلى OAS 3.0 تحسينات مثل تحسين القابلية لإعادة الاستخدام وتوسيع قدرات JSON Schema، مما يجعلها الخيار المفضل في الأبحاث والتطبيقات المعاصرة.

تنبع دوافع البحث من الاهتمام المتزايد في طرق توليد OAS الآلية التي تستخدم التحليل الثابت، والتي، على الرغم من فعاليتها، غالبًا ما تكون محدودة بلغات برمجة أو أطر معينة. تقترح الورقة استغلال نماذج اللغة الكبيرة (LLMs) لتوليد OAS، مع تسليط الضوء على إمكاناتها لفهم قواعد الشفرات المتنوعة وإنتاج مستندات OAS عبر تقنيات مختلفة. ومع ذلك، يحدد المؤلفون ثلاثة تحديات كبيرة: قيود طول السياق، الاعتماد على قواعد محددة بالتكنولوجيا، وظهور الهلوسات في مخرجات LLM. تتضمن الحلول المقترحة نهجًا متعدد المراحل يشمل تحليل التكنولوجيا من جانب الخادم، واستخراج طرق نقاط النهاية، وتوليد OAS، مع استخدام LLMs بطريقة منظمة للتخفيف من هذه التحديات وتعزيز دقة المواصفات المولدة.

القيود

تناقش قسم القيود القيود المرتبطة باستخراج طرق نقاط النهاية، خاصة فيما يتعلق بطول السياق. يبرز أن فعالية هذه الطريقة تتأثر بشكل كبير بالطول الأقصى للسياق الذي يمكن معالجته. عندما يتجاوز السياق هذا الحد، قد تتدهور أداء النموذج، مما يؤدي إلى نتائج استخراج دون المستوى.

علاوة على ذلك، يؤكد المؤلفون أنه بينما تظهر طريقة النقاط النهائية وعدًا في بعض التطبيقات، فإن اعتمادها على طول السياق يطرح تحديات في السيناريوهات التي تتطلب معالجة معلومات واسعة. تتطلب هذه القيود مزيدًا من البحث لتعزيز قابلية تكيف الطريقة وكفاءتها في التعامل مع مجموعات بيانات أكبر أو سياقات أكثر تعقيدًا.

Journal: Journal of Systems and Software, Volume: 239
DOI: https://doi.org/10.1016/j.jss.2026.112914
Publication Date: 2026-04-30
Author(s): Hao Chen et al.
Primary Topic: Model-Driven Software Engineering Techniques

Overview

In this section, the authors introduce OOPS, a novel technology-agnostic approach for generating OpenAPI Specifications (OAS) from REST APIs using large language models (LLMs). Traditional methods for OAS generation often depend on technology-specific rules and human expertise, which can be limiting. OOPS addresses these challenges by employing an LLM-based static analysis workflow that includes endpoint method extraction and OAS generation, thereby eliminating the need for manual intervention. The approach constructs an API dependency graph to manage context length limitations of LLMs and employs multi-stage generation and self-refinement techniques to reduce both syntactic and semantic hallucinations.

The effectiveness of OOPS was evaluated on 12 real-world REST APIs across five programming languages and eight development frameworks, yielding impressive results: an average F1-score of over 98% for endpoint method inference, 97% for request and response inference, and 92% for parameter constraint inference. The authors also outline future work aimed at enhancing OOPS by incorporating support for error status codes and leveraging LLM agents for dynamic validation of generated OAS. This will not only improve the accuracy of the specifications but also broaden the applicability of OOPS in REST API testing through integration with existing LLM-based testing methods.

Introduction

The introduction of this research paper outlines the significance of the OpenAPI Specification (OAS) in the context of REST APIs, highlighting its role as a standard for API documentation and its applications in automated testing and vulnerability detection. Despite its widespread adoption, the manual creation of OAS often leads to inaccuracies, prompting the need for automated generation methods. Current approaches, such as APICARV, Respector, and ExpressO, face limitations in generalizability and require technology-specific rules or human intervention.

To address these challenges, the authors propose a novel method called OpenAI-compatible OpenAPI generator from Project Source (OOPS), which utilizes Large Language Models (LLMs) for OAS generation. OOPS aims to produce valid OAS documents by analyzing REST API source code repositories, leveraging LLMs to overcome context length limitations and mitigate hallucinations through a multi-stage generation process. The method is designed to be technology-agnostic, demonstrating improved generalization across various programming languages and frameworks. Experimental evaluations on multiple REST API implementations indicate that OOPS outperforms existing methods in precision and recall, marking a significant advancement in automated OAS generation.

Methods

The research employed a systematic experimental methodology to investigate the specified phenomena. The experiments were designed to control for various variables, ensuring that the results could be attributed to the factors under study. Data collection involved precise measurements and observations, which were subsequently analyzed using appropriate statistical techniques to validate the findings.

The experimental results demonstrated significant trends that support the initial hypotheses. Key outcomes included measurable effects that were statistically significant, indicating a strong correlation between the variables examined. These findings contribute to the existing body of knowledge and suggest potential implications for future research and practical applications in the field.

Discussion

In this section, the paper discusses the architecture and implementation of REST APIs and the OpenAPI Specification (OAS), emphasizing the evolution from OAS 2.0 to OAS 3.0. REST APIs, which facilitate resource manipulation through CRUD operations, are typically structured around various endpoints that correspond to different HTTP methods. The OAS provides a standardized format for documenting these APIs, allowing for better understanding and interoperability. The transition to OAS 3.0 introduces enhancements such as improved reusability and extended JSON Schema capabilities, making it the preferred choice in contemporary research and applications.

The motivation for the research stems from the increasing interest in automated OAS generation methods that utilize static analysis, which, while effective, are often limited to specific programming languages or frameworks. The paper proposes leveraging Large Language Models (LLMs) for OAS generation, highlighting their potential to understand diverse codebases and produce OAS documents across different technologies. However, the authors identify three significant challenges: context length limitations, reliance on technology-specific rules, and the occurrence of hallucinations in LLM outputs. The proposed solution involves a multi-stage approach that includes server-side technology analysis, endpoint method extraction, and OAS generation, employing LLMs in a structured manner to mitigate these challenges and enhance the accuracy of the generated specifications.

Limitations

The section on limitations discusses the constraints associated with the endpoint method extraction, particularly in relation to context length. It highlights that the effectiveness of this method is significantly influenced by the maximum context length that can be processed. When the context exceeds this limit, the model’s performance may deteriorate, leading to suboptimal extraction results.

Furthermore, the authors emphasize that while the endpoint method shows promise in certain applications, its reliance on context length poses challenges in scenarios requiring extensive information processing. This limitation necessitates further research to enhance the method’s adaptability and efficiency in handling larger datasets or more complex contexts.