haskell-servant / haskell-servant/servant

Generate meaningful example lists for request bodies

Open
#291 6 comments 1 reaction 0 assignees View on GitHub
bug servant-docs
Dominant language
Haskell
Stars
2k
Forks
427
Avg merge
2d 23h
Merged PRs (30d)
5

Description

Right now if a request body is a list of things, the example generated by the documentation code will always be `[]`. It would be more helpful to generate an example list with at least one item.

Details . . .

`ToSample [a]` is defined here: https://github.com/haskell-servant/servant/blob/master/servant-docs/src/Servant/Docs/Internal.hs#L932

It generates an infinite list of `(Text, [a])`, e.g:

```
*Main> toSamples (Proxy :: Proxy [Int])
[("",[]),("",[1]),("",[1,1]),("",[2]),("",[1,1,1]),("",[2,1]),
```

When `docs` and `markdown` are used to generate documentation for an endpoint, the first tuple created by `ToSample` is the one used as the example request body. The second item of this tuple is always `[]`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.