private static JObject ToJson(this ItemsObject items)
        {
            if (items == null)
            {
                return(null);
            }
            var jItems = new JObject
            {
                { "type", items.Type.ToJson() }
            };

            jItems.AddOptional("format", items.Format.ToJson());
            if (items.Type == ItemsType.Array)
            {
                if (items.Items == null)
                {
                    throw new ArgumentException("Items type is array but items not specified", nameof(items));
                }
                jItems.Add("items", items.Items.ToJson());
            }
            else
            {
                jItems.AddOptional("items", items.Items.ToJson());
            }
            jItems.AddOptional("collectionFormat", items.CollectionFormat.ToJson());
            jItems.AddOptional("default", items.Default);
            jItems.AddOptional("maximum", items.Maximum.ToJson());
            jItems.AddOptional("exclusiveMaximum", items.ExclusiveMaximum.ToJson());
            jItems.AddOptional("minimum", items.Minimum.ToJson());
            jItems.AddOptional("exclusiveMinimum", items.ExclusiveMinimum.ToJson());
            jItems.AddOptional("maxLength", items.MaxLength.ToJson());
            jItems.AddOptional("minLength", items.MinLength.ToJson());
            jItems.AddOptional("pattern", items.Pattern.ToJson());
            jItems.AddOptional("maxItems", items.MaxItems.ToJson());
            jItems.AddOptional("minItems", items.MinItems.ToJson());
            jItems.AddOptional("uniqueItems", items.UniqueItems.ToJson());
            jItems.AddOptional("enum", items.Enum);
            jItems.AddOptional("multipleOf", items.MultipleOf.ToJson());
            return(jItems);
        }
Пример #2
0
 public FormDataParameter(string name, ParameterType type, ItemsObject items)
     : base(name, ParameterLocation.FormData)
 {
     this.Type  = type;
     this.Items = items;
 }
Пример #3
0
 public PathParameter(string name, ParameterType type, ItemsObject items)
     : base(name, ParameterLocation.Path)
 {
     this.Type = type;
     this.Items = items;
 }
Пример #4
0
 public Header(ItemsType type, ItemsObject items)
 {
     this.Type  = type;
     this.Items = items;
 }
Пример #5
0
 public ItemsObject(ItemsType type, ItemsObject items)
 {
     this.Type = type;
     this.Items = items;
 }
Пример #6
0
 public PathParameter(string name, ParameterType type, ItemsObject items)
     : base(name, ParameterLocation.Path)
 {
     this.Type  = type;
     this.Items = items;
 }
Пример #7
0
 public HeaderParameter(string name, ParameterType type, ItemsObject items)
     : base(name, ParameterLocation.Header)
 {
     this.Type  = type;
     this.Items = items;
 }
Пример #8
0
 public FormDataParameter(string name, ParameterType type, ItemsObject items)
     : base(name, ParameterLocation.FormData)
 {
     this.Type = type;
     this.Items = items;
 }
Пример #9
0
 public HeaderParameter(string name, ParameterType type, ItemsObject items)
     : base(name, ParameterLocation.Header)
 {
     this.Type = type;
     this.Items = items;
 }