Kong / insomnia

The open-source, cross-platform API client for GraphQL, REST, WebSockets, SSE and gRPC. With Cloud, Local and Git storage.
https://insomnia.rest
Apache License 2.0
34.65k stars 1.96k forks source link

Change Insomnia variables to path parameters in openapi import #8040

Open SpechtD opened 2 weeks ago

SpechtD commented 2 weeks ago

Feature Request

With the introduction of path parameters in version 8.6 it would be more fitting to convert path parameters in openapi format to insomnia path parameters with a colon, instead of insomnia variables with double curly brackets.

Current behavior

openapi: /foo/{bar} insomnia: /foo/{{_.$1}}

Wanted behavior

openapi: /foo/{bar} insomnia: /foo/:bar

Affected code

https://github.com/Kong/insomnia/blob/0ddbccfd3e8d010d3b769a8e562325a8e27ac006/packages/insomnia/src/utils/importers/importers/openapi-3.ts#L272-L278

If my proposal is welcomed, I will open a PR with the requested change myself.

jackkav commented 2 weeks ago

Colon led parameters would not be interpolated by nunjucks rendering. It uses brackets to identify syntax to evaluate.

SpechtD commented 2 weeks ago

I'm not sure if I'm overlooking something here, but after changing this path?.replace(VARIABLE_SEARCH_VALUE, '{{ _.$1 }}') ?? '';

to this path?.replace(VARIABLE_SEARCH_VALUE, ':$1') ?? '';

it works:

grafik

A setting to control the behavior would probably be quite suitable, if some people prefer the old behavior, but in my use case it would be a welcomed change.

jackkav commented 2 weeks ago

I guess it's possible the question is can you make url and headers editable without causing bugs or side effects. @gatzjames what do you think?