[ChatGPT] 10步 让ChatGPT和插件帮助你写API文档

如何使用ChatGPT帮助你编写API文档?

为什么要做这个?

  • 后端有很多通信方式,可以与前端谈论API。
  • 为什么不使用统一格式让chatGPT处理,并使文件更容易且少花费时间。

?让我们开始吧?

  1. 我们需要关注需要编写的 API,因此必须找到所有相关文件,在这个例子中,我有11个文件(Rails)。
  2. 制作一个文件,使用复制粘贴把以下内容放入“Pages”或“Microsoft Word”中。确保有标题,如 文件1 或 响应文件 或 错误代码文件 等...
ChatGPT中文站

3. 另存为PDF文件

4. 前往您的ChatGPT Plus设置,打开插件。

ChatGPT中文站

5. 安装AskYourPDF

ChatGPT中文站

6. 前往官方网站 https://askyourpdf.com/upload ,并在第三步上传您的PDF文件。

7. 上传成功后,您将获得一个文档 ID,请复制它。

ChatGPT中文站

8. 现在,回到您的chatGPT4使用这个提示,记得更改您复制的doc_id并更改您想要撰写的api端点!

You are a technical writer and rails expert, I am sending to you links to API documentation. I would like that you create API specs for the pdf file I share with you :

What is this document about? doc_id: xxxxxxx

Write the api endpoint for "GET /xxx/xd/c/:id/xabvdx/t133ons/impffffrts"
You need specifically to take into account the following principles when you write the API specs. Please, include all endpoints shared.

You need to have operation id defined.
Add the Payload to api document
Add the Response to api document
Add description to parameters
Use correct grammar and ends the plugin description with punctuation
Limited number of endpoints per API specs
Examples should be provided for responses
Provides informative error messages. Guide a user of the plugin about what they can do and the available endpoint for the API otherwise so they are not blocked. This is especially true for errors of not found or request that are not reflecting how the API is being used.”
Additional use of table format for error code , http status code, error description writing

9. 如果这是工作的话,它会看起来像这样。

ChatGPT中文站

10. 错误表格如下所示

ChatGPT中文站

摘要和改进措施

  1. 如果我们可以更改 PDF 文件的标题,而不只是使用“文件1,2,3……”,并使用“响应文件”、“错误代码文件”作为标题,ChatGPT将为您提供更好的 API 错误表和响应。
  2. 如果我们想要通过ChatGPT和Plugin来撰写API文档,只需要稍微更改PDF文件和标题即可。

2023-10-20 17:04:48 AI中文站翻译自原文