use of io.swagger.v3.oas.annotations.media.ArraySchema in project swagger-core by swagger-api.
the class ModelSerializerTest method deserializeArrayModel.
@Test(description = "it should deserialize an array model")
public void deserializeArrayModel() throws IOException {
final String json = "{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/Pet\"}}";
final Schema p = m.readValue(json, Schema.class);
assertTrue(p instanceof ArraySchema);
assertEquals(m.writeValueAsString(p), json);
}
use of io.swagger.v3.oas.annotations.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.annotations.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.annotations.media.ArraySchema in project hippo by NHS-digital-website.
the class BorderHelperTest method lastChildModels.
@DataProvider
public static Object[][] lastChildModels() {
final String expectedBorder = getBorder(SchemaBorder.HORIZONTAL, 1, 0) + getBorder(SchemaBorder.SHORT_VERTICAL, 1, 0);
final Schema currentModel = new Schema();
return new Object[][] { // "properties" child
{ currentModel, new Schema().properties(ImmutableMap.of("child", currentModel)), expectedBorder }, // "allOf" child
{ currentModel, new ComposedSchema().allOf(new ArrayList<>(asList(currentModel))), expectedBorder }, // "anyOf" child
{ currentModel, new ComposedSchema().anyOf(new ArrayList<>(asList(currentModel))), expectedBorder }, // "oneOf" child
{ currentModel, new ComposedSchema().oneOf(new ArrayList<>(asList(currentModel))), expectedBorder }, // "array" -> "items" child
{ currentModel, new ArraySchema().items(currentModel), expectedBorder } };
}
use of io.swagger.v3.oas.annotations.media.ArraySchema in project hippo by NHS-digital-website.
the class SchemaHelperTest method schemaWithXOfPropertyUnderItemsObject.
private Schema<?> schemaWithXOfPropertyUnderItemsObject(final String propertyName) {
final ComposedSchema items = new ComposedSchema();
items.title("items object");
setField(items, propertyName, new ArrayList<>(asList(new ObjectSchema().title(propertyName + " - A"), new ObjectSchema().title(propertyName + " - B"))));
return new ObjectSchema().title("root object").properties(ImmutableMap.of("array-schema", new ArraySchema().items(items)));
}
Aggregations