question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Swagger 2.0 + Jackson: @JsonIdentityInfo doesn't work

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5

github_iconTop GitHub Comments

5reactions
hanymorcoscommented, Aug 10, 2017

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

0reactions
muetycommented, Nov 25, 2020

Same issue here 😞

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swagger 2.0 + Jackson: @JsonIdentityInfo doesn't work
We are attempting to have Swagger 2.0. Basically, it's great except it is ignoring the @JsonIdentityInfo and @JsonIdentityReference ...
Read more >
Swagger 2.0 + Jackson: @JsonIdentityInfo ... - Google Groups
We are attempting to have Swagger 2.0. Basically, it's great except it is ignoring the @JsonIdentityInfo and @JsonIdentityReference annotations. ... You can see ......
Read more >
JsonIdentityInfo (Jackson-annotations 2.14.1 API) - javadoc.io
Annotation used for indicating that values of annotated type or property should be serializing so that instances either contain additional object identifier ...
Read more >
io.swagger.jackson.ModelResolver ... - Download JAR files
JsonIdentityInfo ; import com.fasterxml.jackson.annotation. ... uses raw class, as it does not consider super class while handling schema annotation for ...
Read more >
Inheritance with Jackson - Baeldung
It works in collaboration with @JsonIdentityInfo to force usage of object identities in every serialization, different from all-but-the-first-time when @ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found