Search in sources :

Example 51 with QueryParameter

use of io.swagger.models.parameters.QueryParameter in project swagger-core by swagger-api.

the class ParameterSerializationTest method serializeArrayQueryParameter.

@Test(description = "it should serialize a QueryParameter with array")
public void serializeArrayQueryParameter() {
    final QueryParameter p = new QueryParameter().type(ArrayProperty.TYPE).items(new StringProperty()).collectionFormat("multi");
    final String json = "{" + "   \"in\":\"query\"," + "   \"required\":false," + "   \"type\":\"array\"," + "   \"items\":{" + "      \"type\":\"string\"" + "   }," + "   \"collectionFormat\":\"multi\"" + "}";
    SerializationMatchers.assertEqualsToJson(p, json);
}
Also used : QueryParameter(io.swagger.models.parameters.QueryParameter) StringProperty(io.swagger.models.properties.StringProperty) Test(org.testng.annotations.Test)

Example 52 with QueryParameter

use of io.swagger.models.parameters.QueryParameter in project swagger-core by swagger-api.

the class ParameterSerializationTest method testLongValue.

@Test(description = "should serialize long value")
public void testLongValue() {
    final QueryParameter param = new QueryParameter();
    param.setDefaultValue("1234");
    param.setType("integer");
    param.setFormat("1nt64");
    final String json = "{\"in\":\"query\",\"required\":false,\"type\":\"integer\",\"default\":1234,\"format\":\"1nt64\"}";
    SerializationMatchers.assertEqualsToJson(param, json);
}
Also used : QueryParameter(io.swagger.models.parameters.QueryParameter) Test(org.testng.annotations.Test)

Example 53 with QueryParameter

use of io.swagger.models.parameters.QueryParameter in project swagger-core by swagger-api.

the class ParameterSerializationTest method testFloatValue.

@Test(description = "should serialize double value")
public void testFloatValue() {
    final QueryParameter param = new QueryParameter();
    param.setDefaultValue("12.34");
    param.setType("number");
    param.setFormat("float");
    final String json = "{\"in\":\"query\",\"required\":false,\"type\":\"number\",\"default\":12.34,\"format\":\"float\"}";
    SerializationMatchers.assertEqualsToJson(param, json);
}
Also used : QueryParameter(io.swagger.models.parameters.QueryParameter) Test(org.testng.annotations.Test)

Example 54 with QueryParameter

use of io.swagger.models.parameters.QueryParameter in project swagger-core by swagger-api.

the class ParameterSerializationTest method testAllowEmptyValueParameter.

@Test(description = "should mark a parameter as to allow empty value")
public void testAllowEmptyValueParameter() throws Exception {
    final QueryParameter qp = new QueryParameter().allowEmptyValue(true);
    final String json = "{\"in\":\"query\",\"required\":false,\"allowEmptyValue\":true}";
    SerializationMatchers.assertEqualsToJson(qp, json);
}
Also used : QueryParameter(io.swagger.models.parameters.QueryParameter) Test(org.testng.annotations.Test)

Example 55 with QueryParameter

use of io.swagger.models.parameters.QueryParameter in project swagger-core by swagger-api.

the class SimpleReaderTest method scanClassWithExampleClassQuery.

@Test(description = "scan a resource with query param example (dataTypeClass)")
public void scanClassWithExampleClassQuery() {
    Swagger swagger = getSwagger(ClassWithExamplePostClass.class);
    Parameter param = swagger.getPaths().get("/external/info").getGet().getParameters().get(0);
    QueryParameter bp = (QueryParameter) param;
    assertNotNull(bp.getExample());
    Object value = bp.getExample();
    assertEquals("a,b,c", value);
}
Also used : QueryParameter(io.swagger.models.parameters.QueryParameter) Swagger(io.swagger.models.Swagger) SerializableParameter(io.swagger.models.parameters.SerializableParameter) PathParameter(io.swagger.models.parameters.PathParameter) Parameter(io.swagger.models.parameters.Parameter) QueryParameter(io.swagger.models.parameters.QueryParameter) BodyParameter(io.swagger.models.parameters.BodyParameter) Test(org.testng.annotations.Test)

Aggregations

QueryParameter (io.swagger.models.parameters.QueryParameter)92 Test (org.testng.annotations.Test)58 Parameter (io.swagger.models.parameters.Parameter)42 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 Test (org.junit.Test)12 Operation (io.swagger.models.Operation)11 FormParameter (io.swagger.models.parameters.FormParameter)11 SerializableParameter (io.swagger.models.parameters.SerializableParameter)10 StringProperty (io.swagger.models.properties.StringProperty)10 HashMap (java.util.HashMap)10 Path (io.swagger.models.Path)9 RefModel (io.swagger.models.RefModel)9 Type (java.lang.reflect.Type)9 BigDecimal (java.math.BigDecimal)9 RefProperty (io.swagger.models.properties.RefProperty)8 Response (io.swagger.models.Response)7 Method (java.lang.reflect.Method)7