Skip to content

Add a minify parameter to topics#3080

Open
saengel wants to merge 3 commits intomasterfrom
feature/sc-41570/add-an-optional-toggle-for-get-all-topics
Open

Add a minify parameter to topics#3080
saengel wants to merge 3 commits intomasterfrom
feature/sc-41570/add-an-optional-toggle-for-get-all-topics

Conversation

@saengel
Copy link
Contributor

@saengel saengel commented Feb 9, 2026

Description

The topics endpoint was changed as part of MDL to provide a "minified" response, without including image data. This impacted our users who relied on this endpoint providing images.

The goal of this PR is to allow for a backward-compatible minify parameter (optional). The default is minify=1, which is fully compatible with the expected and desired behavior for Sefaria.org of the topics/ endpoint returned minified responses. Developers can now call this endpoint with ?minify=0 to get a response that is not "minified" and includes the image data as before.

Code Changes

  1. reader/views.py - Adding an optional minify parameter, that defaults to 1 so it's non-breaking for the current desired behavior on the site.
  2. docs/openAPI.json - Updating the API reference documentation.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an optional minify query parameter to the /api/topics endpoint to support backward-compatible “full” topic responses (including images) while keeping the default behavior minified for Sefaria.org.

Changes:

  • Add minify query param parsing to topics_list_api (defaulting to 1).
  • Pass minify through to Topic.contents() to toggle minified vs full topic payloads.
  • Update OpenAPI documentation to describe the new minify parameter and clarify response behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
reader/views.py Adds minify query parameter support for /api/topics, wiring it into Topic.contents().
docs/openAPI.json Documents minify (0/1) and updates endpoint descriptions to reflect minified-by-default behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 4597 to 4607
"parameters": [
{
"examples": {
"Return all topics": {
"value": 0
},
"Return 20 topics": {
"value": 20
}
},
"name": "limit",
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

The newly added parameter blocks under /api/topics use inconsistent indentation compared to the surrounding OpenAPI JSON (many lines are over-indented). Since this file is documentation consumers may diff/parse, please reformat this section to match the existing style (or run the repo’s formatter/generator if applicable) to keep the spec maintainable.

Copilot uses AI. Check for mistakes.
Comment on lines +3308 to 3313
minify = bool(int(request.GET.get("minify", 1)))
all_topics = get_all_topics(limit, active_module=request.active_module)
all_topics_json = []
for topic in all_topics:
topic_json = topic.contents(minify=True, with_html=True)
topic_json = topic.contents(minify=minify, with_html=True)
topic_json["titles"] = topic.titles
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

This change introduces new externally-visible behavior (minify toggles between minified vs full topic payloads) but there are no Django API tests covering /api/topics at all. Adding tests for default behavior (minify omitted/1) vs minify=0 (full payload) and for invalid minify values would help prevent regressions and ensure the endpoint doesn’t 500 on bad input.

Copilot uses AI. Check for mistakes.
@mergify
Copy link

mergify bot commented Feb 9, 2026

🧪 CI Insights

Here's what we observed from your CI run for 9310a45.

🟢 All jobs passed!

But CI Insights is watching 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants