Skip to content
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

Not enough info on JSON messages in api documentation #83

Open
jcpetruzza opened this issue Nov 10, 2014 · 2 comments
Open

Not enough info on JSON messages in api documentation #83

jcpetruzza opened this issue Nov 10, 2014 · 2 comments

Comments

@jcpetruzza
Copy link
Contributor

The generated documentation includes an example of the JSON input/output/error messages. This is a great feature but unfortunately it does not currently provide enough usage information when the messages correspond to sum types, which in my case occurs frequently. XML messages do get at least a schema, but we are not using those, so our users have no real way of figuring out how to use the thing.

Ideally, I would show not just one example, but enough of them to sample at least once every possible field that could occur (one needs, I think, only linearly many samples for this, even with nesting). If you were open to such a thing, I could probably come up with a patch for it, but I'd otherwise very much welcome any solution

@bergmark
Copy link
Member

Agreed! I think I had some todo for this somewhere that never ended up on github.

I think it would be fairly easy to fix, see Rest.Gen.Base.JSON

Another option is to expose the actual json-schema like we do the xml schema. It might involve creating a json representation for the schema.

We are currently not working on doc generation so contributions are most welcome.

@jcpetruzza
Copy link
Contributor Author

One catch that I noticed is that schemas for recursive types are infinite objects. So in principle, it is not a good idea neither to try and show a schema directly nor to try to cover all possible constructors (a limit on nesting will be needed). I'm not familiar with the xml case, so I don't know what happens there.

In fact, I suspect the reason why the current setting works at all with recursive (inductive) types is because, when generating the example, it picks the first constructor in the case of sums, which conventionally will be a non-recursive one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants