use of io.swagger.v3.oas.models.media.StringSchema 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.media.StringSchema 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.media.StringSchema 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);
}
use of io.swagger.v3.oas.models.media.StringSchema in project swagger-core by swagger-api.
the class ParameterSerializationTest method serializeBodyParameter.
@Test(description = "it should serialize a BodyParameter")
public void serializeBodyParameter() {
final Schema model = new Schema().title("Cat").addProperties("name", new StringSchema());
final RequestBody p = new RequestBody().content(new Content().addMediaType("*/*", new MediaType().schema(model)));
final String json = "{\"content\":{\"*/*\":{\"schema\":{\"title\":\"Cat\",\"properties\":{\"name\":{\"type\":\"string\"}}}}}}";
SerializationMatchers.assertEqualsToJson(p, json);
}
use of io.swagger.v3.oas.models.media.StringSchema in project swagger-core by swagger-api.
the class ModelSerializerTest method testEnumParser.
@Test(description = "it retains enums per ")
public void testEnumParser() throws IOException {
String json = "{\n" + " \"properties\": {\n" + " \"AdvStateType\": {\n" + " \"description\": \"Advertising State\",\n" + " \"enum\": [\n" + " \"off\",\n" + " \"on\"\n" + " ],\n" + " \"type\": \"string\"\n" + " }\n" + " }\n" + "}";
final Schema model = Json.mapper().readValue(json, Schema.class);
StringSchema p = (StringSchema) model.getProperties().get("AdvStateType");
assertNotNull(p.getEnum());
assertEquals(p.getEnum().get(0), "off");
assertEquals(p.getEnum().get(1), "on");
}
Aggregations