Skip to content

Enum summary does not work when supplied on the property #2120

@k290

Description

@k290

Consider the below model used for an API endpoint

    public class VideoEventCreateDto 

        /// <summary>
        /// Image Type desc
        /// </summary>
        [Required]
        public ImageType ImageFileType { get; set; }
    }
    
        [JsonConverter(typeof(JsonStringEnumConverter))]
    public enum ImageType
    {
        Jpeg,
        Png,
        Bmp,
    }

No description tag comes through in the swagger.json. Similar issue with other xml comments like <example>
Swashbuckle version 6.1.4

It does however work if you supply it only on the enum:

    public class VideoEventCreateDto 


        [Required]
        public ImageType ImageFileType { get; set; }
    }
            /// <summary>
        /// Image Type desc
        /// </summary>
        [JsonConverter(typeof(JsonStringEnumConverter))]
    public enum ImageType
    {
        Jpeg,
        Png,
        Bmp,
    }

However, I think it would be an improvement to allow it to be supplied on the property, as this is more consistent with how XML comments work on other valuetypes such as datetime. You could have different XML comments depending on the use case.

Unfortunately, to be backward compatible, you may need to implement logic to say that if the XML is supplied on the property, then it takes precedence over what is supplied on the enum. Or some similar logic

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions