diff --git a/swagger.yaml b/swagger.yaml index d9e1604..47b8d16 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -56,26 +56,31 @@ paths: schema: type: object required: - - worksheet-name - out-filename properties: - files: - type: array - items: - $ref: '#/definitions/direktivFile' - description: File to create before running commands. - default: [] - infile: - type: string - description: Name of the json input file to utilise - worksheet-name: - type: string - description: Label for the worksheet created in the spreadsheet - default: "Sheet1" out-filename: type: string description: the filename of the output spreadsheet default: "output.xlsx" + sheets: + type: array + description: Array of worksheets to create in spreadsheet + items: + type: object + properties: + worksheet-name: + type: string + description: Label for the worksheet created in the spreadsheet + default: "Sheet1" + infile: + type: string + description: Name of the json input file to utilise + input-file: + type: array + items: + $ref: '#/definitions/direktivFile' + description: File to create before running commands + default: [] # direktiv code generation is configured here x-direktiv-function: |- functions: @@ -91,12 +96,14 @@ paths: action: function: export-xlsx input: - files: - - name: input.json - data: | - jq(.input) - worksheet-name: "TestSpreadsheet" out-filename: example.xlsx + sheets: + - sheet: + worksheet-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 @@ -104,19 +111,23 @@ paths: action: function: export-xlsx input: - files: - - name: input.json - data: | - jq(.array | {input: . } | tostring ) - worksheet-name: "TestSpreadsheet" out-filename: example.xlsx + sheets: + - sheet: + worksheet-name: "TestSpreadsheet" + input-file: + - name: input.json + data: | + jq(.array | {input: . } | tostring ) x-direktiv-secrets: - name: export-xlsxSecret description: This is a secret value x-direktiv: cmds: - - action: exec - exec: /bin/json2excel -inputJson {{- if eq (deref .Infile) "" }} "input.json" {{- else }} {{ .Infile }} {{- end }} -worksheetName "{{ .WorksheetName }}" -outputFilename '{{ .OutFilename }}' + - 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 }}' silent: false print: true - action: exec