use of io.swagger.v3.oas.models.media.DateSchema in project swagger-core by swagger-api.
the class JodaLocalDateConverterTest method testJodaLocalDate.
@Test
public void testJodaLocalDate() {
final Map<String, Schema> models = ModelConverters.getInstance().read(ModelWithJodaLocalDate.class);
assertEquals(models.size(), 1);
final Schema model = models.get("ModelWithJodaLocalDate");
final Schema dateTimeProperty = (Schema) model.getProperties().get("createdAt");
assertTrue(dateTimeProperty instanceof DateSchema);
assertTrue(model.getRequired().contains("createdAt"));
assertEquals(dateTimeProperty.getDescription(), "creation localDate");
final Schema nameProperty = (Schema) model.getProperties().get("name");
assertTrue(nameProperty instanceof StringSchema);
assertEquals(nameProperty.getDescription(), "name of the model");
}
use of io.swagger.v3.oas.models.media.DateSchema in project swagger-core by swagger-api.
the class PropertySerializationTest method serializeDateProperty.
@Test(description = "it should serialize a DateProperty")
public void serializeDateProperty() throws IOException {
final DateSchema p = new DateSchema();
final String json = "{\"type\":\"string\",\"format\":\"date\"}";
assertEquals(m.writeValueAsString(p), json);
}
use of io.swagger.v3.oas.models.media.DateSchema in project swagger-core by swagger-api.
the class ModelSerializerTest method convertModel.
@Test(description = "it should convert a model")
public void convertModel() throws JsonProcessingException {
final Schema pet = new Schema();
final Map<String, Schema> props = new LinkedHashMap<String, Schema>();
props.put("intValue", new IntegerSchema());
props.put("longValue", new IntegerSchema().format("int64"));
props.put("dateValue", new DateSchema());
props.put("dateTimeValue", new DateTimeSchema());
pet.setProperties(props);
pet.setRequired(Arrays.asList("intValue", "name"));
final String json = "{\n" + " \"required\":[\n" + " \"intValue\"\n" + " ],\n" + " \"properties\":{\n" + " \"intValue\":{\n" + " \"type\":\"integer\",\n" + " \"format\":\"int32\"\n" + " },\n" + " \"longValue\":{\n" + " \"type\":\"integer\",\n" + " \"format\":\"int64\"\n" + " },\n" + " \"dateValue\":{\n" + " \"type\":\"string\",\n" + " \"format\":\"date\"\n" + " },\n" + " \"dateTimeValue\":{\n" + " \"type\":\"string\",\n" + " \"format\":\"date-time\"\n" + " }\n" + " }\n" + "}";
SerializationMatchers.assertEqualsToJson(pet, json);
}
Aggregations