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

[Feature request] Client-side validation of required url params (Try it out) #641

Closed
mortenscheel opened this issue Mar 29, 2023 · 1 comment

Comments

@mortenscheel
Copy link
Contributor

I'll use a simple endpoint as an example: GET /orders/{id} which requires authentication.

By default, Scribe will create an example value, and this value will be added to the Try it out form's id input.
The problem is that the user probably doesn't have access to this random order id, so the default Try it out request will result in a 403 error.
The logical solution to this is to add No-example to this parameter, to avoid having the form filled with an invalid id.
But this leads to a different issue. If the user doesn't enter a value for id, the request is sent to a completely different endpoint: /orders.

This could be solved by adding some very simple client-side validation to the Try it out form. I imagine it would be enough to add required to the relevant inputs, and check if the native browser validation passes before sending the request.

@shalvah
Copy link
Contributor

shalvah commented Mar 29, 2023

We used to add required for required fields in the past, but I changed it. The reason: sometimes the user may want to see how the API responds when a parameter is missing. Obviously, for URL parameters, this takes you to a totally different URL, meaning it's not useful. So we can change that, but very low priority. PRs welcome.

@shalvah shalvah closed this as completed Feb 21, 2025
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

2 participants