Skip to content

[6.0] Enable Schemaorg plugin support via API #45319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: 6.0-dev
Choose a base branch
from

Conversation

Sanjana2906
Copy link

@Sanjana2906 Sanjana2906 commented Apr 14, 2025

Pull Request for Issue #45178.

Summary of Changes

This PR updates the Schemaorg system plugin to allow it to be executed when content is saved via API client, in addition to administrator client. This enables schema metadata to be processed properly for content created or updated through Joomla's REST API.

Testing Instructions

Enable the Schemaorg plugin in the backend.
Use Joomla REST API to create or update an article.
Check if schema metadata is generated or excepted.
Verify that the plugin continues to work correctly in the admin interface as before.

Actual result BEFORE applying this Pull Request

Schemaorg plugin does not execute when content is saved via API.

Expected result AFTER applying this Pull Request

Schemaorg plugin supports execution via both admin and API clients.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@richard67
Copy link
Member

@Sanjana2906 The title of your PR starts with "[5.3]", but you have made the PR for the 5.2-dev branch.

As there will not be any further 5.2.x release, and 5.3.0 will be the next: Could you rebase your PR to the 5.3-dev branch?

If you are not sure how to do that, let me know, then I can do that.

Thanks in advance.

@Sanjana2906 Sanjana2906 changed the base branch from 5.2-dev to 5.3-dev April 14, 2025 16:15
@richard67
Copy link
Member

@Sanjana2906 Thanks for rebasing. Unfortunately you have also pished your .htaccess file. Could you revert that?

@Sanjana2906 Sanjana2906 force-pushed the fix-schemaorg-api-support branch from e27958c to 67d9dfa Compare April 14, 2025 16:36
@Sanjana2906
Copy link
Author

@richard67 Thanks for the review! I've reverted the '.htaccess' commits . The branch is now synced with '5.3-dev' .

@richard67
Copy link
Member

@richard67 Thanks for the review! I've reverted the '.htaccess' commits . The branch is now synced with '5.3-dev' .

@Sanjana2906 Now you deleted the htaccess.txt file. Could you revert that, too? Your PR should show only the desired changes here: https://github.com/joomla/joomla-cms/pull/45319/files

@Sanjana2906
Copy link
Author

@brianteeman Appreciate the link- that was helpful, Thank you!

@richard67
Copy link
Member

@Sanjana2906 Thanks. PR looks good now.

@Sanjana2906
Copy link
Author

@richard67 Thanks for catching that! I've reverted the accidental deletion of 'htaccess.txt' and restored it from '5.3-dev'. The PR now only includes schema.org API support changes.

@alikon
Copy link
Contributor

alikon commented Apr 14, 2025

can you please document what the payload should be ? for POST/PATCH/GET the schemaorg

@Sanjana2906
Copy link
Author

@alikon
I've compiled comprehensive documentation covering the payload for POST, PATCH and, GET requests . You can find the full detail here: [ https://github.com/joomla/joomla-cms/compare/5.3-dev...Sanjana2906:joomla-cms:schemaorg-doc-pr?expand=1#diff-431d327d47e0b4f79604cd2b0a778cac5d94376db392cde6f1e2aa16181316c2 ] .
Thank you for the feedback.

@alikon
Copy link
Contributor

alikon commented Apr 15, 2025

with this pr
i've POSTed an article with the following payload

{
    "title" : "Test Article",
    "catid": 2,
    "language": "*",
    "@type" : "Article",
    "articletext" : "Content",
    "author": {
       "type" : "Person",
       "name" : "John-doe",
       "email" : "[email protected]"
    }
  }

but when i execute the GET

{
    "links": {
        "self": "http://localhost/530/api/index.php/v1/content/articles/107"
    },
    "data": {
        "type": "articles",
        "id": "107",
        "attributes": {
            "typeAlias": "com_content.article",
            "id": 107,
            "asset_id": 168,
            "title": "Test Article",
            "alias": "test-article",
            "state": 0,
            "created": "2025-04-15 12:54:59",
            "created_by": 506,
            "created_by_alias": "",
            "modified": "2025-04-15 12:54:59",
            "modified_by": 506,
            "publish_up": null,
            "publish_down": null,
            "images": [],
            "urls": [],
            "version": 1,
            "metakey": "",
            "metadesc": "",
            "access": 1,
            "hits": 0,
            "metadata": [],
            "featured": 0,
            "language": "*",
            "note": "",
            "tags": [],
            "featured_up": null,
            "featured_down": null,
            "text": "Content "
        },
        "relationships": {
            "category": {
                "data": {
                    "type": "categories",
                    "id": "2"
                }
            },
            "created_by": {
                "data": {
                    "type": "users",
                    "id": "506"
                }
            },
            "tags": {
                "data": []
            },
            "modified_by": {
                "data": {
                    "type": "users",
                    "id": "506"
                }
            }
        }
    }
}

i don't see any schemaorg related data , all the schemaorg plugins are enabled

@Fedik Fedik added the Feature label Apr 15, 2025
@Sanjana2906
Copy link
Author

Hi @alikon ,
Thanks for testing and for the detailed observation.
You're right - currently the structured data ( Schema.org ) is successfully handled during the POST, but it's not yet returned in the GET response. This is because Joomla's core API doesn't automatically include plugin metadata unless we explicitly inject it into the response. I'll extend the implementation to include that by injecting the data during API response generation.
Appreciate you pointing that out - I'll follow up with the necessary changes.

@HLeithner HLeithner changed the title [5.3]Enable Schemaorg plugin support via API [5.3] Enable Schemaorg plugin support via API Apr 15, 2025
@HLeithner HLeithner changed the title [5.3] Enable Schemaorg plugin support via API [6.0] Enable Schemaorg plugin support via API Apr 17, 2025
@HLeithner HLeithner changed the base branch from 5.3-dev to 6.0-dev April 17, 2025 07:09
@HLeithner
Copy link
Member

I rebased this feature pr against 6.0, also please remove the documentation from the pr and create an entry in manual.joomla.org (since we don't have a clean documentation for api in the manual yet please add it to this section.

I also changed the pr to draft till it's complete

@HLeithner HLeithner marked this pull request as draft April 17, 2025 07:11
@Sanjana2906
Copy link
Author

I'll be drafting the updated API documentation and adding it to Joomla Manual by tomorrow. Please let me know if there are specific guidelines or details you'd like me to include.

@Sanjana2906
Copy link
Author

Hi @HLeithner, @alikon,

Thanks for the feedback and for moving the PR to 6.0-dev. I've written the documentation under docs/webservices/schemaorg-api-support.md as suggested — feel free to let me know if the placement looks okay.

I’ve also tested again by POSTing an article with the schema.org metadata, but I’m still not seeing any schema data returned in the GET response. The Schemaorg plugins are all enabled, but it doesn’t seem like they’re being triggered.

I’ve tried using the onAfterApiData event to inject the structured data, but I’m not fully sure if that’s the best or only way — would appreciate a little guidance if I’m missing something here.

Thanks again for your help and for reviewing the PR.

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

Successfully merging this pull request may close these issues.

7 participants