@@ -14,6 +14,7 @@ public readonly record struct TypeData(
1414 bool IsDateTime ,
1515 bool IsBinary ,
1616 bool IsValueType ,
17+ bool IsUnixTimestamp ,
1718 int AnyOfCount ,
1819 int OneOfCount ,
1920 int AllOfCount ,
@@ -35,6 +36,7 @@ public readonly record struct TypeData(
3536 IsDateTime : false ,
3637 IsBinary : false ,
3738 IsValueType : false ,
39+ IsUnixTimestamp : false ,
3840 AnyOfCount : 0 ,
3941 OneOfCount : 0 ,
4042 AllOfCount : 0 ,
@@ -61,15 +63,18 @@ CSharpTypeWithoutNullability is "string" or "int" or "long" or "float" or "doubl
6163 IsAnyOf ||
6264 IsEnum ;
6365
64- public string ConverterType => IsEnum || ( ( AnyOfCount > 0 || OneOfCount > 0 || AllOfCount > 0 ) && IsComponent )
65- ? $ "global::OpenApiGenerator.JsonConverters.{ ShortCSharpTypeWithoutNullability } JsonConverter"
66- : AnyOfCount > 0
67- ? $ "global::OpenApiGenerator.JsonConverters.AnyOfJsonConverterFactory{ AnyOfCount } "
68- : OneOfCount > 0
69- ? $ "global::OpenApiGenerator.JsonConverters.OneOfJsonConverterFactory{ OneOfCount } "
70- : AllOfCount > 0
71- ? $ "global::OpenApiGenerator.JsonConverters.AllOfJsonConverterFactory{ AllOfCount } "
72- : string . Empty ;
66+ public string ConverterType =>
67+ IsUnixTimestamp
68+ ? "global::OpenApiGenerator.JsonConverters.UnixTimestampJsonConverter"
69+ : IsEnum || ( ( AnyOfCount > 0 || OneOfCount > 0 || AllOfCount > 0 ) && IsComponent )
70+ ? $ "global::OpenApiGenerator.JsonConverters.{ ShortCSharpTypeWithoutNullability } JsonConverter"
71+ : AnyOfCount > 0
72+ ? $ "global::OpenApiGenerator.JsonConverters.AnyOfJsonConverterFactory{ AnyOfCount } "
73+ : OneOfCount > 0
74+ ? $ "global::OpenApiGenerator.JsonConverters.OneOfJsonConverterFactory{ OneOfCount } "
75+ : AllOfCount > 0
76+ ? $ "global::OpenApiGenerator.JsonConverters.AllOfJsonConverterFactory{ AllOfCount } "
77+ : string . Empty ;
7378
7479 public static TypeData FromSchemaContext ( SchemaContext context )
7580 {
@@ -149,6 +154,7 @@ Default with
149154 IsDate : context . Schema . IsDate ( ) ,
150155 IsDateTime : context . Schema . IsDateTime ( ) ,
151156 IsBinary : context . Schema . IsBinary ( ) ,
157+ IsUnixTimestamp : context . Schema . IsUnixTimestamp ( ) ,
152158 AnyOfCount : context . Schema . AnyOf ? . Count ?? 0 ,
153159 OneOfCount : context . Schema . OneOf ? . Count ?? 0 ,
154160 AllOfCount : context . Schema . AllOf ? . Count ?? 0 ,
@@ -188,6 +194,8 @@ public static string GetCSharpType(SchemaContext context, SchemaContext? additio
188194
189195 var ( type , reference ) = ( context . Schema . Type , context . Schema . Format ) switch
190196 {
197+ ( _, _) when context . Schema . IsUnixTimestamp ( ) => ( "global::System.DateTimeOffset" , false ) ,
198+
191199 ( _, _) when context . Schema . IsAnyOf ( ) && context . IsComponent => ( $ "global::{ context . Settings . Namespace } .{ context . Id } ", true ) ,
192200 ( _, _) when context . Schema . IsOneOf ( ) && context . IsComponent => ( $ "global::{ context . Settings . Namespace } .{ context . Id } ", true ) ,
193201 ( _, _) when context . Schema . IsAllOf ( ) && context . IsComponent => ( $ "global::{ context . Settings . Namespace } .{ context . Id } ", true ) ,
0 commit comments