From ecc9c07837b5b80a57271b307d8748ecde12b663 Mon Sep 17 00:00:00 2001 From: Trevor Judice <tjudice@gfxlabs.io> Date: Fri, 23 Dec 2022 02:50:31 +0000 Subject: [PATCH] Add missing objects to match openrpc spec --- openrpc/types/types.go | 46 +++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/openrpc/types/types.go b/openrpc/types/types.go index df2b5cb..83cf8ca 100644 --- a/openrpc/types/types.go +++ b/openrpc/types/types.go @@ -63,9 +63,10 @@ type Schema struct { } type Param struct { - Name string `json:"name"` - Required bool `json:"required"` - Schema Schema `json:"schema"` + Name string `json:"name"` + Description string `json:"description,omitempty"` + Required bool `json:"required"` + Schema Schema `json:"schema"` } type Result struct { @@ -74,10 +75,41 @@ type Result struct { } type Method struct { - Name string `json:"name"` - Summary string `json:"summary"` - Params []Param `json:"params"` - Result Result `json:"result"` + Name string `json:"name"` + Tags []Tag `json:"tags,omitempty"` + Summary string `json:"summary"` + Params []Param `json:"params"` + Result Result `json:"result"` + Examples []ExamplePairing `json:"examples,omitempty"` +} + +type Tag struct { + Ref string `json:"$ref,omitempty"` + Name string `json:"name"` + Summary string `json:"summary,omitempty"` + Description string `json:"description,omitempty"` + ExternalDocs ExternalDocumentation `json:"externalDocs,omitempty"` +} + +type ExternalDocumentation struct { + Description string `json:"description,omitempty"` + URL string `json:"url"` +} + +type ExamplePairing struct { + Name string `json:"name"` + Description string `json:"description,omitempty"` + Summary string `json:"summary,omitempty"` + Params []Example `json:"params"` + Result Example `json:"result"` +} + +type Example struct { + Ref string `json:"$ref,omitempty"` + Name string `json:"name"` + Summary string `json:"summary,omitempty"` + Description string `json:"description,omitempty"` + Value any `json:"value"` } func (m *Method) Namespace() string { -- GitLab