Skip to content

Commit

Permalink
Merge pull request #1343 from maurosch/main
Browse files Browse the repository at this point in the history
Add array as possible body input type to http:backstage:request action
  • Loading branch information
punkle authored Apr 16, 2024
2 parents bee37f8 + a367778 commit 936dac3
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/two-socks-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@roadiehq/scaffolder-backend-module-http-request': minor
---

Added array as possible body input type to http:backstage:request action
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,43 @@ describe('http:backstage:request', () => {
});
});

describe('with body defined as application/json and passing an array', () => {
it('should create a request and pass body parameter', async () => {
(http as jest.Mock).mockReturnValue({
code: 200,
headers: {},
body: {},
});
await action.handler({
...mockContext,
input: {
path: '/api/proxy/foo',
method: 'POST',
headers: {
'content-type': 'application/json',
},
body: JSON.stringify([
{
name: 'test',
},
]),
},
});
expect(http).toHaveBeenCalledWith(
{
url: 'http://backstage.tests/api/proxy/foo',
method: 'POST',
headers: {
'content-type': 'application/json',
},
body: '[{"name":"test"}]',
},
logger,
false,
);
});
});

describe('with authorization header', () => {
const BACKSTAGE_TOKEN = 'BACKSTAGE_TOKEN';
it('should create a request and pass backstage token as authorization header', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export function createHttpBackstageAction(options: {
body: {
title: 'Request body',
description: 'The body you would like to pass to your request',
type: ['object', 'string'],
type: ['object', 'string', 'array'],
},
logRequestPath: {
title: 'Request path logging',
Expand Down

0 comments on commit 936dac3

Please sign in to comment.