Esempio n. 1
0
        private (string Key, OpenApiSchema Value) ReadType(Type type)
        {
            var properties = type.GetProperties();
            var schema     = new OpenApiSchema()
            {
                Type = TypeIdentifier.Object
            };

            foreach (var property in properties)
            {
                string name = NameToCamelCase(property);

                if (IsRequired(property))
                {
                    schema.Required.Add(name);
                }

                var(propType, format) = TypeIdentifier.Id(property.PropertyType);

                if (propType == TypeIdentifier.Object)
                {
                    BuildObjectSchema(schema, property, name);
                }
                else if (propType == TypeIdentifier.Array)
                {
                    BuildArraySchema(schema, property, name);
                }
                else
                {
                    BuildPropertySchema(schema, name, propType, format);
                }
            }

            return(TypeIdentifier.Name(type), schema);
        }
        private void LoadProperties()
        {
            var properties = _targetType.GetProperties();

            foreach (var property in properties)
            {
                var apiParameter = new OpenApiParameter();

                apiParameter.In     = _location;
                apiParameter.Name   = property.Name;
                apiParameter.Schema = new OpenApiSchema();

                (apiParameter.Schema.Type, apiParameter.Schema.Format) = TypeIdentifier.Id(property.PropertyType);

                Add(apiParameter);
            }
        }