swagger api mock server
Runs an api mock server, by parsing a swagger.yml file. You can edit the swagger.yml, reload the browser and everything should be up-to-date.
how to run
The
-i
is important for thectrl-c
command to be send togrunt
.
just to take a look
docker run -i \
-p 8000:8000 \
-t palo/swagger-api-mock
with your swagger.yml
You need a folder where your swagger.yml
is placed.
It has to be named swagger.yml
.
docker run -i \
-p 8000:8000 \
-v /path/to/folder:/data \
-t palo/swagger-api-mock
If you need to specify a different name for YAML file you can mount a volume like the following:
docker run -i \
-p 8000:8000 \
-v /path/to/file.yaml:/data/swagger.yml \
-t palo/swagger-api-mock
CORS support
HTTP headers for Cross-Origin Resource Sharing (CORS) are automatically set to allow any kind of access. All preflight or normal requests will be automatically served with the following values:
Header | Value |
---|---|
Access-Control-Allow-Origin |
If the HTTP request includes an Origin header, then this value is echoed back; otherwise value is a wildcard * |
Access-Control-Allow-Credentials |
If the Access-Control-Allow-Origin is a wildcard * value is false ; otherwise true . |
Access-Control-Allow-Methods |
All HTTP methods are always sent. |
Access-Control-Allow-Headers |
If the HTTP request includes an Access-Control-Request-Headers header, then this value is echoed back; otherwise it is not set. |
Please note that preflight requests (with OPTIONS
method) will be always forced to HTTP code 200, even if not declared in YAML file.