Render query param examples as placeholders
See original GitHub issueI 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:
- Created 4 years ago
- Reactions:19
- Comments:10 (1 by maintainers)
Top GitHub Comments
I guess in my situation it would just be more beneficial if the example was a hint rather than a default. See example below.
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 😄
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?