Skip to content

Commit 58aec2c

Browse files
committed
feat: add openApi yaml
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
1 parent d8debe4 commit 58aec2c

4 files changed

Lines changed: 539 additions & 29 deletions

File tree

backend/src/api/public/v1/packages/getPackage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export async function getPackage(req: Request, res: Response): Promise<void> {
3636

3737
const [advisories, stewardshipSummary] = await Promise.all([
3838
getAdvisoriesByPackageId(qx, pkg.id),
39-
pkg.stewardshipId ? getStewardshipSummary(qx, pkg.stewardshipId) : null,
39+
pkg.stewardshipId ? getStewardshipSummary(qx, Number(pkg.stewardshipId)) : null,
4040
])
4141

4242
ok(res, {

backend/src/api/public/v1/stewardships/openStewardship.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ const bodySchema = z.object({
1515
.string()
1616
.trim()
1717
.min(1)
18-
.refine((v) => v.startsWith('pkg:'), { message: 'purl must start with pkg:' }),
18+
.refine((v) => v.startsWith('pkg:'), { message: 'purl must start with pkg:' })
19+
.transform(normalizePurl),
1920
})
2021

2122
export async function openStewardship(req: Request, res: Response): Promise<void> {
22-
const { purl: rawPurl } = validateOrThrow(bodySchema, req.body)
23-
const purl = normalizePurl(rawPurl)
23+
const { purl } = validateOrThrow(bodySchema, req.body)
2424

2525
const qx = await getPackagesQx()
2626
const stewardship = await openStewardshipByPurl(qx, purl, req.actor.id)
2727

2828
if (!stewardship) {
29-
throw new NotFoundError(`Package not found: ${rawPurl}`)
29+
throw new NotFoundError(`Package not found: ${purl}`)
3030
}
3131

3232
ok(res, { stewardship })

0 commit comments

Comments
 (0)