0

Problem: I have some java models being used both for request and response body on some endpoints. The thing is, on a specific request, I don't want to show all fields from that model; also, on the response, maybe I want to show completely different fields from that same model.

Question: Is this possible using Enunciate ? Or we just have to use the same model composition on both request and response ?

I've looked into this and found the Enunciate API Facets. However, haven't figured out how to exclude only some fields from the model. Other than this specific feature, for now I've found Enunciate to be extremely useful and nice to use. It also produces quite good looking docs. :)

Bogdan Zurac
  • 6,348
  • 11
  • 48
  • 96
  • 1
    Do you want to change the documentation or the real response? For latter you could use Jacksons [JSON Views](http://wiki.fasterxml.com/JacksonJsonViews). – lefloh Apr 14 '14 at 16:22
  • I'd want to change the documentation only, but I will have a look at your suggestion anyway, might be helpful. Can you think of any other alternative ? I just want to explore all the possibilities (or at least the most used). Thanks a lot for your input. – Bogdan Zurac Apr 14 '14 at 17:13
  • For hiding internal fields you could map/clone/copy to a new object where the internal fields are set to null and tell your serializer to ignore null-values. – lefloh Apr 14 '14 at 17:35
  • I've looked into JSONViews, but I'm not using a serializer, just JAX-RS annotations. From those annotations Enunciate constructs the docs, so I'm not really solving the initial problem. – Bogdan Zurac Apr 14 '14 at 17:45

1 Answers1

1

Unfortunately, Enunciate's documentation engine isn't that sophisticated. There's no way to configure Enunciate to document which fields of a model should be populated based for a specific request (or response).

It would be nice feature though. Why don't you open up a JIRA issue so the request can get tracked?

Ryan Heaton
  • 1,173
  • 7
  • 11
  • Hello Ryan. Firstly, thank you for your answer, it's nice to have an official answer on this matter. Secondly, I would gladly open up an issue, but I cannot seem to sign up on your JIRA subdomain: "Not a member? To request an account, please contact your JIRA administrators." And I could not find any means of achieving this. Could you please provide some directions in order for me to sign up on your subdomain ? Thanks. – Bogdan Zurac Apr 25 '14 at 05:33
  • Is there any chance you could open up a ticket instead ? Or give some indications on how to open an account on your subdomain ? – Bogdan Zurac May 07 '14 at 11:32