You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Therefore we have no information, in the OpenApi schema, that the response for that route is streamed.
ToSchema instance for SourceT is misleading
It explicitly "pretends that it is a [a]", no matter the chosen framing (see here), providing a misleading information to the api schema reader that would expect the return type to be a [a] instead of several a separated by the choses framing. This is particularly true when coupled with the issue above, so the reader has not even the information it is a streamed route.
OpenApi misses specification for streamed responses
This is unrelated to servant-openapi but unless I'm mistaken, the OpenApi spec says nothing about streamed responses, so any indication would be hand made, for example in a description field (see below).
Workaround
I implemented the following custom instance:
instance {-# OVERLAPPING #-} (ToSchemaa, Acceptct, Typeablefr, KnownNatst, OpenApiMethodme)
=>HasOpenApi (Streammestfrct (SourceIOa)) where
toOpenApi _ = toOpenApi (Proxy::Proxy (Verbmest '[ct] (Headers '[]a)))
& setResponseWith (const (& description .~ desc)) 200 (declareResponse "application/json" (Proxy::Proxya))
where
desc = pack $"<b>Streamed response</b><br>\ \An empty chunk means that the stream is finished.<br>\ \Chunk type: the route return type <code>"++ show_type (Proxy::Proxya) ++"</code><br>\ \Chunk separator: <code>"++ show_type (Proxy::Proxyfr) ++"</code>"show_type:: (Typeableb) =>b->String
show_type = (\\"Proxy * ") .show. typeOf
Wouldn't it be worth improving these 2 instances?
The text was updated successfully, but these errors were encountered:
Issues
I see 3 issues here:
HasOpenApi
instance forStream
gives no info that it is a streamed responseIt simply copies the one of
Verb
(see the HasOpenApi instance for Stream)Therefore we have no information, in the OpenApi schema, that the response for that route is streamed.
ToSchema
instance forSourceT
is misleadingIt explicitly "pretends that it is a
[a]
", no matter the chosen framing (see here), providing a misleading information to the api schema reader that would expect the return type to be a[a]
instead of severala
separated by the choses framing. This is particularly true when coupled with the issue above, so the reader has not even the information it is a streamed route.OpenApi misses specification for streamed responses
This is unrelated to
servant-openapi
but unless I'm mistaken, the OpenApi spec says nothing about streamed responses, so any indication would be hand made, for example in a description field (see below).Workaround
I implemented the following custom instance:
Wouldn't it be worth improving these 2 instances?
The text was updated successfully, but these errors were encountered: