From ecb55ccbb8997a35f605cd95ebf12c7a53fc1ea7 Mon Sep 17 00:00:00 2001 From: Steve Konves Date: Sun, 21 Apr 2019 18:52:21 -0700 Subject: [PATCH] fix: allow operation without parameters --- src/tester/factories/missing-parameter.ts | 4 +++- src/tester/utils/index.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/tester/factories/missing-parameter.ts b/src/tester/factories/missing-parameter.ts index 46acc07..36b17de 100644 --- a/src/tester/factories/missing-parameter.ts +++ b/src/tester/factories/missing-parameter.ts @@ -5,7 +5,9 @@ export const createMissingParameters: OperationTestFactory = { type: 'operation', create: function*({ verb, pathPattern, spec, validRequest }, { uriFactory }) { const { parameters } = spec.paths[pathPattern][verb]; - const required = parameters.filter(p => !isRef(p) && p.required); + const required = parameters + ? parameters.filter(p => !isRef(p) && p.required) + : []; for (const parameter of required) { if (!isRef(parameter)) { diff --git a/src/tester/utils/index.ts b/src/tester/utils/index.ts index 1e7839d..2478f8d 100644 --- a/src/tester/utils/index.ts +++ b/src/tester/utils/index.ts @@ -41,7 +41,9 @@ export function createValidRequest( ): RequestParams { const { parameters } = operation; - const required = parameters.filter(p => !isRef(p) && p.required); + const required = parameters + ? parameters.filter(p => !isRef(p) && p.required) + : []; const request: RequestParams = { path: {}, headers: {},