Reputation: 61526
I am using swagger-jaxrs_2.10.0 version 1.2.3 (just upgraded from 1.2.2 which had the same result)
If I have a class like this:
public class XXXResponse
{
private List<Boolean> booleans;
private List<Byte> bytes;
private List<Short> shorts;
private List<Integer> integers;
private List<Long> longs;
private List<Float> floats;
private List<Double> doubles;
private List<String> strings;
private List<Date> dates;
// set/get methods
}
Swagger reports it as:
{
"integers": [
"int"
],
"bytes": [
"any"
],
"longs": [
"any"
],
"dates": [
"any"
],
"shorts": [
"any"
],
"strings": [
"string"
],
"doubles": [
"any"
],
"floats": [
"any"
],
"booleans": [
"boolean"
]
}
What specific magic do I need to incant to make the "any" turn into the appropriate types?
Upvotes: 1
Views: 1100
Reputation: 61526
Turns out that that configuring Jackson did the trick:
@Provider
@Produces(MediaType.APPLICATION_JSON)
public class JacksonJsonProvider extends JacksonJaxbJsonProvider
{
private static ObjectMapper commonMapper = null;
public JacksonJsonProvider()
{
if(commonMapper == null)
{
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT);
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
commonMapper = mapper;
}
super.setMapper(commonMapper);
}
}
Upvotes: 1