Closed tpoxa closed 1 year ago
Describe the bug Default tag does not work for array fields of a struct
To Reproduce
type Recipient struct { Routes []string `json:"routes,omitempty" title:"Routes" default:"A,B"` } func main() { r := jsonschema.Reflector{} sh, _ := r.Reflect(Recipient{}) j, _ := json.MarshalIndent(sh, "", " ") fmt.Println(string(j)) }
Expected behavior
{ "properties": { "routes": { "title": "Routes", "items": { "type": "string" }, "type": "array", "default":["A","B"] <-- Default value } }, "type": "object" }
Actual behaviour
{ "properties": { "routes": { "title": "Routes", "items": { "type": "string" }, "type": "array" } }, "type": "object" }
Additional context I checked with jsonschemavalidator.net that schema where default is set for an array is valid for Draft-7 I guess its quite a challenge to do for an object, but at-least basic type support would be great.
Describe the bug Default tag does not work for array fields of a struct
To Reproduce
Expected behavior
Actual behaviour
Additional context I checked with jsonschemavalidator.net that schema where default is set for an array is valid for Draft-7 I guess its quite a challenge to do for an object, but at-least basic type support would be great.