Skip to content

ExpandedStruct panics with primitive types #163

@slinkydeveloper

Description

@slinkydeveloper

Reproducer:

import (
	"fmt"
	"github.com/invopop/jsonschema"
)

func main() {
	reflector := jsonschema.Reflector{ExpandedStruct: true}
	schema := reflector.Reflect("some string")

	fmt.Printf("%v", schema)
}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4d8eb6]

goroutine 1 [running]:
github.com/invopop/jsonschema.(*Reflector).ReflectFromType(0xc0000b5eb8, {0x541dd8, 0x4ed2c0})
	/home/slinkydeveloper/go/pkg/mod/github.com/invopop/[email protected]/reflect.go:191 +0x196
github.com/invopop/jsonschema.(*Reflector).Reflect(0x0?, {0x4ed2c0?, 0x53f418?})
	/home/slinkydeveloper/go/pkg/mod/github.com/invopop/[email protected]/reflect.go:175 +0x45

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions