joomla / joomla-cms

Home of the Joomla! Content Management System
https://www.joomla.org
GNU General Public License v2.0
4.77k stars 3.65k forks source link

[4.0] API Improvements #27569

Open wilsonge opened 4 years ago

wilsonge commented 4 years ago

Placeholder issue for working on the API including:

  1. Linking of resources (e.g. article to language, tags, category etc)
  2. ~Reviewing that properties we want to be returned are~
  3. ~Public API flag doesn't work~
Razzo1987 commented 4 years ago

Hi @wilsonge , can I add another 2 issues?

  1. Title length in content/article
  2. state in content/article

If I try to create an article with this data:

"title":"La Nigeria prende in consegna l'ex procuratore generale Adoke per un affare di petrolio da 1,3 miliardi di dollari",
"catid":8,
"state":1,
"created":"2020-01-24 08:23:05",
"language":"*",
"metadesc":"ABUJA (Reuters) - Il cane da guardia del crimine finanziario della Nigeria ha accusato l'ex procuratore generale Mohammed Adoke ...",
"metakey":"",
"articletext":"<p>ABUJA (Reuters) - Il cane da guardia del crimine finanziario della Nigeria ha accusato l'ex procuratore generale Mohammed Adoke di aver presumibilmente ricevuto tangenti per facilitare un accordo petrolifero di $ 1,3 miliardi, ha detto l'agenzia in una nota gioved\u00ec.<\/p><div class=\"alert alert-info\" role=\"alert\">Articolo tradotto da <a href=\"http:\/\/feeds.reuters.com\/~r\/reuters\/AFRICATopNews\/~3\/mXLflbrOo7Q\/idAFKBN1ZN0HU-OZATP\" target=\"_blank\">Top Africa News<\/a>.<\/div>"
}

And I recieve this error:

{
   "errors":[
      {
         "title":"Save failed with the following error: Data too long for column 'title' at row 1"
      }
   ]
}

if I use a shorter title, the article is still inserted as unpublished

Quy commented 4 years ago

Add #26564 here or its own issue.

Razzo1987 commented 4 years ago

Add #26564 here or its own issue.

I create a new one: https://github.com/joomla/joomla-cms/issues/27673

alikon commented 4 years ago

for #30130, #30135 test #30134

alikon commented 4 years ago

for the more general question raised #30145

In theory all fields available in the backend should be visible via the API too assuming we are gearing towards making with 100% API driven.

would like to listen @wilsonge before to propose a PR

alikon commented 4 years ago

@wilsonge can you elaborate a bit more on

  1. Public API flag doesn't work

from January some properties has been revisited

  1. Reviewing that properties we want to be returned are
wilsonge commented 3 years ago

In theory all fields available in the backend should be visible via the API too assuming we are gearing towards making with 100% API driven.

would like to listen @wilsonge before to propose a PR

Basically we want to expose everything in the API - there's potentially some fields we may choose to not because they are totally internal to the Joomla UI but I think they will be few and far between. There's going to be a small number of cases where I'm also delaying some sensitive fields to give the API time to bed in and get tested (mainly stuff in com_users that's security related) - hence I merged some of the com_users PRs for 4.1

  1. Public API flag doesn't work

There was a property that a route in a webservice that can return with the boolean public that (by default false) can be set to true to expose a webservice to the public (unlikely to ever be used in core - but could be enabled on websites for custom webservices).

Relevent code: https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/src/Application/ApiApplication.php#L297-L303

This is mainly designed for read endpoints - I don't have any real expectations that this would work for post/put etc endpoints. However if you specify this things still kinda fail to be publically accessible. The login code doesn't run but other things later on in the process fail because there's no valid user objects in JUser or something (can't remember the specifics now)

alikon commented 3 years ago

ok, so for 3 Public API flag doesn't work see #31579