-
Notifications
You must be signed in to change notification settings - Fork 216
Autogenerated documentation
To generate markdown documentation from the pact files, in the pact_helper.rb
file in the consumer project configure:
Pact.configure do | config |
config.doc_generator = :markdown
config.doc_dir = "..." # optional, defaults to "./doc/pacts"
end
If you would like another type of documentation (eg. HTML), you can roll your own.
An example of the generated documentation follows:
-
A request for an alligator given there is an alligator named Mary
-
A request for an alligator given there is not an alligator named Mary
-
A request for an alligator given an error occurs retrieving an alligator
Given there is an alligator named Mary, upon receiving a request for an alligator from Zoo App, with
{
"method": "get",
"path": "/alligators/Mary",
"headers": {
"Accept": "application/json"
}
}
Animal Service will respond with:
{
"status": 200,
"headers": {
"Content-Type": "application/json;charset=utf-8"
},
"body": {
"name": "Mary"
}
}
Given there is not an alligator named Mary, upon receiving a request for an alligator from Zoo App, with
{
"method": "get",
"path": "/alligators/Mary",
"headers": {
"Accept": "application/json"
}
}
Animal Service will respond with:
{
"status": 404
}
Given an error occurs retrieving an alligator, upon receiving a request for an alligator from Zoo App, with
{
"method": "get",
"path": "/alligators/Mary",
"headers": {
"Accept": "application/json"
}
}
Animal Service will respond with:
{
"status": 500,
"headers": {
"Content-Type": "application/json;charset=utf-8"
},
"body": {
"error": "Argh!!!"
}
}