use of io.swagger.v3.oas.models.media.ArraySchema 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.ArraySchema 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.ArraySchema in project swagger-core by swagger-api.
the class ParameterSerializationTest method serializeIntegerArrayPathParameter.
@Test(description = "it should serialize a PathParameter with integer array")
public void serializeIntegerArrayPathParameter() {
final Parameter p = new PathParameter().schema(new ArraySchema().items(new IntegerSchema()));
final String json = "{\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"array\",\"items\":{\"type\":\"integer\",\"format\":\"int32\"}}}\n";
SerializationMatchers.assertEqualsToJson(p, json);
}
use of io.swagger.v3.oas.models.media.ArraySchema in project swagger-core by swagger-api.
the class ReaderTest method testResourceWithSubresources.
@Test(description = "test resource with subresources")
public void testResourceWithSubresources() {
Reader reader = new Reader(new OpenAPI());
OpenAPI openAPI = reader.read(ResourceWithSubResource.class);
Paths paths = openAPI.getPaths();
assertEquals(paths.size(), 3);
PathItem pathItem = paths.get("/employees/{id}");
assertNotNull(pathItem);
Operation operation = pathItem.getGet();
assertNotNull(operation);
ArraySchema arraySchema = (ArraySchema) operation.getResponses().get("200").getContent().values().iterator().next().getSchema();
assertNotNull(arraySchema);
assertEquals(arraySchema.getItems().get$ref(), "#/components/schemas/Pet");
pathItem = paths.get("/employees/{id}/{id}");
assertNotNull(pathItem);
operation = pathItem.getGet();
assertNotNull(operation);
Schema schema = operation.getResponses().get("200").getContent().values().iterator().next().getSchema();
assertNotNull(schema);
assertEquals(schema.get$ref(), "#/components/schemas/Pet");
pathItem = paths.get("/employees/noPath");
assertNotNull(pathItem);
operation = pathItem.getGet();
assertNotNull(operation);
schema = operation.getResponses().getDefault().getContent().values().iterator().next().getSchema();
assertNotNull(schema);
assertEquals(schema.getType(), "string");
}
Aggregations