use of io.swagger.v3.oas.models.parameters.Parameter 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.Parameter 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.Parameter in project swagger-core by swagger-api.
the class ParameterSerializationTest method serializeEnumPathParameter.
@Test(description = "it should serialize a path parameter with enum")
public void serializeEnumPathParameter() {
List<String> values = new ArrayList<>();
values.add("a");
values.add("b");
values.add("c");
Parameter p = new PathParameter().schema(new StringSchema()._enum(values));
final String json = "{" + " \"in\":\"path\"," + " \"required\":true," + " \"schema\":{" + " \"type\":\"string\"," + " \"enum\":[\"a\",\"b\",\"c\"]" + " }" + "}";
SerializationMatchers.assertEqualsToJson(p, json);
}
use of io.swagger.v3.oas.models.parameters.Parameter 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.Parameter in project swagger-core by swagger-api.
the class ParameterSerializationTest method serializeStringArrayPathParameter.
@Test(description = "it should serialize a PathParameter with string array")
public void serializeStringArrayPathParameter() {
Parameter p = new PathParameter().schema(new ArraySchema().items(new StringSchema()));
final String json = "{\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}}";
SerializationMatchers.assertEqualsToJson(p, json);
final String yaml = "---\n" + "in: \"path\"\n" + "required: true\n" + "schema:\n" + " type: \"array\"\n" + " items:\n" + " type: \"string\"";
SerializationMatchers.assertEqualsToYaml(p, yaml);
}
Aggregations