【发布时间】:2014-05-29 06:50:45
【问题描述】:
我想指定在进行 API 调用时必须返回的各种异常/错误。我如何使用 Apiary 实现这一目标。
【问题讨论】:
标签: apiblueprint
我想指定在进行 API 调用时必须返回的各种异常/错误。我如何使用 Apiary 实现这一目标。
【问题讨论】:
标签: apiblueprint
凯尔的回答确实是正确的。我将补充一点,如果您想为此添加更多语义,您可以编写其他可能的响应,如下所示:
## 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(即使它是空的)来区分描述和消息体。
【讨论】:
我不知道错误代码的特定语法。在过去,我只是简单地使用了要点。例如,这是我的重新请求验证码 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
希望对您有所帮助。
【讨论】: