diff --git a/jsonschema/reflection.go b/jsonschema/reflection.go index e86d071..bcc6c21 100644 --- a/jsonschema/reflection.go +++ b/jsonschema/reflection.go @@ -145,11 +145,18 @@ func (r *Reflector) reflectStruct(definitions Definitions, t reflect.Type) (*Typ interactionText := reflect.New(t).MethodByName("InteractionText").Call(dummyInputs)[0].String() + descriptionMethod := reflect.New(t).MethodByName("Description") + + description := "Build a " + name + if descriptionMethod.IsValid() { + description = descriptionMethod.Call(dummyInputs)[0].String() + } + st := &Type{ Name: name, Type: defType, Properties: orderedmap.New(), - Description: "Build a " + name, + Description: description, InteractionText: interactionText, } definitions[r.typeName(t)] = st diff --git a/jsonschema/reflection_test.go b/jsonschema/reflection_test.go index aaa9756..6da4f3e 100644 --- a/jsonschema/reflection_test.go +++ b/jsonschema/reflection_test.go @@ -41,6 +41,10 @@ func (a action) InteractionText() string { return "§Name §Costs §Time §MultipleUse" } +func (a action) Description() string { + return "This allows you to build an Action-card" +} + type costs []cost func (c costs) Validate() error {