sphinx域在rest中标记restful web服务

sphinx-http-domain的Python项目详细描述


说明

sphinx插件添加http域,允许 restful http方法。

这是目前非常初级和实验性的代码。

http方法

您可以记录简单的方法,在路径中包装任何参数 带大括号:

.. http:method:: GET /api/foo/bar/{id}/{slug}

   :arg id: An id
   :arg slug: A slug

   Retrieve list of foobars matching given id.

还支持查询字符串参数,包括强制参数和 可选:

.. http:method:: GET /api/foo/bar/?id&slug

   :param id: An id
   :optparam slug: A slug

   Search for a list of foobars matching given id.

此外,还可以为参数和参数提供类型:

.. http:method:: GET /api/foo/bar/{id}/?slug

   :arg integer id: An id
   :optparam string slug: A slug

   Search for a list of foobars matching given id.

还支持片段:

.. http:method:: GET /#!/username

   :fragment username: A username

   Renders a user's profile page.

此外,您还可以用响应代码记录响应:

.. http:method:: POST /api/foo/bar/

   :param string slug: A slug
   :response 201: A foobar was created successfully.
   :response 400:

   Create a foobar.

要引用http方法,请使用:http:method:

.. http:method:: GET /api/
   :label-name: get-root
   :title: API root

The :http:method:`get-root` contains all of the API.

http响应

记录回复也很简单:

.. http:response:: Foobar object

   A foobar object looks like this::

   .. source-code:: js
      {
         'slug': SLUG
      }

   :data string SLUG: A slug
   :format: JSON

要引用http响应,请使用:http:response:

.. http:response:: Foobar object

A :http:response:`foobar-object` is returned when you foo the bar.

安装

运行pip install sphinx-http-domain

然后,将sphinx_http_domain添加到conf.py:

extensions = ['sphinx_http_domain']

开发

对于贡献,请在github上分叉此项目!

作者

大卫曾格拉夫(https://github.com/deceze

贡献者

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java素数校正(2个数组)   java是否可以将ArrayList除以一个double并创建一个新列表?   列出Java类Java的消息体编写器。util。ArrayList   Java将管道分隔文本\csv文件转换为XML   JAVA木卫一。IOException:读取Transferncode时EOF过早:分块http响应   java Volatile变量的读写   java错误:类型不匹配:无法从ArrayList<Subchild>转换为ArrayList<String>   java:无法向AsyncLoadingCache提供CacheWriter   java多级listview Android Studio   静态Java哈希映射性能   循环如何在JAVA中创建三角形   java在春季为ContextFactoryBean定义多个contextPath路由   java从服务器的URL下载数据,并将其保存在一个私有的安全文件夹中   JavaSpringJPA查询   objective c Java REST服务二进制下载   使用JavaSpringRESTAPI并将记录插入mysql表   java你会选择一个算法的速度而不是它对内存的有效使用吗?   java通过多个字段比较对象,如何添加一个方法?   java在spring框架上使用@ModelAttribute(“myobject”)访问服务器上的JSON