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

Improvement: A menu alternative for "Refresh" and some other stuff (possible PR) #7

Closed
tekeroth-snapcode opened this issue Jun 6, 2022 · 0 comments

Comments

@tekeroth-snapcode
Copy link

tekeroth-snapcode commented Jun 6, 2022

I've been using the Swagger UI tool, but I was missing a "Refresh" button, to refresh the URL that once was used to fetch the OpenAPI spec. Instead, I had to go to "Import URL" and add the URL every time I made a change to the spec in the backend code.

I did try to see if a page refresh (F5) had any effect, but it didnt. So, I cloned the repo, and made some small changes for me to run locally. I was considering a PR for this, but I read this, and here is the issue first for ppl to comment on =)

Changes I made locally, that I can make into a PR if ppl want it:

  • Added a menu alternative "Refresh":
    image
    Pressing this button, will re-download the specification from a url previously entered
  • topbar.jsx: added the refreshURL function, that looks in window.localstorage for the 'url' and refreshes it if it is found. If there is no cached URL, it will call the importFromURL instead, opening up the popup to enter URL
  • topbar.jsx:: added code to importFromURL so that the URL is cached in window.localstorage
  • Modified the logic for Clear editor in function clearEditor to also remove the url from localStorage
  • added a toast library, since I was lacking feedback for some actions (like when doing an 'Import from URL'); https://www.cssscript.com/super-simple-javascript-message-toaster-toast-js/#google_vignette
  • added toasts for both Refresh and the Import from URL options
    image

I am not a web dev or react dev, so I was unsure where to place the toast lib js file. Currently, it is inside the /dist folder, so the index.html is modified like this:

<body>
  <div id="swagger-editor"></div>
  <!--  https://www.cssscript.com/super-simple-javascript-message-toaster-toast-js/#google_vignette -->
  <script src="./dist/toast.min.js"> </script>
  <script src="./dist/swagger-editor-bundle.js"> </script>

Please let me know if I should make a PR out of this, or not =)

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

1 participant