DynamoDBMappingException on mapping Map<String, Object>attribute - amazon-dynamodb

I am trying to save the instance of the class bellow into dynamdb but getting
DynamoDBMappingException: not supported; requires #DynamoDBTyped or #DynamoDBTypeConverted exception.
#DynamoDBTable(tableName = "FulfillmentOrders")
public class FulfillmentOrder {
#DynamoDBHashKey
private String orderId;
#DynamoDBAttribute
#DynamoDBTyped(value = DynamoDBMapperFieldModel.DynamoDBAttributeType.M)
private Map<String, Object> body;
.......
}
It fails during map conversion, seems the problem is in Object generic type.
could someone help, where is the problem here or maybe SDK doesn't support such kind of conversion ?
Thanks!

DynamoDB won't know how to convert the objects in the Map<,>, you'll have to create a custom type converter. once you've done this you can annotate the prooperty with #DynamoDBTypeConverted(converter = xxx):
In your example:
#DynamoDBTable(tableName = "FulfillmentOrders")
public class FulfillmentOrder {
#DynamoDBHashKey
private String orderId;
#DynamoDBAttribute
#DynamoDBTypeConverted(converter = BodyTypeConverter.class)
private Map<String, Object> body;
}
static public class BodyTypeConverter implements DynamoDBTypeConverter<String, Map<String, Object>> {
#Override
public String convert(Map<String, Object> object) {
DimensionType itemDimensions = (Map<String, Object>) object;
// Convert the object to a DynamoDB json string
String json = "wibble";
return json;
}
#Override
public DimensionType unconvert(String s) {
Map<String, Object> item = new Map<String, Object>();
// Convert s to a Map<String, Object> here.
return item;
}
}
More information can be found here

Related

java.util.LinkedHashMap cannot be cast to class GenericEvent - objectmapper typeReference

The messages are getting consumed from kafka topic using json deserializer(spring commons). The generic messages structure as below.
GenericEvent:
{
"id": "10000",
"payload": {
"id": 100
"attribute1": "hi",
"attribute2": "hello"
},
"type": {
"id" : 1,
"name" : "A"
}
}
Different types has different payload and the structure of the payload also will be varied. So i would like to process the payload based on the type.
My respective POJO is as below, and total 3 different payloads and respective payload pojos has been created.
GenericEvent {
private int id;
private T payload:
private Type type;
}
Right now i am using the below code to convert
JsonNode jsonNode = objectMapper.readTree("messagefromKafka);
GenericEvent genericEvent = objectMapper.convertValue(jsonNode, new TypeReference<GenericEvent>() {});
But the code is throwing java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class GenericEvent .
Can someone help on this issue?
EDIT:
//Generic Object i have provided already
//Payload Object - applicable for different types - A, B, C, D
public class Payload {
private int id;
private String name;
private String address;
private String typeAAttribute1; //applicable for type A attribute
private String typeAAttribute2; //applicable for type A attribute
private String typeBAtribute1; //applicable for type B attribute
private String typeABAtribute2; //applicable for type A,B attibute
private String typeCtribute1; //applicable for type C attibute
private String typeABCAtribute1;//applicable for type A,B,C attibute
}
Kafka consumer config:
---------------------
import org.springframework.kafka.support.serializer.JsonDeserializer;
#Bean
public ConcurrentKafkaListenerContainerFactory<Object, Object> reprocessListenerContainerFactory() {
Map<String, Object> props = new HashMap<>();
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, JsonDeserializer.class);
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, JsonDeserializer.class);
props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, false);
props.put(ConsumerConfig.ALLOW_AUTO_CREATE_TOPICS_CONFIG, false);
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapservers);
props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, latest);
props.put(ConsumerConfig.GROUP_ID_CONFIG, "testgroupid");
props.put(ConsumerConfig.REQUEST_TIMEOUT_MS_CONFIG, "300000");
ConcurrentKafkaListenerContainerFactory<Object, Object> factory =
new ConcurrentKafkaListenerContainerFactory<>();
factory.setConsumerFactory(new DefaultKafkaConsumerFactory<>(props));
factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL_IMMEDIATE);
factory.setRecordFilterStrategy(
(consumerRecord) -> {
try {
JsonNode jsonNode = objectMapper.readTree(consumerRecord.value().toString());
GenericEvent genericEvent = objectMapper.convertValue(jsonNode, new TypeReference<GenericEvent>() {});
log.info(
"Retrieved the record {} from the partition {} with offset {}",
consumerRecord.value(),
consumerRecord.partition(),
consumerRecord.offset());
//Process type A and B events
if (genericEvent.getType().equalIgnoreCase("A") || genericEvent.getType().equalIgnoreCase("B"))) {
return false;
}
return true;
} catch (Exception ex) {
log.error("Error occured:{}", ex.getStackTrace());
return true;
}
});
return factory;
}
//Listener
#KafkaListener(id = "MYREPROCESS-ID", topics = "reprocess-test",
containerFactory = "reprocessListenerContainerFactory",
autoStartup = "true")
public void onMessage(ConsumerRecord<String, String> consumerRecord, Acknowledgment acknowledgment) {
JsonNode jsonNode = objectMapper.readTree("messagefromKafka);
GenericEvent genericEvent = objectMapper.convertValue(jsonNode, new TypeReference<GenericEvent>() {});
//I should identify the respective payload during runtime
Payload payload = genericEvent.getPayload();
if (genericEvent.getType().equalsIgnoreCase("A") {
processPayload(payload);
} else {
processPayload(payload);
}
}
Something is odd. Since you are using the Spring JsonDeserializer, you have to tell it what to convert to; properties are documented here https://docs.spring.io/spring-kafka/docs/current/reference/html/#serdes-json-config).
In that case, you would get ConsumerRecord<?, GenericEvent>.
If you want to receive ConsumerRecord<String, String> and do the conversion yourself, you should use StringDeserializer s instead.

How to convert Annotation Interface to JSON?

I am trying to read custom annotation value loaded through a different classloader.
How do I convert the Annotation object to json?
#Retention(RententionPolicy.RUNTIME)
public #interface SendEmail{
public String id;
}
Gson gson = new Gson();
Object object = (Object)annotation // this holds SendEmail object loaded from different classloader
gson.toJson(object);
//I get UnsupportedOperationException: Attempted to Serialize java.lang.Class: SendEmail. Forget to register a type adapter?
What is the type adapter to be used for interfaces?
I'm not really sure why you need to serialize annotation instances that are constant by design, but you're most likely using an Oracle JVM that instantiates annotations using java.lang.proxy.Proxy. Proxies are treated as reflective-access data objects in Gson (and there are no mentions of proxies in the standard Gson bundle) and Gson just fails on serializing java.lang.Class which does not make much sense in your scenario.
You need to create a new type adapter factory that can emit an annotation-aware type adapter that would use reflection over annotations heavily. Say,
final class AnnotationTypeAdapterFactory
implements TypeAdapterFactory {
private static final TypeAdapterFactory instance = new AnnotationTypeAdapterFactory();
private AnnotationTypeAdapterFactory() {
}
static TypeAdapterFactory getInstance() {
return instance;
}
#Override
#Nullable
public <T> TypeAdapter<T> create(final Gson gson, final TypeToken<T> typeToken) {
#Nullable
final Class<? extends Annotation> annotationClass = Annotations.lookupAnnotationClass(typeToken.getRawType());
if ( annotationClass == null ) {
return null;
}
final List<Method> methods = Annotations.lookupMethods(annotationClass);
final int count = methods.size();
final String[] names = new String[count];
#SuppressWarnings("unchecked")
final TypeAdapter<Object>[] typeAdapters = new TypeAdapter[count];
final Map<String, TypeAdapter<Object>> namedTypeAdapters = new HashMap<>();
for ( int i = 0; i < count; i++ ) {
final Method method = methods.get(i);
names[i] = method.getName();
#SuppressWarnings({ "unchecked", "rawtypes" })
final TypeAdapter<Object> typeAdapter = (TypeAdapter) gson.getAdapter(method.getReturnType());
typeAdapters[i] = typeAdapter;
namedTypeAdapters.put(names[i], typeAdapter);
}
final TypeAdapter<T> typeAdapter = new TypeAdapter<T>() {
#Override
#SuppressWarnings("resource")
public void write(final JsonWriter out, final T annotation)
throws IOException {
try {
out.beginObject();
for ( int i = 0; i < count; i++ ) {
out.name(names[i]);
typeAdapters[i].write(out, methods.get(i).invoke(annotation));
}
out.endObject();
} catch ( final IllegalAccessException | InvocationTargetException ex ) {
throw new RuntimeException(ex);
}
}
#Override
public T read(final JsonReader in)
throws IOException {
try {
in.beginObject();
final Map<String, Object> properties = new HashMap<>();
while ( in.hasNext() ) {
final String name = in.nextName();
#Nullable
final TypeAdapter<Object> objectTypeAdapter = namedTypeAdapters.get(name);
if ( objectTypeAdapter == null ) {
in.skipValue();
} else {
properties.put(name, objectTypeAdapter.read(in));
}
}
in.endObject();
#SuppressWarnings("unchecked")
final T annotation = (T) Annotations.create(annotationClass, properties);
return annotation;
} catch ( final NoSuchMethodException ex ) {
throw new RuntimeException(ex);
}
}
};
return typeAdapter.nullSafe();
}
}
where the Annotations class is as follows:
final class Annotations {
private static final boolean SUN_PACKAGE = false;
private Annotations() {
}
static <T extends Annotation> T create(final Class<T> annotationClass, final Map<String, Object> properties)
throws NoSuchMethodException {
return create(annotationClass.getClassLoader(), annotationClass, properties);
}
static <T extends Annotation> T create(final ClassLoader classLoader, final Class<T> annotationClass, final Map<String, Object> properties)
throws NoSuchMethodException {
if ( SUN_PACKAGE ) {
#SuppressWarnings("unchecked")
final T annotation = (T) AnnotationParser.annotationForMap(annotationClass, properties);
return annotation;
}
#SuppressWarnings("unchecked")
final T annotation = (T) Proxy.newProxyInstance(
classLoader,
new Class<?>[]{ annotationClass },
DynamicAnnotation.fromMap(annotationClass, lookupProperties(annotationClass, properties))
);
return annotation;
}
#Nullable
static Class<? extends Annotation> lookupAnnotationClass(final Class<?> clazz) {
if ( clazz.isAnnotation() ) {
#SuppressWarnings("unchecked")
final Class<? extends Annotation> annotationClass = (Class<? extends Annotation>) clazz;
return annotationClass;
}
final Class<?>[] interfaces = clazz.getInterfaces();
if ( interfaces.length != 1 ) {
return null;
}
final Class<?> iface = interfaces[0];
if ( !Annotation.class.isAssignableFrom(iface) ) {
return null;
}
#SuppressWarnings("unchecked")
final Class<? extends Annotation> annotationClass = (Class<? extends Annotation>) iface;
return annotationClass;
}
static List<Method> lookupMethods(final Class<? extends Annotation> annotationClass) {
final List<Method> methods = new ArrayList<>();
for ( final Method method : annotationClass.getMethods() ) {
if ( method.getDeclaringClass() == annotationClass ) {
methods.add(method);
}
}
return Collections.unmodifiableList(methods);
}
static Map<String, Object> lookupProperties(final Class<? extends Annotation> annotationClass, final Map<String, Object> properties) {
final Map<String, Object> namedProperties = new HashMap<>();
namedProperties.putAll(lookupDefaultProperties(annotationClass));
namedProperties.putAll(properties);
return Collections.unmodifiableMap(namedProperties);
}
static Map<String, Object> lookupDefaultProperties(final Class<? extends Annotation> annotationClass) {
final Map<String, Object> defaultProperties = new HashMap<>();
for ( final Method method : lookupMethods(annotationClass) ) {
#Nullable
final Object defaultValue = method.getDefaultValue();
if ( defaultValue != null ) {
defaultProperties.put(method.getName(), defaultValue);
}
}
return Collections.unmodifiableMap(defaultProperties);
}
static String toString(#SuppressWarnings("TypeMayBeWeakened") final Class<? extends Annotation> annotationClass, final Map<String, Object> properties) {
final StringBuilder builder = new StringBuilder("#")
.append(annotationClass.getTypeName())
.append('(');
boolean atTail = false;
for ( final Map.Entry<String, Object> e : properties.entrySet() ) {
if ( atTail ) {
builder.append(", ");
}
builder.append(e.getKey())
.append('=')
.append(e.getValue());
atTail = true;
}
return builder.append(')')
.toString();
}
}
and a custom implementation of annotations:
abstract class DynamicAnnotation
implements Annotation, InvocationHandler {
private static final Method java_lang_Object_equals;
private static final Method java_lang_Object_hashCode;
private static final Method java_lang_Object_toString;
private static final Method java_lang_annotation_Annotation_annotationType;
static {
try {
java_lang_Object_equals = Object.class.getDeclaredMethod("equals", Object.class);
java_lang_Object_hashCode = Object.class.getDeclaredMethod("hashCode");
java_lang_Object_toString = Object.class.getDeclaredMethod("toString");
java_lang_annotation_Annotation_annotationType = Annotation.class.getDeclaredMethod("annotationType");
} catch ( final NoSuchMethodException ex ) {
throw new Error(ex);
}
}
private final String toString;
private final Class<? extends Annotation> annotationClass;
private DynamicAnnotation(final String toString, final Class<? extends Annotation> annotationClass) {
this.toString = toString;
this.annotationClass = annotationClass;
}
static DynamicAnnotation fromMap(final Class<? extends Annotation> annotationClass, final Map<String, Object> properties)
throws NoSuchMethodException {
return FromMap.create(annotationClass, properties);
}
#Nullable
protected abstract Object invoke(final Method method)
throws Throwable;
#Override
public final Class<? extends Annotation> annotationType() {
return annotationClass;
}
// must conform the https://docs.oracle.com/javase/6/docs/api/java/lang/annotation/Annotation.html#hashCode() contract
#Override
public final int hashCode() {
//return hashCode;
throw new UnsupportedOperationException();
}
// must conform the https://docs.oracle.com/javase/6/docs/api/java/lang/annotation/Annotation.html#equals(java.lang.Object) contract
#Override
public final boolean equals(#Nullable final Object obj) {
throw new UnsupportedOperationException();
}
#Override
public final String toString() {
return toString;
}
#Override
#Nonnull
public final Object invoke(final Object proxy, final Method method, final Object[] args)
throws Throwable {
if ( method.equals(java_lang_annotation_Annotation_annotationType) ) {
return annotationType();
}
if ( method.equals(java_lang_Object_equals) ) {
return equals(args[0]);
}
if ( method.equals(java_lang_Object_hashCode) ) {
return hashCode();
}
if ( method.equals(java_lang_Object_toString) ) {
return toString();
}
#Nullable
final Object returnValue = invoke(method);
if ( returnValue == null ) {
throw new NoSuchMethodException("The instance of " + annotationClass + " has no value associated with " + method.getName());
}
return returnValue;
}
private static final class FromMap
extends DynamicAnnotation {
private final Map<String, Object> properties;
private FromMap(final String toString, final Class<? extends Annotation> annotationClass, final Map<String, Object> properties) {
super(/*hashCode, */toString, annotationClass);
this.properties = properties;
}
private static DynamicAnnotation create(final Class<? extends Annotation> annotationClass, final Map<String, Object> properties)
throws NoSuchMethodException {
final Map<String, Object> toStringProperties = new LinkedHashMap<>();
for ( final Method method : Annotations.lookupMethods(annotationClass) ) {
final String name = method.getName();
if ( !properties.containsKey(name) ) {
throw new NoSuchMethodException("Cannot find " + name + " in " + properties + " while constructing an instance of " + annotationClass);
}
final Object value = properties.get(name);
toStringProperties.put(name, value);
}
final String toString = Annotations.toString(annotationClass, Collections.unmodifiableMap(toStringProperties));
return new FromMap(toString, annotationClass, properties);
}
#Override
protected Object invoke(final Method method) {
return properties.get(method.getName());
}
}
}
You might also use AnnotationUtils (if it works for you), or AnnotationParser from the "sun package" (if it's an option either) to fulfill the annotation interface contracts.
Here is an example of use for round-trip:
private static final Gson gson = new GsonBuilder()
.registerTypeAdapterFactory(AnnotationTypeAdapterFactory.getInstance())
.create();
public static void main(final String... args)
throws NoSuchFieldException {
final SendEmail before = Wrapper.class.getDeclaredField("constant").getAnnotation(SendEmail.class);
System.out.println(before);
final String json = gson.toJson(before);
System.out.println(json);
final SendEmail after = gson.fromJson(json, SendEmail.class);
System.out.println(after);
System.out.println(after.annotationType());
System.out.println(gson.toJson(after));
}
private static final class Wrapper {
#SendEmail(id = "email#mail.com")
private static final Object constant = new Object();
}

Not able to merge to Map<String, Long>

I am trying to merge several Map into a single map, for doing this I wrote this piece of code.
public static Map<String, Long> mergeMaps(List<Map<String, Long>> maps){
Map<String, Long> mergedMap = new TreeMap<>();
maps.forEach( map -> {
//Map<String, Long> mx = new TreeMap<>(map);
map.forEach((key, value) -> mergedMap.merge(key, value, Long::sum));
});
logger.info("Merge map successful");
return mergedMap;
}
On doing this the code is throwing an error :
org.springframework.batch.core.step.AbstractStep java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) ~[?:1.8.0_201-1-ojdkbuild]
lambda$mergeMaps$1
I have this pojo
public class MappingDto {
public MappingDto(){
map1 = new LinkedHashMap<>();
map2 = new LinkedHashMap<>();
map3 = new LinkedHashMap<>();
}
private Map<String, Long> map1;
private Map<String, Long> map2;
private Map<String, Long> map3;
getters()/Setters()
toString()
}
I populate this pojo maps with the below codes.
MappingDto.setMap1(Arrays.asList(doc.getDescription().split("\\s+")).stream().collect(Collectors.groupingBy(Function.identity(),LinkedHashMap::new,Collectors.counting())));
after generating this I have to merge this map with the some Stored in File, To read the Map I have the below method.
public static <T> T readJsonFile(String filePath, T t) throws JAXBException, IOException, IllegalAccessException, InstantiationException {
ObjectMapper mapper = new ObjectMapper();
if(!Utils.checkIfFileExists(filePath)){
Utils.createANewFile(filePath);
return t;
}
return mapper.readValue(new File(filePath), new TypeReference<T>(){});
}
After getting this maps I pass it to the
mergeMaps(Arrays.asList(MappingDto.getMap1(),storedData));
and
List<Map<String, Long>> dataList = new LinkedList<>();
dataList.add(MappingDto.getMap1());
dataList.add(MappingDto.getMap2());
dataList.add(MappingDto.getMap3());
mergeMaps(dataList);
I went through this code several time, But not able to figure what exactly is causing this issue.
One is reading the Stored JSON map
public static <T> T readJsonFile(String filePath, Class<T> t) throws JAXBException, IOException, IllegalAccessException, InstantiationException {
ObjectMapper mapper = new ObjectMapper();
if(!Utils.checkIfFileExists(filePath)){
Utils.createANewFile(filePath);
return t.newInstance();
}
return mapper.readValue(new File(filePath), new TypeReference<T>(){});
}
I tried this and several other variations but no results.
public static Map<String, Long> mergeMaps(List<Map<String, Long>> maps){
Map<String, Long> mergedMap = new TreeMap<>();
maps.forEach( map -> {
//Map<String, Long> mx = new TreeMap<>(map);
map.forEach((key, value) -> mergedMap.merge(key, Long.valueOf(value), Long::sum));
});
logger.info("Merge map successful");
return mergedMap;
}
Can you please help me understand what is in Integer and why is being cast to Long
Thanks in advance.

DynamoDBMapper Maps support (java)

I am trying to write a map using com.amazonaws.services.dynamodb.datamodeling.DynamoDBMapper.save() and am getting this error:
Exception in thread "main"
com.amazonaws.services.dynamodb.datamodeling.DynamoDBMappingException:
Unsupported type: interface java.util.Map for public java.util.Map Config.getAttributes()
Is Map not supported by DynamoDBMapper?
Create a HashMapMarshaller
public class HashMapMarshaller extends JsonMarshaller<HashMap<String, String>>
{
#Override
public String marshall(HashMap<String, String> obj) {
return super.marshall(obj);
}
#Override
public HashMap<String, String> unmarshall(Class<HashMap<String, String>> clazz, String json) {
return super.unmarshall(clazz, json);
}
}
And then assign it to your property
#DynamoDBMarshalling(marshallerClass=HashMapMarshaller.class)

How can I set Swagger to ignore #Suspended AsyncResponse in #Asynchronous jax-rs bean methods?

Swagger-Core seems to interpret the #Suspended final AsyncResponse asyncResponse member as request body param. This is clearly not intended nor the case.
I would like to tell swagger-core to ignore this parameter and to exclude it from the api-docs. Any ideas?
This is what my code looks like:
#Stateless
#Path("/coffee")
#Api(value = "/coffee", description = "The coffee service.")
public class CoffeeService
{
#Inject
Event<CoffeeRequest> coffeeRequestListeners;
#GET
#ApiOperation(value = "Get Coffee.", notes = "Get tasty coffee.")
#ApiResponses({
#ApiResponse(code = 200, message = "OK"),
#ApiResponse(code = 404, message = "Beans not found."),
#ApiResponse(code = 500, message = "Something exceptional happend.")})
#Produces("application/json")
#Asynchronous
public void makeCoffee( #Suspended final AsyncResponse asyncResponse,
#ApiParam(value = "The coffee type.", required = true)
#QueryParam("type")
String type)
{
coffeeRequestListeners.fire(new CoffeeRequest(type, asyncResponse));
}
}
Update: Solution based on Answer
public class InternalSwaggerFilter implements SwaggerSpecFilter
{
#Override
public boolean isOperationAllowed(Operation operation, ApiDescription apiDescription, Map<String, List<String>> stringListMap, Map<String, String> stringStringMap, Map<String, List<String>> stringListMap2) {
return true;
}
#Override
public boolean isParamAllowed(Parameter parameter, Operation operation, ApiDescription apiDescription, Map<String, List<String>> stringListMap, Map<String, String> stringStringMap, Map<String, List<String>> stringListMap2) {
if( parameter.paramAccess().isDefined() && parameter.paramAccess().get().equals("internal") )
return false;
return true;
}
}
FilterFactory.setFilter(new InternalSwaggerFilter());
Revised Example Code Fragment
...
#Asynchronous
public void makeCoffee( #Suspended #ApiParam(access = "internal") final AsyncResponse asyncResponse,...)
...
Fast forward to 2016 where swagger-springmvc is replaced by springfox (documentation is available here). Ignoring paramaters is available in springfox, but is for some reason not documented:
Alternative 1: Globally ignore types or annotated types with .ignoredParameterTypes(...) in Docket configuration:
#Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.host(reverseProxyHost)
.useDefaultResponseMessages(false)
.directModelSubstitute(OffsetDateTime.class, String.class)
.directModelSubstitute(Duration.class, String.class)
.directModelSubstitute(LocalDate.class, String.class)
.forCodeGeneration(true)
.globalResponseMessage(RequestMethod.GET, newArrayList(
new ResponseMessageBuilder()
.code(200).message("Success").build()
)
.apiInfo(myApiInfo())
.ignoredParameterTypes(AuthenticationPrincipal.class, Predicate.class, PathVariable.class)
.select()
.apis(withClassAnnotation(Api.class))
.paths(any())
.build();
}
Alternativ 2: Use #ApiIgnore-annotation to ignore single parameter in method:
#ApiOperation(value = "User details")
#RequestMapping(value = "/api/user", method = GET, produces = APPLICATION_JSON_UTF8_VALUE)
public MyUser getUser(#ApiIgnore #AuthenticationPrincipal MyUser user) {
...
}
I solved this issue with the same technique that you use, but with a different approach. Instead of marking it as internal I just ignore all the params with the type AsyncResponse, that way I don't need to update the code in all methods to add the access modifier.
public class CustomSwaggerSpecFilter implements SwaggerSpecFilter {
#Override
public boolean isOperationAllowed(Operation operation, ApiDescription api, Map<String, List<String>> params, Map<String, String> cookies,
Map<String, List<String>> headers) {
return true;
}
#Override
public boolean isParamAllowed(Parameter parameter, Operation operation, ApiDescription api, Map<String, List<String>> params,
Map<String, String> cookies, Map<String, List<String>> headers) {
if(parameter.dataType().equals("AsyncResponse")) { // ignoring AsyncResponse parameters
return false;
}
return true;
}
}
That works better for me.
I think you have to use filters.
Here is an example https://github.com/wordnik/swagger-core/issues/269
Could be coded in java too.
Another way might be to do this.
#Bean
public SwaggerSpringMvcPlugin mvPluginOverride() {
SwaggerSpringMvcPlugin swaggerSpringMvcPlugin = new SwaggerSpringMvcPlugin(this.springSwaggerConfig).apiInfo(apiInfo());
swaggerSpringMvcPlugin.ignoredParameterTypes(PagedResourcesAssembler.class, Pageable.class);
return swaggerSpringMvcPlugin;
}

Resources