craftercms / craftercms

Parent project for Crafter CMS. Issue tracking across all repositories and global builds.
GNU General Public License v3.0
282 stars 98 forks source link

Permit disabling the envelope around studio plugin REST scripts #6746

Open tfield opened 2 weeks ago

tfield commented 2 weeks ago

Duplicates

Is your feature request related to a problem? Please describe.

I would like to write a studio plugin REST script that returns a specific JSON format, however, studio plugin rest scripts return the response wrapped in an envelope. The envelope interferes with my consumption of the REST response.

Here is an example of my problem:

The URL: http://localhost:8080/studio/api/2/plugin/script/plugins/org/myco/graph-preview-proxy/plugin/graph-preview-proxy/graphql-proxy.json

My plugin content:

def result = [:]
result.greeting = "hello russ"
return result

The response:

HTTP/1.1 200 
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Referrer-Policy: no-referrer
Content-Security-Policy-Report-Only: default-src 'self' 'unsafe-inline' 'unsafe-eval' data: blob: *
X-Permitted-Cross-Domain-Policies: none
Content-Type: application/json
Transfer-Encoding: chunked
Date: Fri, 03 May 2024 21:14:18 GMT
Connection: close

{"response":{"code":0,"message":"OK","remedialAction":"","documentationUrl":""},"result":{"greeting":"hello russ"}}

In pretty form:

{
   "response":{
      "code":0,
      "message":"OK",
      "remedialAction":"",
      "documentationUrl":""
   },
   "result":{
      "greeting":"hello russ"
   }
}

As you can see, the

{
  "greeting":"hello russ"
}

object is wrapped in an envelope.

Describe the solution you'd like

I would like to be able to set something in the plugin configuration file that disables the wrapper, and allows my returned object to be the entire REST response.