Skip to content

Commit

Permalink
AsyncAPI facade refactoring to factory
Browse files Browse the repository at this point in the history
  • Loading branch information
KrySeyt committed Sep 17, 2024
1 parent d27ee74 commit ba7a612
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions faststream/specification/asyncapi/facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


class AsyncAPI(AsyncAPIProto):
def __init__(
def __new__(
self,
broker: BrokerUsecase[Any, Any],
/,
Expand All @@ -26,9 +26,9 @@ def __init__(
identifier: Optional[str] = None,
specs_tags: Optional[Sequence[Union["Tag", "TagDict", "AnyDict"]]] = None,
external_docs: Optional[Union["ExternalDocs", "ExternalDocsDict", "AnyDict"]] = None,
):
) -> AsyncAPIProto:
if schema_version.startswith("3.0."):
self.schema = AsyncAPI3(
return AsyncAPI3(
broker,
title=title,
version=version,
Expand All @@ -42,7 +42,7 @@ def __init__(
external_docs=external_docs,
)
elif schema_version.startswith("2.6."):
self.schema = AsyncAPI2(
return AsyncAPI2(
broker,
title=title,
version=version,
Expand All @@ -57,12 +57,3 @@ def __init__(
)
else:
raise NotImplementedError(f"Unsupported schema version: {schema_version}")

def json(self) -> str:
return self.schema.json()

def jsonable(self) -> str:
return self.schema.jsonable()

def yaml(self) -> str:
return self.schema.yaml()

0 comments on commit ba7a612

Please sign in to comment.