-
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Improve reporting of
jsonschema
errors which are caused by n…
…on-string object keys
- Loading branch information
1 parent
b0d5177
commit 78dd617
Showing
6 changed files
with
89 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from typing import Any, Dict, List, Tuple, Union | ||
|
||
|
||
def is_pattern_error(exception: TypeError) -> bool: | ||
"""Detect whether the input exception was caused by invalid type passed to `re.search`.""" | ||
# This is intentionally simplistic and do not involve any traceback analysis | ||
return str(exception) == "expected string or bytes-like object" | ||
|
||
|
||
def find_numeric_http_status_codes(schema: Dict[str, Any]) -> List[Tuple[int, List[Union[str, int]]]]: | ||
found = [] | ||
for path, methods in schema.get("paths", {}).items(): | ||
for method, definition in methods.items(): | ||
for key in definition.get("responses", {}): | ||
if isinstance(key, int): | ||
found.append((key, [path, method])) | ||
return found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters