You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apisix.apache.org by EH <ru...@foxmail.com> on 2021/12/31 07:43:14 UTC

[Proposal] api mocking plugin: generate mock response for debegging,testing or pressure measurement.

Background
usualy when we develop a new feature on website or miniprogram or mobile application, we go through 3 steps:
1. design api documents,include api path,paramter,response;
2. develop frontend and backend at the same time;
3. testing and debugging the frontend and backend program.


in step 2, the frontend need to mock the api’s parameter and response,to debug program,and if there’s multiple front-end applications,each app need to do mock.


consider this scenario,if our api gateway can support api mocking,the steps 2 will come down to:
1. turn on mocking plugin when backend is still developing apis.
2. turn off mocking plugin when the api is finished.
and there is nothing need to do for frontend developer,even neednt to change the api url.


based on the above scenario, the mocking plugin can be use in more scenario,such as:

when we pressure test the APISIX. we can use the mocking plugins to mock duration of api and status and response,instead of real upstream.

in microservice invocation chain,we can mock service one by one to find the&nbsp; abnormal service.
Plugin Design

this plugin design is reference to mock.js and kong's mocking plugin.
it is planned to be implemented in two phases.


phase 1, goal to implement base mock abilities.
the general design is as follows:


local schema = {
    type = "object",
    properties = {
        -- specify response delay time,default 0ms
        delay = { type = "integer" },
        -- specify response status,default 200
        response_status = { type = "integer" },
        -- specify response content type,support application/xml,text/plain and application/json,default application/json
        content_type = { type = "content_type" },
        -- specify response body.
        response_example = {type = "string"},
        -- specify response json schema,if response_example is not nil,this conf will be ignore.
        -- generate random response by json schema.
        response_schema = { type = "object" },
    },
    anyOf = {
        {required = {"response_example"}},
        {required = {"response_schema"}}
    }
}


phase 2, goal to implement higher-order ability,such as "expectation and response patterns".

Re: [Proposal] api mocking plugin: generate mock response for debegging,testing or pressure measurement.

Posted by Zhiyuan Ju <ju...@apache.org>.
Hi Community,

Any ideas on this?

Best Regards!
@ Zhiyuan Ju <https://github.com/juzhiyuan>


EH <ru...@foxmail.com> 于2022年1月6日周四 10:52写道:

> @shuaijinchao&nbsp;Thank you for your attension.And I think these two
> questions are actually same.
> Most of the time, we need a random response generated based on JSON
> SCHEMA, because we usually define only the type of the response parameter,
> not the value of the parameter, when defining the API.
> So when we need a random response based on JSON SCHEMA, we use the
> `response_schema` param, and when we need a fixed response we use the
> `response_example` param.
> Comparing the two plugins,the `mocking` plugin focuses more on mock the
> response body of real apis&nbsp;while the `fault-injection` focuses more on
> mock the delay of apis.
> By the way, the 'mocking' plugin will next support returning different
> response body based on different request headers and params.
>
>
>
>
>
>
> ------------------&nbsp;原始邮件&nbsp;------------------
> 发件人:
>                                                   "dev"
>                                                                 <
> shuaijinchao@apache.org&gt;;
> 发送时间:&nbsp;2022年1月5日(星期三) 晚上7:09
> 收件人:&nbsp;"dev"<dev@apisix.apache.org&gt;;
>
> 主题:&nbsp;Re: [Proposal] api mocking plugin: generate mock response for
> debegging,testing or pressure measurement.
>
>
>
> Hi, @EH Thank you very much for your suggestions
>
> I have two questions:
> 1. Why is JSON response independent, instead of `response_body` that
> combines `response_example` and `response_schema` into one?
> 2. Do you think the `fault-injection`[1] plugin can meet the current needs?
>
> [1]
>
> https://github.com/apache/apisix/blob/master/docs/zh/latest/plugins/fault-injection.md
>
> EH <rui1642@foxmail.com&gt; 于2021年12月31日周五 15:43写道:
>
> &gt; *Background*
> &gt; usualy when we develop a new feature on website or miniprogram or
> mobile
> &gt; application, we go through 3 steps:
> &gt; 1. design api documents,include api path,paramter,response;
> &gt; 2. develop frontend and backend at the same time;
> &gt; 3. testing and debugging the frontend and backend program.
> &gt;
> &gt; in step 2, the frontend need to mock the api’s parameter and
> response,to
> &gt; debug program,and if there’s multiple front-end applications,each app
> need
> &gt; to do mock.
> &gt;
> &gt; consider this scenario,if our api gateway can support api mocking,the
> &gt; steps 2 will come down to:
> &gt; 1. turn on mocking plugin when backend is still developing apis.
> &gt; 2. turn off mocking plugin when the api is finished.
> &gt; and there is nothing need to do for frontend developer,even neednt to
> &gt; change the api url.
> &gt;
> &gt; based on the above scenario, the mocking plugin can be use in more
> &gt; scenario,such as:
> &gt;
> &gt;&nbsp;&nbsp;&nbsp; - when we pressure test the APISIX. we can use the
> mocking plugins to
> &gt;&nbsp;&nbsp;&nbsp; mock duration of api and status and
> response,instead of real upstream.
> &gt;&nbsp;&nbsp;&nbsp; - in microservice invocation chain,we can mock
> service one by one to
> &gt;&nbsp;&nbsp;&nbsp; find the&nbsp; abnormal service.
> &gt;
> &gt; *Plugin Design*
> &gt; this plugin design is reference to mock.js
> &gt; <https://github.com/nuysoft/Mock/wiki/Mock.Random&gt; and kong's
> mocking
> &gt; plugin <https://docs.konghq.com/hub/kong-inc/mocking/&gt;.
> &gt; it is planned to be implemented in two phases.
> &gt;
> &gt; phase 1, goal to implement base mock abilities.
> &gt; the general design is as follows:
> &gt;
> &gt; local schema = {
> &gt;&nbsp;&nbsp;&nbsp;&nbsp; type = "object",
> &gt;&nbsp;&nbsp;&nbsp;&nbsp; properties = {
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- specify response
> delay time,default 0ms
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delay = { type =
> "integer" },
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- specify response
> status,default 200
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; response_status = {
> type = "integer" },
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- specify response
> content type,support application/xml,text/plain and
> application/json,default application/json
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; content_type = { type
> = "content_type" },
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- specify response
> body.
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; response_example =
> {type = "string"},
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- specify response
> json schema,if response_example is not nil,this conf will be ignore.
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- generate random
> response by json schema.
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; response_schema = {
> type = "object" },
> &gt;&nbsp;&nbsp;&nbsp;&nbsp; },
> &gt;&nbsp;&nbsp;&nbsp;&nbsp; anyOf = {
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {required =
> {"response_example"}},
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {required =
> {"response_schema"}}
> &gt;&nbsp;&nbsp;&nbsp;&nbsp; }
> &gt; }
> &gt;
> &gt;
> &gt; phase 2, goal to implement higher-order ability,such as "expectation
> and
> &gt; response patterns".
> &gt;
> &gt;
> &gt;
> &gt;
>
> --
> Thanks,
> Janko

Re: [Proposal] api mocking plugin: generate mock response for debegging,testing or pressure measurement.

Posted by Tsangleslie <le...@icloud.com.INVALID>.
Sound Good. Looking forward to this plugins.

Leslie Tsang
leslie.tsang@icloud.com

> On 10 Jan 2022, at 10:11 AM, EH <ru...@foxmail.com> wrote:
> 
> Sure, its a good advice, how about "x-mock-by: apisix"?
> 
> 
> 
> 
> ------------------&nbsp;原始邮件&nbsp;------------------
> 发件人:                                                                                                                        "dev"                                                                                    <leslie.tsang@icloud.com.INVALID <ma...@icloud.com.INVALID>&gt;;
> 发送时间:&nbsp;2022年1月9日(星期天) 下午5:57
> 收件人:&nbsp;"dev"<dev@apisix.apache.org <ma...@apisix.apache.org>&gt;;
> 
> 主题:&nbsp;Re: [Proposal] api mocking plugin: generate mock response for debegging,testing or pressure measurement.
> 
> 
> 
> LGTM, Shall we add a Header to notify the client that the response is generated by the mock plugin ?
> 
> 
> Leslie Tsang
> leslie.tsang@icloud.com
> 
> &gt; On 6 Jan 2022, at 10:51 AM, EH <rui1642@foxmail.com&gt; wrote:
> &gt; 
> &gt; @shuaijinchao&amp;nbsp;Thank you for your attension.And I think these two questions are actually same.
> &gt; Most of the time, we need a random response generated based on JSON SCHEMA, because we usually define only the type of the response parameter, not the value of the parameter, when defining the API.
> &gt; So when we need a random response based on JSON SCHEMA, we use the `response_schema` param, and when we need a fixed response we use the `response_example` param.
> &gt; Comparing the two plugins,the `mocking` plugin focuses more on mock the response body of real apis&amp;nbsp;while the `fault-injection` focuses more on mock the delay of apis.
> &gt; By the way, the 'mocking' plugin will next support returning different response body based on different request headers and params.
> &gt; 
> &gt; 
> &gt; 
> &gt; 
> &gt; 
> &gt; 
> &gt; ------------------&amp;nbsp;原始邮件&amp;nbsp;------------------
> &gt; 发件人:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "dev"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <shuaijinchao@apache.org <mailto:shuaijinchao@apache.org&gt;&amp;gt;;
> &gt; 发送时间:&amp;nbsp;2022年1月5日(星期三) 晚上7:09
> &gt; 收件人:&amp;nbsp;"dev"<dev@apisix.apache.org <mailto:dev@apisix.apache.org&gt;&amp;gt;;
> &gt; 
> &gt; 主题:&amp;nbsp;Re: [Proposal] api mocking plugin: generate mock response for debegging,testing or pressure measurement.
> &gt; 
> &gt; 
> &gt; 
> &gt; Hi, @EH Thank you very much for your suggestions
> &gt; 
> &gt; I have two questions:
> &gt; 1. Why is JSON response independent, instead of `response_body` that
> &gt; combines `response_example` and `response_schema` into one?
> &gt; 2. Do you think the `fault-injection`[1] plugin can meet the current needs?
> &gt; 
> &gt; [1]
> &gt; https://github.com/apache/apisix/blob/master/docs/zh/latest/plugins/fault-injection.md <https://github.com/apache/apisix/blob/master/docs/zh/latest/plugins/fault-injection.md>
> &gt; 
> &gt; EH <rui1642@foxmail.com <ma...@foxmail.com>&amp;gt; 于2021年12月31日周五 15:43写道:
> &gt; 
> &gt; &amp;gt; *Background*
> &gt; &amp;gt; usualy when we develop a new feature on website or miniprogram or mobile
> &gt; &amp;gt; application, we go through 3 steps:
> &gt; &amp;gt; 1. design api documents,include api path,paramter,response;
> &gt; &amp;gt; 2. develop frontend and backend at the same time;
> &gt; &amp;gt; 3. testing and debugging the frontend and backend program.
> &gt; &amp;gt;
> &gt; &amp;gt; in step 2, the frontend need to mock the api’s parameter and response,to
> &gt; &amp;gt; debug program,and if there’s multiple front-end applications,each app need
> &gt; &amp;gt; to do mock.
> &gt; &amp;gt;
> &gt; &amp;gt; consider this scenario,if our api gateway can support api mocking,the
> &gt; &amp;gt; steps 2 will come down to:
> &gt; &amp;gt; 1. turn on mocking plugin when backend is still developing apis.
> &gt; &amp;gt; 2. turn off mocking plugin when the api is finished.
> &gt; &amp;gt; and there is nothing need to do for frontend developer,even neednt to
> &gt; &amp;gt; change the api url.
> &gt; &amp;gt;
> &gt; &amp;gt; based on the above scenario, the mocking plugin can be use in more
> &gt; &amp;gt; scenario,such as:
> &gt; &amp;gt;
> &gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; - when we pressure test the APISIX. we can use the mocking plugins to
> &gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mock duration of api and status and response,instead of real upstream.
> &gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; - in microservice invocation chain,we can mock service one by one to
> &gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; find the&amp;nbsp; abnormal service.
> &gt; &amp;gt;
> &gt; &amp;gt; *Plugin Design*
> &gt; &amp;gt; this plugin design is reference to mock.js
> &gt; &amp;gt; <https://github.com/nuysoft/Mock/wiki/Mock.Random&amp;gt <https://github.com/nuysoft/Mock/wiki/Mock.Random&amp;gt&gt;; and kong's mocking
> &gt; &amp;gt; plugin <https://docs.konghq.com/hub/kong-inc/mocking/&amp;gt <https://docs.konghq.com/hub/kong-inc/mocking/&amp;gt&gt;;.
> &gt; &amp;gt; it is planned to be implemented in two phases.
> &gt; &amp;gt;
> &gt; &amp;gt; phase 1, goal to implement base mock abilities.
> &gt; &amp;gt; the general design is as follows:
> &gt; &amp;gt;
> &gt; &amp;gt; local schema = {
> &gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type = "object",
> &gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; properties = {
> &gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- specify response delay time,default 0ms
> &gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delay = { type = "integer" },
> &gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- specify response status,default 200
> &gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; response_status = { type = "integer" },
> &gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- specify response content type,support application/xml,text/plain and application/json,default application/json
> &gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; content_type = { type = "content_type" },
> &gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- specify response body.
> &gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; response_example = {type = "string"},
> &gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- specify response json schema,if response_example is not nil,this conf will be ignore.
> &gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- generate random response by json schema.
> &gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; response_schema = { type = "object" },
> &gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; },
> &gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; anyOf = {
> &gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {required = {"response_example"}},
> &gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {required = {"response_schema"}}
> &gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
> &gt; &amp;gt; }
> &gt; &amp;gt;
> &gt; &amp;gt;
> &gt; &amp;gt; phase 2, goal to implement higher-order ability,such as "expectation and
> &gt; &amp;gt; response patterns".
> &gt; &amp;gt;
> &gt; &amp;gt;
> &gt; &amp;gt;
> &gt; &amp;gt;
> &gt; 
> &gt; -- 
> &gt; Thanks,
> &gt; Janko


回复: [Proposal] api mocking plugin: generate mock response for debegging,testing or pressure measurement.

Posted by EH <ru...@foxmail.com>.
Sure, its a good advice, how about "x-mock-by: apisix"?




------------------&nbsp;原始邮件&nbsp;------------------
发件人:                                                                                                                        "dev"                                                                                    <leslie.tsang@icloud.com.INVALID&gt;;
发送时间:&nbsp;2022年1月9日(星期天) 下午5:57
收件人:&nbsp;"dev"<dev@apisix.apache.org&gt;;

主题:&nbsp;Re: [Proposal] api mocking plugin: generate mock response for debegging,testing or pressure measurement.



LGTM, Shall we add a Header to notify the client that the response is generated by the mock plugin ?


Leslie Tsang
leslie.tsang@icloud.com

&gt; On 6 Jan 2022, at 10:51 AM, EH <rui1642@foxmail.com&gt; wrote:
&gt; 
&gt; @shuaijinchao&amp;nbsp;Thank you for your attension.And I think these two questions are actually same.
&gt; Most of the time, we need a random response generated based on JSON SCHEMA, because we usually define only the type of the response parameter, not the value of the parameter, when defining the API.
&gt; So when we need a random response based on JSON SCHEMA, we use the `response_schema` param, and when we need a fixed response we use the `response_example` param.
&gt; Comparing the two plugins,the `mocking` plugin focuses more on mock the response body of real apis&amp;nbsp;while the `fault-injection` focuses more on mock the delay of apis.
&gt; By the way, the 'mocking' plugin will next support returning different response body based on different request headers and params.
&gt; 
&gt; 
&gt; 
&gt; 
&gt; 
&gt; 
&gt; ------------------&amp;nbsp;原始邮件&amp;nbsp;------------------
&gt; 发件人:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "dev"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <shuaijinchao@apache.org <mailto:shuaijinchao@apache.org&gt;&amp;gt;;
&gt; 发送时间:&amp;nbsp;2022年1月5日(星期三) 晚上7:09
&gt; 收件人:&amp;nbsp;"dev"<dev@apisix.apache.org <mailto:dev@apisix.apache.org&gt;&amp;gt;;
&gt; 
&gt; 主题:&amp;nbsp;Re: [Proposal] api mocking plugin: generate mock response for debegging,testing or pressure measurement.
&gt; 
&gt; 
&gt; 
&gt; Hi, @EH Thank you very much for your suggestions
&gt; 
&gt; I have two questions:
&gt; 1. Why is JSON response independent, instead of `response_body` that
&gt; combines `response_example` and `response_schema` into one?
&gt; 2. Do you think the `fault-injection`[1] plugin can meet the current needs?
&gt; 
&gt; [1]
&gt; https://github.com/apache/apisix/blob/master/docs/zh/latest/plugins/fault-injection.md
&gt; 
&gt; EH <rui1642@foxmail.com&amp;gt; 于2021年12月31日周五 15:43写道:
&gt; 
&gt; &amp;gt; *Background*
&gt; &amp;gt; usualy when we develop a new feature on website or miniprogram or mobile
&gt; &amp;gt; application, we go through 3 steps:
&gt; &amp;gt; 1. design api documents,include api path,paramter,response;
&gt; &amp;gt; 2. develop frontend and backend at the same time;
&gt; &amp;gt; 3. testing and debugging the frontend and backend program.
&gt; &amp;gt;
&gt; &amp;gt; in step 2, the frontend need to mock the api’s parameter and response,to
&gt; &amp;gt; debug program,and if there’s multiple front-end applications,each app need
&gt; &amp;gt; to do mock.
&gt; &amp;gt;
&gt; &amp;gt; consider this scenario,if our api gateway can support api mocking,the
&gt; &amp;gt; steps 2 will come down to:
&gt; &amp;gt; 1. turn on mocking plugin when backend is still developing apis.
&gt; &amp;gt; 2. turn off mocking plugin when the api is finished.
&gt; &amp;gt; and there is nothing need to do for frontend developer,even neednt to
&gt; &amp;gt; change the api url.
&gt; &amp;gt;
&gt; &amp;gt; based on the above scenario, the mocking plugin can be use in more
&gt; &amp;gt; scenario,such as:
&gt; &amp;gt;
&gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; - when we pressure test the APISIX. we can use the mocking plugins to
&gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mock duration of api and status and response,instead of real upstream.
&gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; - in microservice invocation chain,we can mock service one by one to
&gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; find the&amp;nbsp; abnormal service.
&gt; &amp;gt;
&gt; &amp;gt; *Plugin Design*
&gt; &amp;gt; this plugin design is reference to mock.js
&gt; &amp;gt; <https://github.com/nuysoft/Mock/wiki/Mock.Random&amp;gt <https://github.com/nuysoft/Mock/wiki/Mock.Random&amp;gt&gt;; and kong's mocking
&gt; &amp;gt; plugin <https://docs.konghq.com/hub/kong-inc/mocking/&amp;gt <https://docs.konghq.com/hub/kong-inc/mocking/&amp;gt&gt;;.
&gt; &amp;gt; it is planned to be implemented in two phases.
&gt; &amp;gt;
&gt; &amp;gt; phase 1, goal to implement base mock abilities.
&gt; &amp;gt; the general design is as follows:
&gt; &amp;gt;
&gt; &amp;gt; local schema = {
&gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type = "object",
&gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; properties = {
&gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- specify response delay time,default 0ms
&gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delay = { type = "integer" },
&gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- specify response status,default 200
&gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; response_status = { type = "integer" },
&gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- specify response content type,support application/xml,text/plain and application/json,default application/json
&gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; content_type = { type = "content_type" },
&gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- specify response body.
&gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; response_example = {type = "string"},
&gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- specify response json schema,if response_example is not nil,this conf will be ignore.
&gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- generate random response by json schema.
&gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; response_schema = { type = "object" },
&gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; },
&gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; anyOf = {
&gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {required = {"response_example"}},
&gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {required = {"response_schema"}}
&gt; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&gt; &amp;gt; }
&gt; &amp;gt;
&gt; &amp;gt;
&gt; &amp;gt; phase 2, goal to implement higher-order ability,such as "expectation and
&gt; &amp;gt; response patterns".
&gt; &amp;gt;
&gt; &amp;gt;
&gt; &amp;gt;
&gt; &amp;gt;
&gt; 
&gt; -- 
&gt; Thanks,
&gt; Janko

Re: [Proposal] api mocking plugin: generate mock response for debegging,testing or pressure measurement.

Posted by Tsangleslie <le...@icloud.com.INVALID>.
LGTM, Shall we add a Header to notify the client that the response is generated by the mock plugin ?


Leslie Tsang
leslie.tsang@icloud.com

> On 6 Jan 2022, at 10:51 AM, EH <ru...@foxmail.com> wrote:
> 
> @shuaijinchao&nbsp;Thank you for your attension.And I think these two questions are actually same.
> Most of the time, we need a random response generated based on JSON SCHEMA, because we usually define only the type of the response parameter, not the value of the parameter, when defining the API.
> So when we need a random response based on JSON SCHEMA, we use the `response_schema` param, and when we need a fixed response we use the `response_example` param.
> Comparing the two plugins,the `mocking` plugin focuses more on mock the response body of real apis&nbsp;while the `fault-injection` focuses more on mock the delay of apis.
> By the way, the 'mocking' plugin will next support returning different response body based on different request headers and params.
> 
> 
> 
> 
> 
> 
> ------------------&nbsp;原始邮件&nbsp;------------------
> 发件人:                                                                                                                        "dev"                                                                                    <shuaijinchao@apache.org <ma...@apache.org>&gt;;
> 发送时间:&nbsp;2022年1月5日(星期三) 晚上7:09
> 收件人:&nbsp;"dev"<dev@apisix.apache.org <ma...@apisix.apache.org>&gt;;
> 
> 主题:&nbsp;Re: [Proposal] api mocking plugin: generate mock response for debegging,testing or pressure measurement.
> 
> 
> 
> Hi, @EH Thank you very much for your suggestions
> 
> I have two questions:
> 1. Why is JSON response independent, instead of `response_body` that
> combines `response_example` and `response_schema` into one?
> 2. Do you think the `fault-injection`[1] plugin can meet the current needs?
> 
> [1]
> https://github.com/apache/apisix/blob/master/docs/zh/latest/plugins/fault-injection.md
> 
> EH <rui1642@foxmail.com&gt; 于2021年12月31日周五 15:43写道:
> 
> &gt; *Background*
> &gt; usualy when we develop a new feature on website or miniprogram or mobile
> &gt; application, we go through 3 steps:
> &gt; 1. design api documents,include api path,paramter,response;
> &gt; 2. develop frontend and backend at the same time;
> &gt; 3. testing and debugging the frontend and backend program.
> &gt;
> &gt; in step 2, the frontend need to mock the api’s parameter and response,to
> &gt; debug program,and if there’s multiple front-end applications,each app need
> &gt; to do mock.
> &gt;
> &gt; consider this scenario,if our api gateway can support api mocking,the
> &gt; steps 2 will come down to:
> &gt; 1. turn on mocking plugin when backend is still developing apis.
> &gt; 2. turn off mocking plugin when the api is finished.
> &gt; and there is nothing need to do for frontend developer,even neednt to
> &gt; change the api url.
> &gt;
> &gt; based on the above scenario, the mocking plugin can be use in more
> &gt; scenario,such as:
> &gt;
> &gt;&nbsp;&nbsp;&nbsp; - when we pressure test the APISIX. we can use the mocking plugins to
> &gt;&nbsp;&nbsp;&nbsp; mock duration of api and status and response,instead of real upstream.
> &gt;&nbsp;&nbsp;&nbsp; - in microservice invocation chain,we can mock service one by one to
> &gt;&nbsp;&nbsp;&nbsp; find the&nbsp; abnormal service.
> &gt;
> &gt; *Plugin Design*
> &gt; this plugin design is reference to mock.js
> &gt; <https://github.com/nuysoft/Mock/wiki/Mock.Random&gt <https://github.com/nuysoft/Mock/wiki/Mock.Random&gt>; and kong's mocking
> &gt; plugin <https://docs.konghq.com/hub/kong-inc/mocking/&gt <https://docs.konghq.com/hub/kong-inc/mocking/&gt>;.
> &gt; it is planned to be implemented in two phases.
> &gt;
> &gt; phase 1, goal to implement base mock abilities.
> &gt; the general design is as follows:
> &gt;
> &gt; local schema = {
> &gt;&nbsp;&nbsp;&nbsp;&nbsp; type = "object",
> &gt;&nbsp;&nbsp;&nbsp;&nbsp; properties = {
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- specify response delay time,default 0ms
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delay = { type = "integer" },
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- specify response status,default 200
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; response_status = { type = "integer" },
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- specify response content type,support application/xml,text/plain and application/json,default application/json
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; content_type = { type = "content_type" },
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- specify response body.
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; response_example = {type = "string"},
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- specify response json schema,if response_example is not nil,this conf will be ignore.
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- generate random response by json schema.
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; response_schema = { type = "object" },
> &gt;&nbsp;&nbsp;&nbsp;&nbsp; },
> &gt;&nbsp;&nbsp;&nbsp;&nbsp; anyOf = {
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {required = {"response_example"}},
> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {required = {"response_schema"}}
> &gt;&nbsp;&nbsp;&nbsp;&nbsp; }
> &gt; }
> &gt;
> &gt;
> &gt; phase 2, goal to implement higher-order ability,such as "expectation and
> &gt; response patterns".
> &gt;
> &gt;
> &gt;
> &gt;
> 
> -- 
> Thanks,
> Janko


回复: [Proposal] api mocking plugin: generate mock response for debegging,testing or pressure measurement.

Posted by EH <ru...@foxmail.com>.
@shuaijinchao&nbsp;Thank you for your attension.And I think these two questions are actually same.
Most of the time, we need a random response generated based on JSON SCHEMA, because we usually define only the type of the response parameter, not the value of the parameter, when defining the API.
So when we need a random response based on JSON SCHEMA, we use the `response_schema` param, and when we need a fixed response we use the `response_example` param.
Comparing the two plugins,the `mocking` plugin focuses more on mock the response body of real apis&nbsp;while the `fault-injection` focuses more on mock the delay of apis.
By the way, the 'mocking' plugin will next support returning different response body based on different request headers and params.






------------------&nbsp;原始邮件&nbsp;------------------
发件人:                                                                                                                        "dev"                                                                                    <shuaijinchao@apache.org&gt;;
发送时间:&nbsp;2022年1月5日(星期三) 晚上7:09
收件人:&nbsp;"dev"<dev@apisix.apache.org&gt;;

主题:&nbsp;Re: [Proposal] api mocking plugin: generate mock response for debegging,testing or pressure measurement.



Hi, @EH Thank you very much for your suggestions

I have two questions:
1. Why is JSON response independent, instead of `response_body` that
combines `response_example` and `response_schema` into one?
2. Do you think the `fault-injection`[1] plugin can meet the current needs?

[1]
https://github.com/apache/apisix/blob/master/docs/zh/latest/plugins/fault-injection.md

EH <rui1642@foxmail.com&gt; 于2021年12月31日周五 15:43写道:

&gt; *Background*
&gt; usualy when we develop a new feature on website or miniprogram or mobile
&gt; application, we go through 3 steps:
&gt; 1. design api documents,include api path,paramter,response;
&gt; 2. develop frontend and backend at the same time;
&gt; 3. testing and debugging the frontend and backend program.
&gt;
&gt; in step 2, the frontend need to mock the api’s parameter and response,to
&gt; debug program,and if there’s multiple front-end applications,each app need
&gt; to do mock.
&gt;
&gt; consider this scenario,if our api gateway can support api mocking,the
&gt; steps 2 will come down to:
&gt; 1. turn on mocking plugin when backend is still developing apis.
&gt; 2. turn off mocking plugin when the api is finished.
&gt; and there is nothing need to do for frontend developer,even neednt to
&gt; change the api url.
&gt;
&gt; based on the above scenario, the mocking plugin can be use in more
&gt; scenario,such as:
&gt;
&gt;&nbsp;&nbsp;&nbsp; - when we pressure test the APISIX. we can use the mocking plugins to
&gt;&nbsp;&nbsp;&nbsp; mock duration of api and status and response,instead of real upstream.
&gt;&nbsp;&nbsp;&nbsp; - in microservice invocation chain,we can mock service one by one to
&gt;&nbsp;&nbsp;&nbsp; find the&nbsp; abnormal service.
&gt;
&gt; *Plugin Design*
&gt; this plugin design is reference to mock.js
&gt; <https://github.com/nuysoft/Mock/wiki/Mock.Random&gt; and kong's mocking
&gt; plugin <https://docs.konghq.com/hub/kong-inc/mocking/&gt;.
&gt; it is planned to be implemented in two phases.
&gt;
&gt; phase 1, goal to implement base mock abilities.
&gt; the general design is as follows:
&gt;
&gt; local schema = {
&gt;&nbsp;&nbsp;&nbsp;&nbsp; type = "object",
&gt;&nbsp;&nbsp;&nbsp;&nbsp; properties = {
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- specify response delay time,default 0ms
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delay = { type = "integer" },
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- specify response status,default 200
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; response_status = { type = "integer" },
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- specify response content type,support application/xml,text/plain and application/json,default application/json
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; content_type = { type = "content_type" },
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- specify response body.
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; response_example = {type = "string"},
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- specify response json schema,if response_example is not nil,this conf will be ignore.
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- generate random response by json schema.
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; response_schema = { type = "object" },
&gt;&nbsp;&nbsp;&nbsp;&nbsp; },
&gt;&nbsp;&nbsp;&nbsp;&nbsp; anyOf = {
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {required = {"response_example"}},
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {required = {"response_schema"}}
&gt;&nbsp;&nbsp;&nbsp;&nbsp; }
&gt; }
&gt;
&gt;
&gt; phase 2, goal to implement higher-order ability,such as "expectation and
&gt; response patterns".
&gt;
&gt;
&gt;
&gt;

-- 
Thanks,
Janko

Re: [Proposal] api mocking plugin: generate mock response for debegging,testing or pressure measurement.

Posted by JinChao Shuai <sh...@apache.org>.
Hi, @EH Thank you very much for your suggestions

I have two questions:
1. Why is JSON response independent, instead of `response_body` that
combines `response_example` and `response_schema` into one?
2. Do you think the `fault-injection`[1] plugin can meet the current needs?

[1]
https://github.com/apache/apisix/blob/master/docs/zh/latest/plugins/fault-injection.md

EH <ru...@foxmail.com> 于2021年12月31日周五 15:43写道:

> *Background*
> usualy when we develop a new feature on website or miniprogram or mobile
> application, we go through 3 steps:
> 1. design api documents,include api path,paramter,response;
> 2. develop frontend and backend at the same time;
> 3. testing and debugging the frontend and backend program.
>
> in step 2, the frontend need to mock the api’s parameter and response,to
> debug program,and if there’s multiple front-end applications,each app need
> to do mock.
>
> consider this scenario,if our api gateway can support api mocking,the
> steps 2 will come down to:
> 1. turn on mocking plugin when backend is still developing apis.
> 2. turn off mocking plugin when the api is finished.
> and there is nothing need to do for frontend developer,even neednt to
> change the api url.
>
> based on the above scenario, the mocking plugin can be use in more
> scenario,such as:
>
>    - when we pressure test the APISIX. we can use the mocking plugins to
>    mock duration of api and status and response,instead of real upstream.
>    - in microservice invocation chain,we can mock service one by one to
>    find the  abnormal service.
>
> *Plugin Design*
> this plugin design is reference to mock.js
> <https://github.com/nuysoft/Mock/wiki/Mock.Random> and kong's mocking
> plugin <https://docs.konghq.com/hub/kong-inc/mocking/>.
> it is planned to be implemented in two phases.
>
> phase 1, goal to implement base mock abilities.
> the general design is as follows:
>
> local schema = {
>     type = "object",
>     properties = {
>         -- specify response delay time,default 0ms
>         delay = { type = "integer" },
>         -- specify response status,default 200
>         response_status = { type = "integer" },
>         -- specify response content type,support application/xml,text/plain and application/json,default application/json
>         content_type = { type = "content_type" },
>         -- specify response body.
>         response_example = {type = "string"},
>         -- specify response json schema,if response_example is not nil,this conf will be ignore.
>         -- generate random response by json schema.
>         response_schema = { type = "object" },
>     },
>     anyOf = {
>         {required = {"response_example"}},
>         {required = {"response_schema"}}
>     }
> }
>
>
> phase 2, goal to implement higher-order ability,such as "expectation and
> response patterns".
>
>
>
>

-- 
Thanks,
Janko