ApiAnnotationIntrospector extends NopAnnotationIntrospector { public static TypeToken<?> getSchemaType(TypeToken<?> type, ApiConfig config) { Type rawType = type.getType(); if (rawType instanceof Class || rawType instanceof ParameterizedType) { List<Class<? extends Transformer<?, ?>>> serializers = Serializers.getSerializerClasses(type, config.getSerializationConfig()); if (!serializers.isEmpty() && !(ResourceTransformer.class.isAssignableFrom(serializers.get(0)))) { TypeToken<?> sourceType = Serializers.getSourceType(serializers.get(0)); TypeToken<?> serializedType = Serializers.getTargetType(serializers.get(0)); Preconditions.checkArgument( sourceType.isSupertypeOf(type), "Serializer specified for %s, but only serializes for %s: %s", type, sourceType, serializers.get(0)); Preconditions.checkArgument( serializedType != null, "Couldn't find Serializer interface in serializer for %s: %s", type, serializers.get(0)); return serializedType; } } return type; } ApiAnnotationIntrospector();  ApiAnnotationIntrospector(ApiSerializationConfig config); @Override boolean hasIgnoreMarker(AnnotatedMember member); @Override PropertyName findNameForSerialization(Annotated a); @Override PropertyName findNameForDeserialization(Annotated a); @Override String findPropertyDescription(Annotated a); @Override JsonSerializer<?> findSerializer(Annotated method); @Override String findEnumValue(Enum<?> value); @Override JsonDeserializer<?> findDeserializer(Annotated a); @Override VisibilityChecker<?> findAutoDetectVisibility(
      AnnotatedClass ac, VisibilityChecker<?> checker); static TypeToken<?> getSchemaType(TypeToken<?> type, ApiConfig config);  }
@Test public void testGetSerializerTypeWithIncompatibleSourceType() throws Exception { try { ApiConfig config = new ApiConfig.Factory().create( ServiceContext.create(), new TypeLoader(), TestEndpoint.class); ApiAnnotationIntrospector.getSchemaType(TypeToken.of(BadSerializerBean.class), config); fail("no exception thrown when a bad serializer was specified"); } catch (IllegalArgumentException e) { } }