8000 feat(web): add /api/v1/managers endpoint listing 22 package managers by dominicusin · Pull Request #62 · dominicusin/package-maximizer · GitHub
[go: up one dir, main page]

Skip to content
Merged
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
20 changes: 20 additions & 0 deletions package_maximizer/web/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,26 @@ def list_parsers() -> tuple[dict, int]:
return jsonify({"parsers": parsers}), 200


# ─── List available managers (package managers) ──────────────
@app.get("/api/v1/managers")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

1. Managers endpoint undocumented 🐞 Bug ≡ Correctness

The live /api/v1/managers route is missing from both /api/v1/openapi.json and /api/v1/docs.
API consumers relying on either advertised documentation surface cannot discover the new endpoint.
Agent Prompt
## Issue description
The new `GET /api/v1/managers` route is exposed by Flask but omitted from both the machine-readable OpenAPI paths and the human-readable docs page, leaving the published API descriptions incomplete.

## Issue Context
The project maintains these documentation surfaces manually in `package_maximizer/web/app.py`. Add the managers operation and response description to the OpenAPI map, add the route to the HTML endpoint list, and strengthen tests to assert that both surfaces include it.

## Fix Focus Areas
- package_maximizer/web/app.py[222-238]
- package_maximizer/web/app.py[542-632]
- tests/test_web_api.py[81-90]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@require_api_key
def list_managers() -> tuple[dict, int]:
"""List all available package managers (parsers)."""
from ..parsers import PARSER_REGISTRY

managers = []
for name, cls in PARSER_REGISTRY.items():
doc = cls.__doc__ or "No description"
managers.append(
{
"name": name,
"description": doc.strip().split("\n")[0],
"class": cls.__name__,
}
)
return jsonify({"managers": managers, "count": len(managers)}), 200


# ─── Maximize packages ───────────────────────────────────────
@app.post("/api/v1/maximize")
@require_api_key
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Repository = "https://github.com/dominicusin/package-maximizer.git"
PyPI = "https://pypi.org/project/package-maximizer/"

[tool.setuptools_scm]
fallback_version = "0.5.0"
fallback_version = "0.6.0"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

2. Runtime version remains stale 🐞 Bug ≡ Correctness

Changing only setuptools_scm.fallback_version to 0.6.0 can produce distribution metadata for
0.6.0 while the imported package, health endpoint, and OpenAPI document still report 0.5.0. Version
checks and production diagnostics therefore return contradictory release identities.
Agent Prompt
## Issue description
The fallback package version is bumped to `0.6.0`, but every runtime-facing version value remains hard-coded to `0.5.0`, creating inconsistent package metadata and API/runtime output when the fallback is used.

## Issue Context
Use a single authoritative runtime version source, preferably distribution metadata with an appropriate source-tree fallback, and have the package attribute, health response, and OpenAPI info consume it. Update the version assertion accordingly so tests detect future drift.

## Fix Focus Areas
- pyproject.toml[78-79]
- package_maximizer/__init__.py[1-7]
- package_maximizer/web/app.py[164-178]
- package_maximizer/web/app.py[542-552]
- tests/test_basic.py[6-15]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


[tool.package-maximizer]
plugin-metadata-version = "1"
13 changes: 13 additions & 0 deletions tests/test_web_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ def test_list_parsers(client):
assert "parsers" in r.get_json()


def test_list_managers(client):
r = client.get("/api/v1/managers", headers=auth_headers())
assert r.status_code == 200
body = r.get_json()
assert "managers" in body
assert "count" in body
assert body["count"] >= 22
names = {m["name"] for m in body["managers"]}
assert "apt" in names
assert "pip" in names
assert "conda" in names


def test_openapi_spec(client):
r = client.get("/api/v1/openapi.json", headers=auth_headers())
assert r.status_code == 200
Expand Down
Loading
0