Skip to content

Commit 791a286

Browse files
Some fixes to json schema
1 parent 64fa5b1 commit 791a286

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

cmd/dipdup-gen/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func generateTypes(name, postfix string, schema *js.JSONSchema, types map[string
108108
resultType.Type = StringType
109109
case schema.Type == "object":
110110
var props map[string]js.JSONSchema
111-
if schema != nil && schema.ObjectItem != nil {
111+
if schema != nil && schema.Type == js.ItemTypeObject {
112112
props = schema.Properties
113113
}
114114

@@ -174,7 +174,7 @@ func generateField(title string, prop *js.JSONSchema, types map[string]goType) f
174174
func generateArrayItem(name string, prop *js.JSONSchema, types map[string]goType) goType {
175175
name = buildName(name, "Item")
176176

177-
if prop.ArrayItem != nil {
177+
if prop.ArrayItem.Items != nil {
178178
switch len(prop.Items) {
179179
case 0:
180180
return goType{

pkg/contract/evm.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (vm *EVM) createEntrypointsSchema(contractABI abi.ABI) (map[string]js.Type,
6161
return nil, err
6262
}
6363
if inputsBody != nil {
64-
typ.Inputs.ObjectItem = inputsBody
64+
typ.Inputs.ObjectItem = *inputsBody
6565
}
6666

6767
result[event.Name] = typ
@@ -88,15 +88,15 @@ func (vm *EVM) createEntrypointsSchema(contractABI abi.ABI) (map[string]js.Type,
8888
return nil, err
8989
}
9090
if inputsBody != nil {
91-
typ.Inputs.ObjectItem = inputsBody
91+
typ.Inputs.ObjectItem = *inputsBody
9292
}
9393

9494
outputsBody, err := getBodyByArgs(method.Outputs)
9595
if err != nil {
9696
return nil, err
9797
}
9898
if outputsBody != nil {
99-
typ.Outputs.ObjectItem = outputsBody
99+
typ.Outputs.ObjectItem = *outputsBody
100100
}
101101

102102
result[method.Name] = typ
@@ -155,7 +155,7 @@ func createSchemaItem(name string, idx int, typ *abi.Type) (js.JSONSchema, error
155155
return elem, err
156156
}
157157

158-
schema.ArrayItem = &js.ArrayItem{
158+
schema.ArrayItem = js.ArrayItem{
159159
Items: []js.JSONSchema{
160160
elem,
161161
},
@@ -167,7 +167,7 @@ func createSchemaItem(name string, idx int, typ *abi.Type) (js.JSONSchema, error
167167
schema := js.JSONSchema{
168168
Type: js.ItemTypeObject,
169169
Title: name,
170-
ObjectItem: &js.ObjectItem{
170+
ObjectItem: js.ObjectItem{
171171
Properties: make(map[string]js.JSONSchema),
172172
Required: make([]string, 0),
173173
},

pkg/jsonschema/json_schema.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ type JSONSchema struct {
2121
Examples []any `json:"examples,omitempty"`
2222
Enum []any `json:"enum,omitempty"`
2323

24-
InternalType string `json:"internal_type"`
24+
InternalType string `json:"internal_type,omitempty"`
2525
Index int `json:"index,omitempty"`
2626

27-
Type ItemType `json:"type"`
28-
*StringItem `json:",omitempty"`
29-
*NumberItem `json:",omitempty"`
30-
*ObjectItem `json:",omitempty"`
31-
*ArrayItem `json:",omitempty"`
27+
Type ItemType `json:"type"`
28+
StringItem
29+
NumberItem
30+
ObjectItem
31+
ArrayItem
3232
}
3333

3434
// ItemType -
@@ -109,5 +109,5 @@ type ArrayItem struct {
109109
MaxContains int64 `json:"maxContains,omitempty"`
110110
MinItems int64 `json:"minItems,omitempty"`
111111
MaxItems int64 `json:"maxItems,omitempty"`
112-
UniqueItems bool `json:"uniqueItems"`
112+
UniqueItems bool `json:"uniqueItems,omitempty"`
113113
}

0 commit comments

Comments
 (0)