Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Workflow: parameters as object not as string #151

Merged
merged 1 commit into from
Mar 23, 2023

Conversation

eloycoto
Copy link
Collaborator

@eloycoto eloycoto commented Mar 23, 2023

Required is set as "true" as string, but Backstage is not rendering it well, so moving to a native type and using Object instead of String.

Example output:

{
    "id": "ffe20407-7af4-4a14-b6a8-e1c4c02cfaf5",
    "name": "simpleSequentialWorkFlow_INFRASTRUCTURE_WORKFLOW",
    "type": "INFRASTRUCTURE",
    "processingType": "SEQUENTIAL",
    "author": null,
    "createDate": "2023-03-23T14:05:40.325+00:00",
    "modifyDate": "2023-03-23T14:05:40.325+00:00",
    "works": [
      {
        "id": "749705aa-7a2d-4ff2-8c7c-40369dfb50d8",
        "name": "restCallTask",
        "workType": "TASK",
        "parameters": {
          "payload": {
            "format": "text",
            "description": "Json of what to provide for data. (ie: 'Hello!')",
            "type": "string",
            "required": true
          },
          "user-id": {
            "format": "text",
            "description": "The user id",
            "type": "string",
            "required": true
          },
          "url": {
            "format": "url",
            "description": "The Url of the service (ie: https://httpbin.org/post",
            "type": "string",
            "required": true
          }
        },
        "outputs": [
          "HTTP2XX",
          "OTHER"
        ]
      },
      {
        "id": "191a4f56-0653-4799-864b-9633141951ce",
        "name": "loggingTask",
        "workType": "TASK",
        "parameters": {
          "user-id": {
            "minLength": 1,
            "format": "text",
            "description": "The user id",
            "type": "string",
            "required": true,
            "maxLength": 64
          },
          "api-server": {
            "format": "url",
            "description": "The api server",
            "type": "string",
            "required": true
          }
        },
        "outputs": [
          "OTHER"
        ]
      }
    ]
  }

Let me highlight the required, minLength and maxLength parameters that are no longer string.

Related to FLPATH-193

Required is set as "true" as string, but Backstage is not rendering it
well, so moving to a native type and using Object instead of String.

Example output:
```
{
    "id": "ffe20407-7af4-4a14-b6a8-e1c4c02cfaf5",
    "name": "simpleSequentialWorkFlow_INFRASTRUCTURE_WORKFLOW",
    "type": "INFRASTRUCTURE",
    "processingType": "SEQUENTIAL",
    "author": null,
    "createDate": "2023-03-23T14:05:40.325+00:00",
    "modifyDate": "2023-03-23T14:05:40.325+00:00",
    "works": [
      {
        "id": "749705aa-7a2d-4ff2-8c7c-40369dfb50d8",
        "name": "restCallTask",
        "workType": "TASK",
        "parameters": {
          "payload": {
            "format": "text",
            "description": "Json of what to provide for data. (ie: 'Hello!')",
            "type": "string",
            "required": true
          },
          "user-id": {
            "format": "text",
            "description": "The user id",
            "type": "string",
            "required": true
          },
          "url": {
            "format": "url",
            "description": "The Url of the service (ie: https://httpbin.org/post",
            "type": "string",
            "required": true
          }
        },
        "outputs": [
          "HTTP2XX",
          "OTHER"
        ]
      },
      {
        "id": "191a4f56-0653-4799-864b-9633141951ce",
        "name": "loggingTask",
        "workType": "TASK",
        "parameters": {
          "user-id": {
            "minLength": 1,
            "format": "text",
            "description": "The user id",
            "type": "string",
            "required": true,
            "maxLength": 64
          },
          "api-server": {
            "format": "url",
            "description": "The api server",
            "type": "string",
            "required": true
          }
        },
        "outputs": [
          "OTHER"
        ]
      }
    ]
  }
```

Let me highlight the required, minLength and maxLength parameters that
are no longer string.

Related  to FLPATH-193

Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
Copy link
Collaborator

@pkliczewski pkliczewski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Map<String, String> properties = this.getType().getAsJsonSchema();
properties.put("required", String.valueOf(!this.isOptional()));
Map<String, Object> properties = this.getType().getAsJsonSchema();
properties.put("required", !this.isOptional());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doubt: did you check if it's ok to put a boolean instead of a Boolean if the map expect Object?

Copy link
Contributor

@gabriel-farache gabriel-farache Mar 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure Java itself allows primitive types in Collections, but it may have change

Bit old but still relevant: https://stackoverflow.com/questions/2504959/why-can-java-collections-not-directly-store-primitives-types

@openshift-ci
Copy link

openshift-ci bot commented Mar 23, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: eloycoto, lshannon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@lshannon lshannon merged commit 662ae18 into parodos-dev:main Mar 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants