From b50c6993adeb537c51d0119ab531ffb0eae73746 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Tue, 21 Nov 2023 14:36:15 +1100 Subject: [PATCH] functionbuilder again --- .../models/post_params_body_sheets_items.go | 2 +- build/app/restapi/embedded_spec.go | 16 ++++++++-------- build/app/restapi/operations/direktiv_post.go | 2 +- readme.md | 16 +++++++--------- swagger.yaml | 18 ++++++++---------- 5 files changed, 25 insertions(+), 29 deletions(-) diff --git a/build/app/models/post_params_body_sheets_items.go b/build/app/models/post_params_body_sheets_items.go index 301cf8f..3bfc899 100644 --- a/build/app/models/post_params_body_sheets_items.go +++ b/build/app/models/post_params_body_sheets_items.go @@ -27,7 +27,7 @@ type PostParamsBodySheetsItems struct { InputFile []apps.DirektivFile `json:"input-file"` // Label for the worksheet created in the spreadsheet - WorksheetName *string `json:"worksheet-name,omitempty"` + Name *string `json:"name,omitempty"` } // Validate validates this post params body sheets items diff --git a/build/app/restapi/embedded_spec.go b/build/app/restapi/embedded_spec.go index 2564af7..769c1be 100644 --- a/build/app/restapi/embedded_spec.go +++ b/build/app/restapi/embedded_spec.go @@ -94,7 +94,7 @@ func init() { "$ref": "#/definitions/direktivFile" } }, - "worksheet-name": { + "name": { "description": "Label for the worksheet created in the spreadsheet", "type": "string", "default": "Sheet1" @@ -141,7 +141,7 @@ func init() { "cmds": [ { "action": "foreach", - "exec": "/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) \"\" }} \"input.json\" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName \"{{ .Item.WorksheetName }}\" -outputFilename '{{ .OutFilename }}'", + "exec": "/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) \"\" }} \"input.json\" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName \"{{ .Item.Name }}\" -outputFilename '{{ .OutFilename }}'", "loop": ".Sheets", "print": true, "silent": false @@ -160,11 +160,11 @@ func init() { }, "x-direktiv-examples": [ { - "content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx\n sheets:\n - sheet:\n worksheet-name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.input)", + "content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx\n sheets:\n - name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.input)", "title": "Basic" }, { - "content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx \n sheets:\n - sheet:\n worksheet-name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.array | {input: . } | tostring ) ", + "content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx \n sheets:\n - name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.array | {input: . } | tostring ) ", "title": "Use jq to add a parent key 'input' containing array of objects" } ], @@ -305,7 +305,7 @@ func init() { "cmds": [ { "action": "foreach", - "exec": "/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) \"\" }} \"input.json\" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName \"{{ .Item.WorksheetName }}\" -outputFilename '{{ .OutFilename }}'", + "exec": "/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) \"\" }} \"input.json\" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName \"{{ .Item.Name }}\" -outputFilename '{{ .OutFilename }}'", "loop": ".Sheets", "print": true, "silent": false @@ -324,11 +324,11 @@ func init() { }, "x-direktiv-examples": [ { - "content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx\n sheets:\n - sheet:\n worksheet-name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.input)", + "content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx\n sheets:\n - name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.input)", "title": "Basic" }, { - "content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx \n sheets:\n - sheet:\n worksheet-name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.array | {input: . } | tostring ) ", + "content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx \n sheets:\n - name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.array | {input: . } | tostring ) ", "title": "Use jq to add a parent key 'input' containing array of objects" } ], @@ -431,7 +431,7 @@ func init() { "$ref": "#/definitions/direktivFile" } }, - "worksheet-name": { + "name": { "description": "Label for the worksheet created in the spreadsheet", "type": "string", "default": "Sheet1" diff --git a/build/app/restapi/operations/direktiv_post.go b/build/app/restapi/operations/direktiv_post.go index 89422d8..f3f2503 100644 --- a/build/app/restapi/operations/direktiv_post.go +++ b/build/app/restapi/operations/direktiv_post.go @@ -185,7 +185,7 @@ func runCommand0(ctx context.Context, params.DirektivDir, } - cmd, err := templateString(`/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) "" }} "input.json" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName "{{ .Item.WorksheetName }}" -outputFilename '{{ .OutFilename }}'`, ls) + cmd, err := templateString(`/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) "" }} "input.json" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName "{{ .Item.Name }}" -outputFilename '{{ .OutFilename }}'`, ls) if err != nil { ir := make(map[string]interface{}) ir[successKey] = false diff --git a/readme.md b/readme.md index 67adffe..0b08632 100644 --- a/readme.md +++ b/readme.md @@ -33,12 +33,11 @@ functions: input: out-filename: example.xlsx sheets: - - sheet: - worksheet-name: "TestSpreadsheet" - input-file: - - name: input.json - data: | - jq(.input) + - name: "TestSpreadsheet" + input-file: + - name: input.json + data: | + jq(.input) ``` #### Use jq to add a parent key 'input' containing array of objects ```yaml @@ -49,8 +48,7 @@ functions: input: out-filename: example.xlsx sheets: - - sheet: - worksheet-name: "TestSpreadsheet" + - name: "TestSpreadsheet" input-file: - name: input.json data: | @@ -135,6 +133,6 @@ functions: |------|------|---------|:--------:| ------- |-------------|---------| | infile | string| `string` | | | Name of the json input file to utilise | | | input-file | [][DirektivFile](#direktiv-file)| `[]apps.DirektivFile` | | | File to create before running commands | | -| worksheet-name | string| `string` | | `"Sheet1"`| Label for the worksheet created in the spreadsheet | | +| name | string| `string` | | `"Sheet1"`| Label for the worksheet created in the spreadsheet | | diff --git a/swagger.yaml b/swagger.yaml index 1090c00..64d260a 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -68,7 +68,7 @@ paths: items: type: object properties: - worksheet-name: + name: type: string description: Label for the worksheet created in the spreadsheet default: "Sheet1" @@ -98,12 +98,11 @@ paths: input: out-filename: example.xlsx sheets: - - sheet: - worksheet-name: "TestSpreadsheet" - input-file: - - name: input.json - data: | - jq(.input) + - name: "TestSpreadsheet" + input-file: + - name: input.json + data: | + jq(.input) - title: Use jq to add a parent key 'input' containing array of objects content: |- - id: export-xlsx @@ -113,8 +112,7 @@ paths: input: out-filename: example.xlsx sheets: - - sheet: - worksheet-name: "TestSpreadsheet" + - name: "TestSpreadsheet" input-file: - name: input.json data: | @@ -127,7 +125,7 @@ paths: - action: foreach loop: .Sheets #exec: /bin/json2excel -inputJson {{- if eq (deref .Infile) "" }} "input.json" {{- else }} {{ .Infile }} {{- end }} -worksheetName "{{ .WorksheetName }}" -outputFilename '{{ .OutFilename }}' - exec: /bin/json2excel -inputJson {{- if eq (deref .Item.Infile) "" }} "input.json" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName "{{ .Item.WorksheetName }}" -outputFilename '{{ .OutFilename }}' + exec: /bin/json2excel -inputJson {{- if eq (deref .Item.Infile) "" }} "input.json" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName "{{ .Item.Name }}" -outputFilename '{{ .OutFilename }}' silent: false print: true - action: exec