Skip to content
New issue

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

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

Already on GitHub? # to your account

Bug: miss nested model in AsyncAPI docoumentation #2035

Open
Lancetnik opened this issue Jan 12, 2025 · 1 comment
Open

Bug: miss nested model in AsyncAPI docoumentation #2035

Lancetnik opened this issue Jan 12, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Lancetnik
Copy link
Member

from dataclasses import dataclass, field

from faststream.rabbit import RabbitBroker
from faststream.specification import AsyncAPI

@dataclass
class PartnerOrderProduct:
    product_uid: str

@dataclass
class PartnerOrderPayload:
    uid: str
    status: str
    date: str
    products: list[PartnerOrderProduct] = field(default_factory=list)

broker = RabbitBroker()

@broker.subscriber(queue="test")
async def partner_order_to_1c(
    payload: PartnerOrderPayload,
):
    print(payload)

docs = AsyncAPI(broker)

Generated schema

{
  "info": {
    "title": "FastStream",
    "version": "0.1.0",
    "description": ""
  },
  "asyncapi": "3.0.0",
  "defaultContentType": "application/json",
  "servers": {
    "development": {
      "host": "admin:admin@localhost:5672",
      "pathname": "/robots",
      "protocol": "amqp",
      "protocolVersion": "0.9.1"
    }
  },
  "channels": {
    "test:_:PartnerOrderTo1C": {
      "address": "test:_:PartnerOrderTo1C",
      "servers": [
        {
          "$ref": "#/servers/development"
        }
      ],
      "messages": {
        "SubscribeMessage": {
          "$ref": "#/components/messages/test:_:PartnerOrderTo1C:SubscribeMessage"
        }
      },
      "bindings": {
        "amqp": {
          "is": "queue",
          "bindingVersion": "0.3.0",
          "queue": {
            "name": "test",
            "durable": false,
            "exclusive": false,
            "autoDelete": false,
            "vhost": "/robots"
          }
        }
      }
    }
  },
  "operations": {
    "test:_:PartnerOrderTo1CSubscribe": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/test:_:PartnerOrderTo1C"
      },
      "bindings": {
        "amqp": {
          "cc": [
            "test"
          ],
          "ack": true,
          "bindingVersion": "0.3.0"
        }
      },
      "messages": [
        {
          "$ref": "#/channels/test:_:PartnerOrderTo1C/messages/SubscribeMessage"
        }
      ]
    }
  },
  "components": {
    "messages": {
      "test:_:PartnerOrderTo1C:SubscribeMessage": {
        "title": "test:_:PartnerOrderTo1C:SubscribeMessage",
        "correlationId": {
          "location": "$message.header#/correlation_id"
        },
        "payload": {
          "$ref": "#/components/schemas/PartnerOrderPayload"
        }
      }
    },
    "schemas": {
      "PartnerOrderPayload": {
        "properties": {
          "uid": {
            "title": "Uid",
            "type": "string"
          },
          "status": {
            "title": "Status",
            "type": "string"
          },
          "date": {
            "title": "Date",
            "type": "string"
          },
          "products": {
            "items": {
              "$ref": "#/components/schemas/PartnerOrderProduct"  # there is no such schema
            },
            "title": "Products",
            "type": "array"
          }
        },
        "required": [
          "uid",
          "status",
          "date"
        ],
        "title": "PartnerOrderPayload",
        "type": "object"
      }
    }
  }
}
@Lancetnik Lancetnik added the bug Something isn't working label Jan 12, 2025
@Lancetnik Lancetnik moved this to Todo in FastStream Jan 12, 2025
@pepellsd
Copy link
Contributor

.

@Lancetnik Lancetnik moved this from Todo to In Progress in FastStream Jan 12, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
Status: In Progress
Development

No branches or pull requests

2 participants