diff --git a/reflect_test.go b/reflect_test.go index f56d680..265e54f 100644 --- a/reflect_test.go +++ b/reflect_test.go @@ -626,6 +626,27 @@ func TestUnsignedIntHandling(t *testing.T) { fixtureContains(t, "fixtures/unsigned_int_handling.json", `"maxItems": 0`) } +type NullableWithOddFields struct { + SimpleMap map[string]string `json:"simple_map"` + MapWithNullableValues map[string]*string `json:"map_with_nullable_values"` + + IntSlice []int `json:"int_slice"` + PointerToIntSlice *[]int `json:"pointer_to_int_slice"` + IntSliceWithNullableValues []*int `json:"int_slice_with_nullable_values"` + PointerToIntSliceWithNullableValues *[]*int `json:"pointer_to_int_slice_with_nullable_values"` + + Chan chan int `json:"chan"` + UnsafePointer unsafe.Pointer `json:"unsafe_pointer"` + Reader io.Reader `json:"reader"` +} + +func TestNullableFromType(t *testing.T) { + r := &Reflector{} + compareSchemaOutput(t, "fixtures/nullable_from_type_disabled.json", r, &NullableWithOddFields{}) + r.NullableFromType = true + compareSchemaOutput(t, "fixtures/nullable_from_type_enabled.json", r, &NullableWithOddFields{}) +} + type AliasObjectA struct { PropA string `json:"prop_a"` } @@ -660,24 +681,3 @@ func TestJSONSchemaAlias(t *testing.T) { compareSchemaOutput(t, "fixtures/schema_alias.json", r, &AliasObjectB{}) compareSchemaOutput(t, "fixtures/schema_alias_2.json", r, &AliasObjectC{}) } - -type NullableWithOddFields struct { - SimpleMap map[string]string `json:"simple_map"` - MapWithNullableValues map[string]*string `json:"map_with_nullable_values"` - - IntSlice []int `json:"int_slice"` - PointerToIntSlice *[]int `json:"pointer_to_int_slice"` - IntSliceWithNullableValues []*int `json:"int_slice_with_nullable_values"` - PointerToIntSliceWithNullableValues *[]*int `json:"pointer_to_int_slice_with_nullable_values"` - - Chan chan int `json:"chan"` - UnsafePointer unsafe.Pointer `json:"unsafe_pointer"` - Reader io.Reader `json:"reader"` -} - -func TestNullableFromType(t *testing.T) { - r := &Reflector{} - compareSchemaOutput(t, "fixtures/nullable_from_type_disabled.json", r, &NullableWithOddFields{}) - r.NullableFromType = true - compareSchemaOutput(t, "fixtures/nullable_from_type_enabled.json", r, &NullableWithOddFields{}) -}