@@ -6,6 +6,7 @@ package jsonschema_test
66
77import (
88 "log/slog"
9+ "math"
910 "math/big"
1011 "reflect"
1112 "strings"
@@ -49,12 +50,46 @@ func TestFor(t *testing.T) {
4950 want * jsonschema.Schema
5051 }
5152
53+ f64Ptr := jsonschema .Ptr [float64 ]
54+
5255 tests := func (ignore bool ) []test {
5356 return []test {
5457 {"string" , forType [string ](ignore ), & schema {Type : "string" }},
58+ {
59+ "int8" ,
60+ forType [int8 ](ignore ),
61+ & schema {Type : "integer" , Minimum : f64Ptr (math .MinInt8 ), Maximum : f64Ptr (math .MaxInt8 )},
62+ },
63+ {
64+ "uint8" ,
65+ forType [uint8 ](ignore ),
66+ & schema {Type : "integer" , Minimum : f64Ptr (0 ), Maximum : f64Ptr (math .MaxUint8 )},
67+ },
68+ {
69+ "int16" ,
70+ forType [int16 ](ignore ),
71+ & schema {Type : "integer" , Minimum : f64Ptr (math .MinInt16 ), Maximum : f64Ptr (math .MaxInt16 )},
72+ },
73+ {
74+ "uint16" ,
75+ forType [uint16 ](ignore ),
76+ & schema {Type : "integer" , Minimum : f64Ptr (0 ), Maximum : f64Ptr (math .MaxUint16 )},
77+ },
78+ {
79+ "int32" ,
80+ forType [int32 ](ignore ),
81+ & schema {Type : "integer" , Minimum : f64Ptr (math .MinInt32 ), Maximum : f64Ptr (math .MaxInt32 )},
82+ },
83+ {
84+ "uint32" ,
85+ forType [uint32 ](ignore ),
86+ & schema {Type : "integer" , Minimum : f64Ptr (0 ), Maximum : f64Ptr (math .MaxUint32 )},
87+ },
88+ {"int64" , forType [int64 ](ignore ), & schema {Type : "integer" }},
89+ {"uint64" , forType [uint64 ](ignore ), & schema {Type : "integer" , Minimum : f64Ptr (0 )}},
5590 {"int" , forType [int ](ignore ), & schema {Type : "integer" }},
56- {"int16 " , forType [int16 ](ignore ), & schema {Type : "integer" }},
57- {"uint32 " , forType [int16 ](ignore ), & schema {Type : "integer" }},
91+ {"uint " , forType [uint ](ignore ), & schema {Type : "integer" , Minimum : f64Ptr ( 0 ) }},
92+ {"uintptr " , forType [uintptr ](ignore ), & schema {Type : "integer" , Minimum : f64Ptr ( 0 ) }},
5893 {"float64" , forType [float64 ](ignore ), & schema {Type : "number" }},
5994 {"bool" , forType [bool ](ignore ), & schema {Type : "boolean" }},
6095 {"time" , forType [time.Time ](ignore ), & schema {Type : "string" }},
@@ -65,6 +100,10 @@ func TestFor(t *testing.T) {
65100 Type : "object" ,
66101 AdditionalProperties : & schema {Type : "integer" },
67102 }},
103+ {"int8map" , forType [map [string ]int8 ](ignore ), & schema {
104+ Type : "object" ,
105+ AdditionalProperties : & schema {Type : "integer" , Minimum : f64Ptr (math .MinInt8 ), Maximum : f64Ptr (math .MaxInt8 )},
106+ }},
68107 {"anymap" , forType [map [string ]any ](ignore ), & schema {
69108 Type : "object" ,
70109 AdditionalProperties : & schema {},
0 commit comments