this.modelProvider = modelProvider;
}
@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);
modelType = swaggerGlobalSettings.getAlternateTypeProvider().alternateFor(modelType);
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.getTypeResolver(),
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);
}
mergeModelMap(modelMap, readParametersApiModel(handlerMethodResolver, swaggerGlobalSettings, handlerMethod));
log.debug("Finished reading models for handlerMethod |{}|", handlerMethod.getMethod().getName());
context.put("models", modelMap);
}