This tool generate a mock-server from a swagger spec
- Install Golang
- Run
go get .
in swagger-mock directory
$ ./build.sh
Will copy files to template folder and build swagger-mock executable
This will generate go sources in source folder
$ ./swagger-mock -spec=test.yml -out=sources -rule=rules.json -host=localhost:9000
This will start the embedded server
$ ./swagger-mock -spec=spec.yml -rule=rules.json -host=localhost:9000 -embedded=true
Example
{
"rules": [
{
"opId": "createPets",
"method" : "POST",
"timeout": "10s",
"statusCode":201,
"args": [{
"argType": "JSON",
"body":{"id":"1"}
}],
"response":
{
"id":"3",
"name": "4"
}
}
]
}
This will serve the response for a request for the path from createPets operation id if the request body is {"id":"1"}
.
In the repo exists a rule.json and a spec.yml for testing