Repository navigation
Throw when registering over a schema with a different $id - #146
MohitSAGAR11 wants to merge 1 commit into
Conversation
|
The 9 CI failures are the |
SHUBHANSHU602
left a comment
There was a problem hiding this comment.
Job 128628431168 in hyperjump-io/json-schema
The job failed because 9 tests across different schema drafts all hit the same multipleOf validation error.
Each failing test checks that 1.5e-8 is not a multiple of 1e-8. The validator returned true, but the test expected false (expected true to equal false). This points to a shared issue in handling very small numbers—likely in the multipleOf validation logic—rather than nine separate draft-specific failures.
registerSchema stores a schema at its retrieval URI, but only checked its $id for an existing schema. Registering a schema with a different $id at the same retrieval URI replaced the old one instead of throwing. Check the retrieval URI too, and keep the $id check. addSchema replaces schemas, so it now unregisters the retrieval URI as well as the $id. Fixes hyperjump-io#142
17acf91 to
48e94f2
Compare
|
Rebased onto |
Fixes #142
registerSchemastores a schema at its retrieval URI, but it only checked the schema's$idfor an existing entry. Registering a schema with a different$idat the same retrieval URI silently replaced the old one.Changes
registerSchemachecks the retrieval URI it's about to write to. It still checks the$idtoo, so registering a schema whose$idis already registered keeps throwing as before.addSchemais meant to replace schemas, so it now unregisters the retrieval URI as well as the$id. Without this, callingaddSchematwice at the same retrieval URI with different$ids would start throwing.Tests
Added to
lib/schema.spec.ts:duplicate registered schema with a different $id: the case from the issue. Fails without the fix.registered schema with an $id that is already registered: the existing$idcheck still throws.addSchema replaces a schema with a different $id:addSchemastill replaces.npm test, type-check and lint pass, except the multipleOf suite cases that #140 fixes.