Uploaded image for project: 'FlightPath'
  1. FlightPath
  2. FLPATH-193

Task Parameters as jsonschema

XMLWordPrintable

    • Icon: Story Story
    • Resolution: Done
    • Icon: Undefined Undefined
    • v1.0.3
    • None
    • None
    • None
    • False
    • Hide

      None

      Show
      None
    • False

      At this moment, task parameters are defined in each task definition as
      TaskParameters, and it's rendered like this:

      ```
      {
      "id": "6977217b-89b3-49cb-a652-b32cc13177f7",
      "name": "certWorkFlowTask",
      "workType": "TASK",
      "parameters": [

      { "description": "The api server", "optional": false, "type": "URL", "key": "api-server" }

      ,

      { "description": "The user id", "optional": false, "type": "TEXT", "key": "user-id" }

      ],
      "outputs": [
      "OTHER"
      ]
      },
      ```

      These parameters are not great, mainly because are hard to understand from the
      frontend teams, and hard to implement custom validations. My proposal is to use
      jsonschema to define the task parameters, so the params can be defined in a
      good way. so the params will looks like this:

      ```
      {
      "id": "6977217b-89b3-49cb-a652-b32cc13177f7",
      "name": "certWorkFlowTask",
      "workType": "TASK",
      "parameters": {
      "api-server":

      { "title": "The api server", "optional": false, "type": "string", }

      ,
      "user-id":

      { "description": "The user id", "optional": false, "type": "TEXT", }

      }
      "outputs": [
      "OTHER"
      ]
      },

      ```

      The good thing is that users can define custom validations in there, like:

      ```
      "user-id":

      { "description": "The user id", "optional": false, "type": "string", "minimum": 18 }

      ```

      For workflows will be looks like this:

      ```

      WorkFlowTaskParameter
      .builder()
      .key("api-server")
      .description("The api server")
      .type(WorkFlowTaskParameterType.URL)
      .optional(false).
      .extraParams(HashMap<String, String>put("minimum", "18"))
      .build(),
      ```

      Where the extraParams are the tools that the user wants to implement. On the
      workload definition is kinda easy to match

      https://github.com/redhat-developer/parodos/blob/7cd74dfb2eacc8aae44e58d12aed59f6ea21853c/workflow-service/src/main/java/com/redhat/parodos/workflow/definition/service/WorkFlowDefinitionServiceImpl.java#L110

      On the frontend side, can be consumed by any library, but I had great success
      with react-jsonschema

      https://rjsf-team.github.io/react-jsonschema-form/

            eloycoto Eloy Coto
            eloycoto Eloy Coto
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: