我們?cè)谶M(jìn)行審計(jì)時(shí)注意的最后一個(gè)因素是使用API的開發(fā)人員的總體印象。

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源代碼分析、內(nèi)部文檔和API審計(jì)計(jì)劃執(zhí)行

API審核計(jì)劃包含以下內(nèi)容:

以下是對(duì)CI/CD流程的修改,其中包含了自動(dòng)化驗(yàn)證、測(cè)試和創(chuàng)建交互式文檔的新元素。這些行動(dòng)不僅改善和加強(qiáng)了流程,自動(dòng)化還會(huì)影響新功能的實(shí)施速度。

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改進(jìn)

第三步:開發(fā)者中心

如何簡(jiǎn)化API測(cè)試

我們選擇了5種測(cè)試方法,并使用元語(yǔ)言對(duì)其進(jìn)行了描述。根據(jù)所選擇的概念,我們將能夠在CI/CD過程中包括文檔和API合規(guī)性驗(yàn)證、自動(dòng)測(cè)試或交互式文檔。為此,我們使用了:

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

1.API藍(lán)圖

2.互動(dòng)文件(Apiary)

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

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

簡(jiǎn)介部分包含有關(guān)如何設(shè)置一切以便能夠使用API的信息,例如,如何對(duì)系統(tǒng)進(jìn)行身份驗(yàn)證或注冊(cè)。參考部分包含API中所有可用資源的實(shí)際定義。每個(gè)對(duì)象都有自己的部分,其中包括一組指向每個(gè)方法定義的鏈接。數(shù)據(jù)結(jié)構(gòu)部分包含作為API一部分的所有對(duì)象及其定義的列表,如參數(shù)和類型。

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

下面的屏幕截圖顯示了主文檔視圖,其中包含打開的調(diào)用方法詳細(xì)信息和嘗試控制臺(tái)面板。它顯示了URL、帶描述的URI參數(shù)、請(qǐng)求和標(biāo)頭的標(biāo)頭、示例正文和響應(yīng)方案。

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.

下面的屏幕截圖顯示了調(diào)用方法的詳細(xì)信息,可以生成許多流行編程語(yǔ)言的代碼示例(供您的應(yīng)用程序使用)。這有助于促進(jìn)通過API接口將任何應(yīng)用程序或系統(tǒng)與API平臺(tái)集成的過程。可用的語(yǔ)言有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.

下面的屏幕截圖顯示了嘗試控制臺(tái)面板,該面板提供了直接從文檔中測(cè)試API的機(jī)會(huì)。它允許我們放入自定義參數(shù)、標(biāo)頭和正文,并向服務(wù)器創(chuàng)建完全自定義的請(qǐng)求。我們還可以通過模擬端點(diǎn)調(diào)用方法,這使我們能夠檢查API周圍的所有流量。

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

3.自動(dòng)化API測(cè)試(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測(cè)試結(jié)果。它們包含所有方法調(diào)用的報(bào)告,包括錯(cuò)誤(如果發(fā)生)、請(qǐng)求或響應(yīng)中的任何不一致,以及其他有價(jià)值的信息,這些信息可以幫助調(diào)查API的問題。Dredd還可以與任何CI/CD工具連接,當(dāng)任何更改應(yīng)用于代碼時(shí),該工具會(huì)自動(dòng)運(yùn)行測(cè)試。

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

API審核:最重要的

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

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

上一篇:

調(diào)用Leonardo.ai API 實(shí)現(xiàn)文生圖:小白上手指南

下一篇:

使用.Net構(gòu)建一個(gè)RESTful Web API
#你可能也喜歡這些API文章!

我們有何不同?

API服務(wù)商零注冊(cè)

多API并行試用

數(shù)據(jù)驅(qū)動(dòng)選型,提升決策效率

查看全部API→
??

熱門場(chǎng)景實(shí)測(cè),選對(duì)API

#AI文本生成大模型API

對(duì)比大模型API的內(nèi)容創(chuàng)意新穎性、情感共鳴力、商業(yè)轉(zhuǎn)化潛力

25個(gè)渠道
一鍵對(duì)比試用API 限時(shí)免費(fèi)

#AI深度推理大模型API

對(duì)比大模型API的邏輯推理準(zhǔn)確性、分析深度、可視化建議合理性

10個(gè)渠道
一鍵對(duì)比試用API 限時(shí)免費(fèi)