Swagger-core: Swagger 2.0 + Jackson: @JsonIdentityInfo doesn't work

Created on 21 Sep 2015  路  5Comments  路  Source: swagger-api/swagger-core

Referencing: http://stackoverflow.com/posts/32692609/edit

We are attempting to have Swagger 2.0. Basically, it's great except it is ignoring the @JsonIdentityInfo and @JsonIdentityReference annotations.

public class Source {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ManyToOne
    @JsonIdentityReference(alwaysAsId=true)
    @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "name")
    @JsonProperty("sourceDefinitionName")
    private SourceDefinition sourceDefinition;

    ... getters and setters
}

Resulting in the Swagger schema output:

{
     "id": 0,
     "sourceDefinitionName": {
          "configuration": {},
          "driver": "string",
          "id": "string",
          "name": "string",
          "sourceType": "QUERY",
          "title": "string"
     }
}

You can see that it indeed reads the @JsonProperty annotation renaming the "sourceDefinition" to "sourceDefinitionName" but the value should just be a string.

Does anyone have any insight into this sort of problem with this integration?

Most helpful comment

JsonIdentityReference still doesn't work, using spring fox 2.6.1 version

All 5 comments

JsonIdentityReference still doesn't work, using spring fox 2.6.1 version

Same for me, I have cyclic dependencies, so I have to use @JsonIdentityInfo.
I get a stackoverflow

I'm using JSON Property. That's working for me through swagger. I'm tweaking jhiptser generated code.

Still doesn't work. Spring Fox 3.0.0-SNAPSHOT and Swagger Maven Plugin 2.4.0.

Same issue here :disappointed:

Was this page helpful?
0 / 5 - 0 ratings