Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Create a mocks file for the MockResponsePlugin from files containing raw HTTP responses.
Synopsis
devproxy mocks from-http-responses <http-response-files>... [options]
Arguments:
<http-response-files> Glob pattern to the file(s) containing HTTP responses to create mock responses from
Options:
--mocks-file <mocks file> File to save the generated mock responses to (required)
--log-level <level> Logging level: trace|debug|information|warning|error
-h, --help Show help
Usage
devproxy mocks from-http-responses <http-response-files> --mocks-file <mocks-file>
Arguments
| Name | Description | Required | Default |
|---|---|---|---|
<http-response-files> |
One or more glob patterns to the files containing HTTP responses to create mock responses from, for example, *.http. Dev Proxy resolves the patterns relative to the current folder. |
Yes | None |
Options
| Name | Description | Allowed values | Default |
|---|---|---|---|
--mocks-file <mocks file> |
File to save the generated mock responses to. Required. | None | |
--log-level <loglevel> |
Level of messages to log | trace, debug, information, warning, error |
information |
Exit codes
| Code | Meaning |
|---|---|
0 |
Success |
1 |
No files match the specified patterns, or Dev Proxy couldn't parse one or more of the HTTP response files |
2 |
Invalid input or usage |
When Dev Proxy can't parse some of the files, it still writes mocks for the files that it parsed successfully and exits with 1.
Remarks
The mocks command is available only when you enable the MockResponsePlugin in your Dev Proxy configuration file.
Each file must contain a single raw HTTP response that starts with the status line, for example:
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": 1,
"name": "Contoso"
}
For each file, Dev Proxy creates a mock with the response's status code, headers, and body. If the response has the application/json content type, Dev Proxy stores the body as JSON. Otherwise, it stores the body as a string. Each generated mock matches requests to any URL (*), so update the request property of each mock to match the requests that you want to mock.