Skip to content

Commit eee7de5

Browse files
committed
fix: align config schemas to data model.
1 parent 1b634cb commit eee7de5

File tree

8 files changed

+101
-27
lines changed

8 files changed

+101
-27
lines changed

docs/rate_limiting.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,9 @@ concurrency:
157157

158158
- threshold: 5
159159
response:
160-
delay:
161-
range:
162-
min: 500
163-
max: 2000 # Random delay between 0.5-2 seconds
160+
delay: # Random delay between 0.5-2 seconds
161+
min: 500
162+
max: 2000
164163
statusCode: 200
165164
content: "Heavily throttled"
166165
```

examples/rest/rate-limiting/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,8 @@ resources:
9090
"processingTime": "normal"
9191
}
9292
delay:
93-
range:
94-
min: 100
95-
max: 500
93+
min: 100
94+
max: 500
9695
headers:
9796
Content-Type: application/json
9897

examples/rest/rate-limiting/imposter-config.yaml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,8 @@ resources:
114114
"status": "success"
115115
}
116116
delay:
117-
range:
118-
min: 100
119-
max: 500
117+
min: 100
118+
max: 500
120119
headers:
121120
Content-Type: application/json
122121

@@ -211,9 +210,8 @@ resources:
211210
"status": "success"
212211
}
213212
delay:
214-
range:
215-
min: 50
216-
max: 200
213+
min: 50
214+
max: 200
217215
headers:
218216
Content-Type: application/json
219217

@@ -250,9 +248,8 @@ resources:
250248
"estimatedTime": "5-10 seconds"
251249
}
252250
delay:
253-
range:
254-
min: 5000
255-
max: 10000
251+
min: 5000
252+
max: 10000
256253
headers:
257254
Content-Type: application/json
258255

examples/rest/steps/imposter-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ resources:
6363
expression: "${remote.response.body.id}"
6464

6565
response:
66-
content: User created with ID: ${stores.request.userId}
66+
content: "User created with ID: ${stores.request.userId}"
6767
statusCode: 201
68-
template: true
68+
template: true

tools/validate_config/current-format-schema.json

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@
44
"definitions": {
55
"currentFormat": {
66
"type": "object",
7-
"required": ["plugin", "resources"],
7+
"required": ["plugin"],
88
"properties": {
99
"plugin": {
1010
"type": "string",
11-
"enum": ["rest", "soap", "hbase", "openapi"]
11+
"enum": ["rest", "soap", "hbase", "openapi", "oidc-server", "swaggerui"]
1212
},
1313
"basePath": {
1414
"type": "string"
1515
},
16+
"specFile": {
17+
"description": "OpenAPI specification file (YAML or JSON)",
18+
"type": "string"
19+
},
1620
"wsdlFile": {
1721
"type": "string"
1822
},
@@ -71,7 +75,13 @@
7175
}
7276
},
7377
"additionalProperties": false
74-
}
78+
},
79+
"config": {
80+
"type": "object",
81+
"description": "Plugin-specific configuration block for external plugins",
82+
"additionalProperties": true
83+
},
84+
"validation": { "$ref": "shared-definitions.json#/definitions/validation" }
7585
},
7686
"additionalProperties": false
7787
}

tools/validate_config/legacy-format-schema.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@
99
{
1010
"required": ["resources"],
1111
"not": {
12-
"required": ["response", "path", "method", "contentType"]
12+
"required": ["response", "path", "method", "contentType", "specFile", "wsdlFile"]
1313
}
1414
},
1515
{
1616
"anyOf": [
1717
{ "required": ["response"] },
1818
{ "required": ["path"] },
1919
{ "required": ["method"] },
20-
{ "required": ["contentType"] }
20+
{ "required": ["contentType"] },
21+
{ "required": ["specFile"] },
22+
{ "required": ["wsdlFile"] }
2123
],
2224
"not": {
2325
"required": ["resources"]
@@ -32,6 +34,10 @@
3234
"basePath": {
3335
"type": "string"
3436
},
37+
"specFile": {
38+
"description": "OpenAPI specification file (YAML or JSON)",
39+
"type": "string"
40+
},
3541
"wsdlFile": {
3642
"type": "string"
3743
},
@@ -99,6 +105,12 @@
99105
"contentType": {
100106
"type": "string",
101107
"description": "[DEPRECATED] Please use response.headers['Content-Type'] instead. This property will be removed in a future version."
108+
},
109+
"validation": { "$ref": "shared-definitions.json#/definitions/validation" },
110+
"config": {
111+
"type": "object",
112+
"description": "Plugin-specific configuration block for external plugins",
113+
"additionalProperties": true
102114
}
103115
}
104116
}

tools/validate_config/shared-definitions.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,41 @@
161161
}
162162
},
163163
"additionalProperties": true
164+
},
165+
"validation": {
166+
"type": "object",
167+
"description": "OpenAPI request/response validation configuration",
168+
"properties": {
169+
"request": {
170+
"oneOf": [
171+
{ "type": "boolean" },
172+
{
173+
"type": "string",
174+
"enum": ["fail", "log", "ignore", "true", "false"]
175+
}
176+
],
177+
"description": "Enable/disable request validation against OpenAPI spec"
178+
},
179+
"response": {
180+
"oneOf": [
181+
{ "type": "boolean" },
182+
{
183+
"type": "string",
184+
"enum": ["fail", "log", "ignore", "true", "false"]
185+
}
186+
],
187+
"description": "Enable/disable response validation against OpenAPI spec"
188+
},
189+
"levels": {
190+
"type": "object",
191+
"description": "Map of validation keys to log levels",
192+
"additionalProperties": {
193+
"type": "string",
194+
"enum": ["ERROR", "WARN"]
195+
}
196+
}
197+
},
198+
"additionalProperties": false
164199
}
165200
}
166201
}

tools/validate_config/validate_configs.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def validate_config_file(file_path, schema):
3737
"""Validate a single config file against the schema."""
3838
try:
3939
with open(file_path, 'r') as f:
40-
config = yaml.safe_load(f)
40+
# Handle multi-document YAML files
41+
documents = list(yaml.safe_load_all(f))
4142

4243
# Create a resolver that can handle references to other schema files
4344
schema_dir = Path(__file__).parent.resolve()
@@ -64,9 +65,30 @@ def custom_uri_handler(uri):
6465
handlers={'': custom_uri_handler}
6566
)
6667

67-
Draft7Validator(schema, resolver=resolver).validate(config)
68-
print(f"✓ {file_path} - Valid")
69-
return True
68+
validator = Draft7Validator(schema, resolver=resolver)
69+
70+
# Validate each document
71+
all_valid = True
72+
for i, config in enumerate(documents):
73+
if config is None: # Skip empty documents
74+
continue
75+
try:
76+
validator.validate(config)
77+
except ValidationError as e:
78+
print(f"✗ {file_path} - Document {i+1} Invalid:")
79+
print(f" Error: {e.message}")
80+
print(f" Path: {' -> '.join(str(p) for p in e.path)}")
81+
all_valid = False
82+
83+
if all_valid:
84+
doc_count = len([d for d in documents if d is not None])
85+
if doc_count > 1:
86+
print(f"✓ {file_path} - Valid ({doc_count} documents)")
87+
else:
88+
print(f"✓ {file_path} - Valid")
89+
return True
90+
return False
91+
7092
except ValidationError as e:
7193
print(f"✗ {file_path} - Invalid:")
7294
print(f" Error: {e.message}")

0 commit comments

Comments
 (0)