airtai / faststream

FastStream is a powerful and easy-to-use Python framework for building asynchronous services interacting with event streams such as Apache Kafka, RabbitMQ, NATS and Redis.
https://faststream.airt.ai/latest/
Apache License 2.0
3.13k stars 161 forks source link

Bug: documentation schema hosting returns blank page #1802

Open yann-combarnous opened 1 month ago

yann-combarnous commented 1 month ago

Describe the bug Following the tutorial for the AsyncAPI documentation generation, generation works, but hosting with FastStream returns a blank page.

How to reproduce Here is the generated HTML by FastStream:

   <!DOCTYPE html>
   <html>
   <head>
    
   <title>FastStream AsyncAPI</title>
    
   <link rel="icon" href="https://www.asyncapi.com/favicon.ico">
   <link rel="icon" type="image/png" sizes="16x16" href="https://www.asyncapi.com/favicon-16x16.png">
   <link rel="icon" type="image/png" sizes="32x32" href="https://www.asyncapi.com/favicon-32x32.png">
   <link rel="icon" type="image/png" sizes="194x194" href="https://www.asyncapi.com/favicon-194x194.png">
    
   <link rel="stylesheet" href="https://unpkg.com/@asyncapi/react-component@1.0.0-next.54/styles/default.min.css">
    
   </head>
    
   <style>
   html {
   font-family: ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sns,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;
   line-height: 1.5;
   }
   </style>
    
   <body>
   <div id="asyncapi"></div>
    
   <script src="https://unpkg.com/@asyncapi/react-component@1.0.0-next.54/browser/standalone/index.js"></script>
   <script>
    
   AsyncApiStandalone.render({"schema": "{\"asyncapi\":\"2.6.0\",\"defaultContentType\":\"application/json\",\"info\":{\"title\":\"FastStream\",\"version\":\"0.1.0\",\"description\":\"\"},\"servers\":{\"development\":{\"url\":\"xyz.confluent.cloud:9092\",\"protocol\":\"kafka-secure\",\"protocolVersion\":\"auto\",\"security\":[{\"oauthbearer\":[]}]}},\"channels\":{\"topic1:Subscriber\":{\"servers\":[\"development\"],\"bindings\":{\"kafka\":{\"topic\":\"topic1\",\"bindingVersion\":\"0.4.0\"}},\"subscribe\":{\"message\":{\"$ref\":\"#/components/messages/topic1:Subscriber:Message\"}}}},\"components\":{\"messages\":{\"topic1:Subscriber:Message\":{\"title\":\"topic1:Subscriber:Message\",\"correlationId\":{\"location\":\"$message.header#/correlation_id\"},\"payload\":{\"$ref\":\"#/components/schemas/Subscriber:Message:Payload\"}}},\"schemas\":{\"Subscriber:Message:Payload\":{\"title\":\"Subscriber:Message:Payload\"}},\"securitySchemes\":{\"oauthbearer\":{\"type\":\"oauthBearer\"}}}}", "config": {"show": {"sidebar": true, "info": true, "servers": true, "operations": true, "messages": true, "schemas": true, "errors": true}, "expand": {"messageExamples": true}, "sidebar": {"showServers": "byDefault", "showOperations": "byDefault"}}}, document.getElementById('asyncapi'));
    
   </script>
   </body>
   </html>
from faststream import FastStream
...

And/Or steps to reproduce the behavior:

  1. ...

Expected behavior Documentation display asyncAPI doc

Observed behavior Browser returns blank page, no error.

Screenshots N/A

Environment Running FastStream 0.5.23 with CPython 3.12.4 on Darwin

Additional context N/A

Lancetnik commented 1 month ago

@yann-combarnous can you check generated schema by this tool?

https://studio.asyncapi.com/

Probably, it just not correct

Lancetnik commented 1 month ago

Seems like the problem in ouath bearer schema

Lancetnik commented 1 month ago

oauthBearer is an invalid type, we have to refactor this place

KrySeyt commented 1 month ago

It will be nice if there is not an empty page, but a description of the error - https://github.com/asyncapi/asyncapi-react/issues/1048

yann-combarnous commented 1 month ago

oauthBearer is an invalid type, we have to refactor this place

Indeed, this is where the issue is, even though my code is valid.

For reference if it helps, here is my working code:

from faststream.confluent import KafkaBroker
from faststream.security import SASLOAuthBearer

broker = KafkaBroker(
            f"{kafka_creds['bootstrap_server_url']}:9092",
            config=kafka_creds["read_config"],
            security=SASLOAuthBearer(use_ssl=True),
        )
Lancetnik commented 1 week ago

@AceTheCreator can you help us here, please?