From 6c52263c3c6a1771f29a1bc4db0c7b7d908ec8f0 Mon Sep 17 00:00:00 2001 From: bplatta Date: Mon, 23 Oct 2023 11:35:07 -0500 Subject: [PATCH] Update openapi v3 import handle no operationId and no security --- .../src/utils/importers/openapi-collection.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/bruno-app/src/utils/importers/openapi-collection.js b/packages/bruno-app/src/utils/importers/openapi-collection.js index 1f648516..0b419568 100644 --- a/packages/bruno-app/src/utils/importers/openapi-collection.js +++ b/packages/bruno-app/src/utils/importers/openapi-collection.js @@ -53,9 +53,15 @@ const buildEmptyJsonBody = (bodySchema) => { const transformOpenapiRequestItem = (request) => { let _operationObject = request.operationObject; + + let operationName = _operationObject.operationId || _operationObject.summary || _operationObject.description; + if (!operationName) { + operationName = `${request.method} ${request.path}`; + } + const brunoRequestItem = { uid: uuid(), - name: _operationObject.operationId, + name: operationName, type: 'http-request', request: { url: ensureUrl(request.global.server + '/' + request.path), @@ -100,7 +106,7 @@ const transformOpenapiRequestItem = (request) => { let auth; // allow operation override - if (_operationObject.security) { + if (_operationObject.security && _operationObject.security.length > 0) { let schemeName = Object.keys(_operationObject.security[0])[0]; auth = request.global.security.getScheme(schemeName); } else if (request.global.security.supported.length > 0) {