mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
feat: add json schema validation for testcase v2
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
**Added**
|
||||
|
||||
- feat: add json schema validation for api
|
||||
- feat: add json schema validation for testcase v2
|
||||
|
||||
**Changed**
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import importlib
|
||||
import os
|
||||
|
||||
from httprunner import exceptions, logger, utils
|
||||
from httprunner.loader.check import JsonSchemaChecker
|
||||
from httprunner.loader.check import JsonSchemaChecker, JsonSchemaV2Checker
|
||||
from httprunner.loader.load import load_module_functions, load_file, load_dot_env_file, \
|
||||
load_folder_files
|
||||
from httprunner.loader.locate import init_project_working_directory, get_project_working_directory
|
||||
@@ -225,6 +225,7 @@ def load_testcase_v2(raw_testcase):
|
||||
}
|
||||
|
||||
"""
|
||||
JsonSchemaV2Checker.validate_testcase_format(raw_testcase)
|
||||
raw_teststeps = raw_testcase.pop("teststeps")
|
||||
raw_testcase["teststeps"] = [
|
||||
load_teststep(teststep)
|
||||
|
||||
@@ -2,23 +2,6 @@
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"description": "httprunner testcase schema definition",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"config": {
|
||||
"$ref": "common.schema.json#/definitions/config"
|
||||
},
|
||||
"teststeps": {
|
||||
"description": "teststep of a testcase",
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"$ref": "#/definitions/teststep"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"config",
|
||||
"teststeps"
|
||||
],
|
||||
"definitions": {
|
||||
"teststep": {
|
||||
"type": "object",
|
||||
@@ -84,5 +67,22 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"config": {
|
||||
"$ref": "common.schema.json#/definitions/config"
|
||||
},
|
||||
"teststeps": {
|
||||
"description": "teststep of a testcase",
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"$ref": "testcase.schema.v2.json#/definitions/teststep"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"config",
|
||||
"teststeps"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user