-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcreate_json_schema.py
More file actions
41 lines (27 loc) · 1.6 KB
/
create_json_schema.py
File metadata and controls
41 lines (27 loc) · 1.6 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
import json
import re
with open("testbench2robotframework/model.py", "r", encoding="utf8") as model_py:
model_str = model_py.read()
pydantic_model = re.sub(r"(@dataclass\n)(class .*?)(:)", r"\2(BaseModel)\3", model_str)
pydantic_model = re.sub(r"( {4}@classmethod.*?)(\nclass|$)", r"\2", pydantic_model, flags=re.DOTALL)
pydantic_model = re.sub(r"from dataclasses import dataclass", r"from pydantic import BaseModel", pydantic_model, flags=re.DOTALL)
with open("pydantic_model.py", "w", encoding="utf8") as pydantic_model_py:
pydantic_model_py.write(pydantic_model)
from pydantic_model import *
from yaml import dump, Dumper
with open("model.json", "w") as schema:
schema.write(json.dumps(AllModels.model_json_schema(), indent=2))
with open("model.yml", "w") as schema:
schema.write(dump(AllModels.model_json_schema(), Dumper=Dumper))
with open("TestCaseDetails.json", "w") as schema:
schema.write(json.dumps(TestCaseDetails.model_json_schema(), indent=2))
with open("TestCaseDetails.yml", "w") as schema:
schema.write(dump(TestCaseDetails.model_json_schema(), Dumper=Dumper))
with open("TestCaseSetDetails.json", "w") as schema:
schema.write(json.dumps(TestCaseSetDetails.model_json_schema(), indent=2))
with open("TestCaseSetDetails.yml", "w") as schema:
schema.write(dump(TestStructureTree.model_json_schema(), Dumper=Dumper))
with open("TestStructureTree.json", "w") as schema:
schema.write(json.dumps(TestStructureTree.model_json_schema(), indent=2))
with open("TestStructureTree.yml", "w") as schema:
schema.write(dump(TestStructureTree.model_json_schema(), Dumper=Dumper))