-
Notifications
You must be signed in to change notification settings - Fork 112
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
Cannot use the openapi annotation with any of the rocket typed stream response types #68
Comments
Hi @ralpha, Unfortunately all the stream methods are not supported yet, any idea what could be missing for |
These types should work:
With regards to the The I'll have a quick look if I can add that, but don't have that much time if it happens to be a bigger problem. |
There, still took me still too long, but here is a fix. It is a somewhat dirty fix, but it works.
So that resulted in a compile error. We can always make this nicer in the future, but this at least gives you a fix. Created an example to test this and add some docs: https://github.com/GREsau/okapi/blob/master/examples/streams/src/main.rs I also documented a way you can add undocumented endpoints in case it does not fit your needs or still have some errors because of special return types. (you can still report to error so we can fix it) okapi/examples/streams/src/main.rs Lines 62 to 66 in e686b44
okapi/examples/streams/src/main.rs Lines 75 to 76 in e686b44
Let me know if this works for you. |
Please also note that RapiDoc and Swagger do not work well with infinite streams. So watch out when using the |
Hi,
Thank you so much for this library! It really is quite impressive what you have implemented thus far!
This issue is alluded to in #52 but I have observed that this seems to be a larger issue impacting all of the typed streams in
rocket 0.5.0-rc.1
. I hit the same issue mentioned in #52 but I saw thatOpenApiResponderInner
had already been implemented forTextStream<S>
,ReaderStream<S>
, andByteStream<S
so I decided to see ifTextStream
would work for my use case. The result is the same compiler error encountered withEventStream!
:The
EventStream!
and other typed streams return types ultimately expand to a type like the following and they trip up theopenapi
macro because it can't just reuse the type as defined.I pulled your latest code and dug around a bit and made an attempt at a fix but I didn't see a clear path forward. In the case of
TextStream
andByteStream
, I could see where theopenapi
macro could rewrite the type to one of the string or byte representations that already have an implementation ofOpenApiResponderInner
. ForEventStream
, I was thinking along the same lines and tried rewriting the type as the rocketEvent
type; however, this type doesn't implementrocket::response::Responder
so that looked like a dead end.One alternative I was thinking might be possible would be to add an optional field to the
openapi
attribute that allows the developer to specify a type to substitute in place of the type that the typed stream macros expand to. I obviously don't have the same insight into the inner workings so this may be a terrible idea!If you have some guidance on how you would like to see this functionality implemented I would be glad to take on this effort!
Thanks!
The text was updated successfully, but these errors were encountered: