use of io.vertigo.dynamo.domain.metamodel.DtDefinition in project vertigo by KleeGroup.
the class SwaggerApiBuilder method appendPropertiesDtObject.
private void appendPropertiesDtObject(final Map<String, Object> entity, final Class<? extends DtObject> objectClass) {
// can't be a primitive nor array nor DtListDelta
final Map<String, Object> properties = new LinkedHashMap<>();
// mandatory fields
final List<String> required = new ArrayList<>();
final DtDefinition dtDefinition = DtObjectUtil.findDtDefinition(objectClass);
for (final DtField dtField : dtDefinition.getFields()) {
final String fieldName = StringUtil.constToLowerCamelCase(dtField.getName());
final Type fieldType = getFieldType(dtField);
// not Nullable
final Map<String, Object> fieldSchema = createSchemaObject(fieldType);
fieldSchema.put("title", dtField.getLabel().getDisplay());
if (dtField.isRequired()) {
required.add(fieldName);
}
// could add enum on field to specify all values authorized
properties.put(fieldName, fieldSchema);
}
putIfNotEmpty(entity, REQUIRED, required);
putIfNotEmpty(entity, "properties", properties);
}
Aggregations