Swashbuckle.WebApi icon indicating copy to clipboard operation
Swashbuckle.WebApi copied to clipboard

<example> value is not used by enum values

Open aureole82 opened this issue 4 years ago • 1 comments

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 avatar Feb 02 '21 13:02 aureole82

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

aureole82 avatar Apr 13 '21 15:04 aureole82