0

We have an existing REST API build with Spring MVC. We are now spiking to see if we can use Swagger to generate internal documentation (quickly).

The problem with our REST implementation is that we do use Spring MVC to convert business objects to json, but that we have custom json converters that basically create Jettison json objects (key/values) from the business objects. There is currently no way to change this unfortunately. The same goes for input btw. It's basically always a Hashmap that we send to the client.

As we can generate the controllers and it's methods using Springfox is a good start. But we want to document the input/output as well. Is there a way to use Swagger Annotation to document the input/output models manually without reference to a Java domain class?

Alternative is that we completely write our own low level Swagger spec or look into other solution.

Marcel Overdijk
  • 11,041
  • 17
  • 71
  • 110

1 Answers1

-1

Why not use spring rest-docs? I think its exactly what you might need when you're service models are not really strongly typed. It has a couple of advantages int that

  • You can write tests for each of your endpoints
  • The models will reflect reality all the time, rather than having ways to describe your model externally and feed it to the springfox infrastructure.
  • If the models are externally supplied, it is not really possible for one to keep up these changes with reality without some kind of tests anyways.

This is probably not in your control, which is why you have this question, but to re-state the obvious the alternative is to have your models reflect the expectations from a client rather than have loosey-goosey json-key-value conversions.

Dilip Krishnan
  • 5,417
  • 3
  • 37
  • 53