Skip to content

Commit

Permalink
Merge pull request #18 from kaleido-io/optimize-jsonschema
Browse files Browse the repository at this point in the history
Optimize JSON Schema compilation
  • Loading branch information
peterbroadhurst authored Aug 16, 2022
2 parents 9358fd2 + 1ab8232 commit 57d32cc
Showing 1 changed file with 120 additions and 118 deletions.
238 changes: 120 additions & 118 deletions pkg/ffi2abi/ffi_param_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,141 +22,143 @@ import (

type ParamValidator struct{}

func (v *ParamValidator) Compile(ctx jsonschema.CompilerContext, m map[string]interface{}) (jsonschema.ExtSchema, error) {
return nil, nil
}

func (v *ParamValidator) GetMetaSchema() *jsonschema.Schema {
return jsonschema.MustCompileString("ffiParamDetails.json", `{
"$ref": "#/$defs/ethereumParam",
"$defs": {
"ethereumParam": {
"oneOf": [
{
"type": "object",
"properties": {
"type": {
"type": "string",
"not": {
"const": "object"
}
},
"details": {
"$ref": "#/$defs/details"
var compiledMetaSchema = jsonschema.MustCompileString("ffiParamDetails.json", `{
"$ref": "#/$defs/ethereumParam",
"$defs": {
"ethereumParam": {
"oneOf": [
{
"type": "object",
"properties": {
"type": {
"type": "string",
"not": {
"const": "object"
}
},
"required": [
"details"
]
"details": {
"$ref": "#/$defs/details"
}
},
{
"type": "object",
"properties": {
"type": {
"const": "object"
},
"details": {
"$ref": "#/$defs/details"
},
"properties": {
"type": "object",
"patternProperties": {
".*": {
"$ref": "#/$defs/ethereumObjectChildParam"
}
}
}
"required": [
"details"
]
},
{
"type": "object",
"properties": {
"type": {
"const": "object"
},
"details": {
"$ref": "#/$defs/details"
},
"required": [
"details",
"type"
]
}
]
},
"ethereumObjectChildParam": {
"oneOf": [
{
"type": "object",
"properties": {
"type": {
"type": "string",
"not": {
"const": "object"
"type": "object",
"patternProperties": {
".*": {
"$ref": "#/$defs/ethereumObjectChildParam"
}
},
"details": {
"$ref": "#/$defs/objectFieldDetails"
}
},
"required": [
"details"
]
}
},
{
"type": "object",
"properties": {
"type": {
"required": [
"details",
"type"
]
}
]
},
"ethereumObjectChildParam": {
"oneOf": [
{
"type": "object",
"properties": {
"type": {
"type": "string",
"not": {
"const": "object"
},
"details": {
"$ref": "#/$defs/objectFieldDetails"
},
"properties": {
"type": "object",
"patternProperties": {
".*": {
"$ref": "#/$defs/ethereumObjectChildParam"
}
}
}
},
"required": [
"details"
]
}
]
},
"details": {
"type": "object",
"properties": {
"type": {
"type": "string"
"details": {
"$ref": "#/$defs/objectFieldDetails"
}
},
"internalType": {
"type": "string"
"required": [
"details"
]
},
{
"type": "object",
"properties": {
"type": {
"const": "object"
},
"details": {
"$ref": "#/$defs/objectFieldDetails"
},
"properties": {
"type": "object",
"patternProperties": {
".*": {
"$ref": "#/$defs/ethereumObjectChildParam"
}
}
}
},
"indexed": {
"type": "boolean"
}
"required": [
"details"
]
}
]
},
"details": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"internalType": {
"type": "string"
},
"required": [
"type"
]
"indexed": {
"type": "boolean"
}
},
"objectFieldDetails": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"internalType": {
"type": "string"
},
"indexed": {
"type": "boolean"
},
"index": {
"type": "integer"
}
"required": [
"type"
]
},
"objectFieldDetails": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"required": [
"type",
"index"
]
}
"internalType": {
"type": "string"
},
"indexed": {
"type": "boolean"
},
"index": {
"type": "integer"
}
},
"required": [
"type",
"index"
]
}
}`)
}
}`)

func (v *ParamValidator) Compile(ctx jsonschema.CompilerContext, m map[string]interface{}) (jsonschema.ExtSchema, error) {
return nil, nil
}

func (v *ParamValidator) GetMetaSchema() *jsonschema.Schema {
return compiledMetaSchema
}

func (v *ParamValidator) GetExtensionName() string {
Expand Down

0 comments on commit 57d32cc

Please sign in to comment.