? Pending

User tests: Successful: Unsuccessful:

avatar wilsonge
wilsonge
17 Mar 2020

Summary of Changes

  • Allows relations to be shown in the list view of the API
  • Adds filters for author id, category id, state and search into the articles api (for now starting with these and we can expand and move them to other components)
  • Adds author relationship to the output of articles
  • Fixes category relationship being shown as an articles type instead of categories type

Testing Instructions

  1. Test the filters endpoint with e.g.

JROOT_URL/api/index.php/v1/content/article?filter[search]=tag

which will search for the string 'tag'

JROOT_URL/api/index.php/v1/content/article?filter[state]=0

will search for unpublished articles

  1. Test the relationships for category and author are output in both the item and list views of the article output and have the correct type.

Documentation Changes Required

Yes:

  1. How to implement filters in APIs
  2. What filters are available in core components
avatar wilsonge wilsonge - open - 17 Mar 2020
avatar wilsonge wilsonge - change - 17 Mar 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 17 Mar 2020
Category Libraries
avatar wilsonge wilsonge - change - 17 Mar 2020
Title
Add author to output and filter options to com_content
[4.0] Add author to output and filter options to com_content API
avatar wilsonge wilsonge - edited - 17 Mar 2020
avatar wilsonge
wilsonge - comment - 17 Mar 2020

@alikon this should port over some of the work you were doing on filters

avatar alikon
alikon - comment - 19 Mar 2020

@wilsonge please have a look at this silly one #28384 to prevent conflict

avatar alikon
alikon - comment - 20 Mar 2020

a couple of things :

  • should not this show a conflict file cause of #28384 touching api/components/com_content/src/View/Articles/JsonapiView.php

  • calling JROOT_URL/api/index.php/v1/content/article?filter[state]=0 without unpublished give me this response

{
  "links": {
    "self": "http:\/\/localhost\/jbs4\/api\/index.php\/v1\/content\/article?filter%5Bstate%5D=0",
    "first": "http:\/\/localhost\/jbs4\/api\/index.php\/v1\/content\/article?filter[state]=0&page[offset]=0&page[limit]=20",
    "next": "http:\/\/localhost\/jbs4\/api\/index.php\/v1\/content\/article?filter[state]=0&page[offset]=-20&page[limit]=20",
    "previous": "http:\/\/localhost\/jbs4\/api\/index.php\/v1\/content\/article?filter[state]=0&page[offset]=0&page[limit]=20",
    "last": "http:\/\/localhost\/jbs4\/api\/index.php\/v1\/content\/article?filter[state]=0&page[offset]=-20&page[limit]=20"
  },
  "data": [],
  "meta": {
    "total-pages": 0
  }
}

should not it be something like this ?

{
  "errors": [
    {
      "title": "Resource not found",
      "code": 404
    }
  ]
}
avatar alikon
alikon - comment - 20 Mar 2020

a funny thing is that we have relations on the api response and not in the database 🤣

avatar wilsonge
wilsonge - comment - 20 Mar 2020

should not this show a conflict file cause of #28384 touching api/components/com_content/src/View/Articles/JsonapiView.php

No because it's different lines in the file - if i'd modified the same lines of code as you it would cause a conflicts

calling JROOT_URL/api/index.php/v1/content/article?filter[state]=0 without unpublished give me this response

In my opinion no - because the URL is valid - it's just no data matches the filter criteria.

avatar alikon
alikon - comment - 20 Mar 2020

thanks for reply
it works well so let's move on

avatar alikon
alikon - comment - 20 Mar 2020

I have tested this item ✅ successfully on 759417d


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28382.

avatar alikon alikon - test_item - 20 Mar 2020 - Tested successfully
avatar alikon
alikon - comment - 20 Mar 2020

tip for those who want to search on content (fulltext) suppose you would search for word mundi

the call is:
JROOT_URL/api/index.php/v1/content/article?filter[search]=CONTENT:mundi

avatar wilsonge wilsonge - close - 20 Mar 2020
avatar wilsonge wilsonge - merge - 20 Mar 2020
avatar wilsonge wilsonge - change - 20 Mar 2020
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2020-03-20 11:12:33
Closed_By wilsonge
Labels Added: ?
avatar wilsonge
wilsonge - comment - 20 Mar 2020

@alikon can you do the language PR as it's own thing and let's discuss there whether to use PK or the language code for filtering

avatar alikon
alikon - comment - 20 Mar 2020

yes for sure

avatar alikon
alikon - comment - 20 Mar 2020

see #28406

Add a Comment

Login with GitHub to post a comment