Swagger 和 json-rpc [英] Swagger and json-rpc

查看:30
本文介绍了Swagger 和 json-rpc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 Swagger-ui 用于由 php 编写的 json-rpc 服务器.我使用 Swagger-PHP 为 Swagger-ui 生成 json 投诉容器.所以,我对 Swagger 很陌生,我对这样的方法使用了注释:

I'm trying to use Swagger-ui for my json-rpc server which was written by php. I use Swagger-PHP to generate json complaint container for Swagger-ui. So, I'm very new to Swagger and I use annotation for methods like that:

/**
 *  @SWG\Resource(
 *      apiVersion="0.2",
 *      swaggerVersion="0.8",
 *      basePath="http://mydomain.com",
 *      @SWG\Api(
 *          path="/rpc/json/server.php",
 *          description="Operations about Devices",
 *          @SWG\Operations(
 *              @SWG\Operation(
 *                  method="POST",
 *                  summary="Get device by ID",
 *                  nickname="getDevice",
 *                  @SWG\Parameters(
 *                      @SWG\Parameter(
 *                          name="deviceID",
 *                          description="device id",
 *                          required="true",
 *                          type="string"
 *                      )
 *                  ),
 *                  @SWG\ResponseMessages(
 *                      @SWG\ResponseMessage(code=404, message="Device not found")
 *                  )
 *              )
 *          )
 *      )
 *  )
*/

在 SWG\Operation 中,我需要添加一种与 json-rpc 对应的方法"spec.因此,所有请求都将使用 POST 方法作为 http 和 json 容器的一部分,每个请求都有自己的方法".

In SWG\Operation I need to add one more "method" in correspondence with json-rpc spec. As a result all requests will use POST method as part of http and json container will have its own "method" for each one.

问题 - 我应该从哪里开始寻找来解决这个问题?

The question - where should I start searching to solve this issue?

对不起我的英语.不是原生的.

推荐答案

在@SWG\Api() 或@SWG\Operations() 中添加额外的@SWG\Operation()

Add additional @SWG\Operation()s inside the @SWG\Api() or @SWG\Operations()

我添加了一个示例 在一个@SWG\Api() 中演示了多个操作.

I've added an example which demonstrates multiple operations in one @SWG\Api().

这是否回答了您的问题?我不熟悉 json-rpc 规范.

Does this answer your question?, i'm not familiar with the json-rpc spec.

这篇关于Swagger 和 json-rpc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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