Skip to content

Commit

Permalink
Fix FastAPI response models in github.py
Browse files Browse the repository at this point in the history
  • Loading branch information
openhands-agent committed Feb 23, 2025
1 parent 82e2416 commit c90a5f2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions openhands/server/routes/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
app = APIRouter(prefix='/api/github')


@app.get('/repositories')
@app.get('/repositories', response_model=list[GitHubRepository])
async def get_github_repositories(
page: int = 1,
per_page: int = 10,
sort: str = 'pushed',
installation_id: int | None = None,
github_user_id: str | None = Depends(get_user_id),
github_user_token: SecretStr | None = Depends(get_github_token),
) -> Union[list[GitHubRepository], JSONResponse]:
) -> list[GitHubRepository] | JSONResponse:
client = GithubServiceImpl(user_id=github_user_id, token=github_user_token)
try:
repos: list[GitHubRepository] = await client.get_repositories(
Expand All @@ -45,11 +45,11 @@ async def get_github_repositories(
)


@app.get('/user')
@app.get('/user', response_model=GitHubUser)
async def get_github_user(
github_user_id: str | None = Depends(get_user_id),
github_user_token: SecretStr | None = Depends(get_github_token),
) -> Union[GitHubUser, JSONResponse]:
) -> GitHubUser | JSONResponse:
client = GithubServiceImpl(user_id=github_user_id, token=github_user_token)
try:
user: GitHubUser = await client.get_user()
Expand All @@ -68,11 +68,11 @@ async def get_github_user(
)


@app.get('/installations')
@app.get('/installations', response_model=list[int])
async def get_github_installation_ids(
github_user_id: str | None = Depends(get_user_id),
github_user_token: SecretStr | None = Depends(get_github_token),
) -> Union[list[int], JSONResponse]:
) -> list[int] | JSONResponse:
client = GithubServiceImpl(user_id=github_user_id, token=github_user_token)
try:
installations_ids: list[int] = await client.get_installation_ids()
Expand All @@ -91,15 +91,15 @@ async def get_github_installation_ids(
)


@app.get('/search/repositories')
@app.get('/search/repositories', response_model=list[GitHubRepository])
async def search_github_repositories(
query: str,
per_page: int = 5,
sort: str = 'stars',
order: str = 'desc',
github_user_id: str | None = Depends(get_user_id),
github_user_token: SecretStr | None = Depends(get_github_token),
) -> Union[list[GitHubRepository], JSONResponse]:
) -> list[GitHubRepository] | JSONResponse:
client = GithubServiceImpl(user_id=github_user_id, token=github_user_token)
try:
repos: list[GitHubRepository] = await client.search_repositories(
Expand Down

0 comments on commit c90a5f2

Please sign in to comment.