private Map<String, Model> readParametersApiModel(
      HandlerMethodResolver handlerMethodResolver,
      SwaggerGlobalSettings settings,
      HandlerMethod handlerMethod) {

    Method method = handlerMethod.getMethod();
    Map<String, Model> modelMap = newHashMap();

    log.debug(
        "Reading parameters models for handlerMethod |{}|", handlerMethod.getMethod().getName());

    List<ResolvedMethodParameter> parameterTypes =
        handlerMethodResolver.methodParameters(handlerMethod);
    Annotation[][] annotations = method.getParameterAnnotations();

    for (int i = 0; i < annotations.length; i++) {
      Annotation[] pAnnotations = annotations[i];
      for (Annotation annotation : pAnnotations) {
        if (annotation instanceof RequestBody) {
          ResolvedMethodParameter pType = parameterTypes.get(i);
          if (!settings
              .getIgnorableParameterTypes()
              .contains(pType.getResolvedParameterType().getErasedType())) {
            ModelContext modelContext = ModelContext.inputParam(pType.getResolvedParameterType());
            markIgnorablesAsHasSeen(settings.getIgnorableParameterTypes(), modelContext);
            Optional<Model> pModel = modelProvider.modelFor(modelContext);
            if (pModel.isPresent()) {
              log.debug(
                  "Swagger generated parameter model id: {}, name: {}, schema: {} models",
                  pModel.get().id(),
                  pModel.get().name());
              modelMap.put(pModel.get().id(), pModel.get());
            } else {
              log.debug(
                  "Swagger core did not find any parameter models for {}",
                  pType.getResolvedParameterType());
            }
            populateDependencies(modelContext, modelMap);
          }
        }
      }
    }
    log.debug(
        "Finished reading parameters models for handlerMethod |{}|",
        handlerMethod.getMethod().getName());
    return modelMap;
  }
  @Override
  public void execute(RequestMappingContext context) {
    HandlerMethod handlerMethod = context.getHandlerMethod();

    log.debug("Reading models for handlerMethod |{}|", handlerMethod.getMethod().getName());

    Map<String, Model> modelMap = newHashMap();
    SwaggerGlobalSettings swaggerGlobalSettings =
        (SwaggerGlobalSettings) context.get("swaggerGlobalSettings");
    HandlerMethodResolver handlerMethodResolver =
        new HandlerMethodResolver(swaggerGlobalSettings.getTypeResolver());
    ResolvedType modelType =
        ModelUtils.handlerReturnType(swaggerGlobalSettings.getTypeResolver(), handlerMethod);

    ApiOperation apiOperationAnnotation = handlerMethod.getMethodAnnotation(ApiOperation.class);
    if (null != apiOperationAnnotation && Void.class != apiOperationAnnotation.response()) {
      modelType =
          asResolved(swaggerGlobalSettings.getTypeResolver(), apiOperationAnnotation.response());
    }
    if (!swaggerGlobalSettings.getIgnorableParameterTypes().contains(modelType.getErasedType())) {
      ModelContext modelContext = ModelContext.returnValue(modelType);
      markIgnorablesAsHasSeen(swaggerGlobalSettings.getIgnorableParameterTypes(), modelContext);
      Optional<Model> model = modelProvider.modelFor(modelContext);
      if (model.isPresent() && !"void".equals(model.get().name())) {
        log.debug(
            "Swagger generated parameter model id: {}, name: {}, schema: {} models",
            model.get().id(),
            model.get().name());
        modelMap.put(model.get().id(), model.get());
      } else {
        log.debug("Swagger core did not find any models");
      }
      populateDependencies(modelContext, modelMap);
    }
    modelMap.putAll(
        readParametersApiModel(handlerMethodResolver, swaggerGlobalSettings, handlerMethod));

    log.debug(
        "Finished reading models for handlerMethod |{}|", handlerMethod.getMethod().getName());
    context.put("models", modelMap);
  }
 private void markIgnorablesAsHasSeen(
     Set<Class> ignorableParameterTypes, ModelContext modelContext) {
   for (Class ignorableParameterType : ignorableParameterTypes) {
     modelContext.seen(asResolved(new TypeResolver(), ignorableParameterType));
   }
 }