【问题标题】:How to specify error codes in Apiary Documentation?如何在 Apiary 文档中指定错误代码?
【发布时间】:2014-05-29 06:50:45
【问题描述】:

我想指定在进行 API 调用时必须返回的各种异常/错误。我如何使用 Apiary 实现这一目标。

【问题讨论】:

    标签: apiblueprint


    【解决方案1】:

    凯尔的回答确实是正确的。我将补充一点,如果您想为此添加更多语义,您可以编写其他可能的响应,如下所示:

    ## POST /users/resendVerification/{userId}
    
    Resends the user's verification code to the email address on record.
    
    + Response 201
    
    + Response 403
    
        Returned if the user does not have access to the requested account
    
        + Body
    
    + Response 404
    
        Returned if a user was not found for the given userId
    
        + Body
    

    注意:需要+ Body(即使它是空的)来区分描述和消息体。

    【讨论】:

      【解决方案2】:

      我不知道错误代码的特定语法。在过去,我只是简单地使用了要点。例如,这是我的重新请求验证码 API 的代码。

      ## POST /users/resendVerification/{userId}
      
      Resends the user's verification code to the email address on record.</br>
      • 403 is returned if the user does not have access to the requested account</br>
      • 404 is returned if a user was not found for the given userId</br>
      
      + Response 201
      

      希望对您有所帮助。

      【讨论】:

      • 是的,这可能是一个解决方案。实际上,我正在寻找可以突出显示所有可能错误代码的错误部分的东西。您知道的任何其他 API 文档工具。感谢您的回答。
      • Mashery 是另一种。我们对他们和 Apiary 进行了评估,并与 Apiary 一起去了,没有任何抱怨。到目前为止都很棒。
      猜你喜欢
      • 1970-01-01
      • 2012-05-20
      • 1970-01-01
      • 1970-01-01
      • 2016-03-12
      • 2020-07-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多