What I am trying to build is a spring-boot (v1.2.3) application and expose my Rest API with SpringFox(swagger2) v2.0.0
my Swagger Spring config
A couple of things I found missing with the above instructions is the package and imports. When I first tried this, I used my own packages but swagger-ui.html still said there were no packages found. It appears the package is specific.
The classes below are exactly the same as above, but I included the entire class with package names and imports. Registering the adapter is the same as documented above.
First the JSON class
package springfox.documentation.spring.web.json;
import com.fasterxml.jackson.annotation.*;
public class Json {
private final String value;
public Json(String value) {
this.value = value;
}
@JsonValue
@JsonRawValue
public String value() {
return value;
}
}
and the adapter class:
package springfox.documentation.spring.web.json;
import java.lang.reflect.Type;
import com.google.gson.*;
public class SpringfoxJsonToGsonAdapter implements com.google.gson.JsonSerializer {
@Override
public JsonElement serialize(Json json, Type type, JsonSerializationContext context) {
final JsonParser parser = new JsonParser();
return parser.parse(json.value());
}
}