use of io.swagger.models.properties.Property in project swagger-core by swagger-api.
the class HiddenFieldTest method testHiddenField.
@Test(description = "it should ignore a hidden field")
public void testHiddenField() {
final Map<String, Model> models = ModelConverters.getInstance().read(ModelWithHiddenFields.class);
final Model model = models.get("ModelWithHiddenFields");
assertNotNull(model);
assertEquals(model.getProperties().size(), 2);
final Property idValue = model.getProperties().get("id");
assertTrue(idValue instanceof LongProperty);
assertTrue(idValue.getRequired());
final Property nameValue = model.getProperties().get("name");
assertTrue(nameValue instanceof StringProperty);
}
use of io.swagger.models.properties.Property in project swagger-core by swagger-api.
the class JodaDateTimeConverterTest method testJodaDateTime.
@Test
public void testJodaDateTime() {
final Map<String, Model> models = ModelConverters.getInstance().read(ModelWithJodaDateTime.class);
// don't create a Joda DateTime object
assertEquals(models.size(), 1);
final Model model = models.get("ModelWithJodaDateTime");
final Property dateTimeProperty = model.getProperties().get("createdAt");
assertTrue(dateTimeProperty instanceof DateTimeProperty);
assertEquals((int) dateTimeProperty.getPosition(), 1);
assertTrue(dateTimeProperty.getRequired());
assertEquals(dateTimeProperty.getDescription(), "creation timestamp");
final Property nameProperty = model.getProperties().get("name");
assertTrue(nameProperty instanceof StringProperty);
assertEquals((int) nameProperty.getPosition(), 2);
assertEquals(nameProperty.getDescription(), "name of the model");
}
use of io.swagger.models.properties.Property in project swagger-core by swagger-api.
the class JodaLocalDateConverterTest method testJodaLocalDate.
@Test
public void testJodaLocalDate() {
final Map<String, Model> models = ModelConverters.getInstance().read(ModelWithJodaLocalDate.class);
assertEquals(models.size(), 1);
final Model model = models.get("ModelWithJodaLocalDate");
final Property dateTimeProperty = model.getProperties().get("createdAt");
assertTrue(dateTimeProperty instanceof DateProperty);
assertEquals((int) dateTimeProperty.getPosition(), 1);
assertTrue(dateTimeProperty.getRequired());
assertEquals(dateTimeProperty.getDescription(), "creation localDate");
final Property nameProperty = model.getProperties().get("name");
assertTrue(nameProperty instanceof StringProperty);
assertEquals((int) nameProperty.getPosition(), 2);
assertEquals(nameProperty.getDescription(), "name of the model");
}
use of io.swagger.models.properties.Property in project swagger-core by swagger-api.
the class SpecFilter method locateReferencedDefinitions.
private void locateReferencedDefinitions(Map<String, Property> props, Set<String> nestedReferencedDefinitions, Swagger swagger) {
if (props == null)
return;
for (String keyProp : props.keySet()) {
Property p = props.get(keyProp);
String ref = getPropertyRef(p);
if (ref != null) {
locateReferencedDefinitions(ref, nestedReferencedDefinitions, swagger);
}
}
}
use of io.swagger.models.properties.Property in project swagger-core by swagger-api.
the class ServletReaderExtension method parseResponseHeaders.
private static Map<String, Property> parseResponseHeaders(ReaderContext context, ResponseHeader[] headers) {
Map<String, Property> responseHeaders = null;
for (ResponseHeader header : headers) {
final String name = header.name();
if (StringUtils.isNotEmpty(name)) {
if (responseHeaders == null) {
responseHeaders = new HashMap<String, Property>();
}
final Class<?> cls = header.response();
if (!ReflectionUtils.isVoid(cls)) {
final Property property = ModelConverters.getInstance().readAsProperty(cls);
if (property != null) {
final Property responseProperty = ContainerWrapper.wrapContainer(header.responseContainer(), property, ContainerWrapper.ARRAY, ContainerWrapper.LIST, ContainerWrapper.SET);
responseProperty.setDescription(header.description());
responseHeaders.put(name, responseProperty);
appendModels(context.getSwagger(), cls);
}
}
}
}
return responseHeaders;
}
Aggregations