Package com.wordnik.swagger.model

Examples of com.wordnik.swagger.model.AllowableListValues


  private AllowableValues allowableValues(final Optional<String> optionalAllowable, final Field field) {

    AllowableValues allowable = null;
    if (field.getType().isEnum()) {
      allowable = new AllowableListValues(JavaConversions.collectionAsScalaIterable(
              getEnumValues(field.getType())).toList(), "LIST");
    } else if (optionalAllowable.isPresent()) {
      allowable = allowableValueFromString(optionalAllowable.get());
    }
View Full Code Here


        Object[] enumConstants = methodParameter.getParameterType().getEnumConstants();
        List<String> enumNames = new ArrayList<String>();
        for (Object o : enumConstants) {
          enumNames.add(o.toString());
        }
        allowableValues = new AllowableListValues(toScalaList(newArrayList(enumNames)), "LIST");
      }
      if (methodParameter.getParameterType().isArray()
              && methodParameter.getParameterType().getComponentType().isEnum()) {
        Object[] enumConstants = methodParameter.getParameterType().getComponentType().getEnumConstants();
        List<String> enumNames = new ArrayList<String>();
        for (Object o : enumConstants) {
          enumNames.add(o.toString());
        }
        allowableValues = new AllowableListValues(toScalaList(newArrayList(enumNames)), "LIST");
      }
    }
    context.put("allowableValues", allowableValues);
  }
View Full Code Here

      Iterable<String> split = Splitter.on(',').trimResults().omitEmptyStrings().split(allowableValueString);
      List<String> ranges = newArrayList(split);
      allowableValues = new AllowableRangeValues(ranges.get(0), ranges.get(1));
    } else if (allowableValueString.contains(",")) {
      Iterable<String> split = Splitter.on(',').trimResults().omitEmptyStrings().split(allowableValueString);
      allowableValues = new AllowableListValues(toScalaList(newArrayList(split)), "LIST");
    } else if (!isBlank(allowableValueString)) {
      List<String> singleVal = Arrays.asList(allowableValueString.trim());
      allowableValues = new AllowableListValues(toScalaList(singleVal), "LIST");
    }
    return allowableValues;
  }
View Full Code Here

              toOption(null),
              toOption(expression.getValue()),
              true,
              false,
              "string",
              new AllowableListValues(collectionAsScalaIterable(newArrayList(expression.getValue())).toList(),
                      "string"),
              "query",
              toOption("")
      );
View Full Code Here

        public AllowableValues deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {

            String currentName = jp.getCurrentName();
            if (currentName.equalsIgnoreCase("AllowableValues")) {
                if (jp.getText().isEmpty() || jp.getText().equals("{}") || jp.getText().equals("{")) {
                    return new AllowableListValues(JavaToScalaUtil.toScalaList(new ArrayList<String>()), "");
                }
            }
            return new AllowableListValues(JavaToScalaUtil.toScalaList(new ArrayList<String>()), "");
        }
View Full Code Here

    private void addApiParams(ApiParam apiParam, DocumentationParameter documentationParameter) {
        if (ModelUtils.isSet(apiParam.allowableValues())) {
            // we use only one simple string
            List<String> allowableValues = Arrays.asList(apiParam.allowableValues().split("\\s*,\\s*"));
            documentationParameter
                    .setAllowableValues(new AllowableListValues(JavaToScalaUtil.toScalaList(allowableValues), "LIST"));
        }
        documentationParameter.setAllowMultiple(apiParam.allowMultiple());

        if (ModelUtils.isSet(apiParam.defaultValue())) {
            documentationParameter.setDefaultValue(apiParam.defaultValue());
View Full Code Here

  private AllowableValues allowableValues(final Optional<String> optionalAllowable, final Field field) {

    AllowableValues allowable = null;
    if (field.getType().isEnum()) {
      allowable = new AllowableListValues(JavaConversions.collectionAsScalaIterable(
              getEnumValues(field.getType())).toList(), "LIST");
    } else if (optionalAllowable.isPresent()) {
      allowable = allowableValueFromString(optionalAllowable.get());
    }
View Full Code Here

            AllowableListValues>() {
      @Override
      public AllowableListValues apply(ApiModelProperty annotation) {
        List<String> allowableValues
                = Splitter.on(',').omitEmptyStrings().splitToList(nullToEmpty(annotation.allowableValues()));
        return new AllowableListValues(JavaConversions.collectionAsScalaIterable(allowableValues).toList(), "LIST");
      }
    };
  }
View Full Code Here


  public static AllowableValues allowableValues(ResolvedType resolvedType) {
    if (isBaseType(simpleTypeName(resolvedType)) && resolvedType.getErasedType().isEnum()) {
      List<String> enumValues = getEnumValues(resolvedType.getErasedType());
      return new AllowableListValues(JavaConversions.collectionAsScalaIterable(enumValues).toList(), "LIST");
    }
    return null;
  }
View Full Code Here

        return valueType;
    }

    @Override
    public AllowableListValues toSwaggerModel() {
        return new AllowableListValues(Utils.toScalaImmutableList(values), valueType);
    }
View Full Code Here

TOP

Related Classes of com.wordnik.swagger.model.AllowableListValues

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.