use of io.swagger.models.Model in project swagger-core by swagger-api.
the class ByteConverterTest method testDeserializeByteProperty.
@Test
public void testDeserializeByteProperty() throws Exception {
String json = "{\n" + " \"properties\" : {\n" + " \"byteProperty\" : {\n" + " \"type\" : \"string\",\n" + " \"format\" : \"byte\"\n" + " }\n" + " }\n" + "}";
Model model = Json.mapper().readValue(json, Model.class);
assertNotNull(model);
}
use of io.swagger.models.Model 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.Model in project swagger-core by swagger-api.
the class ModelConverterTest method scanModelWithNumbers.
@Test(description = "it should scan a model with numbers")
public void scanModelWithNumbers() throws IOException {
final Map<String, Model> models = readAll(ModelWithNumbers.class);
assertEquals(models.size(), 1);
final Model model = models.get("ModelWithNumbers");
// Check if we get required properties after building models from classes.
checkModel(model);
// Check if we get required properties after deserialization from JSON
checkModel(Json.mapper().readValue(Json.pretty(model), Model.class));
}
use of io.swagger.models.Model in project swagger-core by swagger-api.
the class RequiredFieldModelTest method testApiModelPropertyFirstPosition.
@Test(description = "it should apply read only flag when ApiProperty annotation first")
public void testApiModelPropertyFirstPosition() {
final Map<String, Model> models = ModelConverters.getInstance().readAll(ApiFirstRequiredFieldModel.class);
final Model model = models.get("aaa");
final Property prop = model.getProperties().get("a");
assertTrue(prop.getRequired());
}
use of io.swagger.models.Model in project swagger-core by swagger-api.
the class RequiredFieldModelTest method testApiModelPropertySecondPosition.
@Test(description = "it should apply read only flag when XmlElement annotation first")
public void testApiModelPropertySecondPosition() {
final Map<String, Model> models = ModelConverters.getInstance().readAll(XmlFirstRequiredFieldModel.class);
final Model model = models.get("aaa");
final Property prop = model.getProperties().get("a");
assertTrue(prop.getRequired());
}
Aggregations