use of io.swagger.v3.oas.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 Parameter qp = new QueryParameter().allowEmptyValue(true);
final String json = "{\"in\":\"query\",\"allowEmptyValue\":true}";
SerializationMatchers.assertEqualsToJson(qp, json);
}
use of io.swagger.v3.oas.models.parameters.QueryParameter in project swagger-core by swagger-api.
the class ParameterSerializationTest method testDoubleValue.
@Test(description = "should serialize double value")
public void testDoubleValue() {
final QueryParameter param = new QueryParameter();
param.setSchema(new NumberSchema()._default(new BigDecimal("12.34")).format("double"));
final String json = "{\"in\":\"query\",\"schema\":{\"type\":\"number\",\"format\":\"double\",\"default\":12.34}}";
SerializationMatchers.assertEqualsToJson(param, json);
}
use of io.swagger.v3.oas.models.parameters.QueryParameter in project swagger-core by swagger-api.
the class ParameterSerializationTest method serializeQueryParameter.
@Test(description = "it should serialize a QueryParameter")
public void serializeQueryParameter() {
final Parameter p = new QueryParameter().schema(new StringSchema());
final String json = "{\"in\":\"query\",\"schema\":{\"type\":\"string\"}}";
SerializationMatchers.assertEqualsToJson(p, json);
}
use of io.swagger.v3.oas.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 Parameter p = new QueryParameter().schema(new ArraySchema().items(new StringSchema()));
final String json = "{" + " \"in\":\"query\"," + " \"schema\":{" + " \"type\":\"array\"," + " \"items\":{" + " \"type\":\"string\"" + " }}" + "}";
SerializationMatchers.assertEqualsToJson(p, json);
}
use of io.swagger.v3.oas.models.parameters.QueryParameter in project swagger-core by swagger-api.
the class ParameterSerializationTest method testIncorrectBoolean.
@Test(description = "should serialize incorrect boolean value as string")
public void testIncorrectBoolean() {
final QueryParameter param = (QueryParameter) new QueryParameter().required(false);
Schema schema = new Schema().type("boolean");
schema.setDefault("test");
param.setSchema(schema);
final String json = "{" + " \"in\":\"query\"," + " \"required\":false," + " \"schema\":{" + " \"type\":\"boolean\"," + " \"default\":\"test\"" + " }" + "}";
SerializationMatchers.assertEqualsToJson(param, json);
}
Aggregations