-
Notifications
You must be signed in to change notification settings - Fork 4k
OpenAPI external $ref not resolved when using shared components file #4139
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.