twilio / twilio-cli-core

Core functionality for the twilio-cli
MIT License
14 stars 32 forks source link

-o json changes naming scheme of top level keys #171

Open TheCycoONE opened 2 years ago

TheCycoONE commented 2 years ago

Issue Summary

When the json output mode is used, top level keys are converted from snake case to camel case. Lower level keys are not modified.

Steps to Reproduce

  1. Fetch CustomerProfile evaluation with curl: curl https://trusthub.twilio.com/v1/CustomerProfiles/BUba422222159fd9b24ec6ab18f391650d/Evaluations/EL97cbd107e00509fdb56c0bc30fec6991 -u '<redacted>'
  2. Fetch same evaluation with CLI, using 'raw' json output: twilio api:trusthub:v1:customer-profiles:evaluations:fetch --sid=EL97cbd107e00509fdb56c0bc30fec6991 --customer-profile-sid=BUba422222159fd9b24ec6ab18f391650d -o json --profile=brand-test
  3. Compare the json

Example

From twilio cli

...
    "accountSid": "AC6a4293256e150602674ce979da94c34c",
    "customerProfileSid": "BUba422222159fd9b24ec6ab18f391650d",
    "dateCreated": "2021-10-30T00:41:32.000Z",
    "policySid": "RNdfbf3fae0e1107f8aded0e7cead80bf5",
    "results": [
...

From CURL

...
"account_sid": "AC6a4293256e150602674ce979da94c34c", "date_created": "2021-10-30T00:41:32Z", "sid": "EL97cbd107e00509fdb56c0bc30fec6991", "policy_sid": "RNdfbf3fae0e1107f8aded0e7cead80bf5", "customer_profile_sid": "BUba422222159fd9b24ec6ab18f391650d"}
...

Example from twilio cli of nested field:

...
        "fields": [
          {
            "object_field": "bundle_sid",
            "error_code": null,
            "friendly_name": "Supporting Bundle Status",
            "passed": true,
            "failure_reason": null
          }
...

Technical details:

shrutiburman commented 2 years ago

Thanks for raising this @TheCycoONE and being patient! To parse API responses twilio-cli uses generated Open API Spec which is based upon api-definitions. I have cut out a ticket internally to address the case-inconsistency in top level and lower level keys. +1s and Pull Requests will help us move it up in our backlog.