|
1 |
| -// Copyright (c) Microsoft Corporation. All rights reserved. |
| 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
2 | 2 | // Licensed under the MIT license.
|
3 | 3 |
|
4 | 4 | using System;
|
@@ -227,6 +227,15 @@ public class OpenApiSchema : IOpenApiExtensible, IOpenApiReferenceable, IOpenApi
|
227 | 227 | /// </summary>
|
228 | 228 | public IDictionary<string, OpenApiSchema> Properties { get; set; } = new Dictionary<string, OpenApiSchema>();
|
229 | 229 |
|
| 230 | + /// <summary> |
| 231 | + /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00 |
| 232 | + /// PatternProperty definitions MUST be a Schema Object and not a standard JSON Schema (inline or referenced) |
| 233 | + /// Each property name of this object SHOULD be a valid regular expression according to the ECMA 262 r |
| 234 | + /// egular expression dialect. Each property value of this object MUST be an object, and each object MUST |
| 235 | + /// be a valid Schema Object not a standard JSON Schema. |
| 236 | + /// </summary> |
| 237 | + public IDictionary<string, OpenApiSchema> PatternProperties { get; set; } = new Dictionary<string, OpenApiSchema>(); |
| 238 | + |
230 | 239 | /// <summary>
|
231 | 240 | /// Follow JSON Schema definition: https://tools.ietf.org/html/draft-fge-json-schema-validation-00
|
232 | 241 | /// </summary>
|
@@ -356,11 +365,12 @@ public OpenApiSchema(OpenApiSchema schema)
|
356 | 365 | MinItems = schema?.MinItems ?? MinItems;
|
357 | 366 | UniqueItems = schema?.UniqueItems ?? UniqueItems;
|
358 | 367 | Properties = schema?.Properties != null ? new Dictionary<string, OpenApiSchema>(schema.Properties) : null;
|
| 368 | + PatternProperties = schema?.PatternProperties != null ? new Dictionary<string, OpenApiSchema>(schema.PatternProperties) : null; |
359 | 369 | MaxProperties = schema?.MaxProperties ?? MaxProperties;
|
360 | 370 | MinProperties = schema?.MinProperties ?? MinProperties;
|
361 | 371 | AdditionalPropertiesAllowed = schema?.AdditionalPropertiesAllowed ?? AdditionalPropertiesAllowed;
|
362 | 372 | AdditionalProperties = schema?.AdditionalProperties != null ? new(schema?.AdditionalProperties) : null;
|
363 |
| - Discriminator = schema?.Discriminator != null ? new(schema?.Discriminator) : null; |
| 373 | + Discriminator = schema?.Discriminator != null ? new(schema?.Discriminator) : null; |
364 | 374 | Example = schema?.Example != null ? new(schema?.Example.Node) : null;
|
365 | 375 | Enum = schema?.Enum != null ? new List<JsonNode>(schema.Enum) : null;
|
366 | 376 | Nullable = schema?.Nullable ?? Nullable;
|
@@ -587,6 +597,7 @@ internal void WriteV31Properties(IOpenApiWriter writer)
|
587 | 597 | writer.WriteProperty(OpenApiConstants.V31ExclusiveMaximum, V31ExclusiveMaximum);
|
588 | 598 | writer.WriteProperty(OpenApiConstants.V31ExclusiveMinimum, V31ExclusiveMinimum);
|
589 | 599 | writer.WriteProperty(OpenApiConstants.UnevaluatedProperties, UnevaluatedProperties, false);
|
| 600 | + writer.WriteOptionalMap(OpenApiConstants.PatternProperties, PatternProperties, (w, s) => s.SerializeAsV31(w)); |
590 | 601 | }
|
591 | 602 |
|
592 | 603 | /// <summary>
|
|
0 commit comments