github.com/alecthomas/jsonschema@v0.0.0-20220216202328-9eeeec9d044b/examples/user.go (about) 1 package examples 2 3 import ( 4 "github.com/alecthomas/jsonschema/examples/nested" 5 ) 6 7 // User is used as a base to provide tests for comments. 8 // Don't forget to checkout the nested path. 9 type User struct { 10 // Unique sequential identifier. 11 ID int `json:"id" jsonschema:"required"` 12 // This comment will be ignored 13 Name string `json:"name" jsonschema:"required,minLength=1,maxLength=20,pattern=.*,description=this is a property,title=the name,example=joe,example=lucy,default=alex"` 14 Friends []int `json:"friends,omitempty" jsonschema_description:"list of IDs, omitted when empty"` 15 Tags map[string]interface{} `json:"tags,omitempty"` 16 17 // An array of pets the user cares for. 18 Pets []*nested.Pet `json:"pets"` 19 20 // Set of plants that the user likes 21 Plants []*nested.Plant `json:"plants" jsonschema:"title=Pants"` 22 }