@@ -34,6 +34,7 @@ public static class Crds
3434 private const string Double = "double" ;
3535 private const string Decimal = "decimal" ;
3636 private const string DateTime = "date-time" ;
37+ private const string Uuid = "uuid" ;
3738
3839 private static readonly string [ ] IgnoredToplevelProperties = [ "metadata" , "apiversion" , "kind" ] ;
3940
@@ -311,7 +312,7 @@ private static V1JSONSchemaProps Map(this MetadataLoadContext context, PropertyI
311312 if ( prop . GetCustomAttributesData < ValidationRuleAttribute > ( ) . ToArray ( ) is { Length : > 0 } validations )
312313 {
313314 props . XKubernetesValidations = validations
314- . Select ( validation => new V1ValidationRule ( )
315+ . Select ( validation => new V1ValidationRule
315316 {
316317 Rule = validation . GetCustomAttributeCtorArg < string > ( context , 0 ) ,
317318 FieldPath = validation . GetCustomAttributeCtorArg < string ? > ( context , 1 ) ,
@@ -360,7 +361,7 @@ private static V1JSONSchemaProps Map(this MetadataLoadContext context, Type type
360361 && i . GetGenericTypeDefinition ( ) . FullName == typeof ( IDictionary < , > ) . FullName ) ;
361362
362363 var additionalProperties = context . Map ( dictionaryImpl . GenericTypeArguments [ 1 ] ) ;
363- return new ( ) { Type = Object , AdditionalProperties = additionalProperties , } ;
364+ return new ( ) { Type = Object , AdditionalProperties = additionalProperties } ;
364365 }
365366
366367 if ( interfaceNames . Contains ( typeof ( IDictionary ) . FullName ) )
@@ -405,7 +406,7 @@ static Type GetRootBaseType(Type type)
405406 {
406407 "System.Object" => context . MapObjectType ( type ) ,
407408 "System.ValueType" => context . MapValueType ( type ) ,
408- "System.Enum" => new ( ) { Type = String , EnumProperty = GetEnumNames ( context , type ) , } ,
409+ "System.Enum" => new ( ) { Type = String , EnumProperty = context . GetEnumNames ( type ) } ,
409410 _ => throw InvalidType ( type ) ,
410411 } ;
411412 }
@@ -424,21 +425,11 @@ private static IList<object> GetEnumNames(this MetadataLoadContext context, Type
424425 }
425426 }
426427
427- var enumNames = new List < object > ( ) ;
428-
429- foreach ( var value in Enum . GetNames ( type ) )
430- {
431- if ( attributeNameByFieldName . TryGetValue ( value , out var name ) )
432- {
433- enumNames . Add ( name ) ;
434- }
435- else
436- {
437- enumNames . Add ( value ) ;
438- }
439- }
440-
441- return enumNames ;
428+ return Enum
429+ . GetNames ( type )
430+ . Select ( value => attributeNameByFieldName . GetValueOrDefault ( value , value ) )
431+ . Cast < object > ( )
432+ . ToList ( ) ;
442433#else
443434 return Enum . GetNames ( type ) ;
444435#endif
@@ -516,7 +507,7 @@ private static V1JSONSchemaProps MapEnumerationType(
516507 if ( listType . IsGenericType && listType . GetGenericTypeDefinition ( ) . FullName == typeof ( KeyValuePair < , > ) . FullName )
517508 {
518509 var additionalProperties = context . Map ( listType . GenericTypeArguments [ 1 ] ) ;
519- return new ( ) { Type = Object , AdditionalProperties = additionalProperties , } ;
510+ return new ( ) { Type = Object , AdditionalProperties = additionalProperties } ;
520511 }
521512
522513 var items = context . Map ( listType ) ;
@@ -532,8 +523,8 @@ private static V1JSONSchemaProps MapValueType(this MetadataLoadContext _, Type t
532523 "System.Double" => new ( ) { Type = Number , Format = Double } ,
533524 "System.Decimal" => new ( ) { Type = Number , Format = Decimal } ,
534525 "System.Boolean" => new ( ) { Type = Boolean } ,
535- "System.DateTime" => new ( ) { Type = String , Format = DateTime } ,
536- "System.DateTimeOffset " => new ( ) { Type = String , Format = DateTime } ,
526+ "System.DateTime" or "System.DateTimeOffset" => new ( ) { Type = String , Format = DateTime } ,
527+ "System.Guid " => new ( ) { Type = String , Format = Uuid } ,
537528 _ => throw InvalidType ( type ) ,
538529 } ;
539530
0 commit comments