Skip to content

Commit

Permalink
add possibility to define individuel description
Browse files Browse the repository at this point in the history
  • Loading branch information
nlsui committed Apr 26, 2021
1 parent afe005a commit fd5f580
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion jsonschema/reflection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions jsonschema/reflection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit fd5f580

Please sign in to comment.