Exemple #1
0
 private static IList <SwaggerModelPropertyData> GetPropertiesFromType(Type type)
 {
     return(type.GetTypeInfo().GetProperties()
            .Select(property => new SwaggerModelPropertyData
     {
         ExibitionName = PropertyInfoHelper.GetNameConsideringNewtonsoft(property, SwaggerConfig.JsonSerializerSettings),
         Name = property.Name,
         Type = property.PropertyType
     }).ToList());
 }
Exemple #2
0
        private IEnumerable <SwaggerModelPropertyData> GetPropertiesFromType(Type type)
        {
            List <SwaggerModelPropertyData> models = new List <SwaggerModelPropertyData>();

            var properties = type.GetProperties()
                             .Select(property => new SwaggerModelPropertyData
            {
                Name          = property.Name,
                ExibitionName = PropertyInfoHelper.GetNameConsideringNewtonsoft(property, SwaggerConfig.JsonSerializerSettings),
                Type          = property.PropertyType
            });

            return(properties);
        }
        private SwaggerModelPropertyData CreateSwaggerModelPropertyData(PropertyInfo pi, JsonSerializerSettings jsonSerializerSettings)
        {
            var modelProperty = new SwaggerModelPropertyData
            {
                Type          = pi.PropertyType,
                Name          = pi.Name,
                ExibitionName = PropertyInfoHelper.GetNameConsideringNewtonsoft(pi, jsonSerializerSettings),
            };

            foreach (var attr in pi.GetCustomAttributes <ModelPropertyAttribute>())
            {
                modelProperty.Name          = attr.Name ?? modelProperty.Name;
                modelProperty.ExibitionName = modelProperty.Name;
                modelProperty.Description   = attr.Description ?? modelProperty.Description;
                modelProperty.Minimum       = attr.GetNullableMinimum() ?? modelProperty.Minimum;
                modelProperty.Maximum       = attr.GetNullableMaximum() ?? modelProperty.Maximum;
                modelProperty.Required      = attr.GetNullableRequired() ?? modelProperty.Required;
                modelProperty.UniqueItems   = attr.GetNullableUniqueItems() ?? modelProperty.UniqueItems;
                modelProperty.Enum          = attr.Enum ?? modelProperty.Enum;
            }

            return(modelProperty);
        }