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

Bug: AsyncAPI 2.6.0 schema ignores messages schema overriding #1625

Open
KrySeyt opened this issue Jul 28, 2024 · 1 comment
Open

Bug: AsyncAPI 2.6.0 schema ignores messages schema overriding #1625

KrySeyt opened this issue Jul 28, 2024 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@KrySeyt
Copy link
Contributor

KrySeyt commented Jul 28, 2024

Describe the bug

  1. In some way you describe the message, for example:
@dataclass
class Input:
    value: int
  1. Describe the handler with this message:
@broker.subscriber("in1")
async def handle_msg(a: Input) -> None: ...
  1. Override your message:
@dataclass
class Input:
    not_in_schema: str
  1. Describe the handler with overrided message:
@broker.subscriber("in2")
async def please_good_schema(a: Input) -> None: ...
  1. Create asyncapi schema and look at #/components/schemas
"schemas": {
      "Input": {
        "properties": {
          "value": {
            "title": "Value",
            "type": "integer"
          }
        },
        "required": [
          "value"
        ],
        "title": "Input",
        "type": "object"
      }
    }

Where is my Input.not_in_schema: str?
For example, it will be a problem if I have the same named dataclasses in different packages

How to reproduce

from dataclasses import dataclass

from faststream import FastStream
from faststream.rabbit import RabbitBroker

broker = RabbitBroker()

app = FastStream(broker)


@dataclass
class Input:
    value: int


@broker.subscriber("in1")
async def handle_msg(a: Input) -> None: ...


@dataclass
class Input:
    not_in_schema: str


@broker.subscriber("in2")
async def please_good_schema(a: Input) -> None: ...

And/Or steps to reproduce the behavior:

  1. faststream docs get main:app

Expected behavior
I expect two payload in schema:

  • Input with value: int
  • Input2IdkAnyNameHere with not_in_schema: str

Observed behavior
Message "overriding" just ignored, in the schema all handlers use only the first definition of the message

Environment
Running FastStream 0.5.15 with CPython 3.12.3 on Linux

Additional context
Same problem in the case of handlers + args names duplication:

@broker.subscriber("in1")
async def handle_msg(a: int) -> None: ...

@broker.subscriber("in2")
async def handle_msg(a: str) -> None: ...
"schemas": {
  "HandleMsg:Message:Payload": {
    "title": "HandleMsg:Message:Payload",
    "type": "integer"
  }
}
@KrySeyt KrySeyt added the bug Something isn't working label Jul 28, 2024
@KrySeyt
Copy link
Contributor Author

KrySeyt commented Aug 18, 2024

Warning should be good solution

@Lancetnik Lancetnik added this to the 0.6.0 milestone Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

2 participants