Skip to content

Commit 71215ac

Browse files
committed
Add an OpenApiSchema model with all known keywords
1 parent 6fed385 commit 71215ac

File tree

1 file changed

+50
-5
lines changed

1 file changed

+50
-5
lines changed

src/Microsoft.OpenApi/Models/OpenApiSchema.cs

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,80 @@
11
using System.Collections.Generic;
2+
using System.Text.Json.Nodes;
23
using Microsoft.OpenApi.Any;
34
using Microsoft.OpenApi.Interfaces;
45

56
namespace Microsoft.OpenApi.Models
67
{
7-
internal class OpenApiSchema
8+
/// <summary>
9+
/// The Schema Object allows the definition of input and output data types.
10+
/// </summary>
11+
public class OpenApiSchema : IOpenApiExtensible
812
{
913
/// <summary>
1014
/// Follow JSON Schema definition. Short text providing information about the data.
1115
/// </summary>
1216
public string Title { get; set; }
1317

18+
/// <summary>
19+
/// $schema, a JSON Schema dialect identifier. Value must be a URI
20+
/// </summary>
1421
public string Schema { get; set; }
1522

23+
/// <summary>
24+
/// $id - Identifies a schema resource with its canonical URI.
25+
/// </summary>
1626
public string Id { get; set; }
1727

28+
/// <summary>
29+
/// $comment - reserves a location for comments from schema authors to readers or maintainers of the schema.
30+
/// </summary>
1831
public string Comment { get; set; }
1932

33+
/// <summary>
34+
/// $vocabulary- used in meta-schemas to identify the vocabularies available for use in schemas described by that meta-schema.
35+
/// </summary>
2036
public string Vocabulary { get; set; }
2137

38+
/// <summary>
39+
/// $dynamicRef - an applicator that allows for deferring the full resolution until runtime, at which point it is resolved each time it is encountered while evaluating an instance
40+
/// </summary>
2241
public string DynamicRef { get; set; }
2342

43+
/// <summary>
44+
/// $dynamicAnchor - used to create plain name fragments that are not tied to any particular structural location for referencing purposes, which are taken into consideration for dynamic referencing.
45+
/// </summary>
2446
public string DynamicAnchor { get; set; }
2547

48+
/// <summary>
49+
/// $recursiveAnchor - used to construct recursive schemas i.e one that has a reference to its own root, identified by the empty fragment URI reference ("#")
50+
/// </summary>
2651
public string RecursiveAnchor { get; set; }
2752

53+
/// <summary>
54+
/// $recursiveRef - used to construct recursive schemas i.e one that has a reference to its own root, identified by the empty fragment URI reference ("#")
55+
/// </summary>
2856
public string RecursiveRef { get; set; }
2957

58+
/// <summary>
59+
/// $defs - reserves a location for schema authors to inline re-usable JSON Schemas into a more general schema.
60+
/// The keyword does not directly affect the validation result
61+
/// </summary>
3062
public IDictionary<string, OpenApiSchema> Definitions { get; set; }
3163

32-
public bool UnevaluatedProperties { get; set; }
33-
64+
/// <summary>
65+
/// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
66+
/// </summary>
3467
public decimal V31ExclusiveMaximum { get; set; }
3568

69+
/// <summary>
70+
/// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
71+
/// </summary>
3672
public decimal V31ExclusiveMinimum { get; set; }
3773

74+
/// <summary>
75+
///
76+
/// </summary>
77+
public bool UnEvaluatedProperties { get; set; }
3878

3979
/// <summary>
4080
/// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
@@ -225,13 +265,18 @@ internal class OpenApiSchema
225265
/// <summary>
226266
/// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
227267
/// </summary>
228-
public IList<OpenApiAny> Enum { get; set; } = new List<OpenApiAny>();
268+
public IList<JsonNode> Enum { get; set; } = new List<JsonNode>();
229269

230270
/// <summary>
231271
/// Allows sending a null value for the defined schema. Default value is false.
232272
/// </summary>
233273
public bool Nullable { get; set; }
234274

275+
/// <summary>
276+
/// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
277+
/// </summary>
278+
public bool UnevaluatedProperties { get; set;}
279+
235280
/// <summary>
236281
/// Additional external documentation for this schema.
237282
/// </summary>
@@ -317,7 +362,7 @@ public OpenApiSchema(OpenApiSchema schema)
317362
AdditionalProperties = schema?.AdditionalProperties != null ? new(schema?.AdditionalProperties) : null;
318363
Discriminator = schema?.Discriminator != null ? new(schema?.Discriminator) : null;
319364
Example = schema?.Example != null ? new(schema?.Example.Node) : null;
320-
Enum = schema?.Enum != null ? new List<OpenApiAny>(schema.Enum) : null;
365+
Enum = schema?.Enum != null ? new List<JsonNode>(schema.Enum) : null;
321366
Nullable = schema?.Nullable ?? Nullable;
322367
ExternalDocs = schema?.ExternalDocs != null ? new(schema?.ExternalDocs) : null;
323368
Deprecated = schema?.Deprecated ?? Deprecated;

0 commit comments

Comments
 (0)