JSON Schema validator incorrectly rejects unknown formats
Describe the bug
Incorrectly throws errors when encountering unknown JSON Schema formats, specifically for me "format": "int64". According to JSON Schema Draft 7 specification, validators should ignore unknown formats, not reject them.
To Reproduce Steps to reproduce the behavior:
- Create an OpenRPC specification with a schema containing
"format": "int64" - Use @open-rpc/schema-utils-js to validate the schema (e.g., via parseOpenRPCDocument)
- Initialize a client using the generated OpenRPC spec
- See error in additional context taken from console:
Expected behavior According to JSON Schema Draft 7 specification:
A format attribute can generally only validate a given set of instance types. If the type of the instance to validate is not in this set, validation for this format attribute and instance SHOULD succeed.
or from JSON Schema Validation: A Vocabulary for Structural Validation of JSON
"An implementation MUST NOT fail to collect unknown formats as annotations."
Screenshots
Desktop (please complete the following information):
- OS: Windows
- Browser: Chrome
- Version: 140.0.7339.77
Additional context
I used the following command to generate the client which raised the error:
open-rpc-generator generate -t client -l typescript -n RpcClientTs -d ./spec.json -o ./generated
Attached is the spec
I used int64 as the format as that is what the rust crate schemars determined to be correct.
Full error:
Uncaught (in promise) Error: unknown format "int64" is used in schema at path "#"
at Object.generate_format [as code] (@open-rpc_schema-utils-js.js?v=dc7beea9:5317:19)
at generate_validate (@open-rpc_schema-utils-js.js?v=dc7beea9:4083:39)
at localCompile (@open-rpc_schema-utils-js.js?v=dc7beea9:4239:26)
at Ajv.compile (@open-rpc_schema-utils-js.js?v=dc7beea9:4212:17)
at Ajv._compile (@open-rpc_schema-utils-js.js?v=dc7beea9:8173:27)
at Ajv.getSchema (@open-rpc_schema-utils-js.js?v=dc7beea9:8061:45)
at Ajv.validate (@open-rpc_schema-utils-js.js?v=dc7beea9:8003:18)
at @open-rpc_schema-utils-js.js?v=dc7beea9:9283:48
at Array.map (<anonymous>)
at MethodCallValidator2.validate (@open-rpc_schema-utils-js.js?v=dc7beea9:9264:59)