WSO2 API 管理主体中的两个参数

WSO2 API Manager Two Parameters in Body

我使用 API 管理器版本 3.0.0。

在Resources 的Publisher 页面中,当类型为BODY 且方法HTTP 为POST 时,我需要添加两个或更多参数,与 类似,但仅允许在参数为Body 时添加一个。

是否可以添加多个参数BODY?以及如何?

编辑:

可能在 BODY 中有两个参数,在 API Publisher-> API Definition -> Edit 中以这种形式出现,编辑您需要的服务类似于:

/v1/nipCliente: 
      post: 
        requestBody: 
          content: 
            application/x-www-form-urlencoded: 
              schema: 
                type: "object"
                properties: 
                  id_usuario: 
                    type: "string"
                  password: 
                    type: "string"
                  nip: 
                    type: "string"
          required: false
        responses: 
          200: 
            description: "ok"
        security: 
          - 
            default: []
        x-auth-type: "None"
        x-throttling-tier: "Unlimited"

在同一页中看起来是:

在 API Developer->Try Out 中,看起来类似于:

POST 中的多个 body 参数,PUT 请求是 NOT 设计所允许的,因为请求只能有一个负载。 [1]

如果请求 body 包含多个参数,您可以将其作为单个参数发送 json object.

应修改后端服务方法以接受特定的 object 模型。

例如:假设我想发送以下内容作为 body。

{
   "name" : "Joe",
   "age" : 23,
   "grade" : 9
}

需要Student的后端服务方法object。

@POST
public Response studentPost(Student student) {

}

学生Object

public class Student{
   String name;
   int age;
   int grade;

   ... getters/ setters ...

}

或者,您可以使用不同的参数。即,查询参数 + body + header 参数。

[1] https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parameter-object