use of io.swagger.models.parameters.QueryParameter in project swagger-core by swagger-api.
the class ParameterSerializationTest method testReadOnlyParameter.
@Test(description = "should mark a parameter as readOnly")
public void testReadOnlyParameter() throws Exception {
final QueryParameter qp = new QueryParameter().readOnly(true);
final String json = "{\"in\":\"query\",\"required\":false,\"readOnly\":true}";
SerializationMatchers.assertEqualsToJson(qp, json);
}
use of io.swagger.models.parameters.QueryParameter in project swagger-core by swagger-api.
the class ParameterSerializationTest method deserializeQueryParameter.
@Test(description = "it should deserialize a QueryParameter")
public void deserializeQueryParameter() throws IOException {
final String json = "{\"in\":\"query\",\"required\":false,\"type\":\"string\"}";
final Parameter p = m.readValue(json, Parameter.class);
SerializationMatchers.assertEqualsToJson(p, json);
}
use of io.swagger.models.parameters.QueryParameter in project swagger-core by swagger-api.
the class ParameterProcessorTest method beanValidationSizeOnNumberTest.
@Test
public void beanValidationSizeOnNumberTest() throws NoSuchMethodException {
final Method method = getClass().getDeclaredMethod("beanValidationSizeOnNumber", int.class, short.class, long.class, float.class, double.class, Integer.class, Short.class, Long.class, Float.class, Double.class, BigInteger.class, BigDecimal.class);
final Type[] genericParameterTypes = method.getGenericParameterTypes();
final Annotation[][] paramAnnotations = method.getParameterAnnotations();
for (int i = 0; i < 12; i++) {
final QueryParameter param = (QueryParameter) ParameterProcessor.applyAnnotations(null, new QueryParameter(), genericParameterTypes[i], Arrays.asList(paramAnnotations[i]));
assertNotNull(param);
assertEquals(param.getMinimum(), new BigDecimal(5));
assertEquals(param.getMaximum(), new BigDecimal(10));
}
}
use of io.swagger.models.parameters.QueryParameter in project swagger-core by swagger-api.
the class ParameterProcessorTest method beanValidationDecimalMaxTest.
@Test
public void beanValidationDecimalMaxTest() throws NoSuchMethodException {
final Method method = getClass().getDeclaredMethod("beanValidationDecimalMax", double.class, double.class);
final Type[] genericParameterTypes = method.getGenericParameterTypes();
final Annotation[][] paramAnnotations = method.getParameterAnnotations();
final QueryParameter inclusiveParam = (QueryParameter) ParameterProcessor.applyAnnotations(null, new QueryParameter(), genericParameterTypes[0], Arrays.asList(paramAnnotations[0]));
assertNotNull(inclusiveParam);
assertEquals(inclusiveParam.getMaximum(), new BigDecimal(10.5));
assertNull(inclusiveParam.isExclusiveMaximum());
final QueryParameter exclusiveParam = (QueryParameter) ParameterProcessor.applyAnnotations(null, new QueryParameter(), genericParameterTypes[1], Arrays.asList(paramAnnotations[1]));
assertNotNull(exclusiveParam);
assertEquals(exclusiveParam.getMaximum(), new BigDecimal(10.5));
assertTrue(exclusiveParam.isExclusiveMaximum());
}
use of io.swagger.models.parameters.QueryParameter in project swagger-core by swagger-api.
the class ParameterProcessorTest method beanValidationMaxTest.
@Test
public void beanValidationMaxTest() throws NoSuchMethodException {
final Method method = getClass().getDeclaredMethod("beanValidationMax", 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.getMaximum(), new BigDecimal(10));
}
Aggregations