use of io.swagger.v3.oas.models.media.ArraySchema in project swagger-core by swagger-api.
the class ParameterSerializationTest method serializeStringArrayHeaderParameter.
@Test(description = "it should serialize a string array HeaderParameter")
public void serializeStringArrayHeaderParameter() {
final Parameter p = new HeaderParameter().schema(new ArraySchema().items(new StringSchema()));
final String json = "{\"in\":\"header\",\"schema\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}}";
SerializationMatchers.assertEqualsToJson(p, json);
}
use of io.swagger.v3.oas.models.media.ArraySchema in project swagger-core by swagger-api.
the class ReaderTest method test2497.
@Test(description = "test resource with array in response content")
public void test2497() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(ResponseContentWithArrayResource.class);
Paths paths = openAPI.getPaths();
assertEquals(paths.size(), 1);
PathItem pathItem = paths.get("/user");
assertNotNull(pathItem);
Operation operation = pathItem.getGet();
assertNotNull(operation);
ArraySchema schema = (ArraySchema) operation.getResponses().get("200").getContent().values().iterator().next().getSchema();
assertNotNull(schema);
assertEquals(schema.getItems().get$ref(), "#/components/schemas/User");
assertEquals(openAPI.getComponents().getSchemas().get("User").getRequired().get(0), "issue3438");
}
use of io.swagger.v3.oas.models.media.ArraySchema in project swagger-core by swagger-api.
the class JsonPropertiesDeserializationTest method shouldDeserializeArrayPropertyMinItems.
@Test
public void shouldDeserializeArrayPropertyMinItems() throws Exception {
String path = "json-schema-validation/array.json";
ArraySchema property = (ArraySchema) TestUtils.deserializeJsonFileFromClasspath(path, Schema.class);
assertNotNull(property.getMinItems());
assertEquals(property.getMinItems().intValue(), 1);
}
use of io.swagger.v3.oas.models.media.ArraySchema in project swagger-core by swagger-api.
the class ParameterDeSerializationTest method deserializeEnumPathParameter.
@Test(description = "it should deserialize a path parameter with enum")
public void deserializeEnumPathParameter() throws IOException {
final String json = "{" + " \"in\":\"path\"," + " \"required\":true," + " \"schema\":{" + " \"type\":\"array\"," + " \"items\":{" + " \"type\":\"string\"," + " \"enum\":[\"a\",\"b\",\"c\"]" + " }" + "}}";
final Parameter p = m.readValue(json, Parameter.class);
SerializationMatchers.assertEqualsToJson(p, json);
ArraySchema as = (ArraySchema) p.getSchema();
assertEquals(((StringSchema) as.getItems()).getEnum(), Arrays.asList("a", "b", "c"));
}
use of io.swagger.v3.oas.models.media.ArraySchema in project swagger-core by swagger-api.
the class ArrayPropertyDeserializerTest method testArrayDeserialization.
@Test(description = "it should includes the example in the arrayproperty")
public void testArrayDeserialization() throws Exception {
Operation operation = Yaml.mapper().readValue(yaml, Operation.class);
ApiResponse response = operation.getResponses().get("200");
assertNotNull(response);
MediaType media = response.getContent().get("*/*");
Schema responseSchema = media.getSchema();
assertTrue(media.getExamples().size() == 2);
assertNotNull(responseSchema);
assertTrue(responseSchema instanceof ArraySchema);
ArraySchema mp = (ArraySchema) responseSchema;
assertEquals(mp.getMinItems(), new Integer(3));
assertEquals(mp.getMaxItems(), new Integer(100));
}
Aggregations