use of io.swagger.models.parameters.QueryParameter in project swagger-core by swagger-api.
the class ParameterProcessorTest method beanValidationMinTest.
@Test
public void beanValidationMinTest() throws NoSuchMethodException {
final Method method = getClass().getDeclaredMethod("beanValidationMin", int.class);
final Type[] genericParameterTypes = method.getGenericParameterTypes();
final Annotation[][] paramAnnotations = method.getParameterAnnotations();
final QueryParameter param = (QueryParameter) ParameterProcessor.applyAnnotations(null, new QueryParameter(), genericParameterTypes[0], Arrays.asList(paramAnnotations[0]));
assertNotNull(param);
assertEquals(param.getMinimum(), new BigDecimal(5));
}
use of io.swagger.models.parameters.QueryParameter in project swagger-core by swagger-api.
the class ParameterProcessorTest method parameterProcessorTest.
@Test(description = "parse parameters from method")
public void parameterProcessorTest() throws NoSuchMethodException {
final Method method = getClass().getDeclaredMethod("parametrizedMethod", String.class, List.class, String.class, String.class, Integer.class);
final Type[] genericParameterTypes = method.getGenericParameterTypes();
final Annotation[][] paramAnnotations = method.getParameterAnnotations();
final PathParameter p1 = (PathParameter) ParameterProcessor.applyAnnotations(null, new PathParameter(), genericParameterTypes[0], Arrays.asList(paramAnnotations[0]));
assertNotNull(p1);
assertEquals(p1.getIn(), "path");
assertEquals(p1.getName(), "paramName1");
assertEquals(p1.getDescription(), "paramValue1");
assertEquals(p1.getDefaultValue(), "value1");
assertTrue(p1.getRequired());
assertEquals(p1.getEnum(), Arrays.asList("one", "two", "three"));
assertNull(p1.getAccess());
final QueryParameter p2 = (QueryParameter) ParameterProcessor.applyAnnotations(null, new QueryParameter().items(new IntegerProperty()), genericParameterTypes[1], Arrays.asList(paramAnnotations[1]));
assertNotNull(p2);
final IntegerProperty items = (IntegerProperty) p2.getItems();
assertNotNull(items);
assertEquals(p2.getIn(), "query");
assertEquals(p2.getName(), "paramName2");
assertNull(p2.getDescription());
assertEquals((int) items.getDefault(), 10);
assertFalse(p2.getRequired());
assertEquals(p2.getAccess(), "test");
final Parameter p3 = ParameterProcessor.applyAnnotations(null, null, genericParameterTypes[2], Arrays.asList(paramAnnotations[2]));
assertNull(p3);
final Parameter p4 = ParameterProcessor.applyAnnotations(null, null, genericParameterTypes[3], Arrays.asList(paramAnnotations[3]));
assertNull(p4);
final BodyParameter p5 = (BodyParameter) ParameterProcessor.applyAnnotations(null, null, genericParameterTypes[4], Arrays.asList(paramAnnotations[4]));
assertNotNull(p5);
assertEquals(p5.getIn(), "body");
}
use of io.swagger.models.parameters.QueryParameter in project swagger-core by swagger-api.
the class ParameterProcessorTest method beanValidationPatternTest.
@Test
public void beanValidationPatternTest() throws NoSuchMethodException {
final Method method = getClass().getDeclaredMethod("beanValidationPattern", String.class);
final Type[] genericParameterTypes = method.getGenericParameterTypes();
final Annotation[][] paramAnnotations = method.getParameterAnnotations();
final QueryParameter param = (QueryParameter) ParameterProcessor.applyAnnotations(null, new QueryParameter(), genericParameterTypes[0], Arrays.asList(paramAnnotations[0]));
assertNotNull(param);
assertEquals(param.getPattern(), TEST_PATTERN_REGXP);
}
use of io.swagger.models.parameters.QueryParameter in project swagger-core by swagger-api.
the class ParameterProcessorTest method beanValidationSizeOnStringTest.
@Test
public void beanValidationSizeOnStringTest() throws NoSuchMethodException {
final Method method = getClass().getDeclaredMethod("beanValidationSizeOnString", String.class);
final Type[] genericParameterTypes = method.getGenericParameterTypes();
final Annotation[][] paramAnnotations = method.getParameterAnnotations();
final QueryParameter param = (QueryParameter) ParameterProcessor.applyAnnotations(null, new QueryParameter(), genericParameterTypes[0], Arrays.asList(paramAnnotations[0]));
assertNotNull(param);
assertEquals(param.getMinLength(), new Integer(5));
assertEquals(param.getMaxLength(), new Integer(10));
}
use of io.swagger.models.parameters.QueryParameter in project swagger-core by swagger-api.
the class GenericsTest method checkCollectionsOfEnumerations.
@Test(description = "check collections of enumerations")
public void checkCollectionsOfEnumerations() {
Operation op = getOperation("testEnumContainers");
assertEquals(op.getParameters().size(), 5);
testEnumCollection(getQueryParameter(op, 0), "set");
testEnumCollection(getQueryParameter(op, 1), "list");
testCollection(getQueryParameter(op, 2), "list2D", "string", null);
testEnumCollection(getQueryParameter(op, 3), "array");
QueryParameter scalar = getQueryParameter(op, 4);
testScalar(scalar, "scalar", "string", null);
assertEquals(scalar.getEnum(), enumValues);
}
Aggregations