Get started | Usage | Usage Examples | How does it work? | Features | Optional Headers | Cheatsheet
- Download the latest release of
df.jar - Copy-paste the content of the dump example to the file
dump.txt:GET /api/customer/123 HTTP/1.1 HTTP/1.1 200 OK Content-Type: application/json { "id": 123, "fname": "John", "lname": "Doe", "email": ["john@example.com", "johndoe@example.com"] }
- Start the server from command line:
java -jar df.jar --dump dump.txt
- Use a browser to check whether the server is running:
http://localhost:8080/api/customer/123
- Get response:
For more examples, see the cheatsheet.
java -jar df.jar [OPTIONS] [FLAGS] [COMMANDS]
OPTIONS:
--port <number> HTTP TCP port number, default: 8080
--port-ssl <number> HTTPS TCP port number, default: 8443
--dump <file|url>... dump text file(s) and/or OpenAPI json/yaml file(s)
--data <file|url>... json/yaml/csv data file(s) to populate templates
--openapi-path <path> serve OpenAPI client at specified context path
--openapi-title <text> provide custom OpenAPI spec title
--collect <file> collect live request/response to file
--format <json|yaml> output format for --print-* commands, default: json
--status <number> status code for non-matching requests, default: 400
--max-log-body <number> max body bytes in console log, default: unlimited
FLAGS:
--no-log disable request/response console logging
--no-log-headers disable request/response headers in console logging
--no-log-body disable request/response body in console logging
--no-cors disable CORS headers
--no-etag disable 'ETag' header
--no-powered-by disable 'X-Powered-By' header
--no-watch disable watch files for changes
--no-color disable ANSI color output for --print-* commands
--no-pretty disable prettyprint for --print-* commands
--no-template disable template processing
--no-wildcard disable wildcard processing
--strict-json enable strict JSON comparison
--redirect enable redirect HTTP to HTTPS
COMMANDS:
--help print help message
--print-info print dump files statistics to stdout as json/yaml
--print-requests print dump requests to stdout as json/yaml
--print-openapi print OpenAPI specification to stdout as json/yaml
java -jar df.jar --dump dump.txtStart server on OpenAPI file:
java -jar df.jar --dump openapi.jsonStart server with built-in OpenAPI client:
java -jar df.jar --openapi-path /api --dump dump.txt
more examples…
Start server on few dump files:
java -jar df.jar --dump dump1.txt dump2.txt dump3.txtStart server on mix of dump and OpenAPI files:
java -jar df.jar --dump dump1.txt openapi2.json dump3.txt openapi4.yamlStart server with built-in OpenAPI client with custom title:
java -jar df.jar --openapi-path /api --openapi-title 'My Killer REST API v18.2.1' --dump dump.txt
even more examples…
Collect live request/response to file:
java -jar df.jar --collect /home/john/live.txt --dump dump.txtSpecify JSON data file to populate templates:
java -jar df.jar --data /home/john/data.json --dump dump.txtPrint dump files statistics to stdout as JSON:
java -jar df.jar --print-info --dump dump.txtPrint dump requests to stdout as JSON:
java -jar df.jar --print-requests --dump dump.txtPrint OpenAPI specification to stdout as JSON:
java -jar df.jar --print-openapi --dump dump.txt
- Java 15 or above
- Got the client's request.
- Search the dump for corresponded entry (request-response pair) by matching all specified request's parts:
method, URI, headers, and body. - If the entry was found, the server sends the appropriate response to the client.
- If the entry was not found, the server sends a status
400(400 Bad request).
- No dependencies, no installation, no configs
- Crossplatform single-file executable
- Retrieve response data from HTTP dumps and/or OpenAPI JSON/YAML
more features…
- Optional built-in OpenAPI client
- Asynchronous requests and responses
- HTTP message formats (RFC 7230)
- Unlimited number of request/response pairs in the dump
- Supports methods:
GET,HEAD,POST,PUT,DELETEetc. - Multi-line and multi-value headers (RFC 7230).
- OpenAPI-styled templates in paths
- Wildcards (
*and?with escape/) in query string and header values - Templates in URI, headers, body
- JSON/YAML/CSV data files to populate templates
- Response body fetching from external sources like URLs, local files, and data URI
- Per entry user-defined request and response delays
- Comments
#in dumps - Live request/response collection
- Optional watching dump files for changes
- Optional
ETagsupport - Optional CORS support
- Optional live request/response logging
- TLS(SSL) connections and HTTP to HTTPS redirect
- Customizable OpenAPI client path
- Latest OpenAPI specification (v3.0.3) in JSON and YAML format
- Colorized console output
- Disabling color via
NO_COLORenvironment variable
