@@ -38,6 +38,7 @@ public static T GetAttributeOfType<T>(this Enum enumValue) where T : Attribute
3838 /// Use <see cref="DisplayAttribute"/> if exists.
3939 /// Otherwise, use the standard string representation.
4040 /// </returns>
41+ [ Obsolete ( "Use native AoT-friendly type-specific overloads GetDisplayName methods instead." ) ]
4142 public static string GetDisplayName ( this Enum enumValue )
4243 {
4344 var attribute = enumValue . GetAttributeOfType < DisplayAttribute > ( ) ;
@@ -58,21 +59,21 @@ public static string GetDisplayName(this Enum enumValue)
5859 ParameterStyle . SpaceDelimited => "spaceDelimited" ,
5960 ParameterStyle . PipeDelimited => "pipeDelimited" ,
6061 ParameterStyle . DeepObject => "deepObject" ,
61- _ => parameterStyle . ToString ( )
62+ _ => throw new InvalidOperationException ( $ "Unknown parameter style: { parameterStyle } " )
6263 } ;
6364
6465 /// <summary>
6566 /// Gets the enum display for name <see cref="ParameterLocation" /> without the use of reflection.
6667 /// </summary>
6768 /// <param name="parameterLocation">The enum value.</param>
6869 /// <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
7071 {
7172 ParameterLocation . Query => "query" ,
7273 ParameterLocation . Header => "header" ,
7374 ParameterLocation . Path => "path" ,
7475 ParameterLocation . Cookie => "cookie" ,
75- _ => parameterLocation . ToString ( )
76+ _ => throw new InvalidOperationException ( $ "Unknown parameter location: { parameterLocation } " )
7677 } ;
7778
7879 /// <summary>
@@ -92,7 +93,7 @@ public static string GetDisplayName(this Enum enumValue)
9293 ReferenceType . Link => "links" ,
9394 ReferenceType . Callback => "callbacks" ,
9495 ReferenceType . Tag => "tags" ,
95- _ => referenceType . ToString ( )
96+ _ => throw new InvalidOperationException ( $ "Unknown reference type: { referenceType } " )
9697 } ;
9798
9899 /// <summary>
@@ -110,7 +111,7 @@ public static string GetDisplayName(this Enum enumValue)
110111 OperationType . Head => "head" ,
111112 OperationType . Patch => "patch" ,
112113 OperationType . Trace => "trace" ,
113- _ => operationType . ToString ( )
114+ _ => throw new InvalidOperationException ( $ "Unknown operation type: { operationType } " )
114115 } ;
115116
116117 /// <summary>
@@ -124,7 +125,7 @@ public static string GetDisplayName(this Enum enumValue)
124125 SecuritySchemeType . Http => "http" ,
125126 SecuritySchemeType . OAuth2 => "oauth2" ,
126127 SecuritySchemeType . OpenIdConnect => "openIdConnect" ,
127- _ => securitySchemeType . ToString ( )
128+ _ => throw new InvalidOperationException ( $ "Unknown security scheme type: { securitySchemeType } " )
128129 } ;
129130 }
130131}
0 commit comments