OpenAPI external $ref not resolved when using shared components file
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 29k
- Forks
- 4k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 71
Description
Bug description
GitBook does not resolve external $ref references when using OpenAPI specifications with shared component files.
We are trying to maintain a centralized file containing reusable error responses for our API, but when referencing the file using a relative $ref, GitBook fails to render the response in the documentation.
Example:
"500": {
"$ref": "../error-responses.json#/components/responses/InternalServerErrorResponse"
}
The referenced file exists, the path is correct, and the same structure works correctly in Swagger / OpenAPI tools, but GitBook does not resolve the reference and the response is missing from the rendered documentation.
Expected behavior:
GitBook should support external $ref references in OpenAPI files, allowing reusable components across multiple files, as defined in the OpenAPI specification.
Actual behavior:
External $ref references are ignored and the response schema is not rendered.
This makes it difficult to keep API error definitions centralized and forces duplication across specs.
How to reproduce
- Create an OpenAPI spec inside GitBook
- Create a separate JSON file with shared responses
- Reference the response using
$refwith a relative path - Open the API documentation page in GitBook
- The response is not rendered
Additional context
Example folder structure:
openapi/
specs/
spec.json
error-responses.json
Example error-responses.json:
{
"components": {
"responses": {
"InternalServerErrorResponse": {
"description": "Internal server error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
}
OpenAPI version: 3.x
GitBook version: (please fill)
If external references are not supported, please confirm the recommended way to share common components across multiple OpenAPI specs in GitBook.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue using openapi/specs/spec.json and openapi/error-responses.json with the relative external $ref shown in the report. Start by tracing how the OpenAPI 3.x documentation page loads and resolves that reference; done means the shared InternalServerErrorResponse renders, or the supported limitation and recommended sharing method are documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100