-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoatfile.schema.json
More file actions
158 lines (158 loc) · 4.71 KB
/
coatfile.schema.json
File metadata and controls
158 lines (158 loc) · 4.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/yesdevnull/trenchcoat/coatfile.schema.json",
"title": "Trenchcoat Coat File",
"description": "Schema for Trenchcoat coat files defining HTTP request/response mocks.",
"type": "object",
"required": ["coats"],
"additionalProperties": false,
"properties": {
"coats": {
"description": "List of coat (mock) definitions.",
"type": "array",
"items": {
"$ref": "#/$defs/coat"
}
}
},
"$defs": {
"coat": {
"description": "An individual request/response mock definition.",
"type": "object",
"required": ["request"],
"additionalProperties": false,
"properties": {
"name": {
"description": "Descriptive name for this coat.",
"type": "string"
},
"request": {
"$ref": "#/$defs/request"
},
"response": {
"$ref": "#/$defs/response"
},
"responses": {
"description": "Ordered list of responses for sequence mode. Mutually exclusive with 'response'.",
"type": "array",
"items": {
"$ref": "#/$defs/response"
},
"minItems": 1
},
"sequence": {
"description": "Sequence mode for plural responses. Only valid with 'responses'.",
"type": "string",
"enum": ["cycle", "once"]
}
},
"oneOf": [
{
"required": ["response"],
"properties": {
"responses": false,
"sequence": false
}
},
{
"required": ["responses"],
"properties": {
"response": false
}
}
]
},
"request": {
"description": "Matching criteria for an incoming HTTP request.",
"type": "object",
"required": ["uri"],
"additionalProperties": false,
"properties": {
"method": {
"description": "HTTP method to match. Defaults to GET. Use ANY to match all methods.",
"type": "string",
"default": "GET"
},
"uri": {
"description": "URI path to match. Supports exact strings, glob patterns (*/?) and regex (~/prefix).",
"type": "string"
},
"headers": {
"description": "Subset of headers to match. Values support glob patterns (*/?).",
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"query": {
"description": "Query string matching. Either a raw query string or a map of key/value pairs (values support glob patterns).",
"oneOf": [
{
"type": "string"
},
{
"type": "object",
"additionalProperties": {
"type": "string"
}
}
]
},
"body": {
"description": "Request body to match. When omitted, any body matches.",
"type": "string"
},
"body_match": {
"description": "Body matching mode: exact (default), glob, contains, or regex.",
"type": "string",
"enum": ["exact", "glob", "contains", "regex"],
"default": "exact"
}
}
},
"response": {
"description": "Mock response to return.",
"type": "object",
"additionalProperties": false,
"properties": {
"code": {
"description": "HTTP status code. Defaults to 200.",
"type": "integer",
"minimum": 100,
"maximum": 599,
"default": 200
},
"headers": {
"description": "Response headers to set.",
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"body": {
"description": "Response body string. Mutually exclusive with 'body_file'.",
"type": "string"
},
"body_file": {
"description": "Path to a file whose contents are used as the response body. Resolved relative to the coat file location. Mutually exclusive with 'body'.",
"type": "string"
},
"delay_ms": {
"description": "Delay in milliseconds before sending the response.",
"type": "integer",
"minimum": 0,
"default": 0
},
"delay_jitter_ms": {
"description": "Random jitter in milliseconds added on top of delay_ms. The actual additional delay is a random value in the range [0, N) where N is this value.",
"type": "integer",
"minimum": 0,
"default": 0
}
},
"not": {
"required": ["body", "body_file"]
}
}
}
}