摘要: | 在一個雲端應用中,伺服器需要讓客戶端可以取得它們所需的資料,而伺服器與客戶端的溝通介面就稱為API(Application Programming Interface)。那為了讓使用API的人易於理解,通常都需要為API撰寫文件,來詳細說明用途。 但是撰寫API文件常會遇到以下問題。首先,文檔內容經常不完整或者是與實際功能不一致。此外,維護文檔通常需要額外的人力,但在小型團隊中很難騰出這樣的人力,這會使得每個人的工作變得緊湊且複雜,進而增加文檔錯誤的發生機率。 另外一方面,在有API後,通常伺服器端會將API封裝成一個模組,稱為SDK(Software Development Kit)。但是通常開發SDK是一件煩人的工作,所以有些團隊會使用程式碼產生器來產生SDK。但是現有的程式碼產生器仍存在許多問題,例如:生成的程式碼過於複雜,不容易根據需求進行客製化。並且,如果要修改程式碼產生器的行為,則需要詳細研究官方文檔和設定。 為了解決上述問題,本論文提出了一種架構。該架構透過分析後端程式碼來建立API文檔,並提高可讀性。同時,我們也開發了一個程式碼產生器,用於生成基本的API介面、測試資料,以提供開發SDK的人員更大的彈性,不受程式碼產生器的限制。 ;In a cloud application, servers need to allow clients to access the data they require, and the interface through which servers and clients communicate is called an Application Programming Interface (API). In order to make the API user-friendly and easy to understand, it is usually necessary to write documentation that provides detailed explanations of its usage.
However, there are many challenges when writing API documentation. First, the content of the documentation is frequently incomplete or inconsistent with the actual functionality. Additionally, maintaining the documentation typically requires additional manpower, which can be difficult to allocate in small teams, resulting in increased workload and complexity for each individual and a higher likelihood of documentation errors.
On the other hand, after having an API, the server-side usually packages the API into a module called a Software Development Kit (SDK). However, developing an SDK is often a tedious task, so some teams resort to using code generators to generate the SDK.
But, current code generators, it still have many problems. For example, the generated code can be overly complex and not easily customizable according to specific requirements. Furthermore, making changes to the behavior of a code generator often requires a detailed study of official documentation and configurations.
To address these problems, this paper proposes an architecture that analyzes the backend code to generate API documentation and improve its readability. Additionally, we have developed a code generator that creates basic API interfaces and test data, providing developers who create SDKs with greater flexibility without being constrained by the code generator′s limitations. |