sulu / SuluHeadlessBundle

Bundle that provides controllers and services for using Sulu as headless content management system
MIT License
44 stars 25 forks source link

Normalize returned types by the api #84

Open alexander-schranz opened 3 years ago

alexander-schranz commented 3 years ago

There are current different type returned. First the structure resolver return a singular type e.g.:

{
    "uuid": "...",
    "type": "page",
}

But then there is the teaser_selection which will return a pluralized resource key e.g.:

{
    "uuid": "...",
    "type": "pages",
}

I think this could be a little bit confusing and I think we should have in future a type represented in one form. In sulu internal the resourceKey is pluralized (contacts, examples, accounts, media). So maybe it should only exist this form.

alexander-schranz commented 3 years ago

Until we switch in sulu core from singular to pluralized keys in the template keys (https://github.com/sulu/sulu/blob/34ef10a83648877617f4b89a285a6f10fcf15289/src/Sulu/Bundle/PageBundle/DependencyInjection/SuluPageExtension.php#L161) or in the teaser providers (https://github.com/sulu/sulu/blob/6c08bf8df4bc493cea8a619409d2fd5bc320726e/src/Sulu/Bundle/PageBundle/Resources/config/teaser.xml#L19) we could also work in SuluHeadlessBundle around it using the Inflector to be consistent atleast in the returned Api.