Description and Summary combinators#767
Conversation
|
Build fails for GHC 7.8 with @phadej should we increase stack size for the build? |
| foreignFor lang ftype Proxy req = | ||
| foreignFor lang ftype (Proxy :: Proxy api) req | ||
|
|
||
| instance HasForeign lang ftype api |
There was a problem hiding this comment.
Here we ignore Summary and Description, but it would be super nice to adjust servant-foreign so that we could save descriptions to later translate them into comments.
| route Proxy context subserver = | ||
| route (Proxy :: Proxy api) context (passToServer subserver httpVersion) | ||
|
|
||
| -- | Ignore @'Summary'@ in server handlers. |
There was a problem hiding this comment.
Can/should we use summary/description in error messages?
There was a problem hiding this comment.
I have no idea how the implementation would look like...
There was a problem hiding this comment.
We could (optionally) inject description/summary for 4xx (client side) errors.
There was a problem hiding this comment.
Yeah I understand. We'd need some kind of mapError post phase in Delayed to do that. Can you or @fierce-katie open a ticket about that. Let's not complicate this PR
|
|
||
| import Data.Typeable (Typeable) | ||
| import GHC.TypeLits (Symbol) | ||
| -- | Add a short summary for (part of) API. |
There was a problem hiding this comment.
could we call it Synopsis? Would be more in line with Cabal terminology :P
There was a problem hiding this comment.
We call it Summary since it's what it's called in Swagger terminology, but I'm ok with Synopsis too :)
There was a problem hiding this comment.
@haskell-servant/maintainers bikeshed please!
There was a problem hiding this comment.
I don't care, both are fine. =P
| -- Example: | ||
| -- | ||
| -- >>> type MyApi = Description "Some longer implementation details here." :> "books" :> Capture "isbn" Text :> Get '[JSON] Book | ||
| data Description (sym :: Symbol) |
There was a problem hiding this comment.
I see the motivation, but is it really practical to write any >=80 char description in a type-level? @fizruk?
There was a problem hiding this comment.
Why not? :)
-- | This comment is only visible in Haskell sources and Haddocks.
-- It can be really long and is very easy to read.
-- But we can't extract it even with TH :(
type MyEndpoint = Get '[JSON] Resource
type MyEndpoint = Description
"This comment is visible in multiple Servant interpretations \
\and can be really long if necessary. \
\Haskell multiline support is not perfect \
\but it's still very readable."
:> Get '[JSON] Resource
There was a problem hiding this comment.
@fierce-katie this should get into examples/doctests/tutorial to demonstrate multiline descriptions.
There was a problem hiding this comment.
Now...if only we had a quasiquoter that would produce Symbols instead of Strings.
| route Proxy context subserver = | ||
| route (Proxy :: Proxy api) context (passToServer subserver httpVersion) | ||
|
|
||
| -- | Ignore @'Summary'@ in server handlers. |
There was a problem hiding this comment.
I have no idea how the implementation would look like...
|
I'm 👍 with this. Having two very similar things: |
|
about |
|
@fierce-katie is there something you want to do here, or is this done from your side? I'd like to merge this! |
|
@phadej looks like I've made all the fixes discussed above, so feel free to merge :) |
|
Ping @phadej |
|
Totally forgot, thanks for the ping. |
This PR adds combinators discussed in haskell-servant/servant-swagger#60. They allow you to add documentation for API endpoints right in the type declaration.
Both
DescriptionandSummaryare needed for differentHasSwaggerinstances: