Skip to content

Commit

Permalink
Handle review items
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-zywicki committed Jan 19, 2022
1 parent cacffc9 commit db740c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion asynction/mock_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def from_spec(
* ``custom_formats_sample_size``
:param spec_path: The path where the AsyncAPI YAML specification is located,
or a pre loaded JSONMapping object.
or a dictionary object of the AsyncAPI data structure
:param validation: When set to ``False``, message payloads, channel
bindings and ack callbacks are NOT validated.
Defaults to ``True``.
Expand Down
24 changes: 11 additions & 13 deletions asynction/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,15 @@ def resolve_references(raw_spec: JSONMapping) -> JSONMapping:
return deep_resolve(raw_spec, resolver)


def load_spec(spec_path: Path) -> AsyncApiSpec:
with open(spec_path) as f:
serialized = f.read()
raw = yaml.safe_load(serialized)

raw_resolved = resolve_references(raw_spec=raw)

def load_spec(spec_path: Union[Path, JSONMapping]) -> AsyncApiSpec:
if isinstance(spec_path, Path):
with open(spec_path) as f:
serialized = f.read()
spec = yaml.safe_load(serialized)
else:
spec = spec_path

raw_resolved = resolve_references(spec)
return AsyncApiSpec.from_dict(raw_resolved)


Expand Down Expand Up @@ -126,7 +128,7 @@ def from_spec(
This is the single entrypoint to the Asynction server API.
:param spec_path: The path where the AsyncAPI YAML specification is located,
or a pre loaded JSONMapping object.
or a dictionary object of the AsyncAPI data structure
:param validation: When set to ``False``, message payloads, channel
bindings and ack callbacks are NOT validated.
Defaults to ``True``.
Expand Down Expand Up @@ -157,11 +159,7 @@ def from_spec(
)
"""
if isinstance(spec_path, Path):
spec = load_spec(spec_path=spec_path)
else:
raw_resolved = resolve_references(raw_spec=spec_path)
spec = AsyncApiSpec.from_dict(raw_resolved)
spec = load_spec(spec_path=spec_path)

server_security: Sequence[SecurityRequirement] = []
if (
Expand Down

0 comments on commit db740c8

Please sign in to comment.