Service-checker

From mediawiki.org

service-checker is a generic swagger-based webservice checker. It uses an extension of the swagger specification called x-amples.

Spec[edit]

x-amples is currently supported for both GET and POST requests. Inside each get or post stanza, there can be x-monitor and x-amples keys. x-monitor indicates whether service-checker should test that endpoint. By default it is True. x-amples is a list of objects with title, request and response objects.

title: human description of the request that is being made

request

  • params: interpolated into the URL template according to RFC 6570 (note that only a subset is currently supported)
  • headers: Any HTTP headers that should be sent along with the request
  • query: Any query parameters that should be sent along with the request if a GET request
  • body: Any POST data that should be sent along with the request if a POST request

response

  • status: HTTP status code that should be expected (integer)
  • headers: HTTP headers that should be expected
  • body: Exact body response that is expected or a regex. To indicate that it is a regex, it should start and end with a slash (/)

Additionally, in the root spec, there can be a x-default-params object. Each parameter specified here will be applied to every request (TODO: are these query parameters or for URL interpolation?)

Here's a basic but complete example:

{
	"x-default-params": {
		"format": "json"
	},
	"paths": {
		"/pets/{id}": {
			"get": {
				"x-monitor": true,
				"x-amples": [{
					"request": {
						"params": {
							"id": 10
						},
						"headers": {
							"Accept": "application/json"
						},
						"query": {
							"refresh": "y"
						}
					},
					"response": {
						"status": 200,
						"headers": {
							"X-Pet-Iscute": "yes"
						},
						"body": {
							"species": "/canis .*/"
						}
					}
				}]
			}
		}
	}
}

External links[edit]