Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add array as possible body input type to http:backstage:request action #1343

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading