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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations