domaindrivendev / Swashbuckle.WebApi

Seamlessly adds a swagger to WebApi projects!
BSD 3-Clause "New" or "Revised" License
3.07k stars 678 forks source link

<example> value is not used by enum values #1402

Open aureole82 opened 3 years ago

aureole82 commented 3 years ago

The <example> 756 </example> value is not recognized by Swagger UI.

VERSION:

5.6.3

STEPS TO REPRODUCE:

public class SearchQueryViewModel
{
    /// <summary> ISO 3166 code of the country where to search (required). </summary>
    /// <example> 756 </example>
    [Required]
    [EnumDataType(typeof(Country), ErrorMessage = "Unknown ISO 3166 country code.")]
    public Country Country { get; set; }

Country is an enum:

public enum Country
{
    [Description("Andorra")] Ad = 20,
    [Description("United Arab Emirates")] Ae = 784,
    [Description("Afghanistan")] Af = 4,

EXPECTED RESULT:

Provide a description and example of the expected result image

ACTUAL RESULT:

Provide a description of the actual behavior you're observing image (4 is the smallest value of the Country enum.)

aureole82 commented 3 years ago

I've just realized this issue is fixed in Swashbuckle.AspNetCore Version 6.1.1. Is this correct?