Comments (13)
For starters we can persist the data on localStorage
from swagger-editor.
Hello!
I'm working on this issue for personal enjoy and entertainment. By now I've achived to persist yaml to session but instead of using a unique key, I'm using the YAML title (info.title). By doing this it's possible to save multiple files to localstorage and then retrieve them.
Now I've this feature working but I need to fix two little issues:
- Default YAML loading duplicates the file
- Saving text on top, is stuck on working...
PS: I don't know if I should open a new issue, or only this one...
PS2: I'll push a sample on my gh-pages to test and then a PR to this repository :)
from swagger-editor.
Issues addressed. I'm maintaining the yaml key as the current opened api, but it is saved as yaml and info.title. So header text is working fine and duplicates are not a problem.
from swagger-editor.
PR is done, hope you like it! :)
from swagger-editor.
I didn't have a chance to try your branch. What happens when I edit the title? Do you save a new YAML per key stoke?
from swagger-editor.
If title is edited it will be saved as a new YAML API Key. I reuse the SwaggerEditorCache keystore and then add the title as a key, so the localstorage will look like:
ngStorage-SwaggerEditorCache : {
"intro": true,
"progress": 1,
"yaml": "....",
"Uber API": "....",
"My Custom API": "...."
}
Example:
If I'm editing My Custom API its YAML will be saved to yaml key (maintain compatibility with listeners and loaders) and to My Custom API key in order to store any changes done to that API.
The keys [intro, progress and yaml] are not shown in the modal.
Now I'm working with the possibility to clean non-desired APIs
from swagger-editor.
Thank you for your work on this. We have a plan for having a backend for the editor so you save Swaggers in a database with versioning. We are interested in JSBin model where we use path params (UUID) for identifier and another path param for versioning. Doing too much in client side has less value since you can't share all of those saved YAMLs and also if in middle of editing title you might see another YAML magically appear because it matched the title.
from swagger-editor.
That's true, too much work on user's premises. I didn't know about JSBin, I'll stay tuned for incoming updates!
Are you thinking about how will you implement that backend? In example nodejs+mongo?
from swagger-editor.
Yes, I'm actually designing the backend API for such system. It's going to be very similar to JSBin. The way it works is, for the first time you visit editor it renders /
for you. Then when you make changes, we automatically push URL state to /:id/1
where id
is unique for your Swagger description. Now, every time you make changes, we update the content of the Swagger description in the DB. If you click save button, we save current document as final for version 1
and push URL state to /:id/2
.
There is a bit more complexity to it, when you share your URL with someone else, if they make changes, because they don't have the "ownership" cookie in their browser we save that Swagger description as a new entity and push URL state to /:new-id/1
so people can't mess with each other Swagger specs.
Here is the Swagger for API I explained above:
swagger: 2.0
info:
version: "1.0.0"
title: Bins
description: An api for bins
paths:
/:
get:
responses:
200:
description: Renders empty bin
post:
parameters:
- name: body
in: body
schema:
type: string
responses:
200:
schema:
$ref: Bin
description: Makes a new bin
/:id:
get:
responses:
200:
description: Gets latest version of the bin with `id`
post:
parameters:
- name: body
in: body
schema:
type: string
responses:
200:
schema:
$ref: Bin
description: Makes a new version of the bin
delete:
responses:
400:
description: Delete is not supported
/:id/:version:
get:
responses:
200:
schema:
$ref: Bin
description: Gets a specific version of a bin
delete:
responses:
400:
description: Deletes is not supported
definitions:
Bin:
properties:
uuid:
type: string
versions:
type: array
items:
$ref: Version
Version:
properties:
bin_id:
type: string
version:
type: integer
created_at:
type: Date
body:
type: string
FYI @earth2marsh
@fehguy How can I describe that "ownership cookie" with Swagger?
from swagger-editor.
Hi,
I like that backend schema/idea but what happens if I'm editing my API and then I loose my cookies, or just change between browser/computer. The ownership of that API will be still recoverable?
from swagger-editor.
Yes, if you have the link to your Swagger, you can navigate to it and start editing. You will get a new id and your version number starts from 1 again.
In very long run we can have user login and save documents under your user account.
from swagger-editor.
Nice!
I'll stay tunned about future releases!,
Thanks!
from swagger-editor.
Closing this since we discussed the plans and concerns already
from swagger-editor.
Related Issues (20)
- SwaggerEditor@next: no specification loaded on page refresh HOT 5
- swagger Missing "./jsx-runtime.js" specifier in "react" package
- [next-v5] Allow Swagger file to be set locally via docker HOT 2
- multipart/form-data ui missing schema view
- Wrong Schema when multiple anyOf/oneOf are inside allOf
- Install SwaggerEditor@5 with Vue3
- Switching between examples does not render the changed Example Value and Schema it keeps the request schema
- Swagger editor reports 'should match format "regex"'
- swagger-editor-dist@npm: No v5 alpha versions
- next version Build failed, HOT 1
- apidom context baseURL
- Wrong Schema when allOf
- Resolving OpenAPI References in Swagger Editor HOT 1
- Add possible to use editor in multiple tabs (adding 1 option more in config object)
- editor.swagger.io giving me a blank zip file HOT 1
- generate client code failing HOT 1
- Error representation
- Accessing next branch for AsyncAPI specification editting HOT 4
- Spec paramof swagger editor is unformated HOT 1
- Regression: Wrong request URL if server URL scheme is part of variable (works in v3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swagger-editor.