|
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>
|
@@ -363,11 +372,12 @@ public OpenApiSchema(OpenApiSchema schema)
|
363 | 372 | MinItems = schema?.MinItems ?? MinItems;
|
364 | 373 | UniqueItems = schema?.UniqueItems ?? UniqueItems;
|
365 | 374 | Properties = schema?.Properties != null ? new Dictionary<string, OpenApiSchema>(schema.Properties) : null;
|
| 375 | + PatternProperties = schema?.PatternProperties != null ? new Dictionary<string, OpenApiSchema>(schema.PatternProperties) : null; |
366 | 376 | MaxProperties = schema?.MaxProperties ?? MaxProperties;
|
367 | 377 | MinProperties = schema?.MinProperties ?? MinProperties;
|
368 | 378 | AdditionalPropertiesAllowed = schema?.AdditionalPropertiesAllowed ?? AdditionalPropertiesAllowed;
|
369 | 379 | AdditionalProperties = schema?.AdditionalProperties != null ? new(schema?.AdditionalProperties) : null;
|
370 |
| - Discriminator = schema?.Discriminator != null ? new(schema?.Discriminator) : null; |
| 380 | + Discriminator = schema?.Discriminator != null ? new(schema?.Discriminator) : null; |
371 | 381 | Example = schema?.Example != null ? new(schema?.Example.Node) : null;
|
372 | 382 | Examples = schema?.Examples != null ? new List<JsonNode>(schema.Examples) : null;
|
373 | 383 | Enum = schema?.Enum != null ? new List<JsonNode>(schema.Enum) : null;
|
@@ -596,6 +606,7 @@ internal void WriteV31Properties(IOpenApiWriter writer)
|
596 | 606 | writer.WriteProperty(OpenApiConstants.V31ExclusiveMinimum, V31ExclusiveMinimum);
|
597 | 607 | writer.WriteProperty(OpenApiConstants.UnevaluatedProperties, UnevaluatedProperties, false);
|
598 | 608 | writer.WriteOptionalCollection(OpenApiConstants.Examples, Examples, (nodeWriter, s) => nodeWriter.WriteAny(new OpenApiAny(s)));
|
| 609 | + writer.WriteOptionalMap(OpenApiConstants.PatternProperties, PatternProperties, (w, s) => s.SerializeAsV31(w)); |
599 | 610 | }
|
600 | 611 |
|
601 | 612 | /// <summary>
|
|
0 commit comments