dotCMS / core

Headless/Hybrid Content Management System for Enterprises
http://dotcms.com
Other
839 stars 465 forks source link

Content API, ES Search API and Velocity viewtools needs to return the JSON not as a string #22065

Closed fmontes closed 2 years ago

fmontes commented 2 years ago

Describe the bug As a frontend developer, I need the block data comes as a JSON object and not a string. So, I can use this as it comes.

To Reproduce Steps to reproduce the behavior:

  1. Save a contentlet with a block field
  2. Hit the APIS
  3. See how the block information comes as a string

Expected behavior It should return as JSON

Additional context

Content API:

/api/content/render/false/query/+contentType:webPageContent%20+(conhost:8a7d5e23-da1e-420a-b4f0-471e7da8ea2d%20conhost:SYSTEM_HOST)%20+languageId:1%20+deleted:false%20+working:true/orderby/modDate%20desc

ES API:

curl -H "Content-Type: application/json" -XPOST http://localhost:8080/api/es/search?pretty -d '
{
    "query" : { 
        "query_string" : {
            "query" : "+contentType:webPageContent"
        } 

    },
    "size":3 ,
    "sort":{
        "moddate":"asc"
    }
}'
bryanboza commented 2 years ago

We need some postman test here...

fmontes commented 2 years ago

More work, this endpoint is still returning a JSON in the urlContentMap

https://starter.dotcms.com:8443/api/v1/page/json//blog/post/french-polynesia-everything-you-need-to-know

bryanboza commented 2 years ago

Fixed, tested on release-22.05 // Docker // FF

Now the blog field is coming in JSON format instead of a String

{
    "contentlets": [
        {
            "hostName": "demo.dotcms.com",
            "modDate": "2022-05-04 22:06:58.588",
            "publishDate": "2022-05-04 22:06:58.588",
            "title": "Costa Rica Family Adventure",
            "body": "<h2>Costa Rica Family Adventure</h2>\n<p>Tropical rainforests, zip lines, monkey sightings and waterfall swims make for the most unforgettable vacation&mdash;and photos.</p>\n<p>Abundance abounds in Costa Rica: beautiful beaches, friendly people and endless adventures to embark upon. We dabble in it all with a family-friendly itinerary that will get everyone&rsquo;s heart pumping. Jump right in to adventure life in Costa Rica at Arenal Volcano where we zip along the treetops, get a glimpse of rural Tico life on a local farm, rappel down a canyon waterfall that lies deep in the tropical rainforest, and soak in thermal hot springs.</p>\n<p>Journey south, crossing Lake Arenal by boat, and dive deep into the Monteverde cloud forest. Your hotel is located in the reserve, home to eight different biological zones and thousands of plants and animals. Keep your eyes peeled for monkeys and quetzals during the day and embark on night walks with your guide to experience a whole different world after dark. Spend a unique day exploring the forest giants from the ground up&mdash;climbing up specially outfitted trees and then exploring the forest on foot with your naturalist guide.</p>",
            "blog": {
                "type": "doc",
                "content": [
                    {
                        "type": "paragraph",
                        "attrs": {
                            "textAlign": "left"
                        },
                        "content": [
                            {
                                "type": "text",
                                "text": "test"
                            }
                        ]
                    }
                ]
            },
            "baseType": "CONTENT",
            "inode": "f1d1b785-34bf-4dd4-a09b-4505314ad407",
            "archived": false,
            "host": "48190c8c-42c4-46af-8d1a-0cd5db894797",
            "working": true,
            "locked": false,
            "stInode": "2a3e91e4-fbbf-4876-8c5b-2233c1739b05",
            "contentType": "webPageContent",
            "live": true,
            "owner": "036fd43a-6d98-46e0-b22e-bae02cb86f0c",
            "identifier": "3e6533b7-c3ba-4ec4-8bca-6a88d54cd037",
            "languageId": 1,
            "url": "/content.eadeeed9-64ad-4a5d-96ad-612f14d3037d",
            "titleImage": "TITLE_IMAGE_NOT_FOUND",
            "modUserName": "Admin User",
            "hasLiveVersion": true,
            "folder": "SYSTEM_FOLDER",
            "hasTitleImage": false,
            "sortOrder": 0,
            "modUser": "dotcms.org.1",
            "__icon__": "contentIcon",
            "contentTypeIcon": "wysiwyg"
        },