-
-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathutils.py
More file actions
23 lines (18 loc) · 790 Bytes
/
utils.py
File metadata and controls
23 lines (18 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""OpenAIP spec validator schemas utils module."""
from collections.abc import Hashable
from importlib.resources import as_file
from importlib.resources import files
from os import path
from typing import Any
from typing import Mapping
from typing import Tuple
from jsonschema_path.readers import FilePathReader
def get_schema(version: str) -> Tuple[Mapping[Hashable, Any], str]:
schema_path = f"resources/schemas/v{version}/schema.json"
ref = files("openapi_spec_validator") / schema_path
with as_file(ref) as resource_path:
schema_path_full = path.join(path.dirname(__file__), resource_path)
return FilePathReader(schema_path_full).read()
def get_schema_content(version: str) -> Mapping[Hashable, Any]:
content, _ = get_schema(version)
return content