Open ilya40umov opened 7 years ago
Would really appreciate a PR for this.
This is a feature I require.
What seems to be happening is that the Jackson parser explicitly declines to include JsonValue getters as regular getters, and as a result it concludes further down the line that the field is invisible because there's no getter. The slightly hacky solution is to manually insert the field afterwards, and it works at least somewhat for the purpose described in this issue. Jackson 2.9 had improvements for getting JsonValue fields, so in the future a cleaner solution might be possible.
I've written a piece of code that at the very least fetches the field, though the Swagger output unfortunately still contains the list field name. Not sure how to fix that.
@rgroothuijsen thanks for posting an update. I'll take a look at your patch.
I've been looking into it a bit further, and I haven't found a good way to cleanly generate anonymous JsonValue output in the Swagger spec because Swagger uses key-value maps to generate its property structure. Given that, it would come down to a choice between no output or bad output for JsonValue fields.
I am facing the same problem as was described in: https://github.com/springfox/springfox/issues/184
Essentially, when you have a class that wraps around a list and uses @JsonValue to flatten the resulting JSON (so that it is "[{...}, {...}, ...]" instead of "{'elements':[{...}, {...}, ...]}"), you end up with an empty model and an empty [] in the example.
A model to reproduce this problem might look like this:
I was able to work around this problem by extending a ForwardingList from Guava, but in my opinion JsonValue annotation should also be supported.