tdegrunt / jsonschema

JSON Schema validation
Other
1.82k stars 262 forks source link

SchemaError: no such schema </tag> #253

Closed intelliot closed 6 years ago

intelliot commented 6 years ago

v1.2.3 introduced changes that break a library called ripple-lib. See https://github.com/ripple/ripple-lib/issues/880

Based on when the version in package.json was incremented, these are the changes between v1.2.2 and v1.2.3 - https://github.com/tdegrunt/jsonschema/compare/7cb42c455e93a87d8d86c43e56ac695819164fca...93d5b88927392faec9e87f8a750fb488b5f3d7c7

I don't see SchemaError: no such schema in the diff; I'm not sure where the breaking change occurred.

awwright commented 6 years ago

That error was already in the library, but the code that scans for schemas was updated to handle the test suite better. It's possible some nonstandardized cases might work differently, though none of the officially supported tests broke.

I'm taking a look at how ripple-lib imports schemas right now.

Are you assigning an (full, absolute) URI to schemas anywhere? /tag isn't a valid URI (it would be a valid URI Reference).

awwright commented 6 years ago

Hey @intelliot,

It looks like the quick fix is to import the schemas with a valid URI. Instead of '/' + schemaName, try 'vnd.jsonschema:///' + schemaName, or something more suitable, like if you publish the schemas on a website somewhere, 'http://example.com/schemas/' + schemaName.

Also, you may want to use the "id" keyword to name schemas, instead of the "title" keyword. Then you can provide a descriptive title without changing the id.

I'll add a feature to allow a default URI base when you use a URI Reference to import schemas like you are, but importing schemas with a (full, absolute) URI is the scalable long-term solution in any event.

pefish commented 6 years ago

the same problem

awwright commented 6 years ago

@pefish We haven't pinned down the cause yet, can you please elaborate? Do you have an example that worked before that doesn't now? Thanks.

awwright commented 6 years ago

@intelliot Should ./schemas/objects/private-key.json be in ripple-lib repository? I had to comment that line out to get it to work.

awwright commented 6 years ago

@intelliot @pefish I need your feedback, please.

awwright commented 6 years ago

@intelliot @pefish I'm going to close this issue for inactivity. If you can provide any more information, feel free to drop a comment, reopen the issue, or open a new issue.

intelliot commented 6 years ago

@awwright Sorry for the delay, I'm just getting around to looking at this again.

I'm not sure what you mean. Yes, ./schemas/objects/private-key.json is in the ripple-lib repository.

https://github.com/ripple/ripple-lib/blob/dc623cd0490ab2050e0940145293907c2245fa70/src/common/schemas/objects/private-key.json#L3

I tried using 'vnd.jsonschema:///' + schemaName on the two lines you mentioned, but then I still get errors like this:

     SchemaError: no such schema </address>
      at Validator.resolve (node_modules/jsonschema/lib/validator.js:272:11)
      at Validator.validateSchema (node_modules/jsonschema/lib/validator.js:199:25)
      at Validator.validateProperties (node_modules/jsonschema/lib/attribute.js:195:20)
      at Validator.validateSchema (node_modules/jsonschema/lib/validator.js:211:34)
      at Validator.validate (node_modules/jsonschema/lib/validator.js:150:23)
      at Object.schemaValidate (src/common/schema-validator.ts:7:341)
      at apply (node_modules/lodash/lodash.js:467:27)
      at Object.wrapper [as prepareOrder] (node_modules/lodash/lodash.js:5329:16)
      at RippleAPI.prepareOrder (src/transaction/order.ts:1:6869)
      at Context.<anonymous> (test/api-test.js:447:21)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)
intelliot commented 6 years ago

Looks like I don't have permission to reopen this issue.