Search in sources :

Example 11 with QueryParameter

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);
}
Also used : QueryParameter(io.swagger.models.parameters.QueryParameter) Test(org.testng.annotations.Test)

Example 12 with QueryParameter

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);
}
Also used : BodyParameter(io.swagger.models.parameters.BodyParameter) PathParameter(io.swagger.models.parameters.PathParameter) Parameter(io.swagger.models.parameters.Parameter) QueryParameter(io.swagger.models.parameters.QueryParameter) HeaderParameter(io.swagger.models.parameters.HeaderParameter) Test(org.testng.annotations.Test)

Example 13 with QueryParameter

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));
    }
}
Also used : Type(java.lang.reflect.Type) QueryParameter(io.swagger.models.parameters.QueryParameter) Method(java.lang.reflect.Method) BigDecimal(java.math.BigDecimal) Test(org.testng.annotations.Test)

Example 14 with QueryParameter

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());
}
Also used : Type(java.lang.reflect.Type) QueryParameter(io.swagger.models.parameters.QueryParameter) Method(java.lang.reflect.Method) BigDecimal(java.math.BigDecimal) Test(org.testng.annotations.Test)

Example 15 with QueryParameter

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));
}
Also used : Type(java.lang.reflect.Type) QueryParameter(io.swagger.models.parameters.QueryParameter) Method(java.lang.reflect.Method) BigDecimal(java.math.BigDecimal) Test(org.testng.annotations.Test)

Aggregations

QueryParameter (io.swagger.models.parameters.QueryParameter)88 Test (org.testng.annotations.Test)58 Parameter (io.swagger.models.parameters.Parameter)41 PathParameter (io.swagger.models.parameters.PathParameter)34 BodyParameter (io.swagger.models.parameters.BodyParameter)28 Swagger (io.swagger.models.Swagger)25 HeaderParameter (io.swagger.models.parameters.HeaderParameter)15 Operation (io.swagger.models.Operation)11 FormParameter (io.swagger.models.parameters.FormParameter)11 Test (org.junit.Test)11 SerializableParameter (io.swagger.models.parameters.SerializableParameter)10 StringProperty (io.swagger.models.properties.StringProperty)10 Path (io.swagger.models.Path)9 RefModel (io.swagger.models.RefModel)9 Type (java.lang.reflect.Type)9 BigDecimal (java.math.BigDecimal)9 HashMap (java.util.HashMap)9 RefProperty (io.swagger.models.properties.RefProperty)8 Response (io.swagger.models.Response)7 Method (java.lang.reflect.Method)7