3

By default, Swagger parses a class's data members in order to document the objects used as parameters or returned by a given web service. If you're using Jackson, the Jackson annotations provide a much more accurate description of the API.

Does anyone know an (easy) way to get Swagger to parse Jackson annotations. Perhaps an overridden parser?

Eyal
  • 3,412
  • 1
  • 44
  • 60

2 Answers2

2

Not sure if this would help, but Jackson 2.1 and later expose POJO structure as seen by Jackson itself (ObjectMapper.acceptJsonFormatVisitor), which could be used for generating different kinds of artifacts. I have written an Avro schema generator with it, for example (as part of Jackson Avro module)

StaxMan
  • 113,358
  • 34
  • 211
  • 239
  • Wow, this could be a great solution. Unfortunately, we're using Jackson 1.9 ... I'll have to see how difficult it is to upgrade. Any hints beyond [this answer](http://stackoverflow.com/questions/12461760/jackson-2-0-compatibility-with-jackson-1-x-annotations)? – Eyal Feb 14 '13 at 13:22
  • Changes are mostly mechanical really, and with IDE what I did was to remove old imports, and start replacing with new to solve majority of compilation problems, then moving to remainders. But maybe this -- http://www.cowtowncoder.com/blog/archives/2012/04/entry_469.html -- would help? – StaxMan Feb 14 '13 at 16:19
0

As of version 1.2, Swagger can parse Jackson annotations on its own. I confirmed this using Jackson 2.1.

Eyal
  • 3,412
  • 1
  • 44
  • 60