Files
backstage/.changeset/metal-nails-punch.md
T
Brian Fletcher 6977ed06d7 expand changeset and use accordian for examples
Signed-off-by: Brian Fletcher <brian@roadie.io>
2022-12-22 09:02:33 +00:00

1.3 KiB

@backstage/plugin-scaffolder-backend
@backstage/plugin-scaffolder-backend
patch

This patch adds changes to provide examples alongside scaffolder task actions.

The createTemplateAction function now takes a list of examples e.g.

const actionExamples = [
  {
    description: 'Example 1',
    example: yaml.stringify({
      steps: [
        {
          action: 'test:action',
          id: 'test',
          input: {
            input1: 'value',
          },
        },
      ],
    }),
  },
];

export function createTestAction() {
  return createTemplateAction({
      id: 'test:action',
      examples: [
          {
              description: 'Example 1',
              examples: actionExamples
          }
      ],
      ...,
  });

These examples can be retrieved later from the api.

curl http://localhost:7007/api/scaffolder/v2/actions
[
  {
    "id": "test:action",
    "examples": [
      {
        "description": "Example 1",
        "example": "steps:\n  - action: test:action\n    id: test\n    input:\n      input1: value\n"
      }
    ],
    "schema": {
      "input": {
        "type": "object",
        "properties": {
          "input1": {
            "title": "Input 1",
            "type": "string"
          }
        }
      }
    }
  }
]