Class SchemaExampleAttribute
Specifies an example value for a property in the generated JSON Schema.
[AttributeUsage(AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = true, Inherited = true)]
public sealed class SchemaExampleAttribute : Attribute
- Inheritance
-
SchemaExampleAttribute
- Inherited Members
- Extension Methods
Examples
public class OrderCreated
{
[SchemaExample("ORD-12345")]
public string OrderId { get; init; }
[SchemaExample(99.99)]
public decimal TotalAmount { get; init; }
}
Remarks
When applied to a property, this attribute adds an examples array
to the property's schema definition.
This attribute is only processed when IncludeAnnotations is set to true.
Constructors
SchemaExampleAttribute(object)
Initializes a new instance of the SchemaExampleAttribute class.
public SchemaExampleAttribute(object example)
Parameters
exampleobjectThe example value for the JSON Schema.
Properties
Example
Gets the example value for the JSON Schema.
public object? Example { get; }