Skip to content

Commit 66888a6

Browse files
committed
fix: openapi import use path parameters instead of variables
1 parent 76b8cbe commit 66888a6

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

packages/insomnia/src/utils/importers/importers/openapi-3.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,11 @@ const importFolderItem = (parentId: string) => (
270270
};
271271

272272
/**
273-
* Return path with parameters replaced by insomnia variables
273+
* Return path with parameters replaced by insomnia path parameters
274274
*
275-
* I.e. "/foo/:bar" => "/foo/{{ bar }}"
275+
* I.e. "/foo/{bar}" => "/foo/:bar"
276276
*/
277-
const pathWithParamsAsVariables = (path?: string) =>
278-
path?.replace(VARIABLE_SEARCH_VALUE, '{{ _.$1 }}') ?? '';
277+
const pathWithParamsAsPathParameters = (path?: string) => path?.replace(VARIABLE_SEARCH_VALUE, ':$1') ?? '';
279278

280279
/**
281280
* Return Insomnia request
@@ -301,7 +300,7 @@ const importRequest = (
301300
parentId: parentId,
302301
name,
303302
method: endpointSchema.method?.toUpperCase(),
304-
url: `{{ _.base_url }}${pathWithParamsAsVariables(endpointSchema.path)}`,
303+
url: `{{ _.base_url }}${pathWithParamsAsPathParameters(endpointSchema.path)}`,
305304
body: body,
306305
description: endpointSchema.description || '',
307306
headers: [...paramHeaders, ...securityHeaders],

0 commit comments

Comments
 (0)