-
Notifications
You must be signed in to change notification settings - Fork 50
Replace plural categories
as field name with singular category
#583
Conversation
Signed-off-by: Olga Bulat <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would require a major version change in it's current state.
If we don't want to create a new API version and we want to have category
as singular then we need to support both category
and categories
.
I think I'd prefer to support both, with a note that in the next major version one will be removed. |
I would be included in the release notes of the differences between v1 and v2, no? |
I didn't understand what |
Signed-off-by: Olga Bulat <[email protected]>
Signed-off-by: Olga Bulat <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great! The category filter returns exactly the same count from the database 💯
http://localhost:8000/v1/audio/?q=&category=music
{
"result_count": 180,
...
}
SELECT COUNT(id) FROM audio WHERE category='music';
count |
---|
180 |
We might need to update the test data for audio, it's difficult to get results for anything without looking at the DB because the majority of titles are in German 😅 and there are only two categories: music and pronunciation.
I added a small test for this in #584, let me know if you want to merge it here. Thanks for finding and addressing this so quickly 👏 It's a relief that we don't have to do migrations for this.
Should I open an issue for allowing for this pattern of deprecation (use both options in current version and display a deprecation warning, and treat it as an error in the future version, as is done now with deprecations)? Or do we already have it available in the API, and I haven't found how to use it? @dhruvkb , what do you think? |
I don't think we have a full-fledged deprecation pattern yet but ee do have a rudimentary system here:
I'd love to have a documented deprecation system (even semver) for the future as we move to newer API versions but at this stage, I'm not sure if that's something to invest effort in. We only have a handful of consumers that we can directly notify of breaking changes before we deploy. |
Why have a version prefix if we're going to deploy breaking changes? Unless we're prepared to hold off deploying breaking changes until our small number of API consumers have confirmed that they're ready to handle it, then we're really misleading people by having a version prefix in the API routes. Unless something is a security risk then breaking changes on a single API version doesn't make sense to me. If we need to release new versions of the API with breaking changes then we do need to spend the time to actually version the API (as Dhruv suggested, this isn't trivial work) but until then we'll just have to live with creating a messy v1 API (which is fine IMO, who ever created a clean v1 API anyway?) |
The v1 prefix is kind of misleading anyway. Technically, with all the changes we've made so far, we've already broken backward compatibility with the CC Search's v1 API. So any client relying on https://api.creativecommons.engineering/v1/ has been broken since the redirect. |
I do think healthy versioning practices and not breaking things is like...the way to keep API consumers happy, and we have 172 registered apps currently (some duplicates due to registration emails still not working). |
Just to clarify, the change in this PR is not breaking: One thing that I'd like to check is whether @dhruvkb ? @sarayourfriend ? @AetherUnbound ? Sorry for mentioning all of you here... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! I can't comment too much on the API versioning, as that's not something I have too much experience with.
The database is congruent with category
as a singular word, so from that perspective I don't foresee any issues!
Co-authored-by: Madison Swain-Bowden <[email protected]>
Fixes an issue introduced in #583
Fixes an issue introduced in #583
Fixes an issue introduced in #583
* Use a TextChoices enum for media type categories * Remove explicit help text, defer to DRF's automatically generated one * Simplify categories * Make categories a fancy set-like object that generates its own help * Change validator name to reference correct field name Fixes an issue introduced in #583 * Add tests for make_help_text * Force sorted order when generating help text * Generalize help text, attempt 1 * Generalize help text, functional approach * Apply comma separated list help text to all fields This also adds validation for image sizes * Get sources again in function * Fix validation text * Update documentation
Fixes
Fixes @openverse-frontend#1169
Description
Note: this does not really use category when filtering the search result, hence Draft status.
But setting category to singular is correct because all other parameters use singular words.
category
field was using plural and singular forms interchangeably in the codebase. This caused errors when filtering bycategory
:category
field sent to the front end being set tonull
.To ensure that this change doesn't break anyone's code that was using
categories
as an image filter,I added it to the list of deprecated parameters.I removed it from the deprecated parameters, and added a duplicate filter to the search controller to make sure that both parameters workTesting Instructions
Run
just up
,just init
, and try searching for something, filtering it by category.http://localhost:8000/v1/audio/?q=look%20back&category=music
should return 1 resultChecklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin