Summary
Currently the expected field of a json_match assertion must be a ContentReference object with type and content properties:
assertions:
- type: json_match
path: response.body.json
expected:
type: inline
content: '{"id": 1, "name": "Alice"}'
The request body already supports a shorthand where the value can be a plain string (treated as inline content):
body: '{"id": 1}' # plain string — works today for request body
The same convenience should be available for json_match (and json_schema) expected:
assertions:
- type: json_match
path: response.body.json
expected: '{"id": 1, "name": "Alice"}' # plain string — desired shorthand
When expected is a plain string it should be treated as type: inline with the string as content and an empty ignore list.
Note on Schema File Location
The authoritative YAML schema for test suites is src/main/resources/schemas/test-suite-schema.json — this is the file that is packaged with the application and used at runtime for validation. The file at .vscode/test-suite-schema.json is only a VS Code IDE helper copy and should not be edited directly.
Changes Required
1. JSON Schema (src/main/resources/schemas/test-suite-schema.json)
Change the expected definition for json_match from a bare $ref:
"expected": {
"$ref": "#/$defs/ContentReference"
}
to a oneOf that accepts either a plain string or the full ContentReference object:
"expected": {
"oneOf": [
{
"type": "string",
"description": "Inline expected JSON (shorthand — equivalent to type: inline)"
},
{
"$ref": "#/$defs/ContentReference"
}
]
}
Apply the same change to json_schema's expected field for consistency.
2. YAML Deserialization
ObjectExpectedValue is currently a plain Java record (String type, String content, List<String> ignore). Jackson deserializes it only from an object node.
Add a custom Jackson deserializer (or use @JsonCreator / JsonDeserializer) so that:
- A JSON string node →
new ObjectExpectedValue("inline", theString, null)
- A JSON object node → existing field-by-field mapping (unchanged)
3. No evaluator changes needed
JsonMatchAssertionEvaluator and JsonSchemaAssertionEvaluator already handle type == "inline" correctly, so no changes are needed there once deserialization normalises the plain-string form into an ObjectExpectedValue.
Files to Change
| File |
Change |
src/main/resources/schemas/test-suite-schema.json |
oneOf [string, ContentReference] for json_match and json_schema expected |
src/main/java/.../model/ObjectExpectedValue.java |
Add custom Jackson deserializer to handle plain-string shorthand |
src/test/java/.../model/ObjectExpectedValueDeserializerTest.java (new) |
Unit tests: plain string → ObjectExpectedValue("inline", …, null); object → normal mapping |
src/test/java/.../service/TestSuiteLoaderTest.java |
Integration test: suite YAML using plain-string expected loads correctly |
Summary
Currently the
expectedfield of ajson_matchassertion must be aContentReferenceobject withtypeandcontentproperties:The request body already supports a shorthand where the value can be a plain string (treated as inline content):
The same convenience should be available for
json_match(andjson_schema)expected:When
expectedis a plain string it should be treated astype: inlinewith the string ascontentand an emptyignorelist.Note on Schema File Location
The authoritative YAML schema for test suites is
src/main/resources/schemas/test-suite-schema.json— this is the file that is packaged with the application and used at runtime for validation. The file at.vscode/test-suite-schema.jsonis only a VS Code IDE helper copy and should not be edited directly.Changes Required
1. JSON Schema (
src/main/resources/schemas/test-suite-schema.json)Change the
expecteddefinition forjson_matchfrom a bare$ref:to a
oneOfthat accepts either a plain string or the fullContentReferenceobject:Apply the same change to
json_schema'sexpectedfield for consistency.2. YAML Deserialization
ObjectExpectedValueis currently a plain Java record (String type, String content, List<String> ignore). Jackson deserializes it only from an object node.Add a custom Jackson deserializer (or use
@JsonCreator/JsonDeserializer) so that:new ObjectExpectedValue("inline", theString, null)3. No evaluator changes needed
JsonMatchAssertionEvaluatorandJsonSchemaAssertionEvaluatoralready handletype == "inline"correctly, so no changes are needed there once deserialization normalises the plain-string form into anObjectExpectedValue.Files to Change
src/main/resources/schemas/test-suite-schema.jsononeOf [string, ContentReference]forjson_matchandjson_schemaexpectedsrc/main/java/.../model/ObjectExpectedValue.javasrc/test/java/.../model/ObjectExpectedValueDeserializerTest.java(new)ObjectExpectedValue("inline", …, null); object → normal mappingsrc/test/java/.../service/TestSuiteLoaderTest.javaexpectedloads correctly