API / Swagger Interview questions
Explain the internal working of $ref resolution across multiple OpenAPI files?
When a tool encounters a $ref pointing outside the current file, it has to locate and load the referenced file, navigate to the specific fragment within it, and substitute that fragment in place of the reference — a process called dereferencing, or "bundling" when the goal is producing one fully self-contained output document.
This resolution is inherently recursive: a referenced file's fragment might itself contain further $refs pointing to yet another file, so a correct resolver has to keep following the chain until every reference bottoms out in an actual concrete value, while also detecting and rejecting circular references that would otherwise resolve forever.
Two related but distinct end results are common: dereferencing fully inlines every reference's content directly in place (producing a larger, but entirely self-contained, single document with no remaining $refs), while bundling collects all referenced content into one file's components section but keeps internal $ref pointers between them intact, avoiding the potentially large duplication that full dereferencing can produce when the same schema is referenced from many places.
More Related questions...