Apicurio / apicurio-studio

Open Source API Design
https://www.apicur.io/studio/
Apache License 2.0
987 stars 499 forks source link

Add global menu in API editor to allow download #771

Open mmindenhall opened 5 years ago

mmindenhall commented 5 years ago

I got bit pretty bad by the problem reported in #766 (lost nearly an entire day of work). Within the API editor, I had added and documented several Data Types and Paths. Clicking around within the editor there was no problem. However, when I exited the editor back to the API view (by clicking the API name in the breadcrumbs at the top of the editor view) and then went to download, I discovered that many changes were gone. It seems that the entire API state is maintained locally within the editor, so it would be nice to have the ability to download as YAML or JSON before exiting the editor (just in case).

Also, it seems that this postgresql problem reported in #766 was not detected within Apicurio Studio. Perhaps it would make sense to add code (triggered by a timer) to verify that you can write to postgresql and read back what was written? Then if the connection is broken, an error message can be popped up to the user, and the user can download based on the state held within the browser app.

EricWittmann commented 5 years ago

Yeah I apologize for #766 - there was a database connectivity problem. The state of your changes is actually not stored locally. Each change you make is sent to the server and written to the DB. However, the DB connection was broken and there is a bug in the editor where it doesn't properly handle the case where changes it sends to the server are not being saved.

My next priority is going to be making some significant enhancements to the editor to make it much resilient. That includes properly reacting to error conditions such as:

A number of changes will be made to make all of this better.

That said, I'm not opposed to a download button on the editor - but I think making the editor more resilient to error conditions is the more important fix.

Note that you can always switch to the global "Source" tab in the editor to copy/paste the content of your API design. The problem with that as a workaround is that right now the editor doesn't warn you when things are failing.

One last thing to note: the live version of Apicurio is not meant to be a production system. It is primarily for evaluation purposes. Fortunately we have had very few data loss issues in the past, so you are of course free to use it for whatever purpose you choose - but obviously you assume a bit of risk when you do that. Perhaps the live version will eventually evolved into a monetized production system at some point in the future, but there are currently no plans for that (for now it will remain free but provide no data guarantees).

mmindenhall commented 5 years ago

No worries! The work done took most of a day to get done, but that included thinking, refactoring, etc. So restoring the previous state is tedious, but isn't taking nearly as long as it did to get to that state in the first place. Regardless, the tool has saved me from the much more time-consuming approach of hand-editing YAML while constantly hunting through the OpenApi spec to find the correct names/syntax. I fully understand it's a beta product and some hiccups are to be expected.

EricWittmann commented 5 years ago

Well that is very understanding of you. It's almost like this isn't the internet!

EricWittmann commented 5 years ago

Just an update to this issue - I have made a bunch of changes to the Apicurio editor so that it is more resilient to connection failures. Now you will be notified if the editor is in disconnected mode (for any reason). If you ARE in disconnected mode, you will be warned about closing the browser or navigating away. You can still do work in offline mode, and your changes will be synced the next time you have connectivity (regardless of whether your machine lost connection or the server failed for some reason).

Yet to be done is the option to "save" any outstanding changes made in offline mode to browser-local-storage so that the browser can be closed without losing data.

In any case, @mmindenhall I'm wondering if the upgrades I just described render your request for a download link no longer necessary or if you think it would still be nice to have.

mmindenhall commented 5 years ago

Sounds good to me...thanks!