@JsonIgnore is not ignoring all getters
I'm trying to ignore some fields in my model, but it still seems to be showing up in my swagger ui. I'm using swagger jaxrs:
<groupId>com.wordnik</groupId>
<artifactId>swagger-jersey-jaxrs_2.10</artifactId>
<version>1.3.0</version>
and my code is:
public static class Person
{
private String name = "hello world";
@ApiModelProperty(value = "The name of the person", required=true)
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
@JsonIgnore
public String getMiddleName()
{
return "ignore middle name";
}
}
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/people/{personId}")
@ApiOperation(value = "Find Person", response = Person.class)
public Response getPerson(
@ApiParam(value = "ID of the Person to fetch", required = true)
@PathParam("personId")
String personId)
{
return Response.ok().entity(new Person()).build();
}
In the Swagger UI, the "middleName" property is showing up in Person model even though I've set the JsonIgnore annotation. Am I doing something wrong here?
I added a fix to my own repo:
jknova/swagger-core@85ee010ced2d18a030b4f9f6f58e36cd8198c50b
Seems to be working...
If not for all the activity around swagger-ui I would assume this project must be dead since this is still broken 4 months later.
@rage-shadowman ?
I'm just surprised that this issue is still present, even though there was a pull request to fix it 4 months ago.
Pull requests with tests get priority, in general. Also when there are pieces changing, they won't be merged immediately.
PS - We do appreciate all the work you guys are doing, and I can clearly see a lot of activity and fast responses on the swagger-ui repo, so I know you guys are still working on this stuff. Thank you.
fixed in the develop branch and in 1.3.2-SNAPSHOT in sonatype oss