0

I have dto with several fields

For example

    public class SupplierModel
{
    public string SupplierNameNormalized { get; set; }
    
    public string PostalCode { get; set; }
    
    public string City { get; set; }
}

I want to write attribute [MarkNonNullablePropertiesAsRequired] to mark all fields as required, so swagger can show them as required when project, launched.

I created class for attribute

[AttributeUsage(AttributeTargets.Class)]
public class MarkNonNullablePropertiesAsRequired: Attribute
{
    
}

How I can do this correctly and what I need to write inside class?

Eugene Sukh
  • 1,997
  • 4
  • 25
  • 64
  • Can you show your attemp on doing that? We can then help from wherever you get stuck. You can use this as reference [this](https://stackoverflow.com/questions/4879521/how-to-create-a-custom-attribute-in-c-sharp/4879579#4879579) and [this](https://docs.microsoft.com/en-us/dotnet/standard/attributes/writing-custom-attributes) – Rodrigo Rodrigues Apr 19 '22 at 14:37

0 Answers0