Kreya icon indicating copy to clipboard operation
Kreya copied to clipboard

nguid suggestion in autocomplete

Open ikkentim opened this issue 3 years ago • 6 comments

In Visual Studio I use resharper. When I am writing a unittest and need a GUID, I can type nguid<tab> to generate a GUID.

I think this might be a useful feature for Kreya.

image

image

ikkentim avatar Sep 28 '21 09:09 ikkentim

Thank you for your request.

Do you need the guid to stay consistent across requests or do you want to have a new guid generated each time you send the request?

A shortcut to generate a consistent guid is currently not supported. For the latter you could use {{ math.uuid }} which provides a new guid for each request in the format 2dc55d50-3f6c-446a-87d0-a5a4eed23269. If you need the guid in a different format, you could try manipulating it with the string functions of scriban. Support for the dotnet built in guid format identifiers will be added in Kreya 1.7.

latonz avatar Sep 28 '21 10:09 latonz

The use case is this: I'm working on some system where a submit a request to create a resource with a specific guid, and then want to try and get the resource with the same guid a few times. I'm manually filling the request fields, but manually creating a guid is a bit of a hastle.

ikkentim avatar Sep 28 '21 11:09 ikkentim

Would https://github.com/riok/Kreya/issues/23 address your use case?

latonz avatar Sep 28 '21 11:09 latonz

The "Pre-request Script" in his example would be a decent workaround for what I'm describing. But I'm not very interested in the request chaining part, since I'm not using the tooling for repeated testing, merely for occasional requests to try an API once or twice.

Simply put, all I am looking for is to occasionally generate a guid at my cursor in the request so I can copy/paste it into a subsequent request, without going through the effort of scripting anything. See you guys got a nice autocomplete working, I think the nguid thing I mentioned might be the easiest way (for the user) to works with these ids in non-scripted subsequent requests.

Using the pre-request script from #23 I could insert 1 unique guid in a request, but:

  • If the request should contain multiple guids I cannot use this method.
  • If the response does not contain the same guid, I cannot copy/paste the guid to a subsequent request.

Currently, I'm using the "Create GUID" tool provided by VS as a workaround.

By the way, in postman the variable {{$guid}} is available which contains a unique guid for every use. But this has the same copy/paste caveat I mentioned before. (you can lookup the guid in the console log, but I wouldn't consider this user-friendly)

ikkentim avatar Sep 28 '21 11:09 ikkentim

Now I got your use case :slightly_smiling_face: We may implement this in the future, but this feature isn't currently on our shortlist.

latonz avatar Sep 29 '21 15:09 latonz

No worries, I really like what Kreya has to offer (especially authentication). This very much isn't isn't a blocking issue for my usage ;)

ikkentim avatar Sep 29 '21 16:09 ikkentim