Package com.wordnik.swagger.annotations

Examples of com.wordnik.swagger.annotations.ApiParam


            Map<String, Object> parameter = Maps.newHashMap();
            final Parameter param = new Parameter();

            for (Annotation annotation : annotations) {
                if (annotation instanceof ApiParam) {
                    ApiParam apiParam = (ApiParam) annotation;
                    parameter.put("name", apiParam.name());
                    parameter.put("description", apiParam.value());
                    parameter.put("required", apiParam.required());
                    param.setName(apiParam.name());
                    param.setDescription(apiParam.value());
                    param.setIsRequired(apiParam.required());

                    Type parameterClass = method.getGenericParameterTypes()[i];
                    if (parameterClass.equals(String.class)) {
                        parameter.put("type", "string");
                    } else if (parameterClass.equals(int.class) || parameterClass.equals(Integer.class)) {
View Full Code Here


            // determine name
            String name;
            String paramType= BODY_INDICATOR;
            PathParam pp = paramElement.getAnnotation(PathParam.class);
            QueryParam qp = paramElement.getAnnotation(QueryParam.class);
            ApiParam ap = paramElement.getAnnotation(ApiParam.class);
            if (pp != null) {
                name = pp.value();
                paramType="Path";
            }
            else if (qp!=null) {
                name = qp.value();
                paramType="Query";
            }
            else if (ap!=null)
                name = ap.name();
            else {
                Name nameElement = paramElement.getSimpleName();
                name = nameElement.toString();
            }

            element.setAttribute("name", name);
            element.setAttribute("paramType",paramType);
            ApiParam apiParam = paramElement.getAnnotation(ApiParam.class);
            if (apiParam!=null) {
                String description = apiParam.value();
                setOptionalAttribute(element, "description", description);
                String required = String.valueOf(apiParam.required());
                if (pp!=null || paramType.equals(BODY_INDICATOR)) // PathParams are always required
                    required="true";

                setOptionalAttribute(element, "required", required, "false");
                String allowedValues = apiParam.allowableValues();
                setOptionalAttribute(element, "allowableValues", allowedValues, "all");
            }
            String defaultValue;
            DefaultValue dva = paramElement.getAnnotation(DefaultValue.class);
            if (dva!=null)
View Full Code Here

public class ParameterAccessReader implements Command<RequestMappingContext> {
  @Override
  public void execute(RequestMappingContext context) {
    MethodParameter methodParameter = (MethodParameter) context.get("methodParameter");
    ApiParam apiParam = methodParameter.getParameterAnnotation(ApiParam.class);
    String access = "";
    if (null != apiParam) {
      access = apiParam.access();
    }
    context.put("paramAccess", access);
  }
View Full Code Here

public class ParameterDescriptionReader implements Command<RequestMappingContext> {
  @Override
  public void execute(RequestMappingContext context) {
    MethodParameter methodParameter = (MethodParameter) context.get("methodParameter");
    ApiParam apiParam = methodParameter.getParameterAnnotation(ApiParam.class);
    String description = methodParameter.getParameterName();
    if (null != apiParam && !isBlank(apiParam.value())) {
      description = apiParam.value();
    }
    context.put("description", description);
  }
View Full Code Here

public class ParameterMultiplesReader implements Command<RequestMappingContext> {
  @Override
  public void execute(RequestMappingContext context) {
    MethodParameter methodParameter = (MethodParameter) context.get("methodParameter");
    ApiParam apiParam = methodParameter.getParameterAnnotation(ApiParam.class);

    Boolean allowMultiple = Boolean.FALSE;
    Class<?> parameterType = methodParameter.getParameterType();
    if (null != apiParam && !(parameterType != null
            && parameterType.isArray() && parameterType.getComponentType().isEnum())) {
      allowMultiple = apiParam.allowMultiple();
    } else {
      allowMultiple = parameterType.isArray()
              || Iterable.class.isAssignableFrom(parameterType);
    }
    context.put("allowMultiple", allowMultiple);
View Full Code Here

public class ParameterNameReader implements Command<RequestMappingContext> {
  @Override
  public void execute(RequestMappingContext context) {
    MethodParameter methodParameter = (MethodParameter) context.get("methodParameter");
    ApiParam apiParam = methodParameter.getParameterAnnotation(ApiParam.class);
    String name = "";
    if (null != apiParam && !isBlank(apiParam.name())) {
      name = apiParam.name();
    } else {
      name = findParameterNameFromAnnotations(methodParameter);
      if (isNullOrEmpty(name)) {
        String parameterName = methodParameter.getParameterName();
        name = isNullOrEmpty(parameterName) ? format("param%s", methodParameter.getParameterIndex()) : parameterName;
View Full Code Here

TOP

Related Classes of com.wordnik.swagger.annotations.ApiParam

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.