Merge pull request #15341 from RoadieHQ/scaffolder-examples

add examples of scaffolder action inputs to docs
This commit is contained in:
Fredrik Adelöw
2023-01-10 14:01:28 +01:00
committed by GitHub
13 changed files with 305 additions and 15 deletions
+69
View File
@@ -0,0 +1,69 @@
---
'@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.
```typescript
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.
```bash
curl http://localhost:7007/api/scaffolder/v2/actions
```
```json
[
{
"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"
}
}
}
}
}
]
```
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder': patch
---
Show action example yaml on the scaffolder actions documentation page.