Skip to content

Commit f879a92

Browse files
Fix #22
1 parent ffa59cb commit f879a92

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.0.5] - 2022-12-22 :santa:
9+
- Fixes [#22](https://github.com/Neoteroi/essentials-openapi/issues/22)
10+
811
## [1.0.4] - 2022-11-06 :snake:
912
- Fixes [#18](https://github.com/Neoteroi/essentials-openapi/issues/18)
1013
- Workflow maintenance

openapidocs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = "1.0.4"
1+
VERSION = "1.0.5"

openapidocs/mk/__init__.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ def read_dict(obj, *args, default=None):
2626
assert isinstance(obj, dict)
2727

2828
value = obj
29-
for part in args:
30-
for key in part.split():
31-
if not isinstance(value, dict):
32-
raise ValueError(f"Invalid sub-path: {repr(args)}")
29+
for key in args:
30+
if not isinstance(value, dict):
31+
raise ValueError(f"Invalid sub-path: {repr(args)}")
3332

34-
value = value.get(key)
33+
value = value.get(key)
3534

36-
if value is None:
37-
return default
35+
if value is None:
36+
return default
3837

3938
if value is None or value is obj:
4039
return default

openapidocs/mk/v3/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def get_operations(self):
184184
return groups
185185

186186
def get_schemas(self):
187-
schemas = read_dict(self.doc, "components schemas")
187+
schemas = read_dict(self.doc, "components", "schemas")
188188

189189
if not schemas:
190190
return
@@ -287,7 +287,7 @@ def get_security_scheme(self, name: str) -> dict:
287287
"""
288288
Gets a security scheme from the components section, by name.
289289
"""
290-
security_scheme = read_dict(self.doc, "components securitySchemes")
290+
security_scheme = read_dict(self.doc, "components", "securitySchemes")
291291

292292
if not security_scheme: # pragma: no cover
293293
warnings.warn(
@@ -536,6 +536,10 @@ def expand_references(self, schema, context: Optional[ExpandContext] = None):
536536
if is_reference(schema):
537537
return self.expand_references(self.resolve_reference(schema))
538538

539+
if schema is None:
540+
# this should not happen, but we don't want the whole build to fail
541+
return None
542+
539543
clone = copy.deepcopy(schema)
540544

541545
for key in list(clone.keys()):

tests/test_mk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_is_array_schema():
1919

2020
def test_read_dict_raises_for_non_dict_property():
2121
with pytest.raises(ValueError):
22-
read_dict({"x": 1}, "x a")
22+
read_dict({"x": 1}, "x", "a")
2323

2424

2525
def test_read_dict_default():

0 commit comments

Comments
 (0)