question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Render query param examples as placeholders

See original GitHub issue

I have a lot of optional query params which have examples defined on them. In most cases only a few of the query params are specified in the request.

Currently when defining an example on a query parameter, the example value is being set in the input field by default. This means that the examples become request defaults, which in most cases is undesirable. Setting the example values as placeholders on the input would make more sense, since they are not defaults anymore and can be specified manually. Considering that query params by default are optional, I think that in most cases this is what the user wants.

The default param on a query parameter currently also prefills the input with a value, but contrary to the example param I think that this is the preferred way to define a request default. If I want to define an example without it becoming the default, I currently have to add an example to the description of the parameter.

It also seems to me that current implementation contradicts the intended behavior:

Do not confuse example values with default values. An example illustrates what the value is supposed to be. A default value is what the server uses if the client does not provide the value.

I can’t think of any potential side effects that this could have.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:19
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

24reactions
lucasmfredmarkcommented, Apr 24, 2020

I guess in my situation it would just be more beneficial if the example was a hint rather than a default. See example below.

examples

The examples defined on these query params are there to tell the user in what format the input value should be. All of the query parameters are optional, but when providing an example the input already has a value. This is counterintuitive because most often the user would specify only the query params they want to provide, and now they have to remove the values in the inputs that are not needed.

Query parameters are optional by nature, which is why I think it should be up to the user to decide which query parameters to include. Treating examples are defaults forces the user to include query parameters by default, which I think is undesirable in most cases.

A solution could be to display examples beside the input, and allowing them to easily apply an example value to the input by clicking on it. This way the user can choose to use the example value or not.

I hope this makes sense 😄

8reactions
SleepWalkercommented, Aug 16, 2021

This issue looks too simple to implement. Why is it still open? I can send PR if it is the only thing that missing in order to get the correct behavior.

@char0n, @shockey I don’t know who is responsible to take further decisions. Can you suggest what should be next actions to get this feature released?

Read more comments on GitHub >

github_iconTop Results From Across the Web

OpenAPI query parameter description not set to text box as ...
If the parameter has an example or default value (or x-example in OpenAPI 2.0), Swagger UI will use this value as a placeholder...
Read more >
Change rendering parameters based on placeholder
You can make use of the Parameters field on the View/Controller Rendering templates to pass in some additional values and then use these...
Read more >
The Complete Guide to URL parameters with React Router
In this post you'll learn how to use URL parameters with React ... you render can be dynamic based on the "placeholder" portion...
Read more >
Placeholders for attribute paths in ORDA queries - 4D Blog
The placeholders are inserted as :paramIndex (e.g., :1, :2, … with an increment of 1) in the query string. Their corresponding values are ......
Read more >
Running parameterized queries | BigQuery
Alternatively, use the placeholder value ? to specify a positional parameter. Note that a query can use positional or named parameters but not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found