private Object CreateDefaultRequestBodyExample(HttpActionDescriptor httpActionDescriptor, Type dto)
{
// Create an example DTO based off AutoFixture / ObjectHydrator conventions to be used as reference if properties aren't documented.
var exampleObject = CreateInstanceOfType(dto);
IDictionary<String, Object> requestBodyExample = new ExpandoObject();
foreach (var dtoProperty in dto.GetProperties())
{
if (!TypeHelper.CanConvertFromString(dtoProperty.PropertyType) &&
_WebApiDocumentationMetadata.DtoDocumentation.ContainsKey(dtoProperty.PropertyType))
{
requestBodyExample[dtoProperty.Name] =
CreateRequestBodyExample(httpActionDescriptor, _WebApiDocumentationMetadata.DtoDocumentation[dtoProperty.PropertyType]);
}
else
{
if (_WebApiDocumentationMetadata.Settings
.RequestBuilderConventions
.Any(c => !c.IncludeProperty(httpActionDescriptor.SupportedHttpMethods, dtoProperty, dto)))
{
continue;
}
requestBodyExample[dtoProperty.Name] = dtoProperty.GetValue(exampleObject, BindingFlags.Instance | BindingFlags.Public, null, null, CultureInfo.CurrentCulture);
}
}
return requestBodyExample;
}