问题 如何在Apiary文档中指定错误代码?


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


7461
2018-05-29 06:50


起源



答案:


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

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


12
2018-06-01 06:48





我不知道错误代码的特定语法。在过去,我只使用了子弹点。例如,这是我的重新请求验证代码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

希望有所帮助。


3
2018-05-29 17:29



雅可能是一个解决方案。实际上我正在寻找能够突出显示所有可能错误代码的错误部分的内容。您了解的任何其他API文档工具。感谢你的回答。 - Harshit
Mashery是另一个。我们对它们和Apiary进行了评估,并与Apiary一起进行了评估并且没有任何抱怨。到目前为止一直很棒。 - Kyle Clegg
毫无疑问它很棒:) - Harshit


答案:


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

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


12
2018-06-01 06:48





我不知道错误代码的特定语法。在过去,我只使用了子弹点。例如,这是我的重新请求验证代码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

希望有所帮助。


3
2018-05-29 17:29



雅可能是一个解决方案。实际上我正在寻找能够突出显示所有可能错误代码的错误部分的内容。您了解的任何其他API文档工具。感谢你的回答。 - Harshit
Mashery是另一个。我们对它们和Apiary进行了评估,并与Apiary一起进行了评估并且没有任何抱怨。到目前为止一直很棒。 - Kyle Clegg
毫无疑问它很棒:) - Harshit