Skip to content

Commit

Permalink
explicit server reference and naming fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KrySeyt committed Jul 27, 2024
1 parent cc2dbb1 commit ee09942
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
35 changes: 20 additions & 15 deletions faststream/asyncapi/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def _get_app_schema_3_0(app: Union["FastStream", "StreamRouter[Any]"]) -> Schema

channel.messages = msgs

channel.servers = list(servers.keys())
channel.servers = [{"$ref": f"#/servers/{server_name}"} for server_name in list(servers.keys())]

schema = SchemaV3_0(
info=InfoV3_0(
Expand Down Expand Up @@ -273,7 +273,7 @@ def get_broker_operations_3_0(
),
security=channel_2_6.subscribe.security,
)
operations[f"{channel_name}.subscribe"] = op
operations[f"{channel_name}Subscribe"] = op

elif channel_2_6.publish is not None:
op = OperationV3_0(
Expand All @@ -284,13 +284,14 @@ def get_broker_operations_3_0(
messages=[
Reference(
**{"$ref": f"#/channels/{channel_name}/messages/PublishMessage"},
)],
)]
,
channel=Reference(
**{"$ref": f"#/channels/{channel_name}"},
),
security=channel_2_6.publish.bindings,
)
operations[f"{channel_name}.publish"] = op
operations[f"{channel_name}Publish"] = op

for p in broker._publishers.values():
for channel_name, channel_2_6 in p.schema().items():
Expand All @@ -300,31 +301,35 @@ def get_broker_operations_3_0(
summary=channel_2_6.subscribe.summary,
description=channel_2_6.subscribe.description,
bindings=channel_2_6.subscribe.bindings,
messages=Reference(
**{"$ref": f"#/channels/{channel_name}/messages/SubscribeMessage"},
),
messages=[
Reference(
**{"$ref": f"#/channels/{channel_name}/messages/SubscribeMessage"},
)
],
channel=Reference(
**{"$ref": f"#/channels/{channel_name}"},
),
security=channel_2_6.subscribe.bindings,
security=channel_2_6.subscribe.security,
)
operations[f"{channel_name}.subscribe"] = op
operations[f"{channel_name}Subscribe"] = op

elif channel_2_6.publish is not None:
op = OperationV3_0(
action="send",
summary=channel_2_6.publish.summary,
description=channel_2_6.publish.description,
bindings=channel_2_6.publish.bindings,
messages=Reference(
**{"$ref": f"#/channels/{channel_name}/messages/PublishMessage"},
),
messages=[
Reference(
**{"$ref": f"#/channels/{channel_name}/messages/PublishMessage"},
)
],
channel=Reference(
**{"$ref": f"#/channels/{channel_name}"},
),
security=channel_2_6.publish.bindings,
security=channel_2_6.publish.security,
)
operations[f"{channel_name}.publish"] = op
operations[f"{channel_name}Publish"] = op

return operations

Expand Down Expand Up @@ -401,7 +406,7 @@ def _resolve_msg_payloads_3_0(
payload_name = f"{message_name}Payload"
payloads[payload_name] = m.payload
m.payload = Reference(**{"$ref": f"#/components/schemas/{payload_name}"})
messages[message_name] = m
messages[f"{channel_name}:{message_name}"] = m
return Reference(**{"$ref": f"#/components/messages/{channel_name}:{message_name}"})


Expand Down
4 changes: 2 additions & 2 deletions faststream/asyncapi/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@


class AsyncAPIVersion(str, Enum):
v3_0 = "3.0"
v2_6 = "2.6"
v3_0 = "3.0.0"
v2_6 = "2.6.0"

0 comments on commit ee09942

Please sign in to comment.