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

Change Insomnia variables to path parameters in openapi import #8040

Open
SpechtD opened this issue Oct 3, 2024 · 5 comments
Open

Change Insomnia variables to path parameters in openapi import #8040

SpechtD opened this issue Oct 3, 2024 · 5 comments

Comments

@SpechtD
Copy link

SpechtD commented Oct 3, 2024

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

/**
* Return path with parameters replaced by insomnia variables
*
* I.e. "/foo/:bar" => "/foo/{{ bar }}"
*/
const pathWithParamsAsVariables = (path?: string) =>
path?.replace(VARIABLE_SEARCH_VALUE, '{{ _.$1 }}') ?? '';

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

@jackkav
Copy link
Contributor

jackkav commented Oct 4, 2024

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

@SpechtD
Copy link
Author

SpechtD commented Oct 5, 2024

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
Copy link
Contributor

jackkav commented Oct 7, 2024

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?

@SpechtD
Copy link
Author

SpechtD commented Oct 27, 2024

Have you got any updates on this?

@MGREMY
Copy link

MGREMY commented Dec 9, 2024

Any update here ? Just tried insomnia over postman and actually this seems to be the only thing that I use and is not in insomnia

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants