@@ -16,10 +16,10 @@ public static class OpenApiTypeMapper
16
16
{
17
17
[ typeof ( bool ) ] = ( ) => new ( ) { Type = "boolean" } ,
18
18
[ 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" } ,
23
23
[ typeof ( float ) ] = ( ) => new ( ) { Type = "number" , Format = "float" } ,
24
24
[ typeof ( double ) ] = ( ) => new ( ) { Type = "number" , Format = "double" } ,
25
25
[ typeof ( decimal ) ] = ( ) => new ( ) { Type = "number" , Format = "double" } ,
@@ -31,10 +31,10 @@ public static class OpenApiTypeMapper
31
31
// Nullable types
32
32
[ typeof ( bool ? ) ] = ( ) => new ( ) { Type = "boolean" , Nullable = true } ,
33
33
[ 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 } ,
38
38
[ typeof ( float ? ) ] = ( ) => new ( ) { Type = "number" , Format = "float" , Nullable = true } ,
39
39
[ typeof ( double ? ) ] = ( ) => new ( ) { Type = "number" , Format = "double" , Nullable = true } ,
40
40
[ typeof ( decimal ? ) ] = ( ) => new ( ) { Type = "number" , Format = "double" , Nullable = true } ,
@@ -98,8 +98,9 @@ public static Type MapOpenApiPrimitiveTypeToSimpleType(this OpenApiSchema schema
98
98
var type = ( schema . Type ? . ToLowerInvariant ( ) , schema . Format ? . ToLowerInvariant ( ) , schema . Nullable ) switch
99
99
{
100
100
( "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 ) ,
103
104
( "integer" , null , false ) => typeof ( int ) ,
104
105
( "number" , "float" , false ) => typeof ( float ) ,
105
106
( "number" , "double" , false ) => typeof ( double ) ,
@@ -113,8 +114,8 @@ public static Type MapOpenApiPrimitiveTypeToSimpleType(this OpenApiSchema schema
113
114
( "string" , null , false ) => typeof ( string ) ,
114
115
( "object" , null , false ) => typeof ( object ) ,
115
116
( "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 ? ) ,
118
119
( "integer" , null , true ) => typeof ( int ? ) ,
119
120
( "number" , "float" , true ) => typeof ( float ? ) ,
120
121
( "number" , "double" , true ) => typeof ( double ? ) ,
0 commit comments