com.mangofactory.swagger.readers.operation.parameter.OperationParameterReader Maven / Gradle / Ivy
package com.mangofactory.swagger.readers.operation.parameter;
import com.mangofactory.swagger.configuration.SwaggerGlobalSettings;
import com.mangofactory.swagger.core.CommandExecutor;
import com.mangofactory.swagger.models.alternates.AlternateTypeProvider;
import com.mangofactory.swagger.readers.Command;
import com.mangofactory.swagger.readers.operation.HandlerMethodResolver;
import com.mangofactory.swagger.readers.operation.ResolvedMethodParameter;
import com.mangofactory.swagger.readers.operation.SwaggerParameterReader;
import com.mangofactory.swagger.scanners.RequestMappingContext;
import com.mangofactory.swagger.models.dto.AllowableValues;
import com.mangofactory.swagger.models.dto.Parameter;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.method.HandlerMethod;
import java.lang.annotation.Annotation;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.google.common.collect.Lists.*;
public class OperationParameterReader extends SwaggerParameterReader {
@Override
protected Collection extends Parameter> readParameters(final RequestMappingContext context) {
HandlerMethod handlerMethod = context.getHandlerMethod();
SwaggerGlobalSettings swaggerGlobalSettings = (SwaggerGlobalSettings) context.get("swaggerGlobalSettings");
HandlerMethodResolver handlerMethodResolver
= new HandlerMethodResolver(swaggerGlobalSettings.getTypeResolver());
AlternateTypeProvider alternateTypeProvider = swaggerGlobalSettings.getAlternateTypeProvider();
List methodParameters = handlerMethodResolver.methodParameters(handlerMethod);
List parameters = newArrayList();
List> commandList = newArrayList();
commandList.add(new ParameterAllowableReader());
commandList.add(new ParameterDataTypeReader());
commandList.add(new ParameterTypeReader());
commandList.add(new ParameterDefaultReader());
commandList.add(new ParameterDescriptionReader());
commandList.add(new ParameterMultiplesReader());
commandList.add(new ParameterNameReader());
commandList.add(new ParameterRequiredReader());
ModelAttributeParameterExpander expander = new ModelAttributeParameterExpander(alternateTypeProvider);
for (ResolvedMethodParameter methodParameter : methodParameters) {
if (!shouldIgnore(methodParameter, swaggerGlobalSettings.getIgnorableParameterTypes())) {
RequestMappingContext parameterContext
= new RequestMappingContext(context.getRequestMappingInfo(), handlerMethod);
parameterContext.put("methodParameter", methodParameter.getMethodParameter());
parameterContext.put("resolvedMethodParameter", methodParameter);
parameterContext.put("swaggerGlobalSettings", swaggerGlobalSettings);
CommandExecutor