Please find below all attributes that can be configured on a Stubr scenario.

AttributeTyperequiredDescription
groupstringnoGroups help structuring scenarios. Group is exposed via Stubr UI and as response header.
namestringyesUnique descriptive name of scenario. Name is exposed via Stubr UI and as response header.
routestringyesRoute for which scenario should match. It can also contain dynamic path segments (e.g. /my/{dynamic}/route)
methodenumyesDetermines the http method for which scenario should match. One of: GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD
delaynumbernoIntroduces an artificial delay before the response is sent. This is helpful to e.g. simulate time consuming backend activities.
validateboolean | functionnoIf defined as function, the function optionally receives requestHeaders, requestBody and requestParams as parameters and is supposed to return a boolean if defined. If the function returns true, the scenario is considered to be matched and thus used to resolve the response.
responseCodenumberyesHttp response code to be returned with response (e.g. 200 indicating a default success or 400 indicating a bad request)
responseHeadersobject | functionnoCan either be an object or a function. The function optionally receives requestHeaders, requestBody and requestParams as parameters to determine dynamic headers to be returned.
responseFilePathstringnoDefines the path to a static file to be exposed as response. The path needs to be a string and is interpreted relative to the script file, which defines the register() function. The file type of referenced file is being used to auto populate the Content-Type response header. If responseFilePath is specified, then a potentially additionally defined responseBody would be ignored.
responseBodyobject | functionnoCan either be an object or a function. The function optionally receives requestHeaders, requestBody and requestParams as parameters to determine a dynamic response body to be returned.
Example:
stubr.register({
	// scenarios can be grouped (optional)
	group: "My Group",
	// required
	name: "Scenario 1",
	// required
	route: "/my/first/route", 
	// GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD
	method: Method.GET,
	// delay response (optional)
	delay: 2000,
	// headers, parameters and body are passed to provide context for validation
	validate: (requestHeaders, requestBody, requestParams) => {
		return requestHeaders.Authorization !== undefined; // disallow unauthorized requests
	},
  // http response code
	responseCode: 200,
	// optionally you can receive headers and body to construct dynamic response headers based on request
	responseHeaders: (requestHeaders, requestBody, requestParams) => {
		"X-Custom-Header-Attribute": "abc"
	},
	// optionally you can receive headers and body to construct dynamic response body based on request
	responseBody: (requestHeaders, requestBody, requestParams) => {
		data: "json response"
	}
});
stubr.register({
	// scenarios can be grouped (optional)
	group: "My Group",
	// required
	name: "Scenario 1",
	// required
	route: "/my/first/route", 
	// GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD
	method: "GET",
	// delay response (optional)
	delay: 2000,
	// headers, parameters and body are passed to provide context for validation
	validate: (requestHeaders, requestBody, requestParams) => {
		return requestHeaders.Authorization !== undefined; // disallow unauthorized requests
	},
  // http response code
	responseCode: 200,
	// optionally you can receive headers and body to construct dynamic response headers based on request
	responseHeaders: (requestHeaders, requestBody, requestParams) => {
		"X-Custom-Header-Attribute": "abc"
	},
	// optionally you can receive headers and body to construct dynamic response body based on request
	responseBody: (requestHeaders, requestBody, requestParams) => {
		data: "json response"
	}
});