@@ -16,10 +16,10 @@ public static class OpenApiTypeMapper
1616 {
1717 [ typeof ( bool ) ] = ( ) => new ( ) { Type = "boolean" } ,
1818 [ typeof ( byte ) ] = ( ) => new ( ) { Type = "string" , Format = "byte" } ,
19- [ typeof ( int ) ] = ( ) => new ( ) { Type = "integer " , Format = "int32" } ,
20- [ typeof ( uint ) ] = ( ) => new ( ) { Type = "integer " , Format = "int32" } ,
21- [ typeof ( long ) ] = ( ) => new ( ) { Type = "integer " , Format = "int64" } ,
22- [ typeof ( ulong ) ] = ( ) => new ( ) { Type = "integer " , Format = "int64" } ,
19+ [ typeof ( int ) ] = ( ) => new ( ) { Type = "number " , Format = "int32" } ,
20+ [ typeof ( uint ) ] = ( ) => new ( ) { Type = "number " , Format = "int32" } ,
21+ [ typeof ( long ) ] = ( ) => new ( ) { Type = "number " , Format = "int64" } ,
22+ [ typeof ( ulong ) ] = ( ) => new ( ) { Type = "number " , Format = "int64" } ,
2323 [ typeof ( float ) ] = ( ) => new ( ) { Type = "number" , Format = "float" } ,
2424 [ typeof ( double ) ] = ( ) => new ( ) { Type = "number" , Format = "double" } ,
2525 [ typeof ( decimal ) ] = ( ) => new ( ) { Type = "number" , Format = "double" } ,
@@ -31,10 +31,10 @@ public static class OpenApiTypeMapper
3131 // Nullable types
3232 [ typeof ( bool ? ) ] = ( ) => new ( ) { Type = "boolean" , Nullable = true } ,
3333 [ typeof ( byte ? ) ] = ( ) => new ( ) { Type = "string" , Format = "byte" , Nullable = true } ,
34- [ typeof ( int ? ) ] = ( ) => new ( ) { Type = "integer " , Format = "int32" , Nullable = true } ,
35- [ typeof ( uint ? ) ] = ( ) => new ( ) { Type = "integer " , Format = "int32" , Nullable = true } ,
36- [ typeof ( long ? ) ] = ( ) => new ( ) { Type = "integer " , Format = "int64" , Nullable = true } ,
37- [ typeof ( ulong ? ) ] = ( ) => new ( ) { Type = "integer " , Format = "int64" , Nullable = true } ,
34+ [ typeof ( int ? ) ] = ( ) => new ( ) { Type = "number " , Format = "int32" , Nullable = true } ,
35+ [ typeof ( uint ? ) ] = ( ) => new ( ) { Type = "number " , Format = "int32" , Nullable = true } ,
36+ [ typeof ( long ? ) ] = ( ) => new ( ) { Type = "number " , Format = "int64" , Nullable = true } ,
37+ [ typeof ( ulong ? ) ] = ( ) => new ( ) { Type = "number " , Format = "int64" , Nullable = true } ,
3838 [ typeof ( float ? ) ] = ( ) => new ( ) { Type = "number" , Format = "float" , Nullable = true } ,
3939 [ typeof ( double ? ) ] = ( ) => new ( ) { Type = "number" , Format = "double" , Nullable = true } ,
4040 [ typeof ( decimal ? ) ] = ( ) => new ( ) { Type = "number" , Format = "double" , Nullable = true } ,
@@ -98,8 +98,9 @@ public static Type MapOpenApiPrimitiveTypeToSimpleType(this OpenApiSchema schema
9898 var type = ( schema . Type ? . ToLowerInvariant ( ) , schema . Format ? . ToLowerInvariant ( ) , schema . Nullable ) switch
9999 {
100100 ( "boolean" , null , false ) => typeof ( bool ) ,
101- ( "integer" , "int32" , false ) => typeof ( int ) ,
102- ( "integer" , "int64" , false ) => typeof ( long ) ,
101+ // integer is technically not valid with format, but we must provide some compatibility
102+ ( "integer" or "number" , "int32" , false ) => typeof ( int ) ,
103+ ( "integer" or "number" , "int64" , false ) => typeof ( long ) ,
103104 ( "integer" , null , false ) => typeof ( int ) ,
104105 ( "number" , "float" , false ) => typeof ( float ) ,
105106 ( "number" , "double" , false ) => typeof ( double ) ,
@@ -113,8 +114,8 @@ public static Type MapOpenApiPrimitiveTypeToSimpleType(this OpenApiSchema schema
113114 ( "string" , null , false ) => typeof ( string ) ,
114115 ( "object" , null , false ) => typeof ( object ) ,
115116 ( "string" , "uri" , false ) => typeof ( Uri ) ,
116- ( "integer" , "int32" , true ) => typeof ( int ? ) ,
117- ( "integer" , "int64" , true ) => typeof ( long ? ) ,
117+ ( "integer" or "number" , "int32" , true ) => typeof ( int ? ) ,
118+ ( "integer" or "number" , "int64" , true ) => typeof ( long ? ) ,
118119 ( "integer" , null , true ) => typeof ( int ? ) ,
119120 ( "number" , "float" , true ) => typeof ( float ? ) ,
120121 ( "number" , "double" , true ) => typeof ( double ? ) ,
0 commit comments