Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

got nil pointer when using costom JSONSchema func #84

Open
eternal-dragon opened this issue Jul 13, 2023 · 1 comment
Open

got nil pointer when using costom JSONSchema func #84

eternal-dragon opened this issue Jul 13, 2023 · 1 comment

Comments

@eternal-dragon
Copy link

func (Coustom) JSONSchema() *jsonschema.Schema { return &jsonschema.Schema{ Type:"string", } }

I just add this func to my coustom struct, and got a nil pointer from here:

github.com/invopop/jsonschema.(*Reflector).reflectCustomSchema(0x7f6855c136f8?, 0x7f687f7d8108?, {0xbe1478, 0xad3980})
/home/XXX/go/pkg/mod/github.com/invopop/[email protected]/reflect.go:423 +0xb0
github.com/invopop/jsonschema.(*Reflector).reflectTypeToSchema(0xc00021fa58, 0xc00021f960?, {0xbe1478, 0xad3980})
/home/XXX/go/pkg/mod/github.com/invopop/[email protected]/reflect.go:348 +0x89
github.com/invopop/jsonschema.(*Reflector).reflectTypeToSchemaWithID(0xc00021fa58, 0xbe1478?, {0xbe1478, 0xad3980})
/home/XXX/go/pkg/mod/github.com/invopop/[email protected]/reflect.go:324 +0x2c
github.com/invopop/jsonschema.(*Reflector).ReflectFromType(0xc00021fa58, {0xbe1478, 0xad3980})
/home/XXX/go/pkg/mod/github.com/invopop/[email protected]/reflect.go:244 +0xf3
github.com/invopop/jsonschema.(*Reflector).Reflect(0xb0?, {0xad3980?, 0xc0000c3340?})
/home/XXX/go/pkg/mod/github.com/invopop/[email protected]/reflect.go:230 +0x4a

I tried func (*Coustom) JSONSchema() *jsonschema.Schema ,but still got the same error.

Did I make a mistake somewhere?

@eternal-dragon
Copy link
Author

And if I try to add type on field, it will be like :
"XXX": { "$ref": "#/$defs/Coustom", "type": "string" },
It has both type and ref. I want it only have type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant