Class SchemaDeprecatedAttribute
Marks a property as deprecated in the generated JSON Schema.
[AttributeUsage(AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public sealed class SchemaDeprecatedAttribute : Attribute
- Inheritance
-
SchemaDeprecatedAttribute
- Inherited Members
- Extension Methods
Examples
public class OrderCreated
{
public string OrderId { get; init; }
[SchemaDeprecated("Use CustomerId instead")]
public string LegacyCustomerCode { get; init; }
}
Remarks
When applied to a property, this attribute adds "deprecated": true
to the property's schema definition.
This attribute is only processed when IncludeAnnotations is set to true.
Constructors
SchemaDeprecatedAttribute()
Initializes a new instance of the SchemaDeprecatedAttribute class.
public SchemaDeprecatedAttribute()
SchemaDeprecatedAttribute(string)
Initializes a new instance of the SchemaDeprecatedAttribute class with a deprecation message.
public SchemaDeprecatedAttribute(string message)
Parameters
messagestringA message explaining the deprecation.
Properties
Message
Gets the optional deprecation message.
public string? Message { get; }