Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get install -y libev-dev
python -m pip install --upgrade pip
pip install poetry
poetry install
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
__pycache__
dist
.pytest_cache
tests/fixtures/generated_dtos.py
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tests/test_cases"]
path = tests/test_cases
url = https://github.com/json-schema-org/JSON-Schema-Test-Suite.git
2 changes: 1 addition & 1 deletion opyapi/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.0"
__version__ = "1.1.0"
165 changes: 0 additions & 165 deletions opyapi/_iso_datetime.py

This file was deleted.

7 changes: 6 additions & 1 deletion opyapi/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


class ValidationError(ValueError):
code: str
code: str = "validation_error"
message: str

def __init__(self, *args, **kwargs: Any):
Expand Down Expand Up @@ -156,3 +156,8 @@ class MaximumPropertiesValidationError(ObjectSizeValidationError):
class DependencyValidationError(ObjectValidationError):
code = "dependency_error"
message = "Property `{property}` requires {dependencies} to be provided."


class ContainsValidationError(ValidationError):
code = "contains_error"
message = "Failed to assert that `{value}` contains expected schema. {error}"
16 changes: 14 additions & 2 deletions opyapi/json_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from os import path
from typing import Any, Dict, Optional, Union, List, Set, ItemsView, KeysView, ValuesView
from typing import Protocol
from datetime import datetime

from ._yaml_support import load_yaml

Expand Down Expand Up @@ -199,14 +198,18 @@ def __init__(self, document: Any, id_: JsonUri = None):

self._id = id_
self._document = document
if self._document is True or self._document is False:
self._ready = True
return

self._ready = False
self._current_path: List[Union[str, int]] = []
self.anchors: Dict[str, str] = {}

@classmethod
def from_file(cls, file_name: str) -> "JsonSchema":
if not path.isfile(file_name):
raise ValueError(f"passed file name `{file_name}` is not a valid file.")
raise ValueError(f"Passed file name `{file_name}` is not a valid file.")

return JsonSchemaStore.get(JsonUri(f"file://{file_name}"))

Expand Down Expand Up @@ -332,6 +335,15 @@ def __iter__(self):
def __repr__(self) -> str:
return f"JsonSchema({str(self._id)})"

def keys(self):
return self.document.keys()

def values(self):
return self.document.values()

def items(self):
return self.document.items()


class JsonSchemaStore:
loaders: Dict[str, URILoader] = {
Expand Down
Loading