swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

@JsonIgnore is not ignoring all getters

Open jknova opened this issue 13 years ago • 7 comments

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?

jknova avatar Sep 11 '13 22:09 jknova

I added a fix to my own repo:

jknova/swagger-core@85ee010ced2d18a030b4f9f6f58e36cd8198c50b

Seems to be working...

jknova avatar Sep 13 '13 22:09 jknova

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 avatar Jan 10 '14 19:01 rage-shadowman

@rage-shadowman ?

fehguy avatar Jan 10 '14 19:01 fehguy

I'm just surprised that this issue is still present, even though there was a pull request to fix it 4 months ago.

rage-shadowman avatar Jan 10 '14 21:01 rage-shadowman

Pull requests with tests get priority, in general. Also when there are pieces changing, they won't be merged immediately.

fehguy avatar Jan 10 '14 21:01 fehguy

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.

rage-shadowman avatar Jan 10 '14 21:01 rage-shadowman

fixed in the develop branch and in 1.3.2-SNAPSHOT in sonatype oss

fehguy avatar Jan 15 '14 01:01 fehguy