我想指定在进行API调用时必须返回的各种异常/错误。我如何通过Apiary实现这一目标。
答案 0 :(得分:12)
凯尔的回答确实是对的。我将补充说,如果你想为此添加更多的语义,你可以写下其他可能的响应:
## 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
(即使它是空的)以区分描述和消息正文。
答案 1 :(得分:3)
我不知道错误代码的特定语法。在过去,我只使用了子弹点。例如,这是我的重新请求验证代码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
希望有所帮助。