mocking

    The JSON schema supports the following types in their fields:

    • string
    • number
    • integer
    • boolean
    • object
    • array

    Here is a JSON schema example:

    1. {
    2. "field1": 123.12,
    3. "field3_2": {
    4. "field3_2_1": true,
    5. "field3_2_2": [
    6. 155,
    7. 155
    8. ]
    9. }
    10. },
    11. "field0": "abcd",
    12. "field2": [
    13. "sC"
    14. ]

    The example below configures the Plugin for a specific Route:

    Once you have configured the Plugin as mentioned above, you can test the Route.

    1. {
    2. "delay":0,
    3. "content_type":"",
    4. "with_mock_header":true,
    5. "response_status":201,
    6. "response_example":"{\"a\":1,\"b\":2}"
    7. }

    Now to test the Route:

    1. HTTP/1.1 201 Created
    2. ...
    3. Content-Type: application/json;charset=utf8
    4. x-mock-by: APISIX/2.10.0
    5. ...

    To disable the mocking Plugin, you can delete the corresponding JSON configuration from the Plugin configuration. APISIX will automatically reload and you do not have to restart for this to take effect.