| | | 1 | | |
| | | 2 | | /// <summary> |
| | | 3 | | /// Rich OpenAPI schema metadata for a property or a class. |
| | | 4 | | /// Apply to: |
| | | 5 | | /// <list type="bullet"> |
| | | 6 | | /// <item><description>Class (object-level): set <see cref="RequiredProperties"/> array, XML hints, discriminator, etc.< |
| | | 7 | | /// <item><description>Property (member-level): set description, format, constraints, enum, etc.</description></item> |
| | | 8 | | /// </list> |
| | | 9 | | /// </summary> |
| | | 10 | | public abstract class OpenApiProperties : KestrunAnnotation |
| | | 11 | | { |
| | | 12 | | /// <summary> |
| | | 13 | | /// Human-friendly title for the schema. |
| | | 14 | | /// </summary> |
| | 14 | 15 | | public string? Title { get; set; } |
| | | 16 | | /// <summary>Markdown-capable description.</summary> |
| | 13 | 17 | | public string? Description { get; set; } |
| | | 18 | | |
| | | 19 | | /// <summary>Explicit OpenAPI type override (otherwise inferred).</summary> |
| | 14 | 20 | | public OaSchemaType Type { get; set; } = OaSchemaType.None; |
| | 14 | 21 | | public string? Format { get; set; } |
| | | 22 | | /// <summary>Default value.</summary> |
| | 14 | 23 | | public object? Default { get; set; } |
| | | 24 | | /// <summary>Example value (single example).</summary> |
| | 16 | 25 | | public object? Example { get; set; } |
| | | 26 | | /// <summary>Marks the schema as nullable (OAS 3.0).</summary> |
| | 14 | 27 | | public bool Nullable { get; set; } |
| | | 28 | | /// <summary>Indicates the value is read-only (responses only).</summary> |
| | 14 | 29 | | public bool ReadOnly { get; set; } |
| | | 30 | | /// <summary>Indicates the value is write-only (requests only).</summary> |
| | 14 | 31 | | public bool WriteOnly { get; set; } |
| | | 32 | | /// <summary>Marks the schema/property as deprecated.</summary> |
| | 12 | 33 | | public bool Deprecated { get; set; } |
| | | 34 | | /// <summary> |
| | | 35 | | /// Indicates the property is an array (enables array constraints). |
| | | 36 | | /// </summary> |
| | 7 | 37 | | public bool Array { get; set; } |
| | | 38 | | // ---- Numbers ---- |
| | | 39 | | /// <summary>Value must be a multiple of this.</summary> |
| | 14 | 40 | | public decimal? MultipleOf { get; set; } |
| | | 41 | | /// <summary>Inclusive maximum.</summary> |
| | 14 | 42 | | public string? Maximum { get; set; } |
| | | 43 | | /// <summary>Exclusive maximum flag.</summary> |
| | 0 | 44 | | public bool ExclusiveMaximum { get; set; } |
| | | 45 | | /// <summary>Inclusive minimum.</summary> |
| | 14 | 46 | | public string? Minimum { get; set; } |
| | | 47 | | /// <summary>Exclusive minimum flag.</summary> |
| | 0 | 48 | | public bool ExclusiveMinimum { get; set; } |
| | | 49 | | |
| | | 50 | | // ---- Strings ---- |
| | | 51 | | /// <summary>Maximum length (characters).</summary> |
| | 53 | 52 | | public int MaxLength { get; set; } = -1; |
| | | 53 | | /// <summary>Minimum length (characters).</summary> |
| | 53 | 54 | | public int MinLength { get; set; } = -1; |
| | | 55 | | /// <summary>ECMA-262 compliant regex.</summary> |
| | 14 | 56 | | public string? Pattern { get; set; } |
| | | 57 | | |
| | | 58 | | // ---- Arrays ---- |
| | | 59 | | /// <summary>Max items in array.</summary> |
| | 53 | 60 | | public int MaxItems { get; set; } = -1; |
| | | 61 | | /// <summary>Min items in array.</summary> |
| | 53 | 62 | | public int MinItems { get; set; } = -1; |
| | | 63 | | /// <summary>Items must be unique.</summary> |
| | 14 | 64 | | public bool UniqueItems { get; set; } |
| | | 65 | | |
| | | 66 | | // ---- Objects ---- |
| | | 67 | | /// <summary>Max properties an object may contain.</summary> |
| | 53 | 68 | | public int MaxProperties { get; set; } = -1; |
| | | 69 | | /// <summary>Min properties an object must contain.</summary> |
| | 53 | 70 | | public int MinProperties { get; set; } = -1; |
| | | 71 | | |
| | | 72 | | /// <summary> |
| | | 73 | | /// Object-level required property names (apply this on the CLASS). |
| | | 74 | | /// </summary> |
| | 14 | 75 | | public string[]? RequiredProperties { get; set; } |
| | | 76 | | |
| | | 77 | | // ---- Enum ---- |
| | | 78 | | /// <summary>Allowed constant values for the schema.</summary> |
| | 14 | 79 | | public object[]? Enum { get; set; } |
| | | 80 | | |
| | | 81 | | // ---- Array typing ---- |
| | | 82 | | /// <summary>Items type by OpenAPI reference (e.g., "#/components/schemas/Address").</summary> |
| | | 83 | | /// <summary>Items type by .NET type for code-first generators.</summary> |
| | 1 | 84 | | public Type? ItemsType { get; set; } |
| | | 85 | | |
| | | 86 | | /// <summary> |
| | | 87 | | /// Indicates whether additionalProperties are allowed (default: false). |
| | | 88 | | /// </summary> |
| | 53 | 89 | | public bool AdditionalPropertiesAllowed { get; set; } = true; |
| | | 90 | | |
| | | 91 | | // ---- Composition ---- |
| | | 92 | | /// <summary>oneOf refs (by $ref).</summary> |
| | 0 | 93 | | public string[]? OneOfRefs { get; set; } |
| | | 94 | | /// <summary>anyOf refs (by $ref).</summary> |
| | 0 | 95 | | public string[]? AnyOfRefs { get; set; } |
| | | 96 | | /// <summary>allOf refs (by $ref).</summary> |
| | 0 | 97 | | public string[]? AllOfRefs { get; set; } |
| | | 98 | | /// <summary>not ref (by $ref).</summary> |
| | 0 | 99 | | public string? NotRef { get; set; } |
| | | 100 | | /// <summary>oneOf types (by .NET type).</summary> |
| | 0 | 101 | | public Type[]? OneOfTypes { get; set; } |
| | | 102 | | /// <summary>anyOf types (by .NET type).</summary> |
| | 0 | 103 | | public Type[]? AnyOfTypes { get; set; } |
| | | 104 | | /// <summary>allOf types (by .NET type).</summary> |
| | 0 | 105 | | public Type[]? AllOfTypes { get; set; } |
| | | 106 | | /// <summary>not type (by .NET type).</summary> |
| | 0 | 107 | | public Type? NotType { get; set; } |
| | | 108 | | |
| | | 109 | | // ---- Discriminator ---- |
| | | 110 | | /// <summary>Name of the property used to discriminate between schemas.</summary> |
| | 0 | 111 | | public string? DiscriminatorPropertyName { get; set; } |
| | | 112 | | /// <summary>Payload values matched by the discriminator.</summary> |
| | 0 | 113 | | public string[]? DiscriminatorMappingKeys { get; set; } |
| | | 114 | | /// <summary>Schema $refs that correspond to the mapping keys.</summary> |
| | 0 | 115 | | public string[]? DiscriminatorMappingRefs { get; set; } |
| | | 116 | | |
| | | 117 | | // ---- External Docs ---- |
| | | 118 | | /// <summary>External documentation URL.</summary> |
| | 0 | 119 | | public string? ExternalDocsUrl { get; set; } |
| | | 120 | | /// <summary>Description for the external docs.</summary> |
| | 0 | 121 | | public string? ExternalDocsDescription { get; set; } |
| | | 122 | | |
| | | 123 | | // ---- XML ---- |
| | | 124 | | /// <summary>XML element/attribute name.</summary> |
| | 26 | 125 | | public string? XmlName { get; set; } |
| | | 126 | | /// <summary>XML namespace.</summary> |
| | 24 | 127 | | public string? XmlNamespace { get; set; } |
| | | 128 | | /// <summary>XML prefix.</summary> |
| | 20 | 129 | | public string? XmlPrefix { get; set; } |
| | | 130 | | /// <summary>Indicates the property is an XML attribute.</summary> |
| | 19 | 131 | | public bool XmlAttribute { get; set; } |
| | | 132 | | /// <summary>Indicates arrays are wrapped in an enclosing element.</summary> |
| | 16 | 133 | | public bool XmlWrapped { get; set; } |
| | | 134 | | /// <summary> |
| | | 135 | | /// Sets unevaluatedProperties for OpenAPI Schema (null = generator decides). |
| | | 136 | | /// </summary> |
| | 14 | 137 | | public bool UnevaluatedProperties { get; set; } |
| | | 138 | | } |