Metadata 业务数据定义
```
{
"metadata":{
"record":{
"id":"1234",
"source":"proxy",
"type":"online",
"transID":"c95fb9eb40bc449c87b5cbfb5c774e79"
}
}
}
```
参数解释
| key | value | description |
| --- | --- | --- |
| *id* | UUID | 录制ID |
| *source* | proxy、bury、import | 录制数据来源:proxy为代理录制、bury为埋点录制、import为其他方式录制数据的导入 |
| *type* | online、offline | 录制类型 |
| *transID* | ID | 事务ID(仅用于异步) |
---
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": {
"id": {
"$id": "id",
"description": "stub mapping 的唯一标识",
"type": "string"
},
"priority": {
"$id": "priority",
"description": "该 stub mapping 相对于其他 stub mapping的优先级,最高为1。",
"type": "integer",
"minimum": 1
},
"persistent": {
"$id": "persistent",
"description": "Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default.",
"type": "boolean"
},
"scenarioName": {
"$id": "scenarioName",
"description": "The name of the scenario that this stub mapping is part of",
"type": "string"
},
"requiredScenarioState": {
"$id": "requiredScenarioState",
"description": "The required state of the scenario in order for this stub to be matched.",
"type": "string"
},
"newScenarioState": {
"$id": "newScenarioState",
"description": "The new state for the scenario to be updated to after this stub is served.",
"type": "string"
},
"postServeActions": {
"$id": "postServeActions",
"description": "A map of the names of post serve action extensions to trigger and their parameters.",
"type": "object"
},
"metadata": {
"$id": "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": "request",
"type": "object",
"properties": {
"url": {
"$id": "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": "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": "request.urlPath",
"description": "The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.",
"type": "string"
},
"urlPathPattern": {
"$id": "request.urlPathPattern",
"description": "The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.",
"type": "string"
},
"method": {
"$id": "request.method",
"description": "The HTTP request method e.g. GET",
"type": "string"
},
"headers": {
"$id": "request.headers",
"description": "Header patterns to match against in the <key>: { \"<predicate>\": \"<value>\" } form",
"type": "object"
},
"queryParameters": {
"$id": "request.queryParameters",
"description": "Query parameter patterns to match against in the <key>: { \"<predicate>\": \"<value>\" } form",
"type": "object"
},
"cookies": {
"$id": "request.cookies",
"description": "Cookie patterns to match against in the <key>: { \"<predicate>\": \"<value>\" } form",
"type": "object"
},
"bodyPatterns": {
"$id": "request.bodyPatterns",
"description": "Request body patterns to match against in the <key>: { \"<predicate>\": \"<value>\" } form",
"type": "array",
"items": {
"$id": "request.bodyPatterns[0]",
"type": "object"
}
},
"basicAuthCredentials": {
"$id": "request.basicAuthCredentials",
"description": "Pre-emptive basic auth credentials to match against",
"type": "object",
"properties": {
"username": {
"$id": "request.basicAuthCredentials.username",
"type": "string"
},
"password": {
"$id": "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": "response",
"type": "object",
"properties": {
"status": {
"$id": "response.status",
"description": "The HTTP status code to be returned",
"type": "integer"
},
"statusMessage": {
"$id": "response.statusMessage",
"description": "The HTTP status message to be returned",
"type": "string"
},
"body": {
"$id": "response.body",
"description": "The response body as a string. Only one of body, base64Body, jsonBody or bodyFileName may be specified.",
"type": "string"
},
"headers": {
"$id": "response.headers",
"description": "Map of response headers to send",
"type": "object"
},
"jsonBody": {
"$id": "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": "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": "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": "response.additionalProxyRequestHeaders",
"description": "Extra request headers to send when proxying to another host.",
"type": "object"
},
"fixedDelayMilliseconds": {
"$id": "response.fixedDelayMilliseconds",
"description": "Number of milliseconds to delay be before sending the response.",
"type": "integer"
},
"delayDistribution": {
"$id": "response.delayDistribution",
"description": "Random delay settings.",
"type": "object",
"oneOf": [
{
"description": "Log normal randomly distributed response delay.",
"properties": {
"type": {
"$id": "response.delayDistribution.type",
"type": "string",
"enum": [
"lognormal"
]
},
"median": {
"$id": "response.delayDistribution.median",
"type": "integer"
},
"sigma": {
"$id": "response.delayDistribution.sigma",
"type": "number"
}
},
"required": [
"type",
"median",
"sigma"
]
},
{
"description": "Uniformly distributed random response delay.",
"properties": {
"type": {
"$id": "response.delayDistribution.type",
"type": "string",
"enum": [
"uniform"
]
},
"upper": {
"$id": "response.delayDistribution.upper",
"type": "integer"
},
"lower": {
"$id": "response.delayDistribution.lower",
"type": "integer"
}
},
"required": [
"type",
"upper",
"lower"
]
}
]
},
"fault": {
"$id": "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": "response.proxyBaseUrl",
"description": "The base URL of the target to proxy matching requests to.",
"type": "string"
},
"transformers": {
"$id": "response.transformers",
"description": "List of names of transformers to apply to this response.",
"type": "array",
"items": {
"$id": "response.transformers[0]",
"type": "string"
}
},
"transformerParameters": {
"$id": "response.transformerParameters",
"description": "Parameters to apply to response transformers.",
"type": "object"
},
"fromConfiguredStub": {
"$id": "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"
}
}
}
}
```
- 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 文章模板