Ejemplo n.º 1
0
        /// <summary>
        /// Converts the specified <see cref="OasSchemaType"/> to a <see cref="JToken"/>.
        /// </summary>
        /// <param name="schemaType">The <see cref="OasSchemaType"/> to convert.</param>
        /// <returns>The <see cref="JToken"/>.</returns>
        protected virtual JToken ToJsonValue(OasSchemaType schemaType)
        {
            switch (schemaType)
            {
            case OasSchemaType.String: return(EnumConstants.String);

            case OasSchemaType.Number: return(EnumConstants.Number);

            case OasSchemaType.Object: return(EnumConstants.Object);

            case OasSchemaType.Array: return(EnumConstants.Array);

            case OasSchemaType.Boolean: return(EnumConstants.Boolean);

            case OasSchemaType.Integer: return(EnumConstants.Integer);

            default: throw new ArgumentOutOfRangeException(nameof(schemaType));
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new <see cref="OasSchema"/> value.
 /// </summary>
 /// <param name="type">The general type of the schema.</param>
 /// <param name="format">The specific type of the schema/</param>
 /// <param name="title">The title of the schema.</param>
 /// <param name="description">The description of the schema.</param>
 /// <param name="numberRange">The range of valid numbers.</param>
 /// <param name="itemsRange">The range of valid item counts.</param>
 /// <param name="lengthRange">The range of valid lengths.</param>
 /// <param name="propertiesRange">The range of valid property counts.</param>
 /// <param name="options">The schema options.</param>
 /// <param name="pattern">The regex validation for string values.</param>
 /// <param name="enum">The valid enum values.</param>
 /// <param name="allOf">The list of schemas that this schema must conform to.</param>
 /// <param name="oneOf">The list of schemas that, from which exactly one, this schema must conform to.</param>
 /// <param name="anyOf">The list of schemas that, from which one or more, this schema must conform to.</param>
 /// <param name="not">The list of schemas that this schema must not conform to.</param>
 /// <param name="items">The list of schemas that represent the array items that this schema must contain.</param>
 /// <param name="properties">The list of valid properties.</param>
 /// <param name="additionalProperties">The list of valid properties for children.</param>
 /// <param name="externalDocumentation">The external documentation.</param>
 public OasSchema(
     OasSchemaType type = default,
     string format = null,
     string title = null,
     string description = null,
     NumberConstraint numberRange = default,
     CountConstraint itemsRange = default,
     CountConstraint lengthRange = default,
     CountConstraint propertiesRange = default,
     OasSchemaOptions options = default,
     string pattern = default,
     IReadOnlyList<OasScalarValue> @enum = default,
     IReadOnlyList<OasReferable<OasSchema>> allOf = default,
     IReadOnlyList<OasReferable<OasSchema>> oneOf = default,
     IReadOnlyList<OasReferable<OasSchema>> anyOf = default,
     IReadOnlyList<OasReferable<OasSchema>> not = default,
     OasReferable<OasSchema> items = default,
     IReadOnlyDictionary<string, OasReferable<OasSchema>> properties = default,
     IReadOnlyDictionary<string, OasReferable<OasSchema>> additionalProperties = default,
     OasExternalDocumentation externalDocumentation = default)
 {
     JsonType = type;
     Title = title;
     Format = format;
     Description = description;
     NumberRange = numberRange;
     ItemsRange = itemsRange;
     LengthRange = lengthRange;
     PropertiesRange = propertiesRange;
     Options = options;
     Pattern = pattern;
     Enum = @enum ?? Array.Empty<OasScalarValue>();
     AllOf = allOf ?? Array.Empty<OasReferable<OasSchema>>();
     OneOf = oneOf ?? Array.Empty<OasReferable<OasSchema>>();
     AnyOf = anyOf ?? Array.Empty<OasReferable<OasSchema>>();
     Not = not ?? Array.Empty<OasReferable<OasSchema>>();
     Items = items;
     Properties = properties ?? ImmutableDictionary<string, OasReferable<OasSchema>>.Empty;
     AdditionalProperties = additionalProperties ?? ImmutableDictionary<string, OasReferable<OasSchema>>.Empty;
     ExternalDocumentation = externalDocumentation;
 }