Stub Mapping 列表,包括统计信息。
```
{
"definitions": {},
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://example.mock.com/mappings-get-response.json",
"type": "object",
"title": "mappings-get-response",
"description": "获取 StubMappings 列表。",
"readOnly": true,
"writeOnly": false,
"properties": {
"mappings": {
"$id": "mappings",
"type": "array",
"properties": {
"id": {
"$id": "mappings[0].id",
"description": "stub mapping 的唯一标识",
"type": "string"
},
"priority": {
"$id": "mappings[0].priority",
"description": "该 stub mapping 相对于其他 stub mapping的优先级,最高为1。",
"type": "integer",
"minimum": 1
},
"persistent": {
"$id": "mappings[0].persistent",
"description": "Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default.",
"type": "boolean"
},
"scenarioName": {
"$id": "mappings[0].scenarioName",
"description": "The name of the scenario that this stub mapping is part of",
"type": "string"
},
"requiredScenarioState": {
"$id": "mappings[0].requiredScenarioState",
"description": "The required state of the scenario in order for this stub to be matched.",
"type": "string"
},
"newScenarioState": {
"$id": "mappings[0].newScenarioState",
"description": "The new state for the scenario to be updated to after this stub is served.",
"type": "string"
},
"postServeActions": {
"$id": "mappings[0].postServeActions",
"description": "A map of the names of post serve action extensions to trigger and their parameters.",
"type": "object"
},
"metadata": {
"$id": "mappings[0].metadata",
"type": "object",
"description": "Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs."
},
"request": {
"$id": "mappings[0].request",
"type": "object",
"properties": {
"url": {
"$id": "mappings[0].request.url",
"description": "The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.",
"type": "string"
},
"urlPattern": {
"$id": "mappings[0].request.urlPattern",
"description": "The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.",
"type": "string"
},
"urlPath": {
"$id": "mappings[0].request.urlPath",
"description": "The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.",
"type": "string"
},
"urlPathPattern": {
"$id": "mappings[0].request.urlPathPattern",
"description": "The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.",
"type": "string"
},
"method": {
"$id": "mappings[0].request.method",
"description": "The HTTP request method e.g. GET",
"type": "string"
},
"headers": {
"$id": "mappings[0].request.headers",
"description": "Header patterns to match against in the <key>: { \"<predicate>\": \"<value>\" } form",
"type": "object"
},
"queryParameters": {
"$id": "mappings[0].request.queryParameters",
"description": "Query parameter patterns to match against in the <key>: { \"<predicate>\": \"<value>\" } form",
"type": "object"
},
"cookies": {
"$id": "mappings[0].request.cookies",
"description": "Cookie patterns to match against in the <key>: { \"<predicate>\": \"<value>\" } form",
"type": "object"
},
"bodyPatterns": {
"$id": "mappings[0].request.bodyPatterns",
"description": "Request body patterns to match against in the <key>: { \"<predicate>\": \"<value>\" } form",
"type": "array",
"items": {
"$id": "mappings[0].request.bodyPatterns[0]",
"type": "object"
}
},
"basicAuthCredentials": {
"$id": "mappings[0].request.basicAuthCredentials",
"description": "Pre-emptive basic auth credentials to match against",
"type": "object",
"properties": {
"username": {
"$id": "mappings[0].request.basicAuthCredentials.username",
"type": "string"
},
"password": {
"$id": "mappings[0].request.basicAuthCredentials.password",
"type": "string"
}
},
"required": [
"username",
"password"
]
}
},
"example": {
"method": "POST",
"url": "/some/thing",
"headers": {
"Content-Type": "application/json"
},
"bodyPatterns": [
{
"equalToJson": "{ \"numbers\": [1, 2, 3] }"
}
]
}
},
"response": {
"$id": "mappings[0].response",
"type": "object",
"properties": {
"status": {
"$id": "mappings[0].response.status",
"description": "The HTTP status code to be returned",
"type": "integer"
},
"statusMessage": {
"$id": "mappings[0].response.statusMessage",
"description": "The HTTP status message to be returned",
"type": "string"
},
"body": {
"$id": "mappings[0].response.body",
"description": "The response body as a string. Only one of body, base64Body, jsonBody or bodyFileName may be specified.",
"type": "string"
},
"headers": {
"$id": "mappings[0].response.headers",
"description": "Map of response headers to send",
"type": "object"
},
"jsonBody": {
"$id": "mappings[0].response.jsonBody",
"description": "The response body as a JSON object. Only one of body, base64Body, jsonBody or bodyFileName may be specified.",
"type": "object"
},
"bodyFileName": {
"$id": "mappings[0].response.bodyFileName",
"description": "The path to the file containing the response body, relative to the configured file root. Only one of body, base64Body, jsonBody or bodyFileName may be specified.",
"type": "string"
},
"base64Body": {
"$id": "mappings[0].response.base64Body",
"description": "The response body as a base64 encoded string (useful for binary content). Only one of body, base64Body, jsonBody or bodyFileName may be specified.",
"type": "string"
},
"additionalProxyRequestHeaders": {
"$id": "mappings[0].response.additionalProxyRequestHeaders",
"description": "Extra request headers to send when proxying to another host.",
"type": "object"
},
"fixedDelayMilliseconds": {
"$id": "mappings[0].response.fixedDelayMilliseconds",
"description": "Number of milliseconds to delay be before sending the response.",
"type": "integer"
},
"delayDistribution": {
"$id": "mappings[0].response.delayDistribution",
"description": "Random delay settings.",
"type": "object",
"oneOf": [
{
"description": "Log normal randomly distributed response delay.",
"properties": {
"type": {
"$id": "mappings[0].response.delayDistribution.type",
"type": "string",
"enum": [
"lognormal"
]
},
"median": {
"$id": "mappings[0].response.delayDistribution.median",
"type": "integer"
},
"sigma": {
"$id": "mappings[0].response.delayDistribution.sigma",
"type": "number"
}
},
"required": [
"type",
"median",
"sigma"
]
},
{
"description": "Uniformly distributed random response delay.",
"properties": {
"type": {
"$id": "mappings[0].response.delayDistribution.type",
"type": "string",
"enum": [
"uniform"
]
},
"upper": {
"$id": "mappings[0].response.delayDistribution.upper",
"type": "integer"
},
"lower": {
"$id": "mappings[0].response.delayDistribution.lower",
"type": "integer"
}
},
"required": [
"type",
"upper",
"lower"
]
}
]
},
"fault": {
"$id": "mappings[0].response.fault",
"type": "string",
"description": "The fault to apply (instead of a full, valid response).",
"enum": [
"CONNECTION_RESET_BY_PEER",
"EMPTY_RESPONSE",
"MALFORMED_RESPONSE_CHUNK",
"RANDOM_DATA_THEN_CLOSE"
]
},
"proxyBaseUrl": {
"$id": "mappings[0].response.proxyBaseUrl",
"description": "The base URL of the target to proxy matching requests to.",
"type": "string"
},
"transformers": {
"$id": "mappings[0].response.transformers",
"description": "List of names of transformers to apply to this response.",
"type": "array",
"items": {
"$id": "mappings[0].response.transformers[0]",
"type": "string"
}
},
"transformerParameters": {
"$id": "mappings[0].response.transformerParameters",
"description": "Parameters to apply to response transformers.",
"type": "object"
},
"fromConfiguredStub": {
"$id": "mappings[0].response.fromConfiguredStub",
"description": "Read-only flag indicating false if this was the default, unmatched response. Not present otherwise.",
"type": "boolean"
}
}
}
},
"example": {
"id": "76ada7b0-49ae-4229-91c4-396a36f18e09",
"priority": 3,
"request": {
"method": "GET",
"url": "/some/thing",
"headers": {
"Accept": "text/plain"
}
},
"response": {
"status": 200,
"body": "Hello world!",
"headers": {
"Content-Type": "text/plain"
}
}
}
},
"meta": {
"$id": "meta",
"type": "object",
"properties": {
"total": {
"$id": "meta.total",
"type": "integer"
}
},
"required": [
"total"
]
}
}
}
```
- Admin API
- Stub Mapping API
- /mappings
- GET
- POST
- DELETE
- /mappings/reset
- /mappings/{stubMappingId}
- GET
- PUT
- DELETE
- /mocklab/mappings/normal
- /mocklab/mappings/notify
- Record API
- /recordings/start
- /recordings/stop
- /recordings/status
- /recordings/snapshot
- Settings API
- /mocklab/settings
- JSON Schema
- Stub Mapping
- Stub Mappings
- Stub Mappings meta
- 官方 API 文档
- 文章模板
- API 文章模板