@@ -38,6 +38,7 @@ public static T GetAttributeOfType<T>(this Enum enumValue) where T : Attribute
38
38
/// Use <see cref="DisplayAttribute"/> if exists.
39
39
/// Otherwise, use the standard string representation.
40
40
/// </returns>
41
+ [ Obsolete ( "Use native AoT-friendly type-specific overloads GetDisplayName methods instead." ) ]
41
42
public static string GetDisplayName ( this Enum enumValue )
42
43
{
43
44
var attribute = enumValue . GetAttributeOfType < DisplayAttribute > ( ) ;
@@ -58,21 +59,21 @@ public static string GetDisplayName(this Enum enumValue)
58
59
ParameterStyle . SpaceDelimited => "spaceDelimited" ,
59
60
ParameterStyle . PipeDelimited => "pipeDelimited" ,
60
61
ParameterStyle . DeepObject => "deepObject" ,
61
- _ => parameterStyle . ToString ( )
62
+ _ => throw new InvalidOperationException ( $ "Unknown parameter style: { parameterStyle } " )
62
63
} ;
63
64
64
65
/// <summary>
65
66
/// Gets the enum display for name <see cref="ParameterLocation" /> without the use of reflection.
66
67
/// </summary>
67
68
/// <param name="parameterLocation">The enum value.</param>
68
69
/// <returns>The display string to use.</returns>
69
- internal static string GetDisplayName ( this ParameterLocation parameterLocation ) => parameterLocation switch
70
+ public static string GetDisplayName ( this ParameterLocation parameterLocation ) => parameterLocation switch
70
71
{
71
72
ParameterLocation . Query => "query" ,
72
73
ParameterLocation . Header => "header" ,
73
74
ParameterLocation . Path => "path" ,
74
75
ParameterLocation . Cookie => "cookie" ,
75
- _ => parameterLocation . ToString ( )
76
+ _ => throw new InvalidOperationException ( $ "Unknown parameter location: { parameterLocation } " )
76
77
} ;
77
78
78
79
/// <summary>
@@ -92,7 +93,7 @@ public static string GetDisplayName(this Enum enumValue)
92
93
ReferenceType . Link => "links" ,
93
94
ReferenceType . Callback => "callbacks" ,
94
95
ReferenceType . Tag => "tags" ,
95
- _ => referenceType . ToString ( )
96
+ _ => throw new InvalidOperationException ( $ "Unknown reference type: { referenceType } " )
96
97
} ;
97
98
98
99
/// <summary>
@@ -110,7 +111,7 @@ public static string GetDisplayName(this Enum enumValue)
110
111
OperationType . Head => "head" ,
111
112
OperationType . Patch => "patch" ,
112
113
OperationType . Trace => "trace" ,
113
- _ => operationType . ToString ( )
114
+ _ => throw new InvalidOperationException ( $ "Unknown operation type: { operationType } " )
114
115
} ;
115
116
116
117
/// <summary>
@@ -124,7 +125,7 @@ public static string GetDisplayName(this Enum enumValue)
124
125
SecuritySchemeType . Http => "http" ,
125
126
SecuritySchemeType . OAuth2 => "oauth2" ,
126
127
SecuritySchemeType . OpenIdConnect => "openIdConnect" ,
127
- _ => securitySchemeType . ToString ( )
128
+ _ => throw new InvalidOperationException ( $ "Unknown security scheme type: { securitySchemeType } " )
128
129
} ;
129
130
}
130
131
}
0 commit comments