We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
const resolvedSchema = resolver.resolve( { "$id": "test", "title": "Test", "type": "object", "properties": { "TestString": { "$ref": "DefSchema#/$defs/Username" } } }, { externalSchemas: [ { "$id": "DefSchema", "$defs": { "Username": { "$ref": "#/$defs/string:10" }, "string:10": { "type": "string", "maxLength": 10 } } } ] } )
Produces the following incorrect reference:
{ "$id": "test", "definitions": { "def-0": { "$defs": { "Username": { "$ref": "#/$defs/string:10" } } } } }
As opposed to the expected:
{ "$id": "test", "definitions": { "def-0": { "$defs": { "Username": { "$ref": "#/definitions/def-0/$defs/string:10" } } } } }
The text was updated successfully, but these errors were encountered:
Finally I was able to replicate it:
const RefResolver = require('json-schema-resolver') const ref = RefResolver({ clone: true, // Clone the input schema without changing it. Default: false, buildLocalReference (json, baseUri, fragment, i) { return `def-${i}` // default value } }) const inputSchema = { "$id": "http://example.com/root.json", "definitions": { "A": { "$id": "#foo" }, "B": { "$id": "other.json", "definitions": { "X": { "$id": "#bar", type: 'string' }, "Y": { "$id": "t/inner.json", type: 'boolean' } } }, "C": { "$id": "urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f", type: 'object', } } } const addresSchema = { $id: 'relativeAddress', // Note: prefer always absolute URI like: http://mysite.com type: 'object', properties: { zip: { $ref: 'urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f' }, zip2: { $ref: 'http://example.com/t/inner.json' }, city: { $ref: 'http://example.com/root.json#foo' } } } const singleSchema = ref.resolve(addresSchema, { externalSchemas: [inputSchema] }) console.log(singleSchema)
{ '$id': 'relativeAddress', type: 'object', properties: { zip: { '$ref': '#/definitions/def-5' }, zip2: { '$ref': '#/definitions/def-4' }, city: { '$ref': '#/definitions/def-0foo' } ❗️ the $ref has the additional `foo` }, definitions: { 'def-0': { '$id': 'http://example.com/root.json', definitions: [Object], [Symbol(json-schema-resolver.refToDef)]: 'def-0', [Symbol(json-schema-resolver.consumed)]: true }, 'def-4': { '$id': 't/inner.json', type: 'boolean', [Symbol(json-schema-resolver.refToDef)]: 'def-4', [Symbol(json-schema-resolver.consumed)]: true }, 'def-5': { '$id': 'urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f', type: 'object', [Symbol(json-schema-resolver.refToDef)]: 'def-5', [Symbol(json-schema-resolver.consumed)]: true } }, [Symbol(json-schema-resolver.ignore)]: true }
Sorry, something went wrong.
Eomm
No branches or pull requests
Produces the following incorrect reference:
As opposed to the expected:
The text was updated successfully, but these errors were encountered: