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