use of io.swagger.models.ModelImpl in project swagger-core by swagger-api.
the class ByteConverterTest method testByteArray.
@Test
public void testByteArray() {
Model model = new ModelImpl().property("byteArray", new ArrayProperty(new BinaryProperty()));
assertEquals(Json.pretty(model), "{" + NEWLINE + " \"properties\" : {" + NEWLINE + " \"byteArray\" : {" + NEWLINE + " \"type\" : \"array\"," + NEWLINE + " \"items\" : {" + NEWLINE + " \"type\" : \"string\"," + NEWLINE + " \"format\" : \"binary\"" + NEWLINE + " }" + NEWLINE + " }" + NEWLINE + " }" + NEWLINE + "}");
}
use of io.swagger.models.ModelImpl in project swagger-core by swagger-api.
the class ModelSerializerTest method deserializeModelWithReadOnlyProperty.
@Test(description = "it should deserialize a model with read-only property")
public void deserializeModelWithReadOnlyProperty() throws IOException {
final String json = "{\n" + " \"properties\":{\n" + " \"id\":{\n" + " \"type\":\"integer\",\n" + " \"format\":\"int32\",\n" + " \"readOnly\":true\n" + " }\n" + " }\n" + "}";
final ModelImpl model = Json.mapper().readValue(json, ModelImpl.class);
Property property = model.getProperties().get("id");
assertTrue(property.getReadOnly());
}
use of io.swagger.models.ModelImpl in project swagger-core by swagger-api.
the class ModelSerializerTest method testIssue1852.
@Test
public void testIssue1852() throws Exception {
String json = "{\n" + " \"type\": \"integer\",\n" + " \"minimum\": 10,\n" + " \"maximum\": 20,\n" + " \"default\": 15\n" + "}";
final ModelImpl model = Json.mapper().readValue(json, ModelImpl.class);
assertEquals(model.getMinimum().intValue(), 10);
assertEquals(model.getMaximum().intValue(), 20);
assertEquals(model.getDefaultValue(), 15);
}
use of io.swagger.models.ModelImpl in project swagger-core by swagger-api.
the class ModelSerializerTest method testIssue2064Ip.
@Test
public void testIssue2064Ip() throws Exception {
String json = "{\n" + " \"type\": \"object\",\n" + " \"properties\": {\n" + " \"id\": {\n" + " \"type\": \"integer\",\n" + " \"format\": \"int32\",\n" + " \"multipleOf\": 3.0\n" + " }\n" + " }\n" + "}";
final ModelImpl model = Json.mapper().readValue(json, ModelImpl.class);
IntegerProperty ip = (IntegerProperty) model.getProperties().get("id");
assertEquals(ip.getMultipleOf(), new BigDecimal("3.0"));
}
use of io.swagger.models.ModelImpl in project swagger-core by swagger-api.
the class XMLInfoTest method testSimple.
@Test
public void testSimple() throws Exception {
final ModelConverter mr = modelResolver();
final Model model = mr.resolve(XmlDecoratedBean.class, new ModelConverterContextImpl(mr), null);
assertTrue(model instanceof ModelImpl);
final ModelImpl impl = (ModelImpl) model;
final Xml xml = impl.getXml();
assertNotNull(xml);
assertEquals(xml.getName(), "xmlDecoratedBean");
// Cast it to an array property
final ArrayProperty property = (ArrayProperty) impl.getProperties().get("elements");
assertNotNull(property);
final Xml propertyXml = property.getXml();
assertNotNull(propertyXml);
assertNull(propertyXml.getName());
assertTrue(propertyXml.getWrapped());
// Get the xml for items for the array property
final Xml itemsXml = property.getItems().getXml();
assertNotNull(itemsXml);
// Check the name of item name
assertEquals(itemsXml.getName(), "element");
assertNotNull(impl.getProperties().get("elementC"));
}
Aggregations