11

I want to specify the various exceptions/errors that have to be returned while making an API call. How do I achieve this with Apiary.

4

2 回答 2

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需要 (即使它是空的)来区分描述和消息体。

于 2014-06-01T06:48:17.530 回答
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

希望有帮助。

于 2014-05-29T17:29:59.887 回答