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

feat(curl): optionally display cURL snippet before try #851

Merged
merged 3 commits into from
Dec 2, 2022

Conversation

sroucheray
Copy link
Contributor

This PR had the capability to show cURL snippet before clicking on the TRY button.

  • By default the behaviour of displaying the cURL tab remains the same.
  • I added an attribute show-snippet to the component accepting as a value default | before-try

When setting before-try the cURL snippet box is displayed after the request body and before the response. In this case the cURL tab in the response is not shown.

The cURL snippet is updated when user changes values in forms.

image

Copy link
Collaborator

@mrin9 mrin9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see only showSnippet attribute being added, but don't find the code which is using it.
Can you re-check the PR on your end

also if you are modifying the PR, can you rename the attribute showSnippet to showCurlBeforeTry : true | false .
All our attributes starting with show- or allow- are of boolean type

@sroucheray
Copy link
Contributor Author

Sorry I messed with splitting my branch by commits. I just pushed force the changes, taking into account your feedbacks. It is all fixed now.

@mrin9
Copy link
Collaborator

mrin9 commented Dec 1, 2022

I see that you have changed the attribute name to show-curl-before-try, but I still dont see the code that uses its value

@mrin9
Copy link
Collaborator

mrin9 commented Dec 1, 2022

sorry for the confusion, some of my stashed change was overwriting your changes

Though I am in the middle of the review, and like the idea of displaying curl before TRY.
I like to provide a UI feedback

The curl syntax needs to be little more readable and easy to paste and execute
Here is how the syntax looks in your PR

image

and here is how it looks in current implementation
image

basically

  • have each parameter in separate line
  • do not wrap text - let it have a scroll (large payloads will take up entire screen, which I won't be able get through our UX team

@sroucheray
Copy link
Contributor Author

sroucheray commented Dec 1, 2022

Hi @mrin9,

Sure I can revert the text wrapping to the previous behavior. I'll wait for all your feedback before pushing a fix. I took the time to revert to the original (non) wrapping behavior.

@mrin9 mrin9 merged commit b908431 into rapi-doc:master Dec 2, 2022
@mrin9
Copy link
Collaborator

mrin9 commented Dec 2, 2022

Thanks for contributing to include this awesome feature, also nice work to update documentation and fix some of the typos in code !!!

@sroucheray sroucheray deleted the feat/curl-before-try branch December 2, 2022 07:46
@guideloom
Copy link

guideloom commented Mar 13, 2023

Need this feature. When will it be available for general use?
I'd like to show the curl example, without having the "try" button. If I set "allow-try" to false, the "try" button is no longer displayed, and the curl example disappears as well.

@sroucheray
Copy link
Contributor Author

@guideloom the attribute to set to true is show-curl-before-try https://rapidocweb.com/api.html

@prassie
Copy link

prassie commented Mar 14, 2023

@sroucheray
I think @guideloom is asking for an option just to show cURL without the option to invoke/try the API, like show-curl-without-try.
I guess show-curl-before-try is functioning more like show-curl-before-invoking-try.

From: https://rapidocweb.com/examples/api-demo.html
image

@guideloom
Copy link

Yes, that's exactly it. Would be great to just have the "curl" example showing, without the try button. I had assumed by using the following combination of options that this would be achievable:

allow-try : false
show-curl-before-try: true

However, it seems the curl display is completely dependent of "allow-try" being set to true.

@sroucheray
Copy link
Contributor Author

@guideloom I suggest you open a new ticket for that for better discussions (I am not the maintainer though :) ).

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

Successfully merging this pull request may close these issues.

4 participants