创建Blueprint API文档时如何在URL中格式化基于哈希的参数? [英] How to format hash-based parameters in the URL when creating Blueprint API doc?

查看:206
本文介绍了创建Blueprint API文档时如何在URL中格式化基于哈希的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Rails在URL的参数中添加散列的方式如下所示:

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

如何格式化API Blueprint文档以容纳可用哈希列表?


  • 参数
    < $>
  • person [first](required,string, Jane )...名字




执行文档时,这是不合法的。



欢迎您提供任何想法或提示!

href =https://tools.ietf.org/html/rfc3986#section-3.2.2 =nofollow> https://tools.ietf.org/html/rfc3986#section-3.2.2 < a>,你必须在URI中转义[]。因此,您需要:


  • 参数

    • person%5B first%5D (必需的,字符串,简)...




在你的蓝图中,你也必须逃避[]。
$ b

仅供参考,在Apiary.io代码生成的原始文档中存在一个错误(如果你正在使用)和生成的URI在不正确处理转义的时刻。您可以打开Beta文档,但没有这个问题。


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!

解决方案

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.

这篇关于创建Blueprint API文档时如何在URL中格式化基于哈希的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆