You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First and foremost, this may be a non-issue, I just wanted to confirm the behavior was intended and verify that I am using the library correctly. This also may not be the correct repo for this issue.
I had an issue logged where a user was getting errors in their swagger doc after using multiple $refs to the same file. Example Schema
The following test code demonstrates the issue using the linked schema:
constrefParser = require('json-schema-ref-parser')
constpath = require('path');
varsource = path.join(__dirname, '/schema/petstore.yaml');
refParser.bundle(source, (err, schema) => {
if (err) {
console.error('ERROR:', err);
}
else {
// at this point swagger editor claims the schema is invalidconsole.log('SUCCESS:', JSON.stringify(schema, null, 2));
console.log("DEREFERENCE");
refParser.dereference(schema, (err, drSchema) => {
if (err) {
console.error('ERROR:', err);
}
else {
// after a dereference, swagger editor says schema is validconsole.log('SUCCESS:', JSON.stringify(drSchema, null, 2));
}
});
}
});
An initial call to bundle creates a schema that uses local json pointers for the duplicate references. However, this throws errors when copy/pasted into the official Swagger Editor. I noticed that this same bundled schema does not yield any errors when plugged into your Swagger Validator Demo.
After reading through this issue I determined that you must be calling dereference before doing the validation. When I add a follow up call to dereference, as seen in the test above, the relative json pointers are dereferenced and swagger editor is happy again.
Is this intended behavior?
Is calling bundle followed by dereference a suitable workaround, or should I be doing something else in entirely?
The text was updated successfully, but these errors were encountered:
Hi @philosowaffle. Welcome to the wonderful world of incompatible Swagger tooling! 😄
Unfortunately, as you've discovered, not all Swagger & OpenAPI tools are compatible. Many of them don't fully support the spec, and there are a few areas where the spec is unclear so different tooling authors have implemented it differently.
Swagger Editor is a fantastic tool, but its $ref support is somewhat lacking. This has led to otherissuesin thepast. For now, the only workaround is to use dereference() rather than bundle(), since dereference() produces a file without any $refs, so it's guaranteed to work in Swagger Editor.
First and foremost, this may be a non-issue, I just wanted to confirm the behavior was intended and verify that I am using the library correctly. This also may not be the correct repo for this issue.
I had an issue logged where a user was getting errors in their swagger doc after using multiple $refs to the same file. Example Schema
The following test code demonstrates the issue using the linked schema:
An initial call to bundle creates a schema that uses local json pointers for the duplicate references. However, this throws errors when copy/pasted into the official Swagger Editor. I noticed that this same bundled schema does not yield any errors when plugged into your Swagger Validator Demo.
After reading through this issue I determined that you must be calling
dereference
before doing the validation. When I add a follow up call to dereference, as seen in the test above, the relative json pointers are dereferenced and swagger editor is happy again.bundle
followed bydereference
a suitable workaround, or should I be doing something else in entirely?The text was updated successfully, but these errors were encountered: