Closed Paic closed 5 years ago
@jgroom33 is this possible with jsonpath? I'm not really into the jsonpath feature
I don't think so. Would validating against a json schema work
What do you mean by json schema ? Without using JsonPath ?
It seems it would work for validating array objects, but I think it's a common use case and using an external file to describe those tests would be inconvenient.
In release 2.0, there are some proposed changes to validation. Adding a new validation type of jsonschema
would work as follows (just convert the jsonschema to yaml and specify it in the strest.yml):
validate:
jsonpath: path.to.array
jsonschema:
type: array
items:
type: object
properties:
loc:
type: string
toll:
type:
- string
- 'null'
message:
type:
- string
- 'null'
required:
- loc
it should even be possible to declare the schemas in the global var section:
variables:
mySchema:
type: array
items:
type: object
properties:
loc:
type: string
required:
- loc
requests:
foo:
...
validate:
jsonpath: path.to.array
jsonschema: <$ variables.mySchema $>
Looks awesome! It would cover a lot of use case 😃
Is there any way to check if objects of an array match a "template" (see my comment in #12) ? The current implementation of JsonPath does not seems to be able to fulfill this use case.