| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System.Text.Json.Serialization.Metadata; |
| | | 5 | | |
| | | 6 | | namespace System.Text.Json.Schema |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Defines the context for the generated JSON schema for a particular node in a type graph. |
| | | 10 | | /// </summary> |
| | | 11 | | public readonly struct JsonSchemaExporterContext |
| | | 12 | | { |
| | | 13 | | internal readonly string[] _path; |
| | | 14 | | |
| | | 15 | | internal JsonSchemaExporterContext( |
| | | 16 | | JsonTypeInfo typeInfo, |
| | | 17 | | JsonPropertyInfo? propertyInfo, |
| | | 18 | | JsonTypeInfo? baseTypeInfo, |
| | | 19 | | string[] path) |
| | 0 | 20 | | { |
| | 0 | 21 | | TypeInfo = typeInfo; |
| | 0 | 22 | | PropertyInfo = propertyInfo; |
| | 0 | 23 | | BaseTypeInfo = baseTypeInfo; |
| | 0 | 24 | | _path = path; |
| | 0 | 25 | | } |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// The <see cref="JsonTypeInfo"/> for the type being processed. |
| | | 29 | | /// </summary> |
| | 0 | 30 | | public JsonTypeInfo TypeInfo { get; } |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// The <see cref="JsonPropertyInfo"/> if the schema is being generated for a property. |
| | | 34 | | /// </summary> |
| | 0 | 35 | | public JsonPropertyInfo? PropertyInfo { get; } |
| | | 36 | | |
| | | 37 | | /// <summary> |
| | | 38 | | /// Gets the <see cref="JsonTypeInfo"/> for polymorphic base type if the schema is being generated for a derived |
| | | 39 | | /// </summary> |
| | 0 | 40 | | public JsonTypeInfo? BaseTypeInfo { get; } |
| | | 41 | | |
| | | 42 | | /// <summary> |
| | | 43 | | /// The path to the current node in the generated JSON schema. |
| | | 44 | | /// </summary> |
| | 0 | 45 | | public ReadOnlySpan<string> Path => _path; |
| | | 46 | | } |
| | | 47 | | } |