use of io.swagger.models.properties.ByteArrayProperty in project swagger-core by swagger-api.
the class ByteConverterTest method testByteProperty.
@Test
public void testByteProperty() {
Model model = new ModelImpl().property("byteProperty", new ByteArrayProperty());
assertEquals(Json.pretty(model), "{" + NEWLINE + " \"properties\" : {" + NEWLINE + " \"byteProperty\" : {" + NEWLINE + " \"type\" : \"string\"," + NEWLINE + " \"format\" : \"byte\"" + NEWLINE + " }" + NEWLINE + " }" + NEWLINE + "}");
}
use of io.swagger.models.properties.ByteArrayProperty in project swagger-core by swagger-api.
the class JsonDeserializationTest method testDeserializeConstrainedBase64StringProperty.
@Test(description = "should deserialize a base64 encoded string property with constraints")
public void testDeserializeConstrainedBase64StringProperty() throws Exception {
Swagger swagger = TestUtils.deserializeJsonFileFromClasspath("specFiles/propertiesWithConstraints.json", Swagger.class);
ByteArrayProperty property = (ByteArrayProperty) swagger.getDefinitions().get("Health").getProperties().get("string_base64_encoded");
assertEquals(property.getMinLength(), Integer.valueOf(5));
assertEquals(property.getMaxLength(), Integer.valueOf(50));
assertEquals(property.getPattern(), "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$");
assertNull(property.getEnum());
}
use of io.swagger.models.properties.ByteArrayProperty in project swagger-parser by swagger-api.
the class SwaggerParserTest method testIssue75.
@Test
public void testIssue75() {
SwaggerParser parser = new SwaggerParser();
final Swagger swagger = parser.read("src/test/resources/issue99.json");
BodyParameter param = (BodyParameter) swagger.getPaths().get("/albums").getPost().getParameters().get(0);
Model model = param.getSchema();
assertNotNull(model);
assertTrue(model instanceof ArrayModel);
ArrayModel am = (ArrayModel) model;
assertTrue(am.getItems() instanceof ByteArrayProperty);
assertEquals(am.getItems().getFormat(), "byte");
}
use of io.swagger.models.properties.ByteArrayProperty in project java-chassis by ServiceComb.
the class TestArrayType method test.
@Test
public void test() {
SwaggerOperations swaggerOperations = SwaggerOperations.generate(ArrayType.class);
SwaggerOperation swaggerOperation = swaggerOperations.findOperation("testBytes");
BodyParameter bodyParameter = (BodyParameter) swaggerOperation.getOperation().getParameters().get(0);
ModelImpl model = SwaggerUtils.getModelImpl(swaggerOperations.getSwagger(), bodyParameter);
Assert.assertEquals(ModelImpl.OBJECT, model.getType());
Assert.assertEquals(1, model.getProperties().size());
ByteArrayProperty byteArrayProperty = (ByteArrayProperty) model.getProperties().get("value");
Assert.assertEquals("string", byteArrayProperty.getType());
Assert.assertEquals("byte", byteArrayProperty.getFormat());
}
Aggregations