wso2 / wso2/api-platform

Implement depth based pagination for listing Git repo branch content

Open
#131 0 comments 0 reactions 1 assignee View on GitHub

@thivindu is already working on this.

Since Nov 12, 2025.

Type/Task
Dominant language
Go
Stars
71
Forks
111
Avg merge
1d 14h
Merged PRs (30d)
110

Description

Problem

When fetching the content of a Git repository branch, the repository can be large and contain many subdirectories and files.
Loading the entire structure in one response causes performance issues on the frontend due to the large payload size and rendering overhead.

Proposed Solution

Implement depth-based pagination for listing Git repository branch content.
Introduce an optional query parameter depth to limit how deep the repository traversal goes when fetching content.

For example, if depth=2, the API should return all directories and files within two levels from the root of the repository.

The response should include:

  • Directories
  • Empty directories
  • Files

This approach helps balance data completeness and performance by allowing the frontend to load deeper structures incrementally.

Implementation Details

Endpoint:
POST /git/repo/branch/fetch-content

New Query Parameter:
depth (optional, integer) – defines how deep the repo traversal should go.

Example:
/git/repo/branch/fetch-content?depth=2

Sample Response -

[
    {
        "path": ".samples",
        "subPath": ".samples",
        "children": [
            {
                "path": ".samples/icons",
                "subPath": "icons",
                "children": [],
                "type": "tree"
            },
            {
                "path": ".samples/index.json",
                "subPath": "index.json",
                "children": [],
                "type": "blob"
            }
        ],
        "type": "tree"
    },
    {
        "path": "chat-service-api",
        "subPath": "chat-service-api",
        "children": [
            {
                "path": "chat-service-api/.choreo",
                "subPath": ".choreo",
                "children": [],
                "type": "tree"
            },
            {
                "path": "chat-service-api/asyncapi.yaml",
                "subPath": "asyncapi.yaml",
                "children": [],
                "type": "blob"
            }
        ],
        "type": "tree"
    },
    {
        "path": "cloudmersive-currency-api",
        "subPath": "cloudmersive-currency-api",
        "children": [
            {
                "path": "cloudmersive-currency-api/openapi.yaml",
                "subPath": "openapi.yaml",
                "children": [],
                "type": "blob"
            },
            {
                "path": "cloudmersive-currency-api/weather-api",
                "subPath": "weather-api",
                "children": [],
                "type": "tree"
            }
        ],
        "type": "tree"
    },
    {
        "path": "empty-directory",
        "subPath": "empty-directory",
        "children": [
        {
            "path": null,
            "subPath": null,
            "children": [],
            "type": "EOF"
        }],
        "type": "tree"
    }
]
Behavior Notes

children: [] → Indicates the directory has children that were not loaded because of the current depth limit.

  {
    "path": "cloudmersive-currency-api/weather-api",
    "subPath": "weather-api",
    "children": [],
    "type": "tree"
  }

children: ["EOF"] → Explicitly indicates an empty directory (helps distinguish from untraversed nodes).

  {
    "path": "empty-directory",
    "subPath": "empty-directory",
    "children": [
      {
        "path": null,
        "subPath": null,
        "children": [],
        "type": "EOF"
      }],
    "type": "tree"
  }

When the frontend user clicks a directory with children: [], the backend should fetch the next depth level for that subdirectory.

This distinction avoids redundant API calls and improves both performance and user experience.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.