Add support for @JsonView
In java, many REST services are written using Jersey/dropwizard frameworks and which rely on the Jackson Json library for serialization. With this Jackson library they allow us to define a "JsonView" which acts as a subset of a model that might be exposed via an api (http://wiki.fasterxml.com/JacksonJsonViews).
For example if I have a resource annotated with the following...
@JsonView(View.Public.class)
@ApiOperation(value = "bla bla bal.", notes = "And bla bla bla.",
response = SomeType.class)
Response getSomeResource() {}
Where the class SomeType looks like this:
class SomeType {
@JsonView(View.Public.class)
private String publicProperty;
@JsonView(View.Internal.class)
private String internalProperty;
}
I want the swagger docs to only include the property "publicProperty" since it was annotated with the @JsonView(View.Public.class). This dropwizard/jersey resource renders the correct response, but swagger still generates api docs that include both properties.
Is it possible to fix this or is there a swagger change coming that might fix this? I've heard that in the most recent SNAPSHOT of swagger that there's support for "@ApiModelProperty(hidden=true)", but I'd rather not have to duplicate annotating my models like this especially since I think the @JsonView is more flexible.
Thanks, Brent
+1
Is there any consideration of this? Or any sort of workaround to make it at all possible? We have multiple views per class and would like to be able to customize the view by endpoint (i.e., we can't hide properties across the board because some properties are shown in some services and not in others).
+1
+1
+1
1.5.0 will use pure jackson and therefore the @JsonView annotation.
I'd love to see some samples committed to the develop_2.0 branch to cover @JsonView use cases.
I know this has gone unanswered for a long time, and I hate to do this, but that functionality just doesn't fit in with swagger. I suggest using filters to attain a similar result, which gives you even more control since the determination is dynamic.
https://github.com/swagger-api/swagger-core/blob/develop_2.0/modules/swagger-core/src/main/java/com/wordnik/swagger/core/filter/SwaggerSpecFilter.java
fyi, the filters do not solve the problem here and suck to implement.
fehguy, your link gives 404
https://github.com/swagger-api/swagger-core/blob/master/modules/swagger-core/src/main/java/io/swagger/core/filter/SwaggerSpecFilter.java
+1
+1
Hm it is still not resolved in my opinion. This api implicit model only supports manual setted parameters... that means we have to write it :
in jsonviews + in swagger doc
If jsonviews was supported we only had to write into jsonviews. Please support it
+1
+1
+1
+1
+1
+1