|
| 1 | +using System.Collections.Generic; |
| 2 | +using Microsoft.OpenApi.Any; |
| 3 | +using Microsoft.OpenApi.Interfaces; |
| 4 | + |
| 5 | +namespace Microsoft.OpenApi.Models |
| 6 | +{ |
| 7 | + internal class OpenApiSchema |
| 8 | + { |
| 9 | + /// <summary> |
| 10 | + /// Follow JSON Schema definition. Short text providing information about the data. |
| 11 | + /// </summary> |
| 12 | + public string Title { get; set; } |
| 13 | + |
| 14 | + public string Schema { get; set; } |
| 15 | + |
| 16 | + public string Id { get; set; } |
| 17 | + |
| 18 | + public string Comment { get; set; } |
| 19 | + |
| 20 | + public string Vocabulary { get; set; } |
| 21 | + |
| 22 | + public string DynamicRef { get; set; } |
| 23 | + |
| 24 | + public string DynamicAnchor { get; set; } |
| 25 | + |
| 26 | + public string RecursiveAnchor { get; set; } |
| 27 | + |
| 28 | + public string RecursiveRef { get; set; } |
| 29 | + |
| 30 | + public IDictionary<string, OpenApiSchema> Definitions { get; set; } |
| 31 | + |
| 32 | + public bool UnevaluatedProperties { get; set; } |
| 33 | + |
| 34 | + public decimal V31ExclusiveMaximum { get; set; } |
| 35 | + |
| 36 | + public decimal V31ExclusiveMinimum { get; set; } |
| 37 | + |
| 38 | + |
| 39 | + /// <summary> |
| 40 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 41 | + /// Value MUST be a string in V2 and V3. |
| 42 | + /// </summary> |
| 43 | + public string Type { get; set; } |
| 44 | + |
| 45 | + /// <summary> |
| 46 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 47 | + /// Multiple types via an array are supported in V31. |
| 48 | + /// </summary> |
| 49 | + public string[] TypeArray { get; set; } |
| 50 | + |
| 51 | + /// <summary> |
| 52 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 53 | + /// While relying on JSON Schema's defined formats, |
| 54 | + /// the OAS offers a few additional predefined formats. |
| 55 | + /// </summary> |
| 56 | + public string Format { get; set; } |
| 57 | + |
| 58 | + /// <summary> |
| 59 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 60 | + /// CommonMark syntax MAY be used for rich text representation. |
| 61 | + /// </summary> |
| 62 | + public string Description { get; set; } |
| 63 | + |
| 64 | + /// <summary> |
| 65 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 66 | + /// </summary> |
| 67 | + public decimal? Maximum { get; set; } |
| 68 | + |
| 69 | + /// <summary> |
| 70 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 71 | + /// </summary> |
| 72 | + public bool? ExclusiveMaximum { get; set; } |
| 73 | + |
| 74 | + /// <summary> |
| 75 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 76 | + /// </summary> |
| 77 | + public decimal? Minimum { get; set; } |
| 78 | + |
| 79 | + /// <summary> |
| 80 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 81 | + /// </summary> |
| 82 | + public bool? ExclusiveMinimum { get; set; } |
| 83 | + |
| 84 | + /// <summary> |
| 85 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 86 | + /// </summary> |
| 87 | + public int? MaxLength { get; set; } |
| 88 | + |
| 89 | + /// <summary> |
| 90 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 91 | + /// </summary> |
| 92 | + public int? MinLength { get; set; } |
| 93 | + |
| 94 | + /// <summary> |
| 95 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 96 | + /// This string SHOULD be a valid regular expression, according to the ECMA 262 regular expression dialect |
| 97 | + /// </summary> |
| 98 | + public string Pattern { get; set; } |
| 99 | + |
| 100 | + /// <summary> |
| 101 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 102 | + /// </summary> |
| 103 | + public decimal? MultipleOf { get; set; } |
| 104 | + |
| 105 | + /// <summary> |
| 106 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 107 | + /// The default value represents what would be assumed by the consumer of the input as the value of the schema if one is not provided. |
| 108 | + /// Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object defined at the same level. |
| 109 | + /// For example, if type is string, then default can be "foo" but cannot be 1. |
| 110 | + /// </summary> |
| 111 | + public OpenApiAny Default { get; set; } |
| 112 | + |
| 113 | + /// <summary> |
| 114 | + /// Relevant only for Schema "properties" definitions. Declares the property as "read only". |
| 115 | + /// This means that it MAY be sent as part of a response but SHOULD NOT be sent as part of the request. |
| 116 | + /// If the property is marked as readOnly being true and is in the required list, |
| 117 | + /// the required will take effect on the response only. |
| 118 | + /// A property MUST NOT be marked as both readOnly and writeOnly being true. |
| 119 | + /// Default value is false. |
| 120 | + /// </summary> |
| 121 | + public bool ReadOnly { get; set; } |
| 122 | + |
| 123 | + /// <summary> |
| 124 | + /// Relevant only for Schema "properties" definitions. Declares the property as "write only". |
| 125 | + /// Therefore, it MAY be sent as part of a request but SHOULD NOT be sent as part of the response. |
| 126 | + /// If the property is marked as writeOnly being true and is in the required list, |
| 127 | + /// the required will take effect on the request only. |
| 128 | + /// A property MUST NOT be marked as both readOnly and writeOnly being true. |
| 129 | + /// Default value is false. |
| 130 | + /// </summary> |
| 131 | + public bool WriteOnly { get; set; } |
| 132 | + |
| 133 | + /// <summary> |
| 134 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 135 | + /// Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema. |
| 136 | + /// </summary> |
| 137 | + public IList<OpenApiSchema> AllOf { get; set; } = new List<OpenApiSchema>(); |
| 138 | + |
| 139 | + /// <summary> |
| 140 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 141 | + /// Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema. |
| 142 | + /// </summary> |
| 143 | + public IList<OpenApiSchema> OneOf { get; set; } = new List<OpenApiSchema>(); |
| 144 | + |
| 145 | + /// <summary> |
| 146 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 147 | + /// Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema. |
| 148 | + /// </summary> |
| 149 | + public IList<OpenApiSchema> AnyOf { get; set; } = new List<OpenApiSchema>(); |
| 150 | + |
| 151 | + /// <summary> |
| 152 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 153 | + /// Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema. |
| 154 | + /// </summary> |
| 155 | + public OpenApiSchema Not { get; set; } |
| 156 | + |
| 157 | + /// <summary> |
| 158 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 159 | + /// </summary> |
| 160 | + public ISet<string> Required { get; set; } = new HashSet<string>(); |
| 161 | + |
| 162 | + /// <summary> |
| 163 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 164 | + /// Value MUST be an object and not an array. Inline or referenced schema MUST be of a Schema Object |
| 165 | + /// and not a standard JSON Schema. items MUST be present if the type is array. |
| 166 | + /// </summary> |
| 167 | + public OpenApiSchema Items { get; set; } |
| 168 | + |
| 169 | + /// <summary> |
| 170 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 171 | + /// </summary> |
| 172 | + public int? MaxItems { get; set; } |
| 173 | + |
| 174 | + /// <summary> |
| 175 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 176 | + /// </summary> |
| 177 | + public int? MinItems { get; set; } |
| 178 | + |
| 179 | + /// <summary> |
| 180 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 181 | + /// </summary> |
| 182 | + public bool? UniqueItems { get; set; } |
| 183 | + |
| 184 | + /// <summary> |
| 185 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 186 | + /// Property definitions MUST be a Schema Object and not a standard JSON Schema (inline or referenced). |
| 187 | + /// </summary> |
| 188 | + public IDictionary<string, OpenApiSchema> Properties { get; set; } = new Dictionary<string, OpenApiSchema>(); |
| 189 | + |
| 190 | + /// <summary> |
| 191 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 192 | + /// </summary> |
| 193 | + public int? MaxProperties { get; set; } |
| 194 | + |
| 195 | + /// <summary> |
| 196 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 197 | + /// </summary> |
| 198 | + public int? MinProperties { get; set; } |
| 199 | + |
| 200 | + /// <summary> |
| 201 | + /// Indicates if the schema can contain properties other than those defined by the properties map. |
| 202 | + /// </summary> |
| 203 | + public bool AdditionalPropertiesAllowed { get; set; } = true; |
| 204 | + |
| 205 | + /// <summary> |
| 206 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 207 | + /// Value can be boolean or object. Inline or referenced schema |
| 208 | + /// MUST be of a Schema Object and not a standard JSON Schema. |
| 209 | + /// </summary> |
| 210 | + public OpenApiSchema AdditionalProperties { get; set; } |
| 211 | + |
| 212 | + /// <summary> |
| 213 | + /// Adds support for polymorphism. The discriminator is an object name that is used to differentiate |
| 214 | + /// between other schemas which may satisfy the payload description. |
| 215 | + /// </summary> |
| 216 | + public OpenApiDiscriminator Discriminator { get; set; } |
| 217 | + |
| 218 | + /// <summary> |
| 219 | + /// A free-form property to include an example of an instance for this schema. |
| 220 | + /// To represent examples that cannot be naturally represented in JSON or YAML, |
| 221 | + /// a string value can be used to contain the example with escaping where necessary. |
| 222 | + /// </summary> |
| 223 | + public OpenApiAny Example { get; set; } |
| 224 | + |
| 225 | + /// <summary> |
| 226 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 227 | + /// </summary> |
| 228 | + public IList<OpenApiAny> Enum { get; set; } = new List<OpenApiAny>(); |
| 229 | + |
| 230 | + /// <summary> |
| 231 | + /// Allows sending a null value for the defined schema. Default value is false. |
| 232 | + /// </summary> |
| 233 | + public bool Nullable { get; set; } |
| 234 | + |
| 235 | + /// <summary> |
| 236 | + /// Additional external documentation for this schema. |
| 237 | + /// </summary> |
| 238 | + public OpenApiExternalDocs ExternalDocs { get; set; } |
| 239 | + |
| 240 | + /// <summary> |
| 241 | + /// Specifies that a schema is deprecated and SHOULD be transitioned out of usage. |
| 242 | + /// Default value is false. |
| 243 | + /// </summary> |
| 244 | + public bool Deprecated { get; set; } |
| 245 | + |
| 246 | + /// <summary> |
| 247 | + /// This MAY be used only on properties schemas. It has no effect on root schemas. |
| 248 | + /// Adds additional metadata to describe the XML representation of this property. |
| 249 | + /// </summary> |
| 250 | + public OpenApiXml Xml { get; set; } |
| 251 | + |
| 252 | + /// <summary> |
| 253 | + /// This object MAY be extended with Specification Extensions. |
| 254 | + /// </summary> |
| 255 | + public IDictionary<string, IOpenApiExtension> Extensions { get; set; } = new Dictionary<string, IOpenApiExtension>(); |
| 256 | + |
| 257 | + /// <summary> |
| 258 | + /// Indicates object is a placeholder reference to an actual object and does not contain valid data. |
| 259 | + /// </summary> |
| 260 | + public bool UnresolvedReference { get; set; } |
| 261 | + |
| 262 | + /// <summary> |
| 263 | + /// Reference object. |
| 264 | + /// </summary> |
| 265 | + public OpenApiReference Reference { get; set; } |
| 266 | + } |
| 267 | +} |
0 commit comments