-
Notifications
You must be signed in to change notification settings - Fork 271
Closed
Labels
type:enhancementEnhancement request targeting an existing experienceEnhancement request targeting an existing experience
Milestone
Description
Hi!
I'm writing an OpenApiOperation
extension using enum and I've noticed that it has a method named GetDisplayName
to use a display name instead of a enum name.
public static string GetDisplayName(this Enum enumValue) |
/// <summary>
/// Gets the enum display name.
/// </summary>
/// <param name="enumValue">The enum value.</param>
/// <returns>
/// Use <see cref="DisplayAttribute"/> if exists.
/// Otherwise, use the standard string representation.
/// </returns>
But, DisplayAttribute
is a private attribute and it's not possible to use them.
internal class DisplayAttribute : Attribute |
Is it possible to change this attribute to be public instead internal class?
Example of use:
//my enum, used on docOptions
public enum ApiLevel
{
[DisplayAttribute(Name = "private")]
Privada = 1,
[Display(Name = "public")]
Publica = 2,
[Display(Name = "corporate")]
Corporativa = 3
}
//my filter where i use the enum
internal class OpenApiExampleFilter : IOperationFilter
{
private readonly DocOptions _docOptions;
public OpenApiExampleFilter (DocOptions docOptions)
{
_docOptions = docOptions;
}
public void Apply(OpenApiOperation operation, OperationFilterContext context)
{
operation.AddExtension("x-test", new OpenApiObject
{
["apiLevel"] = new OpenApiString(_docOptions.ApiLevel.GetDisplayName()), //here i cant use GetDisplayName() :(
["apiDomain"] = new OpenApiString(_docOptions.ApiDomain)
});
}
}
Tks!
Metadata
Metadata
Assignees
Labels
type:enhancementEnhancement request targeting an existing experienceEnhancement request targeting an existing experience