-
-
Notifications
You must be signed in to change notification settings - Fork 233
Ability to skip dereferencing inline/internal $ref values #214
New issue
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
Comments
@philsturgeon sorry to mention you directly too, but I see in one of the issues in the now deprecated Stoplight project referenced above that you commented that you've been able to meet your requirements with this library. I'm wondering if you have any suggestions for using it to only dereference the remote references and leave the inline ones in place? |
Why not use bundle if you're ok with references but want them to exist as local refs instead? That's exactly what it's for. :) |
Hmmm, I thought I tried this but I might have been dereferencing & bundling in some incorrect combination. I'll give that another look. Thanks! |
I have the same issue, but I'm not able to solve it with paths:
/example1:
get:
$ref: "./oas-example1.yaml"
/example2:
get:
$ref: "#/components/schemas/Error"
components:
schemas:
Error: "...."
ErrorResponse:
$ref: "#/components/schemas/Error" Which returns this error: The only solution I found is to skip JSON Pointer references checks with some extra option like |
This is not a bug, it's saying that #/components/schemas/Error does not exist in oas-example1.yaml because, it doesnt! :D Each ref needs to point to the filepath then # is the start of the pointer. Perhaps you could make a shared model for ErrorResponse.yml then all locations point to that? |
The only method I currently found to ignore the parsing error of local references is to do something like this: const $RefParser = require("@apidevtools/json-schema-ref-parser")
async function bundle(root) {
let bundle = {}
try {
bundle = await $RefParser.bundle(root, {
continueOnError: true,
})
} catch (e) {
bundle = e.files.schema
}
return bundle
}
const root = './index.yaml'
bundle(root).then(bundle =>{
console.log(bundle)
}) Apparently even if the bundle function fails the schema is generated ignoring the local references |
Hi all,
@stoplight/json-ref-resolver offers options to skip dereferencing either internal or remote references. I've found this feature to be very useful, but now that project is now deprecated and points to this one.
I was wondering if there's already a way to accomplish the same thing using this library?
Essentially I'm hoping to preserve this behavior of taking an example schema:
and only dereference the remote HTTP reference:
@P0lip sorry to ping you directly, but I noticed that you've been active in both projects. If you have any pointers it would be much appreciated.
Hopefully this summary makes sense. Thanks!
The text was updated successfully, but these errors were encountered: