Add PEP 691 JSON support for PyPI Simple API

What does this MR do and why?

References

#586978

This MR adds PEP 691 (JSON Simple API) support to GitLab’s PyPI registry “Simple” endpoints.

Implements a Minimal PEP 691 JSON presenter (Packages::Pypi::SimpleJsonPresenter) for:

  • GET /api/v4/projects/:id/packages/pypi/simple
  • GET /api/v4/groups/:id/-/packages/pypi/simple
  • GET /api/v4/projects/:id/packages/pypi/simple/:package_name
  • GET /api/v4/groups/:id/-/packages/pypi/simple/:package_name

Uses content negotiation based on the Accept header:

  • If Accept includes application/vnd.pypi.simple.v1+json (or ...latest+json), returns JSON
  • Otherwise returns existing PEP 503 HTML

Adds Vary: Accept so caches behave correctly.

Keeps existing HTML behavior unchanged for clients like pip that request HTML.

Why: Some tooling expects/benefits from JSON Simple API responses, and PEP 691 is the standardized format for that.

Screenshots or screen recordings

Before After

How to set up and validate locally

curl -sS \
  -H 'Accept: application/vnd.pypi.simple.v1+json' \
  "http://127.0.0.1:3000/api/v4/projects/<PROJECT_ID>/packages/pypi/simple" | jq

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

  • Behavior is backward compatible (HTML default preserved)
  • JSON responses match PEP 691 minimal structure
  • Covered by request specs
  • No UI changes
Edited by ch8matt

Merge request reports

Loading