How to format hash-based parameters in the URL when creating Blueprint API doc?

青春壹個敷衍的年華 提交于 2020-01-14 06:21:07

问题


With the Rails Way of adding hashes in the parameter of an URL like so:

 http://api.example.com?person[first]=Jane&person[last]=Doe&person[email]=jane@doe.com

How do I format the API Blueprint doc to accommodate a list of available hashes?

  • Parameters
    • person[first] (required, string, Jane) ... First name

This is not legal when I execute the document.

Any ideas or tips are welcome!


回答1:


Per https://tools.ietf.org/html/rfc3986#section-3.2.2, you must escape [] in URIs. As such, you need to do:

  • Parameters
    • person%5Bfirst%5D (required, string, Jane) ...

If you template the URI in your blueprint, you must also escape the [] there as well.

FYI, there is a bug in the original documentation for code generation in Apiary.io (if you are using that) and the generated URIs at the moment that does not properly handle the escaping. You can turn on the Beta documentation, which does not have that issue.



来源:https://stackoverflow.com/questions/27004098/how-to-format-hash-based-parameters-in-the-url-when-creating-blueprint-api-doc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!