elasticio / elasticio-cli

Command-line interface for elastic.io components
2 stars 1 forks source link

CLI tool does not handle asymettrically formated metadata info in component.json #42

Closed jhorbulyk closed 4 years ago

jhorbulyk commented 4 years ago

Steps to Reproduce

  1. Clone the petstore component.
  2. Create a test/fixture.json file with a template fixture:
    {
    "fixtures": {
    "successfulFixture": {
      "cfg": {},
      "msg": {
        "body": {}
      }
    },
    "failFixture": {
      "cfg": {},
      "msg": {
        "body": {}
      }
    }
    }
    }
  3. Create actions in component.json with the following format:
    "actions": {
    "createPet2": {
      "main": "./lib/actions/createPetWithPromise.js",
      "title": "Create a Pet With Promise",
      "metadata": {
        "in": "./lib/schemas/createPet.in.json",
        "out": "./lib/schemas/createPet.out.json"
      }
    },
    "createPet": {
      "main": "./lib/actions/createPet.js",
      "title": "Creates a new pet",
      "description": "Creates a pet and adds it to the shop",
      "metadata": {
        "in": "./lib/schemas/createPet.in.json"
      }
    },
    "createPet1": {
      "main": "./lib/actions/createPet.js",
      "title": "Creates a new pet",
      "description": "Creates a pet and adds it to the shop",
      "metadata": {
        "in": "./lib/schemas/createPet.in.json",
        "out": {
          "type": "object",
          "properties": {
            "result": {
              "type": "object",
              "required": false,
              "title": "Json"
            }
          }
        }
      }
    }
    }
  4. Run the CLI tool while referencing an the above actions. i.e.
    • elasticio cmp:process -a createPet1 -x successfulFixture
    • elasticio cmp:process -a createPet -x successfulFixture

Current Behavior

Currently, an error is printed (not in RED)

The "path" argument must be of type string. Received type object

Desired Behavior

Investigate what the platform does in these situations and apply the appropriate validations.

jhorbulyk commented 4 years ago

Additionally, the CLI tool does not handle the case when metadata is omitted (to signify no mapper should be placed in front of the component).