JsonSchemaProperty

Namespace: NJsonSchema
We found 10 examples in language CSharp for this search. You will see 39 fragments of code.
        
        private static void SetArrayRefToComponent(JObject schemaJObject, KeyValuePair<string, JsonSchemaProperty> schemaProperty, Type enumerableTypeArg)
        {
            schemaJObject["properties"]![schemaProperty.Key]!["items"]!["$ref"] = ComponentRefPath(enumerableTypeArg);
        }

        private static void SetPropertyToRef(Type propertyType, JObject schemaJObject, KeyValuePair<string, JsonSchemaProperty> schemaProperty)
        {
            var jsonForRef = $"{{ \"$ref\": \"{ComponentRefPath(propertyType)}\" }}";

            var propertiesNode = schemaJObject["properties"];
            propertiesNode![schemaProperty.Key] = JObject.Parse(jsonForRef);
        }

using System;
using System.Collections.Generic;

namespace Tenlastic {
    [Serializable]
    public class CollectionModel {

        [Serializable]
        public struct BooleanPermissions {
            public bool @base;
            public dynamic roles;
        }

        [Serializable]
        public struct DynamicPermissions {
            public dynamic @base;
            public dynamic roles;
        }

        [Serializable]
        public struct Index {
            public dynamic key;
            public IndexOptions options;
        }

        [Serializable]
        public struct IndexOptions {
            public int expireAfterSeconds;
            public dynamic partialFilterExpression;
            public bool unique;
        }

        [Serializable]
        public class JsonSchemaProperty {
            public bool additionalProperties;
            public dynamic @default;
            public string format;
            public JsonSchemaProperties properties;
            public string type;
        }

        [Serializable]
        public class JsonSchemaProperties : Dictionary<string, JsonSchemaProperty> { }

        [Serializable]
        public struct Permissions {
            public StringPermissions create;
            public BooleanPermissions delete;
            public DynamicPermissions find;
            public PopulatePermissions[] populate;
            public StringPermissions read;
            public RolePermissions[] roles;
            public StringPermissions update;
        }

        [Serializable]
        public class PopulatePermissions {
            public string path;
            public PopulatePermissions populate;
        }

        [Serializable]
        public struct RolePermissions {
            public string name;
            public dynamic query;
        }

        [Serializable]
        public struct StringPermissions {
            public string[] @base;
            public dynamic roles;
        }

        public string _id;
        public DateTime createdAt;
        public Index[] indexes;
        public JsonSchemaProperty jsonSchema;
        public string name;
        public string namespaceId;
        public Permissions permissions;
        public DateTime updatedAt;

    }
}


        private JsonSchemaProperty GetReferenceIdProperty(JsonSchemaProperty property, bool inherit = true)
        {
            if (property.ExtensionData != null && property.ExtensionData.TryGetValue("x-id", out var propertyName))
            {
                return GetProperty(property.ParentSchema, (string)propertyName);
            }
            return null;
        }

        private IEnumerable<StatementSyntax> GenClientConstructorBody(string clientName, JsonSchemaProperty idKey, JsonSchemaProperty typeKey, HashSet<RefField> cache)
        {
            yield return SF.ParseStatement($"Instance = Instance ?? this;");
            foreach (var refField in cache)
            {
                yield return SF.ParseStatement($"Items.Indexes.Add({refField.InvokerName});");
            }
        }

        private string GetInvokerName(JsonSchemaProperty property)
        {
            return GetPropertyName(property) + "Invoker";
        }

        private IEnumerable<SyntaxToken> GenDefinitionClassPropertyModifiers(JsonSchemaProperty property, JsonSchemaProperty idKey, bool isOverride)
        {
            yield return SF.Token(SyntaxKind.PublicKeyword);
            if (isOverride)
            {
                yield return SF.Token(SyntaxKind.OverrideKeyword);
            }
            else if (property == idKey)
            {
                yield return SF.Token(SyntaxKind.VirtualKeyword);
            }
        }

        private string GetPropertyName(JsonSchemaProperty property)
        {
            return GetDefinitionName(property.Name);
        }

        private string GetFieldName(JsonSchemaProperty property)
        {
            return GetFieldName(property.Name);
        }


        public static Dictionary<string, JsonSchemaProperty> PropertyDictionaryFromType<T>()
        {
            return PropertyDictionaryFromType(typeof(T));
        }

        public static Dictionary<string, JsonSchemaProperty> PropertyDictionaryFromType(Type type)
        {
            Args.ThrowIfNull(type);
            return PropertyDictionaryFromType(type, pi => 
                pi.PropertyType.HasCustomAttributeOfType<JsonSchemaAttribute>() || 
                Extensions.PropertyDataTypeFilter(pi) || 
                pi.PropertyType.IsForEachable() ||
                pi.PropertyType.IsSubclassOf(typeof(RepoData))
            );
        }

        public static Dictionary<string, JsonSchemaProperty> FromDaoType<T>() where T : Dao
        {
            return FromDaoType(typeof(T));
        }

        public static Dictionary<string, JsonSchemaProperty> FromDaoType(Type type)
        {
            Args.ThrowIfNull(type);
            Args.ThrowIf(!type.IsSubclassOf(typeof(Dao)), "Specified type {0} is not a subclass of Dao", type.Name);
            return PropertyDictionaryFromType(type, pi => pi.HasCustomAttributeOfType<ColumnAttribute>());
        }

        public static Dictionary<string, JsonSchemaProperty> PropertyDictionaryFromType(Type type, Func<PropertyInfo, bool> propertyPredicate)
        {
            Dictionary<string, JsonSchemaProperty> result = new Dictionary<string, JsonSchemaProperty>();
            foreach (PropertyInfo prop in type.GetProperties().Where(propertyPredicate))
            {
                result.Add(prop.Name, FromPropertyInfo(prop));
            }
            return result;
        }


        public static JsonSchemaProperty ArrayProperty(JsonSchema item, string? description = null, bool isRequired = false)
        {
            return Enrich(new JsonSchemaProperty { Type = JsonObjectType.Array, Item = item }, description, isRequired);
        }

        public static JsonSchemaProperty BooleanProperty(string? description = null, bool isRequired = false)
        {
            return Enrich(new JsonSchemaProperty { Type = JsonObjectType.Boolean }, description, isRequired);
        }

        public static JsonSchemaProperty DateTimeProperty(string? description = null, bool isRequired = false)
        {
            return Enrich(new JsonSchemaProperty { Type = JsonObjectType.String, Format = JsonFormatStrings.DateTime }, description, isRequired);
        }

        public static JsonSchemaProperty NumberProperty(string? description = null, bool isRequired = false)
        {
            return Enrich(new JsonSchemaProperty { Type = JsonObjectType.Number }, description, isRequired);
        }

        public static JsonSchemaProperty StringProperty(string? description = null, bool isRequired = false)
        {
            return Enrich(new JsonSchemaProperty { Type = JsonObjectType.String }, description, isRequired);
        }

        public static JsonSchemaProperty ObjectProperty(JsonSchema reference, string? description = null, bool isRequired = false)
        {
            return Enrich(new JsonSchemaProperty { Reference = reference }, description, isRequired);
        }

        
        [UnitTest]
        public void JsonSchemaDictionary()
        {
            Dictionary<string, JsonSchemaProperty> props = JsonSchemaProperty.PropertyDictionaryFromType<TestParentRepoData>();
            OutLine(props.ToJson(true));
        }


        public static JsonSchemaProperty ArrayProperty(JsonSchema item, string? description = null, bool isRequired = false)
        {
            return Enrich(new JsonSchemaProperty { Type = JsonObjectType.Array, Item = item }, description, isRequired);
        }

        public static JsonSchemaProperty BooleanProperty(string? description = null, bool isRequired = false)
        {
            return Enrich(new JsonSchemaProperty { Type = JsonObjectType.Boolean }, description, isRequired);
        }

        public static JsonSchemaProperty DateTimeProperty(string? description = null, bool isRequired = false)
        {
            return Enrich(new JsonSchemaProperty { Type = JsonObjectType.String, Format = JsonFormatStrings.DateTime }, description, isRequired);
        }

        public static JsonSchemaProperty GuidProperty(string? description = null, bool isRequired = false)
        {
            return Enrich(new JsonSchemaProperty { Type = JsonObjectType.String, Format = JsonFormatStrings.Guid }, description, isRequired);
        }

        public static JsonSchemaProperty NumberProperty(string? description = null, bool isRequired = false)
        {
            return Enrich(new JsonSchemaProperty { Type = JsonObjectType.Number }, description, isRequired);
        }

        public static JsonSchemaProperty ObjectProperty(JsonSchema item, string? description = null, bool isRequired = false)
        {
            return Enrich(new JsonSchemaProperty { Type = JsonObjectType.Object, Reference = item }, description, isRequired);
        }

using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;

namespace ImageCasterApi.Json
{
    /// <summary>
    /// This is not intended to fulfil the JSON Schema spec nor be
    /// backward compatible with any version of the spec.
    ///
    /// This is due to be removed once .NET Core has official
    /// support for JSON Schemas.
    /// </summary>
    /// <see href="https://github.com/dotnet/runtime/issues/29887"/>
    public class JsonSchemaProperty
    {
        [JsonPropertyName("title")]
        public string Title { get; set; }

        [JsonPropertyName("description")]
        public string Description { get; set; }

        [Required]
        [JsonPropertyName("type")]
        public string Type { get; set; }

        [JsonPropertyName("format")]
        public string Format { get; set; }
        
        [JsonPropertyName("default")]
        public object Default { get; set; }

        [JsonPropertyName("minimum")]
        public int? Minimum { get; set; }

        [JsonPropertyName("maximum")]
        public int? Maximum { get; set; }

        [JsonPropertyName("enum")]
        public IEnumerable<string> Enum { get; set; }

        [JsonPropertyName("items")]
        public JsonSchemaProperty Items { get; set; }

        [JsonPropertyName("properties")]
        public Dictionary<string, JsonSchemaProperty> Properties { get; set; }
    }
}


        public JsonSchemaProperty? Visit(IArrayField field)
        {
            var item = Builder.Object();

            foreach (var nestedField in field.Fields.ForApi(withHiddenFields))
            {
                var childProperty = nestedField.Accept(this);

                if (childProperty != null)
                {
                    childProperty.Description = nestedField.RawProperties.Hints;
                    childProperty.IsRequired = nestedField.RawProperties.IsRequired;

                    item.Properties.Add(nestedField.Name, childProperty);
                }
            }

            return Builder.ArrayProperty(item);
        }

        public JsonSchemaProperty? Visit(IField<AssetsFieldProperties> field)
        {
            var item = schemaResolver("AssetItem", Builder.Guid());

            return Builder.ArrayProperty(item);
        }

        public JsonSchemaProperty? Visit(IField<BooleanFieldProperties> field)
        {
            return Builder.BooleanProperty();
        }

        public JsonSchemaProperty? Visit(IField<DateTimeFieldProperties> field)
        {
            return Builder.DateTimeProperty();
        }

        public JsonSchemaProperty? Visit(IField<GeolocationFieldProperties> field)
        {
            var geolocationSchema = Builder.Object();

            geolocationSchema.Properties.Add("latitude", new JsonSchemaProperty
            {
                Type = JsonObjectType.Number,
                Minimum = -90,
                Maximum = 90,
                IsRequired = true
            });

            geolocationSchema.Properties.Add("longitude", new JsonSchemaProperty
            {
                Type = JsonObjectType.Number,
                Minimum = -180,
                Maximum = 180,
                IsRequired = true
            });

            var reference = schemaResolver("GeolocationDto", geolocationSchema);

            return Builder.ObjectProperty(reference);
        }

        public JsonSchemaProperty? Visit(IField<JsonFieldProperties> field)
        {
            return Builder.JsonProperty();
        }


        /// <summary>
        /// Receive the JSON Schema for the ImageCaster configuration, or
        /// a partial schema from part including one or more of the properties.
        /// </summary>
        /// <param name="properties">The properties to obtain.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentException"></exception>
        [HttpGet("json-schema")]
        public ActionResult<JsonSchema> GetSchema([FromQuery] string[] properties)
        {
            JsonSchema response;
            
            if (properties.Length == 0)
            {
                response = _schema;
            }
            else
            {
                response = new JsonSchema()
                {
                    Schema = _schema.Schema,
                    Id = _schema.Id,
                    Title = _schema.Title,
                    Description = _schema.Description,
                    Type = _schema.Type,
                    Properties = new Dictionary<string, JsonSchemaProperty>()
                };

                Dictionary<string, JsonSchemaProperty> jsonProperties = _schema.Properties;

                foreach (string property in properties)
                {
                    if (!jsonProperties.ContainsKey(property))
                    {
                        return StatusCode(404, "Property not found.");
                    }
                    
                    response.Properties.Add(property, jsonProperties[property]);
                }
            }

            return response;
        }

        /// <returns>All exif tags values available in ImageCaster.</returns>
        [HttpGet("exif-tags")]
        public ActionResult<List<string>> ExifTags()
        {
            return _exifTags;
        }

        /// <returns>All IPTC tags in ImageCaster.</returns>
        [HttpGet("iptc-tags")]
        public ActionResult<List<string>> IptcTags()
        {
            return _iptcTags;
        }
        
        /// <returns>All resize filters available in ImageCaster.</returns>
        [HttpGet("resize-filters")]
        public ActionResult<List<string>> ResizeFilters()
        {
            return _resizeFilters;
        }

        /// <returns>All fonts available on the server.</returns>
        [HttpGet("fonts")]
        public ActionResult<List<string>> ServerFonts()
        {
            return _fontFamilies;
        }

NJsonSchema.JsonSchemaProperty : IJsonReferenceBase, IDocumentPathProvider, IJsonReference, IJsonExtensionObject

Constructors :

public JsonSchemaProperty()

Methods :

public String get_Name()
public Object get_Parent()
public Void set_Parent(Object value = )
public Boolean get_IsRequired()
public Void set_IsRequired(Boolean value = )
public Boolean get_IsReadOnly()
public Void set_IsReadOnly(Boolean value = )
public Boolean get_IsWriteOnly()
public Void set_IsWriteOnly(Boolean value = )
public Boolean get_IsInheritanceDiscriminator()
public Boolean IsNullable(SchemaType schemaType = )
public ICollection<Object> get_Enumeration()
public Boolean get_IsEnumeration()
public ICollection<String> get_RequiredProperties()
public JsonSchema get_DictionaryKey()
public Void set_DictionaryKey(JsonSchema value = )
public IDictionary<String, JsonSchemaProperty> get_Properties()
public JsonXmlObject get_Xml()
public Void set_Xml(JsonXmlObject value = )
public IDictionary<String, JsonSchemaProperty> get_PatternProperties()
public JsonSchema get_Item()
public Void set_Item(JsonSchema value = )
public ICollection<JsonSchema> get_Items()
public JsonSchema get_Not()
public Void set_Not(JsonSchema value = )
public IDictionary<String, JsonSchema> get_Definitions()
public ICollection<JsonSchema> get_AllOf()
public ICollection<JsonSchema> get_AnyOf()
public ICollection<JsonSchema> get_OneOf()
public Boolean get_AllowAdditionalItems()
public Void set_AllowAdditionalItems(Boolean value = )
public JsonSchema get_AdditionalItemsSchema()
public Void set_AdditionalItemsSchema(JsonSchema value = )
public Boolean get_AllowAdditionalProperties()
public Void set_AllowAdditionalProperties(Boolean value = )
public JsonSchema get_AdditionalPropertiesSchema()
public Void set_AdditionalPropertiesSchema(JsonSchema value = )
public Boolean get_IsObject()
public Boolean get_IsArray()
public Boolean get_IsTuple()
public Boolean get_IsDictionary()
public Boolean get_IsAnyType()
public String ToJson()
public String ToJson(Formatting formatting = )
public JToken ToSampleJson()
public Boolean InheritsSchema(JsonSchema parentSchema = )
public ICollection<ValidationError> Validate(String jsonData = , IFormatValidator[] customValidators = )
public ICollection<ValidationError> Validate(JToken token = , IFormatValidator[] customValidators = )
public ICollection<ValidationError> Validate(String jsonData = , SchemaType schemaType = , IFormatValidator[] customValidators = )
public ICollection<ValidationError> Validate(JToken token = , SchemaType schemaType = , IFormatValidator[] customValidators = )
public JsonSchema get_ActualSchema()
public JsonSchema get_ActualTypeSchema()
public Boolean get_HasReference()
public Boolean get_HasAllOfSchemaReference()
public Boolean get_HasOneOfSchemaReference()
public Boolean get_HasAnyOfSchemaReference()
public JsonSchema get_Reference()
public Void set_Reference(JsonSchema value = )
public IDictionary<String, Object> get_ExtensionData()
public Void set_ExtensionData(IDictionary<String, Object> value = )
public String get_ActualDiscriminator()
public String get_Discriminator()
public Void set_Discriminator(String value = )
public OpenApiDiscriminator get_ActualDiscriminatorObject()
public OpenApiDiscriminator get_DiscriminatorObject()
public Void set_DiscriminatorObject(OpenApiDiscriminator value = )
public Collection<String> get_EnumerationNames()
public Void set_EnumerationNames(Collection<String> value = )
public Boolean get_IsBinary()
public JsonSchema get_InheritedSchema()
public JsonSchema get_InheritedTypeSchema()
public IReadOnlyCollection<JsonSchema> get_AllInheritedSchemas()
public Boolean Inherits(JsonSchema schema = )
public OpenApiDiscriminator get_ResponsibleDiscriminatorObject()
public Boolean get_HasActualProperties()
public IReadOnlyDictionary<String, JsonSchemaProperty> get_ActualProperties()
public String get_SchemaVersion()
public Void set_SchemaVersion(String value = )
public String get_Id()
public Void set_Id(String value = )
public String get_Title()
public Void set_Title(String value = )
public Boolean get_HasTypeNameTitle()
public String get_Description()
public Void set_Description(String value = )
public JsonObjectType get_Type()
public Void set_Type(JsonObjectType value = )
public JsonSchema get_ParentSchema()
public String get_Format()
public Void set_Format(String value = )
public Object get_Default()
public Void set_Default(Object value = )
public Nullable<Decimal> get_MultipleOf()
public Void set_MultipleOf(Nullable<Decimal> value = )
public Nullable<Decimal> get_Maximum()
public Void set_Maximum(Nullable<Decimal> value = )
public Nullable<Decimal> get_ExclusiveMaximum()
public Void set_ExclusiveMaximum(Nullable<Decimal> value = )
public Boolean get_IsExclusiveMaximum()
public Void set_IsExclusiveMaximum(Boolean value = )
public Nullable<Decimal> get_Minimum()
public Void set_Minimum(Nullable<Decimal> value = )
public Nullable<Decimal> get_ExclusiveMinimum()
public Void set_ExclusiveMinimum(Nullable<Decimal> value = )
public Boolean get_IsExclusiveMinimum()
public Void set_IsExclusiveMinimum(Boolean value = )
public Nullable<Int32> get_MaxLength()
public Void set_MaxLength(Nullable<Int32> value = )
public Nullable<Int32> get_MinLength()
public Void set_MinLength(Nullable<Int32> value = )
public String get_Pattern()
public Void set_Pattern(String value = )
public Int32 get_MaxItems()
public Void set_MaxItems(Int32 value = )
public Int32 get_MinItems()
public Void set_MinItems(Int32 value = )
public Boolean get_UniqueItems()
public Void set_UniqueItems(Boolean value = )
public Int32 get_MaxProperties()
public Void set_MaxProperties(Int32 value = )
public Int32 get_MinProperties()
public Void set_MinProperties(Int32 value = )
public Boolean get_IsDeprecated()
public Void set_IsDeprecated(Boolean value = )
public String get_DeprecatedMessage()
public Void set_DeprecatedMessage(String value = )
public Boolean get_IsAbstract()
public Void set_IsAbstract(Boolean value = )
public Nullable<Boolean> get_IsNullableRaw()
public Void set_IsNullableRaw(Nullable<Boolean> value = )
public Object get_Example()
public Void set_Example(Object value = )
public Boolean get_IsFlagEnumerable()
public Void set_IsFlagEnumerable(Boolean value = )
public String get_DocumentPath()
public Void set_DocumentPath(String value = )
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()

Other methods