Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 0.6.0 AsyncAPI #1834

Open
wants to merge 6 commits into
base: 0.6.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions docs/docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -816,21 +816,14 @@ search:
- [SASLScram256](api/faststream/security/SASLScram256.md)
- [SASLScram512](api/faststream/security/SASLScram512.md)
- specification
- [AsyncAPI](api/faststream/specification/AsyncAPI.md)
- [Contact](api/faststream/specification/Contact.md)
- [ExternalDocs](api/faststream/specification/ExternalDocs.md)
- [License](api/faststream/specification/License.md)
- [Tag](api/faststream/specification/Tag.md)
- asyncapi
- [AsyncAPI](api/faststream/specification/asyncapi/AsyncAPI.md)
- [AsyncAPIProto](api/faststream/specification/asyncapi/AsyncAPIProto.md)
- [get_asyncapi_html](api/faststream/specification/asyncapi/get_asyncapi_html.md)
- base
- [AsyncAPIProto](api/faststream/specification/asyncapi/base/AsyncAPIProto.md)
- asyncapi
- [AsyncAPIProto](api/faststream/specification/asyncapi/base/asyncapi/AsyncAPIProto.md)
- schema
- [BaseInfo](api/faststream/specification/asyncapi/base/schema/BaseInfo.md)
- [BaseSchema](api/faststream/specification/asyncapi/base/schema/BaseSchema.md)
- info
- [BaseInfo](api/faststream/specification/asyncapi/base/schema/info/BaseInfo.md)
- schema
- [BaseSchema](api/faststream/specification/asyncapi/base/schema/schema/BaseSchema.md)
- factory
- [AsyncAPI](api/faststream/specification/asyncapi/factory/AsyncAPI.md)
- message
Expand Down Expand Up @@ -1041,10 +1034,20 @@ search:
- [Schema](api/faststream/specification/asyncapi/v3_0_0/schema/schema/Schema.md)
- servers
- [Server](api/faststream/specification/asyncapi/v3_0_0/schema/servers/Server.md)
- proto
- [SpecApplication](api/faststream/specification/proto/SpecApplication.md)
- [SpecificationProto](api/faststream/specification/proto/SpecificationProto.md)
- base
- info
- [BaseInfo](api/faststream/specification/base/info/BaseInfo.md)
- proto
- [EndpointProto](api/faststream/specification/base/proto/EndpointProto.md)
- schema
- [BaseSchema](api/faststream/specification/base/schema/BaseSchema.md)
- specification
- [Specification](api/faststream/specification/base/specification/Specification.md)
- schema
- [Contact](api/faststream/specification/schema/Contact.md)
- [ExternalDocs](api/faststream/specification/schema/ExternalDocs.md)
- [License](api/faststream/specification/schema/License.md)
- [Tag](api/faststream/specification/schema/Tag.md)
- bindings
- [ChannelBinding](api/faststream/specification/schema/bindings/ChannelBinding.md)
- [OperationBinding](api/faststream/specification/schema/bindings/OperationBinding.md)
Expand Down Expand Up @@ -1088,8 +1091,6 @@ search:
- [Message](api/faststream/specification/schema/message/Message.md)
- operation
- [Operation](api/faststream/specification/schema/operation/Operation.md)
- schema
- [BaseSchema](api/faststream/specification/schema/schema/BaseSchema.md)
- security
- [OauthFlowObj](api/faststream/specification/schema/security/OauthFlowObj.md)
- [OauthFlows](api/faststream/specification/schema/security/OauthFlows.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ search:
boost: 0.5
---

::: faststream.specification.proto.SpecApplication
::: faststream.specification.AsyncAPI
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ search:
boost: 0.5
---

::: faststream.specification.asyncapi.AsyncAPIProto
::: faststream.specification.Contact
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ search:
boost: 0.5
---

::: faststream.specification.proto.SpecificationProto
::: faststream.specification.ExternalDocs
11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/specification/License.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: faststream.specification.License
11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/specification/Tag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: faststream.specification.Tag

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/specification/base/info/BaseInfo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: faststream.specification.base.info.BaseInfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: faststream.specification.base.proto.EndpointProto
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ search:
boost: 0.5
---

::: faststream.specification.schema.schema.BaseSchema
::: faststream.specification.base.schema.BaseSchema
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ search:
boost: 0.5
---

::: faststream.specification.asyncapi.base.AsyncAPIProto
::: faststream.specification.base.specification.Specification
11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/specification/schema/Contact.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: faststream.specification.schema.Contact
11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/specification/schema/ExternalDocs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: faststream.specification.schema.ExternalDocs
11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/specification/schema/License.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: faststream.specification.schema.License
11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/specification/schema/Tag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: faststream.specification.schema.Tag
36 changes: 16 additions & 20 deletions faststream/rabbit/subscriber/subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,24 @@ def get_schema(self) -> dict[str, Channel]:
),
bindings=ChannelBinding(
amqp=amqp.ChannelBinding(
is_="routingKey",
queue=amqp.Queue(
name=self.queue.name,
durable=self.queue.durable,
exclusive=self.queue.exclusive,
autoDelete=self.queue.auto_delete,
vhost=self.virtual_host,
)
if is_routing_exchange(self.exchange) and self.queue.name
else None,
exchange=(
amqp.Exchange(type="default", vhost=self.virtual_host)
if not self.exchange.name
else amqp.Exchange(
type=self.exchange.type.value,
name=self.exchange.name,
durable=self.exchange.durable,
autoDelete=self.exchange.auto_delete,
is_="queue", queue=amqp.Queue(
name=self.queue.name,
durable=self.queue.durable,
exclusive=self.queue.exclusive,
autoDelete=self.queue.auto_delete,
vhost=self.virtual_host,
), exchange=(
amqp.Exchange(type="default", vhost=self.virtual_host)
if not self.exchange.name
else amqp.Exchange(
type=self.exchange.type.value,
name=self.exchange.name,
durable=self.exchange.durable,
autoDelete=self.exchange.auto_delete,
vhost=self.virtual_host,
)
)
),
),
)
),
),
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,15 @@ class ChannelBinding(BaseModel):
def from_spec(cls, binding: spec.bindings.amqp.ChannelBinding) -> Self:
return cls(
**{
"is": binding.is_,
"is": "routingKey",

"queue": Queue.from_spec(binding.queue)
if binding.queue is not None
and binding.queue.name
and binding.exchange
and binding.exchange.type in {"default", "direct", "topic"}
else None,

"exchange": Exchange.from_spec(binding.exchange)
if binding.exchange is not None
else None,
Expand Down
8 changes: 4 additions & 4 deletions faststream/specification/asyncapi/v2_6_0/schema/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ def from_spec(cls, channel: spec.channel.Channel) -> Self:
bindings=channel_binding_from_spec(channel.bindings)
if channel.bindings is not None
else None,
subscribe=operation_from_spec(channel.subscribe)
if channel.subscribe is not None
else None,
publish=operation_from_spec(channel.publish)
subscribe=operation_from_spec(channel.publish)
if channel.publish is not None
else None,
publish=operation_from_spec(channel.subscribe)
if channel.subscribe is not None
else None,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ def from_spec(binding: spec.bindings.amqp.ChannelBinding) -> ChannelBinding:
"is": binding.is_,
"bindingVersion": "0.3.0",
"queue": Queue.from_spec(binding.queue)
if binding.queue is not None
if binding.queue is not None and binding.is_ == "queue"
else None,
"exchange": Exchange.from_spec(binding.exchange)
if binding.exchange is not None
if binding.exchange is not None and binding.is_ == "routingKey"
else None,
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_basic_customization():
"kafka": {"bindingVersion": "0.4.0", "topic": "input_data"},
},
"servers": ["development"],
"subscribe": {
"publish": {
"message": {
"$ref": "#/components/messages/input_data:OnInputData:Message",
},
Expand All @@ -23,7 +23,7 @@ def test_basic_customization():
"bindings": {
"kafka": {"bindingVersion": "0.4.0", "topic": "output_data"},
},
"publish": {
"subscribe": {
"message": {
"$ref": "#/components/messages/output_data:Publisher:Message",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ def test_handler_customization():
"description": "Consumer function\n\n Args:\n msg: input msg\n ",
"servers": ["development"],
"bindings": {"kafka": {"topic": "input_data", "bindingVersion": "0.4.0"}},
"subscribe": {
"publish": {
"message": {"$ref": "#/components/messages/input_data:Consume:Message"},
},
},
"output_data:Produce": {
"description": "My publisher description",
"servers": ["development"],
"bindings": {"kafka": {"topic": "output_data", "bindingVersion": "0.4.0"}},
"publish": {
"subscribe": {
"message": {
"$ref": "#/components/messages/output_data:Produce:Message"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/asyncapi/base/v2_6_0/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async def handle(msg): ...

key = tuple(schema["channels"].keys())[0] # noqa: RUF015
assert schema["channels"][key].get("description") is None
assert schema["channels"][key].get("publish") is not None
assert schema["channels"][key].get("subscribe") is not None

payload = schema["components"]["schemas"]
for v in payload.values():
Expand Down
2 changes: 1 addition & 1 deletion tests/asyncapi/confluent/v2_6_0/test_naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def handle(): ...
"test:Handle": {
"servers": ["development"],
"bindings": {"kafka": {"topic": "test", "bindingVersion": "0.4.0"}},
"subscribe": {
"publish": {
"message": {
"$ref": "#/components/messages/test:Handle:Message"
},
Expand Down
Loading
Loading