Quick Start
Download the
httpstubJAR file from the Github repository's releases page. Or download docker image fromghcr.ioCreate folder for stubs
mkdir -p dataCreate a YAML file
api-definition.yamlatdatafolder with the API definition.
Here's an example YAML file that defines a simple endpoint that returns a static JSON response:
#data/api-definition.yaml
rules:
request:
path: /hello
response:
body: Hello, world!This YAML file specifies that when an HTTP GET request is received with a path of /hello, the server should respond with a 200 status code and a plain text containing the message "Hello, world!".
Run the
httpstubserver using the following command(replacinghttpstub.jarwith the name of the JAR file you downloaded in step 1):
STUB_DATA=$(pwd)/data java -jar httpstub.jarThis will start the httpstub server and load the API definition from the YAML file from $(pwd)/data (folder with data from our current location).
Test the
httpstubserver by sending an HTTP GET request to the endpoint defined in the YAML file. For example, if you're running the server onlocalhostport8080, you can use a tool likecurlto send the request:
curl http://localhost:8080/helloThis should return the following response:
Hello, world!sThat's it! You've successfully set up and tested an httpstub server using a YAML API definition file.
Docker
Docker image is available on ghcr.io/gleb619/httpstub
docker run -v $PWD/data:/app/data:ro -p 8080:8080 ghcr.io/gleb619/httpstubLast updated