Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
"@types/node": "^24.0.8",
"@types/nprogress": "^0.2.3",
"@types/pg": "^8.15.2",
"@typescript-eslint/eslint-plugin": "^8.35.1",
"@types/react": "^19.1.9",
"@types/react-dom": "^19.1.7",
"@typescript-eslint/eslint-plugin": "^8.35.1",
"@typescript-eslint/parser": "^8.31.1",
"eslint": "^9.30.0",
"eslint-config-next": "^15.3.4",
Expand Down
54 changes: 54 additions & 0 deletions src/app/api/diff/[owner]/[repository]/[...path]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { NextRequest, NextResponse } from "next/server"
import { session, userGitHubClient } from "@/composition"
import { makeUnauthenticatedAPIErrorResponse } from "@/common"
import { execSync } from "child_process"

interface GetDiffParams {
owner: string
repository: string
path: [string]
}

export async function GET(req: NextRequest, { params }: { params: Promise<GetDiffParams> }) {
const isAuthenticated = await session.getIsAuthenticated()
if (!isAuthenticated) {
return makeUnauthenticatedAPIErrorResponse()
}

const { path: paramsPath, owner, repository } = await params
const path = paramsPath.join("/")

const fromRef = req.nextUrl.searchParams.get("from")
const toRef = req.nextUrl.searchParams.get("to")

if (!fromRef || !toRef) {
return NextResponse.json({ error: "Missing from/to parameters" }, { status: 400 })
}

const fullRepositoryName = repository + "-openapi"

const spec1 = await userGitHubClient.getRepositoryContent({
repositoryOwner: owner,
repositoryName: fullRepositoryName,
path: path,
ref: fromRef
})

const spec2 = await userGitHubClient.getRepositoryContent({
repositoryOwner: owner,
repositoryName: fullRepositoryName,
path: path,
ref: toRef
})

const result = execSync(`oasdiff changelog --format json "${spec1.downloadURL}" "${spec2.downloadURL}"`, { encoding: 'utf8' })


const diffData = JSON.parse(result)

return NextResponse.json({
from: fromRef,
to: toRef,
changes: diffData
})
}
22 changes: 15 additions & 7 deletions src/common/ui/SpacedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,21 @@ const SpacedList = ({
}) => {
return (
<List disablePadding sx={{ ...sx }}>
{React.Children.map(children, (child, idx) => (
<Box sx={{
marginBottom: idx < React.Children.count(children) - 1 ? itemSpacing : 0
}}>
{child}
</Box>
))}
{React.Children.map(children, (child, idx) => {
const baseKey = (child as React.ReactElement)?.key ?? "idx";
const key = `${String(baseKey)}-${idx}`;
return (
<Box
key={key}
sx={{
marginBottom:
idx < React.Children.count(children) - 1 ? itemSpacing : 0,
}}
>
{child}
</Box>
);
})}
</List>
)
}
Expand Down
3 changes: 2 additions & 1 deletion src/features/projects/data/GitHubProjectDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ export default class GitHubProjectDataSource implements IProjectDataSource {
name: ref.name,
specifications: specifications,
url: `https://github.com/${ownerName}/${repositoryName}/tree/${ref.name}`,
isDefault: isDefaultRef || false
isDefault: isDefaultRef || false,
baseRef: ref.baseRef,
}
}

Expand Down
Loading