我們在進行審計時注意的最后一個因素是使用API的開發人員的總體印象。

Image 2: PLAN - business analysis, design and planning of new API functionalities; CODE - new functions are coded on the basis of the project; BUILD - unit testing and installation package building; TEST - acceptance testing / e2e and any other Q&A processes; DEPLOY - package installation on the environment; USER DEPLOY - publication of materials for users, i.e. documentation, help files, articles, tutorials; OPERATE - operational use of the API integrated by external programmers; MONITORING - API monitoring.

第1步:API源代碼分析、內部文檔和API審計計劃執行

API審核計劃包含以下內容:

以下是對CI/CD流程的修改,其中包含了自動化驗證、測試和創建交互式文檔的新元素。這些行動不僅改善和加強了流程,自動化還會影響新功能的實施速度。

Image 3: PLAN - business analysis, design and planning of new API functionalities; API DESCRIBE - semantic API description in meta language (symbolic); CODE - new functions are coded on the basis of the project; BUILD - unit testing and installation package building; compliance tests of the semantic API description with API services; TEST - acceptance testing / e2e and any other Q&A processes; automatic API tests; DEPLOY - package installation on the environment; USER DEPLOY - publication of materials for users, i.e. documentation, help files, articles, tutorials; generating documentation with examples and interactive code; OPERATE - operational use of the API integrated by external programmers; MONITORING - API monitoring;

第2步:API改進

第三步:開發者中心

如何簡化API測試

我們選擇了5種測試方法,并使用元語言對其進行了描述。根據所選擇的概念,我們將能夠在CI/CD過程中包括文檔和API合規性驗證、自動測試或交互式文檔。為此,我們使用了:

Image 4: Screenshot that shows technical documentation about API services.

1.API藍圖

2.互動文件(Apiary)

下面的屏幕截圖顯示了文檔的主視圖。

Image 5: The screenshot presents the main view of the documentation.

簡介部分包含有關如何設置一切以便能夠使用API的信息,例如,如何對系統進行身份驗證或注冊。參考部分包含API中所有可用資源的實際定義。每個對象都有自己的部分,其中包括一組指向每個方法定義的鏈接。數據結構部分包含作為API一部分的所有對象及其定義的列表,如參數和類型。

Image 6: The screenshot presents the Introduction section that contains the information how to set up everything to be able to use the API.

下面的屏幕截圖顯示了主文檔視圖,其中包含打開的調用方法詳細信息和嘗試控制臺面板。它顯示了URL、帶描述的URI參數、請求和標頭的標頭、示例正文和響應方案。

Image 7: The screenshot presents the main documentation view with an opened call method details and Try console panel. It shows the URL, URI parameters with description, headers for request and headers, example body, and scheme for response.

下面的屏幕截圖顯示了調用方法的詳細信息,可以生成許多流行編程語言的代碼示例(供您的應用程序使用)。這有助于促進通過API接口將任何應用程序或系統與API平臺集成的過程。可用的語言有cURL、Java、JavaScript、Node.js、Perl、Python、PHP、Ruby、Go、C#、Visual Basic、Groovy、Objective-C、Swift。

Image 8: The screenshot presents a call method details with a possibility to generate code examples (for the use in your application) in many popular programming languages.

下面的屏幕截圖顯示了嘗試控制臺面板,該面板提供了直接從文檔中測試API的機會。它允許我們放入自定義參數、標頭和正文,并向服務器創建完全自定義的請求。我們還可以通過模擬端點調用方法,這使我們能夠檢查API周圍的所有流量。

Image 9: The screenshot presents the Try console panel which offers an opportunity to test API directly from the documentation.

3.自動化API測試(Dredd)

Image 10: Dredd reads API description and step by step validates whether API implementation replies with responses as they are described in the documentation.

下面的截圖以更易讀的形式展示了Dredd測試結果。它們包含所有方法調用的報告,包括錯誤(如果發生)、請求或響應中的任何不一致,以及其他有價值的信息,這些信息可以幫助調查API的問題。Dredd還可以與任何CI/CD工具連接,當任何更改應用于代碼時,該工具會自動運行測試。

Image 11: The screenshot presents the Dredd test results in a more readable form.

API審核:最重要的

文檔是任何API的重要組成部分。沒有它,就很難找出可用的端點、它們的用途以及我們可以使用的參數。這種交互式文檔不僅允許我們查看可用的端點、它們的參數或返回值的方案,還允許我們嘗試它們。這不僅有助于找到特定的資源,而且有助于根據請求調用它,這在開發過程中往往很有用。

文章轉自: https://deviniti.com/blog/software-engineering/how-to-audit-api-step-by-step/

上一篇:

調用Leonardo.ai API 實現文生圖:小白上手指南

下一篇:

使用.Net構建一個RESTful Web API
#你可能也喜歡這些API文章!

我們有何不同?

API服務商零注冊

多API并行試用

數據驅動選型,提升決策效率

查看全部API→
??

熱門場景實測,選對API

#AI文本生成大模型API

對比大模型API的內容創意新穎性、情感共鳴力、商業轉化潛力

25個渠道
一鍵對比試用API 限時免費

#AI深度推理大模型API

對比大模型API的邏輯推理準確性、分析深度、可視化建議合理性

10個渠道
一鍵對比試用API 限時免費