Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19,105 changes: 10,546 additions & 8,559 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@easyops-cn/docusaurus-search-local": "0.52.2",
"@graphql-inspector/core": "~3.3.0",
"@mdx-js/react": "^3.0.0",
"@open-rpc/docusaurus-plugin": "0.1.6",
"@open-rpc/docusaurus-plugin": "0.2.0",
"clsx": "^2.1.1",
"docusaurus-plugin-copy-page-button": "^0.3.5",
"graphql": "~16.3.0",
Expand All @@ -48,5 +48,8 @@
"react-dom": "^19.0.0",
"remark-gfm": "~4.0.1",
"typescript": "~5.6.2"
},
"overrides": {
"webpack": "5.106.2"
}
}
2 changes: 1 addition & 1 deletion tools/cmd/speccheck/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"regexp"
"strings"

openrpc "github.com/open-rpc/meta-schema"
openrpc "github.com/open-rpc/spec-types/generated/packages/go/v1_4"
"github.com/santhosh-tekuri/jsonschema/v5"
)

Expand Down
2 changes: 1 addition & 1 deletion tools/cmd/speccheck/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"os"

openrpc "github.com/open-rpc/meta-schema"
openrpc "github.com/open-rpc/spec-types/generated/packages/go/v1_4"
)

type ContentDescriptor struct {
Expand Down
2 changes: 1 addition & 1 deletion tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/ethereum/go-ethereum v1.17.3-0.20260413114535-ecae519972c0
github.com/holiman/uint256 v1.3.2
github.com/mattn/go-jsonpointer v0.0.1
github.com/open-rpc/meta-schema v0.0.0-20210416041958-626a15d0a618
github.com/open-rpc/spec-types/generated/packages/go v0.1.1
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2
golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3
Expand Down
4 changes: 2 additions & 2 deletions tools/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9k
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/open-rpc/meta-schema v0.0.0-20210416041958-626a15d0a618 h1:EoH8oqYGi6BElF3PnUr65GoPVTtaDlnYkrVZct1Q/Sg=
github.com/open-rpc/meta-schema v0.0.0-20210416041958-626a15d0a618/go.mod h1:Ag6rSXkHIckQmjFBCweJEEt1mrTPBv8b9W4aU/NQWfI=
github.com/open-rpc/spec-types/generated/packages/go v0.1.1 h1:eznQY3vMHCOy8ja79aUmBVhj2lEmpjqmLmscgMdVnBs=
github.com/open-rpc/spec-types/generated/packages/go v0.1.1/go.mod h1:rYSefdRESnIagAH8sxqBc2ThCLPsJZMGd1O0PQoVRHc=
github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7 h1:oYW+YCJ1pachXTQmzR3rNLYGGz4g/UgFcjb28p/viDM=
Expand Down
39 changes: 28 additions & 11 deletions tools/internal/metaschema/metaschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package metaschema

import (
"encoding/json"
"strings"

openrpc "github.com/open-rpc/meta-schema"
openrpc "github.com/open-rpc/spec-types/generated/packages/go/v1_4"
"github.com/santhosh-tekuri/jsonschema/v6"
)

var openrpcSchemaRaw = openrpc.RawOpenrpc_document
var openrpcSchemaRaw = openrpc.RawOpenrpcDocument
var openrpcSchema *jsonschema.Schema

const OpenRpcSchemaURL = "https://meta.open-rpc.org/"
Expand All @@ -23,15 +24,12 @@ func init() {
// Override it to a supported JSON Schema draft so compilation doesn't require that metaschema.
openrpcSchemaJSON["$schema"] = "http://json-schema.org/draft-07/schema"

// The upstream OpenRPC meta-schema embeds a copy of the json-schema-tools meta-schema under
// `definitions.JSONSchema` and gives it `$id: https://meta.json-schema.tools/`.
// Remove those identifiers so the embedded definition behaves like a normal local subschema.
if defs, ok := openrpcSchemaJSON["definitions"].(map[string]any); ok {
if js, ok := defs["JSONSchema"].(map[string]any); ok {
delete(js, "$id")
delete(js, "$schema")
}
}
// In spec-types v1_4, several `$ref`s point at the external json-schema-tools meta-schema
// (`https://meta.json-schema.tools[/#/...]`) — an URL we don't fetch at build time. The old
// meta-schema package inlined that content; v1_4 refs out instead. Walk the parsed schema and
// replace each `{$ref: "<json-schema.tools URL>"}` object with an empty (permissive) schema so
// it resolves locally. The OpenRPC document's structural rules still get validated.
stripExternalRefs(openrpcSchemaJSON)

compiler := jsonschema.NewCompiler()
err = compiler.AddResource(OpenRpcSchemaURL, openrpcSchemaJSON)
Expand All @@ -45,3 +43,22 @@ func init() {
func Validate(schema map[string]any) error {
return openrpcSchema.Validate(schema)
}

func stripExternalRefs(v any) {
switch x := v.(type) {
case map[string]any:
if ref, ok := x["$ref"].(string); ok && strings.Contains(ref, "json-schema.tools") {
for k := range x {
delete(x, k)
}
return
}
for _, vv := range x {
stripExternalRefs(vv)
}
case []any:
for _, vv := range x {
stripExternalRefs(vv)
}
}
}
2 changes: 1 addition & 1 deletion tools/internal/specgen/base-doc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"openrpc": "1.2.4",
"openrpc": "1.4.1",
"info": {
"title": "Ethereum JSON-RPC Specification",
"description": "A specification of the standard interface for Ethereum clients.",
Expand Down
Loading