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

fix: getParams when operation parameters is absent #103

Merged
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
2 changes: 1 addition & 1 deletion src/services/open-api-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class OpenApiClient {

getParams(opts, operation) {
const params = {};
operation.parameters.forEach((parameter) => {
(operation.parameters || []).forEach((parameter) => {
/*
* Build the actual request params from the spec's query parameters. This
* effectively drops all params that are not in the spec.
Expand Down
18 changes: 18 additions & 0 deletions test/services/twilio-api/twilio-client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,24 @@ describe('services', () => {
});
});

describe('absent operation parameters', () => {
test
.nock('https://conversations.twilio.com', (api) => {
api.get(`/v1/Configuration`).reply(200, {
// eslint-disable-next-line camelcase
account_sid: accountSid,
});
})
.it('can fetch', async () => {
const response = await apiClient.fetch({
domain: 'conversations',
path: '/v1/Configuration',
});

expect(response).to.eql({ accountSid });
});
});

describe('regional and edge support', () => {
const defaultRegionTest = test.nock('https://api.edge.us1.twilio.com', (api) => {
api.post(`/2010-04-01/Accounts/${accountSid}/Messages.json`).reply(201, {
Expand Down